<template>
	<view>
		<view class="hm-header-xian"></view>
		<scroll-view scroll-y class="hm-w-h" @scrolltolower="reachBottom">
			<view v-if="(list.data).length" class="hm-bg-f hm-p-lr-20">
				<!--列表-->
				<view class="hm-p-20 hm-border-t" v-for="(item, index) in list.data" :key="index">
					<view class="hm-dis-block-inline">
						<view class="hm-font-28">奖励{{item.type.text}}</view>
						<view class="hm-col-light hm-font-22">{{item.create_time}}</view>
					</view>
					<view class="hm-dis-block-inline hm-fr hm-font-b hm-m-t-15">
						+ {{item.number}}
					</view>
				</view>
				<view>
					<u-loadmore :status="loadStatus" bgColor="#f3f4f6" height="40" line></u-loadmore>
				</view>
			</view>
			<view v-else class="hm">
				<img :src="applet.domain + '/addons/food/img/empty/message.png'" />
				<view class="text">暂无签到记录</view>
			</view>
		</scroll-view>
		<!-- 技术支持 -->
		<view class="hm">
			{{applet.copyright}} <text class="v">V{{applet.version}}</text>
		</view>
	</view>
</template>

<script>
	let App = getApp();

	export default {
		data() {
			return {
				applet: {},
				list: {data:{}},
				loadStatus: 'loadmore',
				page: 1,

			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			let _this = this;
			_this.applet = uni.getStorageSync('applet');
			_this.getList();
		},
		methods: {
			/**
			 * 触底加载
			 */
			reachBottom: function() {
				let _this = this;
				_this.loadStatus = "loading"; //加载中
				// 已经是最后一页
				if (_this.page >= _this.list.last_page) {
					_this.loadStatus = "nomore"; //没有数据
					return false;
				}
				// 加载下一页列表
				_this.page = _this.page + 1;
				_this.getList();
			},
			/**
			 * 获取充值套餐
			 */
			getList() {
				let _this = this;
				App._get('market.sign/logs', {
					page: _this.page
				}, function(result) {
					if(_this.page == 1){
						_this.list = result.data.list;
					}else{
						let resList = result.data.list,
							dataList = _this.list;
						_this.list.data = dataList.data.concat(resList.data);
						_this.loadStatus = 'loadmore';
					}
				});
			}
		}
	};
</script>
<style>

</style>
