From b755a6369ec07c12a18275b2161906e8b6aeb3a0 Mon Sep 17 00:00:00 2001 From: zeb <936152864@qq.com> Date: Fri, 30 Jul 2021 08:46:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 84 +++++++++++++++++++++++----------------------- app.json | 3 +- pages/auth/auth.js | 54 +++++++++++++++++++---------- 3 files changed, 80 insertions(+), 61 deletions(-) diff --git a/app.js b/app.js index 5ccbc36..9493e5e 100644 --- a/app.js +++ b/app.js @@ -6,30 +6,30 @@ App({ let token = wx.getStorageSync('access_token') let userInfo = wx.getStorageSync('userInfo') if(token&&userInfo)return; - wx.login({ - success (res) { - if (res.code) { - //发起网络请求 - $api.getUserAuth(res.code).then(data=>{ - if(data.access_token){ - wx.setStorage({ - key:"access_token", - data:data.access_token - }) - that.queryUsreInfo(); - }else if(data.code==2){ - that.registerBind(res.code) - }else{ + // wx.login({ + // success (res) { + // if (res.code) { + // //发起网络请求 + // $api.getUserAuth(res.code).then(data=>{ + // if(data.access_token){ + // wx.setStorage({ + // key:"access_token", + // data:data.access_token + // }) + // that.queryUsreInfo(); + // }else if(data.code==2){ + // that.registerBind(res.code) + // }else{ - } - }).catch(err=>{ - console.log('err',err) - }) - } else { - console.log('登录失败!' + res.errMsg) - } - } - }) + // } + // }).catch(err=>{ + // console.log('err',err) + // }) + // } else { + // console.log('登录失败!' + res.errMsg) + // } + // } + // }) @@ -66,25 +66,25 @@ App({ }) } }, - registerBind(code){ - let that = this; - let params = { - state:'MINI', - code, - phone:'15198094357', - phoneCode:'', - nickName:'', - avatar:'', - legalName:'' - }; - $api.registerBind(params).then(data=>{ - wx.setStorage({ - key:"access_token", - data:data.access_token - }) - that.queryUsreInfo(); - }) - }, + // registerBind(code){ + // let that = this; + // let params = { + // state:'MINI', + // code, + // phone:'15198094357', + // phoneCode:'', + // nickName:'', + // avatar:'', + // legalName:'' + // }; + // $api.registerBind(params).then(data=>{ + // wx.setStorage({ + // key:"access_token", + // data:data.access_token + // }) + // that.queryUsreInfo(); + // }) + // }, queryUsreInfo(){ $api.getUserInfo().then(res=>{ if(res.code===0){ diff --git a/app.json b/app.json index e60913c..5b2dac5 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,6 @@ { "pages": [ + "pages/auth/auth", "pages/index/index", "pages/calendar/calendar", "pages/look/look", @@ -10,7 +11,7 @@ "pages/look-detail/look-detail", "pages/history/history", "pages/air-report/air-report", - "pages/auth/auth", + "pages/feasibility-study/feasibility-study", "pages/periodic-report/periodic-report", "pages/special-research/special-research", diff --git a/pages/auth/auth.js b/pages/auth/auth.js index e3e8f71..f28b981 100644 --- a/pages/auth/auth.js +++ b/pages/auth/auth.js @@ -41,13 +41,7 @@ Page({ success: (eve) => { console.log(eve) att = eve; - } - }) - wx.getUserProfile({ - desc: '用户展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 - success: (resT) => { - console.log(resT) - $api.Login('POST', 'social/token', { code: 'MINI@' + att.code }).then(res => { + $api.Login('POST', 'social/token?' + 'code=MINI@' + eve.code).then(res => { console.log(res); if(res.code == 2){ wx.showToast({ @@ -58,21 +52,35 @@ Page({ }) that.setData({ code:att.code, - user:resT.userInfo, is_login:false, }) + } else { + wx.setStorage({ + 'access_token': res.access_token + }) + wx.switchTab({ + url:'/pages/index/index' + }) } }) - }, - fail: (res) => { - wx.showToast({ - title: '授权失败,请重试。', - icon: 'none', - mask: true, - duration: 1500, - }) } }) + // wx.getUserProfile({ + // desc: '用户展示用户信息', + // success: (resT) => { + // console.log(resT) + + // }, + // fail: (res) => { + // wx.showToast({ + // title: '授权失败,请重试。', + // icon: 'none', + // mask: true, + // duration: 1500, + // }) + // } + // }) + }, // 一键注册 获取手机号 getphonenumberFun(e){ @@ -91,14 +99,24 @@ Page({ } console.log(e) console.log(user) - + $api.AJAX('POST', 'social/register-bind', { state:'MINI', - phone:'15608615712', + encryptedData:e.detail.encryptedData, + iv: e.detail.iv, code: code, nickName:user.nickName, avatar:user.avatarUrl, }, false).then(res => { + if(res.code == 1) { + wx.showToast({ + title: res.msg, + icon: 'none', + mask: true, + duration: 1500, + }) + return + } wx.showToast({ title: '注册成功', icon: 'none',