<template>
	<view class="content">
		<view class="onecontentone">
			我的会员卡<text v-if="orderForm.list.length!=0">({{orderForm.list.length}})</text>
		</view>
		<view class="flex-colum">
			<view class="towcontentitem" v-if="orderForm.list.length>0" v-for="(item,index) in orderForm.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="orderForm.list.length <= 0 && orderForm.is_end" class="flex-colum">
			<image style="width: 402rpx;height: 442rpx;margin:240rpx auto 32rpx;"
				src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/nomore.png" mode="aspectFill"></image>
		</view>
		<up-loadmore :status="orderForm.form.status" iconSize='12' fontSize='12' height='20' />
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		onMounted
	} from 'vue';

	import {
		onReachBottom
	} from '@dcloudio/uni-app'

	import {
		APIusershopUservipCard
	} from '@/common/api/member.js'

	const orderForm = reactive({
		type: '', //类型
		list: [],
		is_end: false,
		form: {
			page: 1, //页数
			size: 10, //页容量
			status: 'loadmore',
		}
	})


	const paygetShopByMember = async () => {
		let res = await APIusershopUservipCard({
			page: orderForm.form.page,
			pageSize: orderForm.form.size,
		})

		if (res.totalPage == 1 && res.totalRow <= 10) {
			orderForm.form.status = 'nomore'
			orderForm.list = res.records
			if (orderForm.form.page == 1 && res.records.length == 0) {
				orderForm.records = []
				orderForm.is_end = true
			}
			return false;
		} else {
			orderForm.form.status = 'loading';
			orderForm.list = [...orderForm.list, ...res.records];
			orderForm.form.page = ++orderForm.form.page;
			if (orderForm.form.page > res.totalPage) {
				orderForm.form.status = 'nomore';
			} else {
				orderForm.form.status = 'loading';
			}
		}
	}

	const eeInfo = async (item) => {
		// if (res.code == 0) {
		// 	uni.cache.set('shopUserInfo', res)
		// 	uni.cache.set('shopId', item.shopId)
		if (orderForm.type && orderForm.type == 'user_payCode') {
			uni.navigateTo({
				url: '/pages/pay_code/pay_code?shopInfo=' + JSON.stringify(item)
			})
		} else if (orderForm.type && orderForm.type == 'user_recharge') {
			uni.pro.navigateTo('member/index', {
				shopId: item.shopId,
				type: 'index',
			})
		} else if (orderForm.type && orderForm.type == 'user_points') {
			uni.pro.navigateTo('/pagesPoints/index/index', {
				shopId: item.shopId,
				type: 'member_list',
			})
		} else {
			uni.pro.navigateTo('user/member/memberdetails', {
				shopId: item.shopId
			})

		}
	}
	onReachBottom(() => {
		paygetShopByMember()
	})
	onMounted((e) => {
		paygetShopByMember()
	})
</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>