<template>
<view class="box">
	<view style="height: 20rpx;"></view>
 <view class="line" v-for="(item,index) in list">
	 <view class="linetop">
		 <view class="name">{{item.CustomerName}}</view>
		 <view class="nickNameBox">
			 <image src="../../static/timg/icon_wechat.png" mode="" class="nickNameImg"></image>
			 <view class="nickName">{{item.WxNickName?item.WxNickName:''}}</view>
		 </view>
	 </view>
	 <view class="lineCOnt">
		 <view class="lineline">
		 	<view class="lineContLeft">
				 <image src="../../static/timg/icon_dianhua.png" mode="" class="lineContLeftImg"></image>
				 <view class="lineContLeftMs">{{item.MobilePhone}}</view>
		 	</view>
			<view class="lineTIme">{{item.PJCreateTime}}</view>
		 </view>
		
	 </view>
 </view>
 <nodata v-if="list.length==0"></nodata>
 <!-- 手机号授权 -->
 	<view class="authorizBox" v-if="authorizShow" @click="authorizShow=false">
 		<view class="authorizCont" @click.stop="">
 			<view class="authorizName">{{wxOpenData.miniAppName}}</view>
 			<view class="authorizMs">未注册的手机号登录后将自动创建会员账号，如果您不同意授权获取手机号，会影响您使用我们的产品和服务。</view>
 			<button class="authorizContbutton" type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权</button>
 		</view>
 		<view style="text-align: center;padding-top: 56rpx;">
 			<image src="../../static/timg/icon_guanbi@2x.png" mode="" class="authorizCloseImg"></image>
 		</view>
 	</view>
</view>
</template>

<script>
	import nodata from '../../components/nodata/nodata.vue'
	export default {
		components: {
			nodata
		},
		
		data() {
			return {
				list:[],
				themeColor:'',
				userInfo:'',
				page:1,
				limit:20,
				authorizShow:false,
				userInfo:'',
				ext:'',
				wxOpenData:'',
			}
		},
		onLoad(opt) {
			this.themeColor = uni.getStorageSync("themeColor");
			this.userInfo=this.$store.state.userInfo;
			this.ext=this.$common.getExtStoreId();
			if(this.userInfo){
				this.getList()
			}else{
				this.$common.automaticlogin().then(val => {
					this.userInfo=this.$store.state.userInfo;
					this.wxOpenData=this.$store.state.wxOpenData;
					this.themeColor = uni.getStorageSync("themeColor");
					if(!this.userInfo){
						this.authorizShow=true
					}
					this.getList()
				})
			}
			//this.getList()
		},
		onShow() {
			
		},
		methods: {
			getList(){
				uni.showLoading({
					title: '加载中'
				})
				this.$http('opencarInfoOwner/listPJBonusPage', {
				    page:this.page,limit:this.limit,
				}, 'GET').then(res => {
					uni.hideLoading();
					console.log(res.data)
					var data=res.data.Items;
					this.list=this.list.concat(data);
					//this.list = res.data.Items
					//console.log('list+=', this.queryShopList);
				
				})
			},
			decryptPhoneNumber: function(e) {
			  console.log(e);
			  this.code=e.detail.code
			  this.wxPhoneLogin()
			  this.authorizShow=false;
			},
			wxPhoneLogin(){
					 var that=this;
					 this.$http('miniApp2/sys/wxPhoneLogin', {
					   appId:this.ext.appId,
					   unionId:this.ext.unionId,
					   code:this.code,
					   openId:this.wxOpenData.openid
					  },'POST').then(res => {
						var data = res.data;
						if(data.loginInfo){
							this.userInfo=data.loginInfo.openUser;
							this.wxOpenData=data.loginInfo;
							this.$store.commit('mutationswxOpenData', data)
							this.$store.commit('mutationsuserInfo', this.userInfo)
							this.list=[]
						    this.getList()
						}	
					  })
			},
			
		},
		onReachBottom(){
			this.page++;
			this.getList()
			//console.log("shanglas")
		},
		onPullDownRefresh(){
		    this.page=1;
			this.list=[];
			this.getList();
			setTimeout(() => {
					uni.stopPullDownRefresh(); // 关闭下拉刷新 
			}, 2000);
		}
	}
</script>

<style scoped lang="less">
.box {
	width: 100vw;
	min-height: 100vh;
	background: #F4F5F7;
}
.nickNameBox{
	display: flex;
	padding-top: 6rpx;
}
.nickName{
	font-weight: 400;
	color: #999999;
	font-size: 24rpx;
	line-height: 30rpx;
	padding-left: 10rpx;
}
.lineContLeftImg{
	width: 30rpx;
	height: 30rpx;
	margin-right: 10rpx;
}
.line{
	width: 702rpx;
	background: #FFFFFF;
	border-radius: 10rpx;
	margin-bottom: 20rpx;
	margin-left: 24rpx;
}
.linetop{
	display: flex;
	justify-content: space-between;
	font-size: 30rpx;
	padding: 20rpx;
	padding-bottom: 0;
}
.lineline{
	display: flex;
	justify-content: space-between;
	padding: 20rpx;
	font-weight: 400;
	color: #999999;
	font-size: 24rpx;
	line-height: 30rpx;
}
.lineContLeft{
	display: flex;
}
.name{
	font-weight: 500;
	color: #3C3C3C;
}
.amount{
	color: #EC0F0A;
}
.nickNameImg{
	width: 30rpx;
	height: 30rpx;
}
.authorizBox{
			width: 100vw;
			height: 100vh;
			background: rgba(0, 0, 0, 0.5);
			position: fixed;
			top: 0;
			left: 0;
		}
		.authorizCont{
			margin-top: 30vh;
			width: 564rpx;
			height: 408rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			margin-left: 93rpx;
			position: relative;
		}
		.authorizCloseImg{
			width: 62rpx;
			height: 62rpx;
		}
		.sqLogoBox{
			width: 180rpx;
			height: 180rpx;
			background: #FFFFFF;
			border-radius: 90rpx;
			text-align: center;
			position: absolute;
			top: -50rpx;
			left: 192rpx;
		}
		.authorizName{
			color: #333333;
			line-height: 42rpx;
			font-size: 30rpx;
			text-align: center;
			padding-top: 58rpx;
		}
		.authorizMs{
			color: #999999;
			line-height: 36rpx;
			font-size: 26rpx;
			width: 452rpx;
			padding-top: 24rpx;
			text-align: center;
			margin-left: 56rpx;
		}
		.authorizContbutton{
			width: 422rpx;
			height: 88rpx;
			background: #EC0F0A;
			border-radius: 44rpx;
			line-height: 88rpx;
			text-align: center;
			font-size:30rpx;
			color: #FFFFFF;
			margin-top: 62rpx;
			margin-left:71rpx;
		}
</style>
