<template>
	<view class="content">
		<view class="onecontentone">
			我的会员卡<text v-if="list.length!=0">({{list.length}})</text>
		</view>
		<view class="flex-colum">
			<view class="towcontentitem" v-if="list.length>0" v-for="(item,index) in list" :key="index"
				@click="eeInfo(item)">
				<image class="towcontentitemimage"
					src="https://ointmentweapp.oss-cn-beijing.aliyuncs.com/my/recharge.png" mode="aspectFill"></image>
				<view class="towcontentitemone flex-start">
					<image class="towcontentitemoneimage" :src="item.logo" mode="aspectFill"></image>
					<text class="towcontentitemonetext" style="color: #333333;">{{item.chainName}}</text>
					<!-- 余额：<text class="towcontentitemtheretext">{{userInfo.amount || '0.00'}}</text> -->
				</view>
				<view class="towcontentitemtow flex-between">
					<text class="towcontentitemtowetext" style="color:#333333;">余额:{{item.amount}}</text>
					<text>{{item.shopName}}</text>
				</view>
			</view>
		</view>
		<view v-if="list.length== 0 && is_end == true" class="flex-colum">
			<image :src="bgnothave" mode="aspectFill">
			</image>
		</view>
		<u-loadmore :status="form.status" iconSize='24' fontSize='24' height='40' />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgnothave: uni.getStorageSync('bgnothave'),
				list: [],
				is_end: false,
				nickname: uni.cache.get('userInfo').nickName,
				form: {
					page: 1, //页数
					size: 10, //页容量
					status: 'loadmore',
				},
				userId:null
			}
		},
		onLoad() {
			this.userId = uni.cache.get('userInfo').id
			// this.paygetShopByMember()
		},
		onShow() {
			this.paygetShopByMember()
		},
		onReachBottom() {
			this.paygetShopByMember()
		},
		computed: {},
		methods: {
			async paygetShopByMember() {
				let res = await this.api.paygetShopByMember({
					page: this.form.page,
					pageSize: this.form.size,
					userId: uni.cache.get('userInfo').id,
					shopId: ''
				})

				if (res.data.pages < this.form.page) {
					this.form.status = 'nomore'
					if (this.form.page == 1 && res.data.list == 0) {
						this.is_end = true
					}
					return false;
				} else {
					this.form.status = 'loading';
					this.form.page = ++this.form.page;
					setTimeout(() => {
						this.list = [...this.list, ...res.data.list];
						this.form.status = 'loading';
						if (res.data.pageNum == res.data.pages) {
							this.form.status = 'nomore';
						} else {
							this.form.status = 'loading';
						}
					}, 500)
				}
			},
			eeInfo(item) {
			
				uni.pro.navigateTo('member/memberdetails', {
					shopId_id: item.shopId,
					type: 'list'
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #FFFFFF;
	}

	.content {
		border-top: 16rpx solid #f7f7f7;
		padding: 28rpx;
		padding-bottom: 40rpx;

		.flex-colum_image {
			display: flex;
			align-items: center;
			justify-content: center;
			height: 100%;

			text {
				margin-top: 30rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #666666;
			}
		}

		.onecontentone {
			font-size: 32rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.flex-colum {
			.towcontentitem {
				margin-top: 22rpx;
				width: 96%;
				position: relative;
				height: 224rpx;
				padding: 32rpx;
				border-radius: 12rpx;

				.towcontentitemimage {
					top: 0;
					left: 0;
					position: absolute;
					width: 100%;
					height: 100%;
					border-radius: 12rpx;
					z-index: 9;
				}

				.towcontentitemone {
					position: relative;
					z-index: 10;

					.towcontentitemoneimage {
						width: 76rpx;
						height: 76rpx;
						border-radius: 50%;
					}

					.towcontentitemonetext {
						width: 60%;
						margin-left: 16rpx;
						font-size: 32rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-family: Source Han Sans CN-Medium, Source Han Sans CN;
						font-weight: 500;
						color: #422A07;
					}
				}

				.towcontentitemtow {
					z-index: 10;
					position: absolute;
					width: 100%;
					left: 0;
					bottom: 18rpx;
					padding: 0 32rpx;
					// margin-top: 52rpx;
					font-size: 24rpx;
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					font-weight: 400;
					color: #422A07;
				}
			}
		}

	}
</style>