Kaynağa Gözat

登录相关

htc 3 gün önce
ebeveyn
işleme
b751f40b35
4 değiştirilmiş dosya ile 127 ekleme ve 12 silme
  1. 2 2
      http/baseApi.js
  2. 16 1
      pages/home.vue
  3. 42 5
      pages/login.vue
  4. 67 4
      pages/registerInfo.vue

+ 2 - 2
http/baseApi.js

@@ -1,6 +1,6 @@
 // const BaseApi = 'https://transcend.ringzle.com/chuangheng-app/app' //线上
-const BaseApi = 'https://wxapp.transcend-intl.cn/chuangheng-app/app' //生产
-// const BaseApi = 'http://192.168.2.19:9023/chuangheng-app/app' //李勇
+// const BaseApi = 'https://wxapp.transcend-intl.cn/chuangheng-app/app' //生产
+const BaseApi = 'http://192.168.2.19:9023/chuangheng-app/app' //李勇
 // const BaseApi = 'http://192.168.2.16:9023/chuangheng-app/app' //严总
 
 export {

+ 16 - 1
pages/home.vue

@@ -71,7 +71,22 @@
 				reportCount:0
 			}
 		},
-		onLoad() {
+		onLoad(options) {
+			if(options.q){
+				try{
+					console.log("扫码进入参数:", options.q);
+					const decodedUrl = decodeURIComponent(options.q);
+					console.log("decodedUrl:", decodedUrl);
+					const codeMatch = decodedUrl.match(/type=([^&]+)/);
+					console.log("codeMatch:", codeMatch);
+					const stationCode = codeMatch ? codeMatch[1] : null;
+					console.log("stationCode:", stationCode);
+					if(stationCode) uni.setStorageSync('channelType',stationCode)
+				}catch(e){
+					console.log(e,'e');
+				}
+			}
+			
 			if(uni.getStorageSync('token')){
 				this.getWjList();
 				this.getReportList();

+ 42 - 5
pages/login.vue

@@ -22,7 +22,7 @@
 			</div>
 			<div class="c_bottom">
 				<button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
-				<div class="qx_btn" style="margin-top: 40rpx;" @tap="codeLogin">授权码登录</div>
+				<div class="qx_btn" style="margin-top: 40rpx;" @tap="codeLogin" v-if="!channelType">授权码登录</div>
 				<div class="agree adfacjc" @click="changeAgree">
 					<image :src="imgBase+'not_select.png'" v-if="!agree"></image>
 					<image :src="imgBase+'selected.png'" v-else></image>
@@ -52,9 +52,13 @@
 				show:false,
 				phone:'',
 				code:'',
-				agree:false
+				agree:false,
+				channelType:''
 			}
 		},
+		created() {
+			if(uni.getStorageSync('channelType')) this.channelType = uni.getStorageSync('channelType')
+		},
 		methods:{
 			decryptPhoneNumber(e){
 				if(!this.agree) return this.$showToast('请勾选协议与政策')
@@ -92,10 +96,40 @@
 					success(res){
 						that.$api.get('/wx/login',{
 							code:res.code,
-							phoneCode:code
+							phoneCode:code,
+							channelType:that.channelType
 						},false).then(res=>{
 							if(res.data.code===0){
-								that.loginSuccessFn(res);
+								if(res.data.data.isRegister==1) that.loginSuccessFn(res);
+								else{
+									uni.navigateTo({
+										url:'/pages/registerInfo?params='+encodeURIComponent(JSON.stringify({
+											info:{
+												channelType:that.channelType,
+												mobile:res.data.data.mobile||'',
+												isRegister:res.data.data.isRegister,
+												referrerId:res.data.data.referrerId||'',
+												teamQuestionnaireId:res.data.data.teamQuestionnaireId||'',
+												userId:res.data.data.id||''
+											},
+											user:{
+												token:res.data.data.token,
+												id:res.data.data.id,
+												gender:res.data.data.gender,
+												realName:res.data.data.realName,
+												mobile:res.data.data.mobile,
+												headUrl:res.data.data.headUrl,
+												teamId:res.data.data.teamId,
+												enterpriseId:res.data.data.enterpriseId,
+												enterpriseName:res.data.data.enterpriseName,
+												teamName:res.data.data.teamName,
+												referrerId:res.data.data.referrerId,
+												teamQuestionnaireId:res.data.data.teamQuestionnaireId,
+												isRegister:res.data.data.isRegister
+											}
+										}))
+									})
+								}
 							}else that.$showToast(res.data.msg)
 						})
 					}
@@ -112,7 +146,10 @@
 					teamId:res.data.data.teamId,
 					enterpriseId:res.data.data.enterpriseId,
 					enterpriseName:res.data.data.enterpriseName,
-					teamName:res.data.data.teamName
+					teamName:res.data.data.teamName,
+					referrerId:res.data.data.referrerId,
+					teamQuestionnaireId:res.data.data.teamQuestionnaireId,
+					isRegister:res.data.data.isRegister
 				}));
 				
 				uni.hideLoading();

+ 67 - 4
pages/registerInfo.vue

@@ -8,7 +8,7 @@
 				<div class="info-form-item adfacjb">
 					<div class="info-form-item-left">您的姓名</div>
 					<div class="info-form-item-right">
-						<u-input v-model="dto.name" border="none" placeholder="请填写姓名"></u-input>
+						<u-input v-model="dto.realName" border="none" placeholder="请填写姓名"></u-input>
 					</div>
 				</div>
 				<div class="info-form-item adfacjb">
@@ -19,7 +19,7 @@
 				</div>
 			</div>
 		</div>
-		<div class="zt_btn">提交</div>
+		<div class="zt_btn" @click="handleSubmit">提交</div>
 	</view>
 </template>
 
@@ -27,14 +27,77 @@
 	export default {
 		data(){
 			return {
+				info:null,
+				user:null,
 				dto:{
-					name:'',
+					mobile:'',
+					realName:'',
 					email:''
 				}
 			}
 		},
+		onLoad(options) {
+			let params = JSON.parse(decodeURIComponent(options.params));
+			this.info = params.info;
+			this.user = params.user;
+			this.dto.mobile = this.info.mobile||'';
+		},
 		methods:{
-			
+			handleSubmit(){
+				if(!this.dto.realName) return this.$showToast('请输入姓名')
+				if(!this.$reg.email(this.dto.email)) return this.$showToast('请输入正确的邮箱')
+				
+				uni.showLoading({ title:'注册提交中' });
+				this.$api.post('/wx/register',this.dto,false).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					this.postRegisterRecord()
+				})
+			},
+			postRegisterRecord(){
+				this.$api.post('/core/register/record',{
+					channelType:this.info.channelType||'',
+					referrerId:this.info.referrerId||'',
+					teamQuestionnaireId:this.info.teamQuestionnaireId||'',
+					userId:this.info.userId||''
+				},false).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					
+					uni.setStorageSync('token',this.user.token);
+					uni.setStorageSync('userInfo',JSON.stringify({
+						id:this.user.id,
+						gender:this.user.gender,
+						realName:this.user.realName,
+						mobile:this.user.mobile,
+						headUrl:this.user.headUrl,
+						teamId:this.user.teamId,
+						enterpriseId:this.user.enterpriseId,
+						enterpriseName:this.user.enterpriseName,
+						teamName:this.user.teamName,
+						referrerId:this.user.referrerId,
+						teamQuestionnaireId:this.user.teamQuestionnaireId,
+						isRegister:1
+					}));
+					
+					uni.hideLoading();
+					this.$showToast('提交成功');
+					uni.reLaunch({
+						url:'/pages/home'
+					})
+				})
+			},
+			checkUser(){
+				this.$api.post('/wx/check',{
+					channelType:this.info.channelType||'',
+					isRegister:this.info.isRegister,
+					referrerId:this.info.referrerId||'',
+					teamQuestionnaireId:this.info.teamQuestionnaireId||'',
+					userId:this.info.userId||''
+				},false).then(({data:res})=>{
+					if(res.code!==0) return this.$showToast(res.msg)
+					uni.hideLoading();
+					console.log(res);
+				})
+			},
 		}
 	}
 </script>