From 0e1bce71603c5cbb92b3fe6387c87430528d18a9 Mon Sep 17 00:00:00 2001
From: zhaojs <349234519@qq.com>
Date: 星期二, 18 七月 2023 16:14:45 +0800
Subject: [PATCH] no message

---
 uniapp/pages/login/setInviteCode.vue |  133 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 115 insertions(+), 18 deletions(-)

diff --git a/uniapp/pages/login/setInviteCode.vue b/uniapp/pages/login/setInviteCode.vue
index 3271537..efa0c41 100644
--- a/uniapp/pages/login/setInviteCode.vue
+++ b/uniapp/pages/login/setInviteCode.vue
@@ -4,27 +4,47 @@
 			璇疯緭鍏ラ個璇风爜
 		</view>
 		<view class="grey-input-content rowCen borderBox">
-			<input class="iptclas" type="text" v-model="inviteCode" placeholder="璇峰~鍐欓個璇风爜" placeholder-class="pla-input"/>
+			<input class="iptclas" type="text" v-model="inviteCode" placeholder="璇峰~鍐欓個璇风爜锛�" placeholder-class="pla-input"/>
 		</view>
-		<view class="model-tips" v-if="appInfo.isOpenOfficialCode==1">
+		 <view class="model-tips" v-if="appInfo.isOpenOfficialCode==1">
 			<view>濉啓閭�璇风爜鏈夊姪浜庢偍鐨勮喘鐗╄繑浣e摝锛�</view>
 		</view>
 		
-		<template v-if="isShowCode">
-		<view class="copy-bar rowCenBet borderBox" v-if="appInfo.isOpenOfficialCode==1">
-			<view class="left-code">
-				{{appInfo.officialInvitationCode}}
-			</view>
-			<view class="copybtn rowCenCen" @tap="useCode()">
-				<view>浣跨敤閭�璇风爜</view>
-			</view>
-		</view>
-		</template>
+		
 		<view @click="setCode" class="login-btn rowCenCen" :class="inviteCode?'colorfulbtn':''" >
 			<view class="btn-font"  >
 				纭畾
 			</view>
 		</view>
+		
+		<template v-if="isShowCode">
+			<template v-if='commonInvite!=null&&commonInvite.length>0'>
+			<view class="s_inviter" @click="userInviter()">
+				<view class="s_img">
+					<image :src="commonInvite[inviteIndex].avatar"></image>
+					<span>{{commonInvite[inviteIndex].nickname}}</span>
+				</view>
+				<view>
+					<view>浣跨敤Ta鐨勯個璇风爜</view>
+				</view>
+			</view>
+			<view @click="changeInviter()" style="color: #999999; margin-top: 20rpx;">
+				鎹竴涓�
+			</view>
+			</template>
+			<template v-else>
+			<view class="copy-bar rowCenBet borderBox" style="margin-top: 70rpx;" v-if="appInfo.isOpenOfficialCode==1">
+								<view class="left-code">
+									{{appInfo.officialInvitationCode}}
+								</view>
+								<view class="copybtn rowCenCen" @tap="useCode()">
+									<view>浣跨敤閭�璇风爜</view>
+								</view>
+							</view>
+			</template>
+			
+			
+		</template>
 		
 		<view class="yqmtip rowCenCen">
 			<span @click="showinvite">娌℃湁閭�璇风爜锛�</span>
@@ -49,14 +69,47 @@
 				inviteCode:'',
 				appInfo:'',
 				inviterShow:false,
-				platform:''
+				platform:'',
+				commonInvite:[],
+				inviteIndex:0
 			}
+		},
+		onLoad()
+		{
+			this.getInviter();
 		},
 		mounted() {
 			this.appInfo = uni.getStorageSync('appInfo');
 			this.platform = uni.getSystemInfoSync().platform
 		},
 		methods: {
+			//鑾峰彇绯荤粺鎺ㄨ崘浜�
+			getInviter()
+			{
+				var that=this;
+				this.$u.api.getRecomInviter({}).then(e => {
+					console.log(e)
+					that.commonInvite=e.data;
+				}).catch(function (err) {
+					console.log(err)
+				})
+			},
+			changeInviter()
+			{
+				console.log(this.commonInvite.length)
+				if(this.inviteIndex==this.commonInvite.length-1)
+				{
+					this.inviteIndex=0;
+				}
+				else{
+					this.inviteIndex=this.inviteIndex+1;
+				}
+			},
+			userInviter()
+			{
+				this.inviteCode=this.commonInvite[this.inviteIndex].invitation_code;
+			},
+			
 			useCode()
 			{
 				this.inviteCode=this.appInfo.officialInvitationCode;
@@ -97,7 +150,10 @@
 				this.$u.api.getUserInfo({}).then(e => {
 					console.log(e)
 					util.setCache('userInfo', e.data.userinfo);
-					if (e.data.userinfo.isPwd == 'N') {
+					uni.switchTab({
+					  url: '../index/index'
+					})
+					/* if (e.data.userinfo.isPwd == 'N') {
 						uni.redirectTo({
 							url: './setPass'
 						})
@@ -105,13 +161,14 @@
 						uni.switchTab({
 						  url: '../index/index'
 						})
-					}
+					 }*/
 				}).catch(function (err) {
 					console.log(err)
 				})
 			},
 			setCode()
 			{
+				console.log("纭畾");
 				var that=this;
 				if(this.inviteCode)
 				{
@@ -121,12 +178,32 @@
 						console.log(e)
 						if(e.code != 0) return that.$alert(e.msg)
 						uni.setStorageSync('inviterInfo',e.data)
-						this.inviterShow = true
+						//this.inviterShow = true
+						this.setinvite();
 					}).catch(function (err) {
 					})
 				}
-			}
-
+			},
+			setinvite() {
+				var that = this;
+				let deviceInfo = uni.getDeviceInfo();
+				console.log(deviceInfo.deviceId);
+				this.$u.api.bindInvitation({
+					invite_code:this.inviteCode,
+					deviceid:deviceInfo.deviceId
+				}).then(e => {
+					if(e.code != 0) return that.$alert(e.msg)
+					uni.showToast({
+						title:'缁戝畾鎴愬姛锛�',
+						icon:'none'
+					})
+					setTimeout(function(){
+						that.getuserInfo();
+					},1000)
+				}).catch(function (err) {
+				})
+					
+			},
 		}
 	}
 </script>
@@ -136,6 +213,26 @@
 	{
 		background: #fff;
 	}
+	.s_inviter
+	{
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
+		margin-top: 70rpx;
+		width:100%;
+		.s_img
+		{
+			display: flex;
+			align-items: center;
+			span{
+				margin-left: 13rpx;
+			};
+		}
+		image{
+			width:100rpx;
+			height: 100rpx;
+		}
+	}
 	
 	.yqmtip
 	{

--
Gitblit v1.9.3