<template>
	<view>
		<view class="hm-header-xian"></view>
		<scroll-view scroll-y class="hm-w-h" @scrolltolower="reachBottom">
			<view v-if="(list.data).length">
				<view class="list">
					充值记录
					<view class="item" v-for="(item, index) in list.data" :key="index">
						{{item.remark}}<text>{{item.mode.text}}{{item.money}}</text>
						<view class="time">{{item.create_time}}</view>
					</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/order.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: {},
				userInfo:{},
				list: {data:{}},
				loadStatus: 'loadmore',
				page: 1,

			};
		},

		components: {},
		props: {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			let _this = this;
			_this.applet = uni.getStorageSync('applet');
			_this.getUserDetail();
			_this.getList();
		},
		methods: {
			/**
			 * 获取当前用户信息
			 */
			getUserDetail() {
				let _this = this;
				App._get('user/detail', {}, result => {
					_this.userInfo = result.data.detail;
				});
			},
			/**
			 * 触底加载
			 */
			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('user.record/logs', {
					page: _this.page,
					mode:10
				}, 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 lang="scss" scoped>
	.box{
		background-color: #fff;
		padding: 50rpx 0rpx;
		text-align: center;
		.number{
			font-size: 50rpx;
			font-weight: bold;
			padding-top: 20rpx;
			color: #fa3534;
		}
	}
	.list{
		padding: 20rpx;
		margin-top: 20rpx;
		background-color: #fff;
		.item{
			padding: 20rpx 0rpx;
			font-size: 30rpx;
			color: #606266;
			text{
				color: #fa3534;
				float: right;
			}
			.time{
				padding-top: 10rpx;
				font-size: 24rpx;
				color: #909193;
			}
		}
	}
</style>
