<template>
	<view class="page">
		<navBar title="活动商品" :back="true" color="black" background="white" />

		<view class="con" v-if="list.length!=0">
			<view class="item" v-for="(item,index) in list" @click="goDetail(item)">
				<view class="topBox">
					<image :src="picBase+item.image" mode=""></image>
				</view>
				<view class="bottom">
					<view class="txt">
						{{item.title}}
					</view>

					<view class="txt1">
						<view class="l">
							{{item.start_time|timeF(item.start_time)}}
						</view>
						<view class="r">
							活动开始
						</view>
					</view>
					<view class="txt1">
						<view class="l">
							{{item.end_time|timeF(item.end_time)}}
						</view>
						<view class="r">
							活动结束
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="con" v-else style="justify-content: center;">
			<u-empty mode="data" text="暂无数据" width="160" height="160" :icon="picUrl+'/static/other/empty.png'">
			</u-empty>
		</view>
		<u-loadmore v-if="list.length!=0" style="" loadmoreText="已经到底啦" color="#CCCCCC" lineColor="#CCCCCC" line />

		<u-loading-page :loading="loading" image="/static/index/logo.png" loading-text="页面加载中..."></u-loading-page>
	</view>
</template>

<script>
	import {
		getMallReq,
		getActivityDataReq
	} from '@/api/test/index.js'
	import moment from 'moment'

	export default {
		components: {},
		data() {
			return {
				picUrl: this.$picUrl,
				picBase: this.$picBase,
				list: [],
				loading: true
			}
		},
		async onLoad(o) {

		},
		async onShow() {
			let res = await getActivityDataReq()
			if (res.code == 0) {
				this.list = res.data
				this.loading = false
				console.log('活动商品列表返回值:', res.data);
			} else {
				this.loading = false
				uni.showToast({
					title: res.message,
					icon: 'none'
				})
			}
		},
		filters: {
			timeF(t) {
				return moment(t).format("YYYY年MM月DD日 HH:mm")
			}
		},
		methods: {
			goDetail(item) {
				getApp().actId = item.id
				uni.navigateTo({
					url: '/pages/my/actDetail2/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>