From 338b2fd1c682864ddc6e3372887a38c1820c1805 Mon Sep 17 00:00:00 2001 From: zhaojs <349234519@qq.com> Date: 星期二, 27 六月 2023 13:57:54 +0800 Subject: [PATCH] no message --- uniapp/pages/login/wxlogin.vue | 162 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 144 insertions(+), 18 deletions(-) diff --git a/uniapp/pages/login/wxlogin.vue b/uniapp/pages/login/wxlogin.vue index f91d1e3..5b2d4f4 100644 --- a/uniapp/pages/login/wxlogin.vue +++ b/uniapp/pages/login/wxlogin.vue @@ -8,9 +8,16 @@ <image class="logoIcon" src="../../static/images/mine/wxwhite.png" mode=""></image> <view>寰俊涓�閿櫥褰�</view> </view> - <view class="goaccount rowCenCen" @tap="goaccount()"> + <view v-if="isSupportMob" class="goaccount rowCenCen" @tap="mobileLogin()"> + <view>鏈満鎵嬫満鍙蜂竴閿櫥褰�/娉ㄥ唽</view> + </view> + <view v-else class="goaccount rowCenCen" @tap="goaccount()"> <view>鎵嬫満鍙风櫥褰�/娉ㄥ唽</view> </view> + <view style="margin-top: 20px;" v-if="isother" @tap="goaccount()"> + 鎵嬫満鍙风櫥褰�/娉ㄥ唽 + </view> + </view> <view class="bottom-fixed colCen"> @@ -28,6 +35,7 @@ mapMutations } from 'vuex'; import titleBar from '../../components/backTitlebar.vue' + const univerifyManager = uni.getUniverifyManager(); export default { components: { titleBar @@ -37,15 +45,19 @@ appInfo: '', ifPasslogin: false, isread: false, - haswxlogin: false + haswxlogin: false, + isSupportMob:false, + isother:false, + clientid:'' } }, onLoad() { this.appInfo = uni.getStorageSync('appInfo') - console.log(this.appInfo.iosExamine) - console.log(getApp().globalData.ifwt) + //console.log(this.appInfo.iosExamine) + //console.log(getApp().globalData.ifwt) //this.haswxlogin = this.appInfo.iosExamine ? false : (getApp().globalData.ifwt == 1 ? true : false) this.haswxlogin = getApp().globalData.ifwt == 1 ? true :false; + this.isSupportMoblie(); }, methods: { ...mapMutations(['login']), @@ -62,8 +74,133 @@ }) } }, + isSupportMoblie() + { + var that=this; + uni.preLogin({ + provider: 'univerify', + success(){ //棰勭櫥褰曟垚鍔� + // 鏄剧ず涓�閿櫥褰曢�夐」 + that.isSupportMob=true; + }, + fail(res){ // 棰勭櫥褰曞け璐� + // 涓嶆樉绀轰竴閿櫥褰曢�夐」锛堟垨缃伆锛� + // 鏍规嵁閿欒淇℃伅鍒ゆ柇澶辫触鍘熷洜锛屽鏈夐渶瑕佸彲灏嗛敊璇彁浜ょ粰缁熻鏈嶅姟鍣� + console.log(res) + } + }) + }, + doMobileLogin(mobRes) + { + var that=this; + uniCloud.callFunction({ + name: 'getPhoneNumber', // 浣犵殑浜戝嚱鏁板悕绉� + data: { + 'access_token': mobRes.access_token, // 瀹㈡埛绔竴閿櫥褰曟帴鍙h繑鍥炵殑access_token + 'openid': mobRes.openid ,// 瀹㈡埛绔竴閿櫥褰曟帴鍙h繑鍥炵殑openid + 'push_cid':that.clientid//瀹㈡埛绔帹閫佺殑cid + } + }).then(res => { + console.log(res) + that.targetToIndex(res.result.data); + // 鐧诲綍鎴愬姛锛屽彲浠ュ叧闂竴閿櫥褰曟巿鏉冪晫闈簡 + univerifyManager.close(); + }).catch(err=>{ + // 澶勭悊閿欒 + console.log(err) + that.isother=true; + that.$alert('鑾峰彇鎵嬫満鍙风爜澶辫触锛岃浣跨敤鍏朵粬鏂瑰紡鐧诲綍') + setTimeout(function(){ + univerifyManager.close(); + },2000); + + }) + }, + mobileLogin() + { + var that=this; + // #ifdef APP-PLUS + plus.push.getClientInfoAsync((info) => { + that.clientid = info["clientid"]; + }); + // #endif + + if (this.isread) { + univerifyManager.login({ + provider: 'univerify', + univerifyStyle: { // 鑷畾涔夌櫥褰曟鏍峰紡 + "fullScreen":false, + "authButton": + { + "normalColor":"#F73314", + "highlightColor":"#F73314" + } + + }, + success(res){ // 鐧诲綍鎴愬姛 + console.log(res.authResult); + that.doMobileLogin(res.authResult); + }, + fail(res){ // 鐧诲綍澶辫触 + console.log(res) + if(res.errCode==30002) + {//鍒囨崲鐧诲綍鏂瑰紡 + that.isother=true; + } + else + { + that.$alert('鑾峰彇鎵嬫満鍙风爜澶辫触锛岃浣跨敤鍏朵粬鏂瑰紡鐧诲綍') + setTimeout(function(){ + univerifyManager.close(); + },2000); + } + that.isother=true; + } + }) + + } + else + { + uni.showToast({ + title: '璇峰厛闃呰骞跺悓鎰忋�婄敤鎴峰崗璁�嬪拰銆婇殣绉佸崗璁��', + icon: "none", + }) + } + + }, + targetToIndex(e) + { + var that = this; + + that.login(e.data.userinfo); + + that.$alert('鐧诲綍鎴愬姛') + setTimeout(function(){ + console.log(e.data.userinfo) + if(!e.data.userinfo.invitation_code) + { + uni.redirectTo({ + url: './setInviteCode' + }) + } + else if (e.data.userinfo.isPwd == 'N') { + uni.redirectTo({ + url: './setPass' + }) + } else { + uni.switchTab({ + url: '../index/index' + }) + } + },1000) + }, wxlogin() { var that = this; + // #ifdef APP-PLUS + plus.push.getClientInfoAsync((info) => { + that.clientid = info["clientid"]; + }); + // #endif if (this.isread) { uni.getProvider({ service: 'oauth', @@ -73,27 +210,16 @@ uni.login({ provider: 'weixin', success: (loginRes) => { + console.log(loginRes); that.$u.api.wxapplogin({ openid: loginRes.authResult.openid, access_token: loginRes.authResult.access_token }).then(e => { + console.log(e); if (e.code != 0) return that.$alert(e.msg) var res = e.data; if(res.type == 'goUser'){ - that.login(e.data.userinfo); - that.$alert('鐧诲綍鎴愬姛') - setTimeout(function() { - if (res.userinfo.isPwd == - 'N') { - uni.redirectTo({ - url: './setPass' - }) - } else { - uni.switchTab({ - url: '../index/index' - }) - } - }, 1000) + this.targetToIndex(e); }else if(res.type == 'bindMobile'){ uni.navigateTo({ url: "./bindingPhone?wx="+encodeURIComponent(JSON.stringify(res.info)) -- Gitblit v1.9.3