<template>
	<view class="page">
		<u-navbar title="会员列表" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			back-icon-color="#000" height='50'></u-navbar>
		<view class="box">
			<view class="serch">
				<view class="lt">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uaG7R4JLfYOzBhWfDN0j" mode=""></image><input type="text" v-model="keyword" placeholder="搜索"/> <view class="sousuo" @click="searchs">搜索</view>
				</view>
			</view>
	        <view class="gongji">
	        	我的会员（{{total}}）
	        </view>
			<view class="list" @scrolltolower="onReachBottom">
				<view class="list_item" v-for="(item,index) in list" :key="index" @click="btnxq(item.id)">
					<image src="https://api.ccttiot.com/smartmeter/img/static/uSU18e6TYbq8kSE7S1DZ" mode=""></image>
					<view class="top">
						<view class="lt">
							用户：{{item.userName == null ? '--' : item.userName}}
						</view>
						<view class="rt">
							使用记录  <u-icon name="arrow-right" color="#5854A2" size="28"></u-icon>
						</view>
					</view>
					<view class="cen">
						{{item.vipLevelName == null ? '--' : item.vipLevelName}}
					</view>
					<view class="bot">
						<view class="lt">
							有效期至{{item.endTime == null ? '--' : item.endTime}}
						</view>
						<view class="rt">
							剩余次数 <text>{{item.surplusCount == null ? '--' : item.surplusCount}}</text>
						</view>
					</view>
				</view>
				<view class="wz">
					没有更多会员啦...
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: " #fff",
				},
				keyword: '',
				storeId:'',
				pagenum:1,
				list:[],
				total:''
			}
		},
		onLoad(option) {
           if(option.storeId){
			   this.storeId = option.storeId
			   this.getlist()
		   }
		},
		// 分享到好友（会话）
		  onShareAppMessage: function () {  
		    return {  
		      title: '创想物联',  
		      path: '/pages/shouye/index'  
		    }  
		  },  
		  
		  // 分享到朋友圈  
		  onShareTimeline: function () {  
		    return {  
		      title: '创想物联',  
		      query: '',  
		      path: '/pages/shouye/index'  
		    }  
		  },
		onShow() {

		},
		methods: {
			// 请求会员列表
			getlist() {
				this.$u.get(`/mch/vip/list?pageNum=${this.pagenum}&pageSize=10&storeId=${this.storeId}&keyword=${this.keyword}`).then((res) => {
					if (res.code == 200) {
						this.total = res.total
						if(this.pagenum > 1){
							this.list = this.list.concat(res.rows)
							this.pagenum ++
						}else{
							this.list = res.rows
							this.pagenum ++
						}
					}
				})
			},
			// 上拉加载更多
			onReachBottom() {
				if(this.list.length < this.total){
					this.getlist()
				}else{
					uni.showToast({
						title: '暂无更多数据',
						icon: 'none',
						duration:2000
					})
				}
			},
            // 点击搜索
			searchs() {
                this.pagenum = 1
				this.getlist()
			},
			// 点击跳转到使用记录
			btnxq(id){
				uni.navigateTo({
					url:'/page_geren/huiyuanxq?vipid=' + id
				})
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .u-title {
		padding-bottom: 22rpx;
	}
	/deep/ .uicon-nav-back {
		padding-bottom: 22rpx;
	}
	.serch{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 36rpx;
		box-sizing: border-box;
		padding-top: 22rpx;
		padding-bottom: 22rpx;
		background-color: #fff;
		.lt{
			display: flex;
			align-items: center;
			width: 100%;
			height: 68rpx;
			border: 2rpx solid #8883F0;
			border-radius: 24rpx;
			padding-left: 30rpx;
			box-sizing: border-box;
			.sousuo{
				width: 140rpx;
				height: 66rpx;
				text-align: center;
				line-height: 66rpx;
				font-size: 32rpx;
				color: #FFFFFF;
				background: #8883F0;
				border: 2rpx solid #8883F0;
				border-radius: 0 20rpx 20rpx 0;
			}
			image{
				width: 46rpx;
				height: 46rpx;
			}
			input{
				width: 460rpx;
				margin-left: 30rpx;
				height: 68rpx;
				line-height: 68rpx;
			}
		}
	}
	.page {
		width: 750rpx;
		// height: 99vh;
		.box {
			width: 750rpx;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			.list{
				width: 100%;
				padding: 0 36rpx;
				box-sizing: border-box;
				padding-bottom: 50rpx;
				height: 79vh;
				overflow: scroll;
				.wz{
					width: 100%;
					text-align: center;
					font-size: 32rpx;
					margin-top: 30rpx;
					color: #ccc;
				}
				.list_item{
					position: relative;
					padding: 34rpx 40rpx;
					box-sizing: border-box;
					margin-top: 28rpx;
					.cen{
						font-weight: 600;
						font-size: 32rpx;
						color: #5854A2;
						margin-top: 30rpx;
					}
					.bot{
						margin-top: 10rpx;
						display: flex;
						justify-content: space-between;
						.lt{
							font-size: 24rpx;
							color: #5854A2;
						}
						.rt{
							font-size: 28rpx;
							color: #5854A2;
							text{
								font-weight: 600;
								font-size: 70rpx;
								color: #5854A2;
								margin-left: 26rpx;
							}
						}
					}
					.top{
						display: flex;
						justify-content: space-between;
						.lt{
							font-size: 36rpx;
							color: #5854A2;
						}
						.rt{
							font-size: 24rpx;
							color: #5854A2;
						}
					}
					image{
						width: 680rpx;
						height: 284rpx;
						position: absolute;
						top: 0;
						left: 0;
						z-index: -1;
					}
				}
			}
			.gongji{
				font-size: 28rpx;
				color: #3D3D3D;
				width: 100%;
				padding: 0 36rpx;
				box-sizing: border-box;
				margin-top: 28rpx;
			}
		}
	}
</style>