Procházet zdrojové kódy

fix: 调整手机号一键登录模块

wenxingxing před 1 dnem
rodič
revize
a70ff4786f
4 změnil soubory, kde provedl 69 přidání a 32 odebrání
  1. 1 1
      .hbuilderx/launch.json
  2. 2 1
      main.js
  3. 65 29
      pages/auth/loginIndex.vue
  4. 1 1
      utils/login.js

+ 1 - 1
.hbuilderx/launch.json

@@ -3,7 +3,7 @@
     "configurations" : [
     "configurations" : [
         {
         {
             "app" : {
             "app" : {
-                "launchtype" : "local"
+                "launchtype" : "remote"
             },
             },
             "default" : {
             "default" : {
                 "launchtype" : "local"
                 "launchtype" : "local"

+ 2 - 1
main.js

@@ -8,7 +8,7 @@ import uView from "@/node_modules/uview-ui";
 
 
 import {parseIDCardInfo,logout,checkCompanyUserLoginState,parseText,getDictLabelName,parseIdCard,getAge,parsePhone,isEmpty,getDict,
 import {parseIDCardInfo,logout,checkCompanyUserLoginState,parseText,getDictLabelName,parseIdCard,getAge,parsePhone,isEmpty,getDict,
 isLogin,navBack,navTo,getUserInfo,formatHour,dateFormatStr,registerIdCode,updateMsgDot,handleBindCompanyFsUser,
 isLogin,navBack,navTo,getUserInfo,formatHour,dateFormatStr,registerIdCode,updateMsgDot,handleBindCompanyFsUser,
-setSource,companyUserIsLogin,checkWechatInstalled,isIos,isAndroid} from './utils/common.js'
+setSource,companyUserIsLogin,checkWechatInstalled,isIos,isAndroid,isAgreePrivacy} from './utils/common.js'
 
 
 import { showLoginPage,getRegistrationID } from './utils/login.js'
 import { showLoginPage,getRegistrationID } from './utils/login.js'
 import { formatSeconds,formatDate } from './utils/tools.js'
 import { formatSeconds,formatDate } from './utils/tools.js'
@@ -28,6 +28,7 @@ Vue.use(uView);
 Vue.prototype.$getDict = getDict;
 Vue.prototype.$getDict = getDict;
 Vue.prototype.$checkCompanyUserLoginState = checkCompanyUserLoginState;
 Vue.prototype.$checkCompanyUserLoginState = checkCompanyUserLoginState;
 Vue.prototype.$isLogin = isLogin;
 Vue.prototype.$isLogin = isLogin;
+Vue.prototype.$isAgreePrivacy = isAgreePrivacy;
 Vue.prototype.$isEmpty = isEmpty;
 Vue.prototype.$isEmpty = isEmpty;
 Vue.prototype.$parsePhone = parsePhone;
 Vue.prototype.$parsePhone = parsePhone;
 Vue.prototype.$showLoginPage = showLoginPage;
 Vue.prototype.$showLoginPage = showLoginPage;

+ 65 - 29
pages/auth/loginIndex.vue

@@ -10,31 +10,35 @@
 			<!-- <view class="phone">187****8783</view>
 			<!-- <view class="phone">187****8783</view>
 			<view class="tips">认证服务由中国移动统一认证提供</view> -->
 			<view class="tips">认证服务由中国移动统一认证提供</view> -->
 			<!-- #ifndef APP-HARMONY -->
 			<!-- #ifndef APP-HARMONY -->
-			 
-			<button class="login-btn x-c" v-if="checkWechatInstalled()" style="margin-top: 74rpx;" :loading="btnLoading" :disabled="btnLoading" @click="quickClick(1)">
+
+			<button class="login-btn x-c" v-if="checkWechatInstalled()" style="margin-top: 74rpx;" :loading="btnLoading"
+				:disabled="btnLoading" @click="quickClick(1)">
 				<image class="es-icon-50 es-mr-10" src="/static/images/icon_wx.png"></image>
 				<image class="es-icon-50 es-mr-10" src="/static/images/icon_wx.png"></image>
 				<text>微信快捷登录</text>
 				<text>微信快捷登录</text>
 			</button>
 			</button>
 			<!-- #endif -->
 			<!-- #endif -->
-			
-			<button class="login-btn apple-login-btn x-c"  :loading="btnLoading"  v-if="$isIos()" :disabled="btnLoading" @click="quickClick(2)">
+
+			<button class="login-btn apple-login-btn x-c" :loading="btnLoading" v-if="$isIos()" :disabled="btnLoading"
+				@click="quickClick(2)">
 				<image class="es-icon-50 es-mr-10" src="/static/image/login/apple.png"></image>
 				<image class="es-icon-50 es-mr-10" src="/static/image/login/apple.png"></image>
 				<text>苹果登录</text>
 				<text>苹果登录</text>
-			</button>	
-				
-				
-		   <button class="login-btn other-login-btn" :loading="btnLoading" :disabled="btnLoading" @click="submit()">手机号一键登录</button>
-			
+			</button>
+
+
+			<button class="login-btn other-login-btn" :loading="btnLoading" :disabled="btnLoading"
+				@click="submit()">手机号一键登录</button>
+
 			<button class="login-btn other-login-btn" :disabled="btnLoading" @tap="handleOtherLogin">其他方式登录</button>
 			<button class="login-btn other-login-btn" :disabled="btnLoading" @tap="handleOtherLogin">其他方式登录</button>
 			<view class="checkbox">
 			<view class="checkbox">
 				<view class="checkbox-icon" @tap="handleAgree">
 				<view class="checkbox-icon" @tap="handleAgree">
 					<image src="../../static/image/login/radio_default.png" v-show="!agree"></image>
 					<image src="../../static/image/login/radio_default.png" v-show="!agree"></image>
 					<image src="../../static/image/login/radio_choose.png" v-show="agree"></image>
 					<image src="../../static/image/login/radio_choose.png" v-show="agree"></image>
 				</view>
 				</view>
-				<view class="es-fs-36" @tap="handleAgree">我已阅读并同意<text @tap.stop="goToWeb(0)">《用户协议》</text><text @tap.stop="goToWeb(1)">《隐私政策》</text> 并使用本机号码登录</view>
+				<view class="es-fs-36" @tap="handleAgree">我已阅读并同意<text @tap.stop="goToWeb(0)">《用户协议》</text><text
+						@tap.stop="goToWeb(1)">《隐私政策》</text> 并使用本机号码登录</view>
 			</view>
 			</view>
 		</view>
 		</view>
-		
+
 		<u-popup :show="show" :safeAreaInsetBottom="false" mode="center" round="16rpx" @close="show=false">
 		<u-popup :show="show" :safeAreaInsetBottom="false" mode="center" round="16rpx" @close="show=false">
 			<view class="popupBox u-f-ajc">
 			<view class="popupBox u-f-ajc">
 				<view class="es-c-33 es-fs-32 es-fw ">
 				<view class="es-c-33 es-fs-32 es-fw ">
@@ -52,23 +56,32 @@
 				</view>
 				</view>
 			</view>
 			</view>
 		</u-popup>
 		</u-popup>
-	
+
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script>
 <script>
-	import {navBack} from "../../utils/common";
-	import {login} from "@/api/user.js"
-	import { quickAppleLogin,quickWechatLogin} from "@/utils/login.js"
-	import { checkWechatInstalled} from '@/utils/common.js'
+	import {
+		navBack
+	} from "../../utils/common";
+	import {
+		login
+	} from "@/api/user.js"
+	import {
+		quickAppleLogin,
+		quickWechatLogin
+	} from "@/utils/login.js"
+	import {
+		checkWechatInstalled
+	} from '@/utils/common.js'
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
 				btnLoading: false,
 				btnLoading: false,
 				agree: false,
 				agree: false,
 				show: false,
 				show: false,
-				quickLoginType:1 ,// 1:微信登录  2:苹果登录,
-				
+				quickLoginType: 1, // 1:微信登录  2:苹果登录,
+				curRegistrationID: null,
 			}
 			}
 		},
 		},
 		onLoad() {
 		onLoad() {
@@ -83,7 +96,7 @@
 				} else {
 				} else {
 					// #ifdef APP-PLUS
 					// #ifdef APP-PLUS
 					//this.submit()
 					//this.submit()
-					
+
 					// #endif
 					// #endif
 					// #ifndef APP-PLUS
 					// #ifndef APP-PLUS
 					if (String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger") {
 					if (String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger") {
@@ -122,20 +135,40 @@
 					animationDuration: 2000
 					animationDuration: 2000
 				})
 				})
 			}
 			}
+
+			// #ifdef APP-PLUS
+			let curAgreePrivacy = this.$isAgreePrivacy();
+			if (curAgreePrivacy) {
+				this.getRegistrationID();
+			}
+			// #endif
 		},
 		},
 		methods: {
 		methods: {
+			getRegistrationID() {
+				this.curRegistrationID = uni.getStorageSync('registrationID');
+				if (!this.curRegistrationID) {
+					uni.getPushClientId({
+						success: (res) => {
+							uni.setStorageSync('registrationID', res.cid);
+							this.curRegistrationID = res.cid;
+						}
+					});
+				}
+			},
+
+
 			checkWechatInstalled,
 			checkWechatInstalled,
-		    quickClick(type){
-				this.quickLoginType=type;
-				this.show=true;
+			quickClick(type) {
+				this.quickLoginType = type;
+				this.show = true;
 			},
 			},
 			quickLogin() {
 			quickLogin() {
-				this.agree=true;
-				if(this.quickLoginType==1){
+				this.agree = true;
+				if (this.quickLoginType == 1) {
 					quickWechatLogin(false);
 					quickWechatLogin(false);
 				}
 				}
-				if(this.quickLoginType==2){
-				    quickAppleLogin(false);
+				if (this.quickLoginType == 2) {
+					quickAppleLogin(false);
 				}
 				}
 			},
 			},
 			goToWeb(index) {
 			goToWeb(index) {
@@ -322,6 +355,7 @@
 		&-icon {
 		&-icon {
 			flex-shrink: 0;
 			flex-shrink: 0;
 			margin-right: 12rpx;
 			margin-right: 12rpx;
+
 			image {
 			image {
 				height: 40rpx;
 				height: 40rpx;
 				width: 40rpx;
 				width: 40rpx;
@@ -347,14 +381,14 @@
 			border: none;
 			border: none;
 		}
 		}
 	}
 	}
-	
-	
+
+
 	.apple-login-btn {
 	.apple-login-btn {
 		background: #fff;
 		background: #fff;
 		border: 2rpx solid #000000;
 		border: 2rpx solid #000000;
 		color: #000 !important;
 		color: #000 !important;
 	}
 	}
-	
+
 
 
 	.other-login-btn {
 	.other-login-btn {
 		background: #fff;
 		background: #fff;
@@ -366,9 +400,11 @@
 		padding: 48rpx 24rpx;
 		padding: 48rpx 24rpx;
 		width: 500rpx;
 		width: 500rpx;
 		flex-direction: column;
 		flex-direction: column;
+
 		.colorFF5C03 {
 		.colorFF5C03 {
 			color: #FF5C03;
 			color: #FF5C03;
 		}
 		}
+
 		.popupbox-btn {
 		.popupbox-btn {
 			width: 100%;
 			width: 100%;
 			border-radius: 8rpx;
 			border-radius: 8rpx;

+ 1 - 1
utils/login.js

@@ -645,7 +645,7 @@ export function setPhoneAct(phone,unionId){
   
   
   
   
 export function bindWechatAct(phone,code){
 export function bindWechatAct(phone,code){
-   	  let params={"phone":phone,"code":code,"jpushId":registrationID,"source":plus.runtime.channel || source};
+   	  let params={"phone":phone,"code":code,"jpushId":registrationID,"source":plus.runtime.channel || source,"appId":'wxecdaff01852ca309'};
    	  bindWechat(params).then(res => {
    	  bindWechat(params).then(res => {
    	  		uni.hideLoading();
    	  		uni.hideLoading();
 			console.log("qxj bindWeChat res:"+JSON.stringify(res));
 			console.log("qxj bindWeChat res:"+JSON.stringify(res));