From 27cb79337f9111219a28f95406867eeca140a84d Mon Sep 17 00:00:00 2001 From: liudan <18634735655@163.com> Date: Wed, 21 Jun 2023 17:23:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- androidPrivacy.json | 2 +- manifest.json | 4 +- pages/login.vue | 113 ++++++++++++++++++++-------------------- utils/req.js | 124 ++++++++++++++++++++++++++++++-------------- 4 files changed, 145 insertions(+), 98 deletions(-) diff --git a/androidPrivacy.json b/androidPrivacy.json index c478f39..6cc8c98 100644 --- a/androidPrivacy.json +++ b/androidPrivacy.json @@ -1,5 +1,5 @@ { - "version" : "7.0.0", + "version" : "9.0.0", "prompt" : "template", "title" : "服务协议和隐私政策", "message" : "  请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的位置信息、设备标识、操作日志等信息用于分析、优化应用性能。
  你可阅读《服务协议》《隐私政策》了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。", diff --git a/manifest.json b/manifest.json index d3ca9b8..b286433 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "appid" : "__UNI__3303922", // "appid" : "__UNI__AE4A250", "description" : "希希到家", - "versionName" : "7.0.0", - "versionCode" : 700, + "versionName" : "9.0.0", + "versionCode" : 900, "transformPx" : false, "uniStatistics" : { "enable" : false //全局关闭 diff --git a/pages/login.vue b/pages/login.vue index 90b8707..8617572 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -60,12 +60,12 @@ - + - + @@ -118,17 +118,19 @@ } }, async onLoad() { - console.log('pages/login') + console.log('pages/login',"888") let { autograph = '', - appLogin = '' + appLogin = '' } = this console.log('autograph,appLogin', autograph, appLogin) if (autograph && appLogin) { if(appLogin.unionId){ + console.log("999") this.toLogin(appLogin) return }else{ + console.log("777") this.checked=[] this.checked.push('1') this.smsLogin(appLogin) @@ -164,59 +166,60 @@ ...mapActions(['getConfigInfo', 'getUserInfo']), ...mapMutations(['updateConfigItem', 'updateUserItem']), //微信登录 - // async wxLogin() { - // this.$refs.show_rule_item.close() - // try { - // let [providerErr, providerData] = await uni.getProvider({ - // service: 'oauth', - // }); - // console.log("111") - // // let [loginErr, loginData] =await uni.getUserProfile({ - // // desc: '用于您的页面展示用户头像与昵称', - // // lang: 'zh_CN', - // // success: res => { - // // console.log(res,"jjj"); - // // // this.isShowLogin = false; - // // // this.userInfo = res.userInfo; - // // }, - // // fail: err => { - // // console.log(err.errMsg); - // // } - // // }); + async wxLogin() { + this.$refs.show_rule_item.close() + try { + let [providerErr, providerData] = await uni.getProvider({ + service: 'oauth', + }); + console.log("111") + // let [loginErr, loginData] =await uni.getUserProfile({ + // desc: '用于您的页面展示用户头像与昵称', + // lang: 'zh_CN', + // success: res => { + // console.log(res,"jjj"); + // // this.isShowLogin = false; + // // this.userInfo = res.userInfo; + // }, + // fail: err => { + // console.log(err.errMsg); + // } + // }); - // let [loginErr, loginData] = await uni.login({ - // provider: 'weixin' - // }); - // console.log("222") - // let [infoErr, infoData] = await uni.getUserInfo({ - // provider: 'weixin' - // }) - // console.log("333",infoData) - // let { - // userInfo = {} - // } = infoData - // let { - // openId = '' - // } = userInfo - // if (!openId) return - // this.$util.showLoading({ - // title: "登录中..." - // }) - // try { - // this.toLogin(userInfo) - // } catch (e) { - // this.$util.hideAll() - // } - // } catch (e) { - // console.log(e) - // this.$util.showToast({ - // title: '请先安装微信或升级版本' + let [loginErr, loginData] = await uni.login({ + provider: 'weixin' + }); + console.log("222") + let [infoErr, infoData] = await uni.getUserInfo({ + provider: 'weixin' + }) + console.log("333",infoData) + let { + userInfo = {} + } = infoData + let { + openId = '' + } = userInfo + if (!openId) return + this.$util.showLoading({ + title: "登录中..." + }) + try { + this.toLogin(userInfo) + } catch (e) { + this.$util.hideAll() + } + } catch (e) { + console.log(e) + this.$util.showToast({ + title: '请先安装微信或升级版本' - // }); - // } + }); + } - // }, + }, async smsLogin(item){ + console.log("短信登陆") if(this.checked.length==0){ uni.$u.toast('请阅读并同意《隐私政策》'); return false; diff --git a/utils/req.js b/utils/req.js index ce6d137..7c1e304 100644 --- a/utils/req.js +++ b/utils/req.js @@ -212,38 +212,59 @@ const appLogin = async function() { let url = formatUrl("index/appLogin") try { let userInfo = $store.state.user.appLogin - let { - openId = '' - } = userInfo - if (!openId) return - let d = await tokenFly.post(url, { - data: userInfo - }); - let { - code, - data, - error - } = d.data - if (code !== 200) { - uni.hideLoading() - serverError({ - code, - msg: error - }); - throw d; - } - //登录成功 - uni.hideLoading() - $store.commit('updateUserItem', { - key: 'userInfo', - val: data.data - }) - $store.commit('updateUserItem', { - key: 'autograph', - val: data.autograph - }) - return data + // if(userInfo.data){ + if(userInfo.data&&userInfo.data.openid){ + let arr = ['autograph', 'userInfo', 'location', 'appLogin'] + arr.map(key => { + uni.setStorageSync(key, ''); + $store.commit('updateUserItem', { + key, + val: '' + }) + uni.navigateTo({ + url:'/pages/login' + }) + uni.hideLoading() + }) + return; + }else{ + let { + openId = '' + } = userInfo + + if (!openId) return + console.log(userInfo,"aaaaa") + let d = await tokenFly.post(url, { + data: userInfo + }); + let { + code, + data, + error + } = d.data + if (code !== 200) { + uni.hideLoading() + serverError({ + code, + msg: error + }); + throw d; + } + //登录成功 + uni.hideLoading() + $store.commit('updateUserItem', { + key: 'userInfo', + val: data.data + }) + $store.commit('updateUserItem', { + key: 'autograph', + val: data.autograph + }) + return data + } + } catch (e) { + console.log("登陆失败",e) return await Promise.reject(e); } } @@ -301,26 +322,50 @@ fly.interceptors.response.use( //#endif //#ifdef APP-PLUS - console.log("==> APP-PLUS 401") - await appLogin() + console.log("==> APP-PLUS 401",response) + let res = await appLogin() + console.log(res,"999") + // let userInfo = $store.state.user.appLogin + // console.log(userInfo,"111") + // if(userInfo.data){ + // if(userInfo.data.openid){ + // let arr = ['autograph', 'userInfo', 'location', 'appLogin'] + // arr.map(key => { + // uni.setStorageSync(key, ''); + // $store.commit('updateUserItem', { + // key, + // val: '' + // }) + // uni.navigateTo({ + // url:'/pages/login' + // }) + // uni.hideLoading() + // }) + // } + // return; + // }else{ + // await appLogin() + // } + //#endif response.request.headers["autograph"] = $store.state.user.autograph || '' fly.unlock(); - return fly.request(response.request); + // return fly.request(response.request); }, async (err) => { - console.log(err, "=======fly.interceptors.response.use err",err); + // console.log(err, "=======fly.interceptors.response.use err"); + console.log(err,"--=====") let { status = 0, } = err $util.hideAll() - console.log(err) - msgError({ - msg: err.response.data.error.error + // msgError({ + // // msg: err.response.data.error.error + // msg:err - }) + // }) networkError({ code: status, }) @@ -328,7 +373,6 @@ fly.interceptors.response.use( return await Promise.reject(err); } ) - //统一处理请求,satus=200网络正常code=200服务器正常 const httpType = ["post", "get"] const formatReq = function() {