<style>
	.cardsdStyle .mingxilist{
		margin-top: 15px;
		display: flex;
		width: 100%;
		justify-content: space-between;
		padding: 0 15px;
		
	}
	.mingxilist-l{
		width: calc(100vw - 60rpx - 30px - 50px);
		font-size: 15px;
		color: #000000;
	}
	.mingxilist-r{
		display: flex;
		flex-direction: column;
		align-items: flex-end;
		font-size: 15px;
		color: #000000;
		font-weight: bold;
		
	}
</style>
<template>
	<view class="cardsdStyle" :style="{ height: contentHeight }">
		<u-empty v-if="g.length == 0" text="暂无相关数据" mode="coupon"></u-empty>

		<view v-if="g.length > 0" style="
        height: calc(100vh);
        width: calc(100vw);
        overflow: hidden;
		
      ">
			<scroll-view :scroll-y="true" :enable-back-to-top="true" :enable-flex="true" @scrolltolower="lower"
				:style="{ height: '100%' }">
				<view class="couponList">
					
					<view class="mingxilist" v-for="(x, i) in g" :key="i" >
						<view class="mingxilist-l">
							<view class="oneText" style="text-align: left;">{{x.Remarks}}</view>
							<view style="font-size: 12px;color: #BCBCBC;">{{x.CreateDate}}</view>
						</view>
						<view class="mingxilist-r">
							<view v-if="x.Type== 1" :style="{color:mainColor}">+{{x.Surplus - x.Balance}}</view>
							<view v-if="x.Type== 2" >-{{x.Balance-x.Surplus}}</view>
							<!-- <view style="font-size: 12px;color: #F44235;font-weight: normal;">
								{{x.Remarks}}
							</view> -->
						</view>
					</view>
				</view>

				<u-loadmore :status="status" :load-text="loadText" :font-size="24" :margin-top="20" :margin-bottom="20"
					bg-color="#f3f4f6" />
			</scroll-view>
		</view>
	
		<!-- 加载中 -->
		<view class="loading" v-if="loading">
			<u-loading mode="flower" size="48">></u-loading>
			<Text style="color: #fff; margin-top: 10rpx;">加载中...</Text>
		</view>
		<!-- 取消提示 -->
		<u-toast ref="uToast" />
		<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth='gbAuth'></auth>
	</view>
</template>

<script>
	import auth from "../../../components/auth/index.vue";
	export default {
		components: {
			auth
		},
		data() {
			return {
				pageTitle: "卡片明细",
				showAuth: false,
				U: {},
				mainColor: "",
				contentHeight: 0,

				msg: {
					pageIndex: 1,
					pageSize: 20,
					OldDepositBuyId:0,
				},
				page_count: 1,
				g: [],
				loading: false,
				status: "loadmore",
				loadText: {
					loadmore: "轻轻上拉，加载更多",
					loading: "努力加载中",
					nomore: "没有更多了",
				},
				
			};
		},
		created() {
			this.contentHeight = this.$utils.calcContentHeight(-40) + "px";
			this.mainColor = this.$uiConfig.mainColor;
		},
		mounted() {
			let currentPages = getCurrentPages();
			let u = "/" + currentPages[currentPages.length - 1].route;
			let pages = wx.getStorageSync("basedata") ?
				wx.getStorageSync("basedata").bar_title :
				[];
			pages.forEach((x) => {
				if (x.value == u) {
					this.pageTitle = x.new_name ? x.new_name : x.name;
				}
			});
			uni.setNavigationBarTitle({
				title: this.pageTitle,
			});
		},
		onLoad: function(option) {
			if(option && option.ID){
				this.msg.OldDepositBuyId= option.ID
			}
			this.u = uni.getStorageSync("mall_UserInfo");
			if (!this.u) {
				this.u = {
					nickName: "未登录",
					avatarUrl: ""
				};
				this.showAuth = true;
			} else {
				this.init();
			}
		},
		methods: {

			init() {

				this.request2({
						url: '/api/AppletCoupon/GetDepositBalancePageList',
						data: this.msg
					},
					res => {

						if (res.resultCode == 1) {
							this.loading = false;
							res.data.pageData.forEach(x=>{
								x.ischecked = false
							})
							this.g = this.g.concat(res.data.pageData);
							this.page_count = res.data.pageCount;
							if (this.page_count == 1) {
								this.status = "nomore";
							}
						}
					}
				);
			},
		
			lower(e) {
				if (this.msg.pageIndex < this.page_count) {
					this.msg.pageIndex++;
					this.status = "loading";
					this.init();
				} else {

					this.status = "nomore";
				}
			},
			
		
			
			
		},
	};
</script>
<style>
	.cardsdStyle {
		width: 100%;
		height: 100%;
		background: #f3f4f6;
		position: relative;
	}
	.cardsdStyle .loading {
		width: 180rpx;
		height: 180rpx;
		background: #000000;
		opacity: 0.7;
		border-radius: 10rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: fixed;
		left: 50%;
		top: 30%;
		margin-left: -100rpx;
		z-index: 999;
	}
	.cardsdStyle .couponList {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.cardsdStyle .item {
		display: flex;
		margin-top: 15px;
		align-items: flex-start;
		background: #fff;
		width: 94%;
		border-radius: 12rpx;
		overflow: hidden;
	}
</style>
