From 8fa222fadf0a978b0489ee76419765c497c53080 Mon Sep 17 00:00:00 2001 From: fanp Date: Mon, 11 Nov 2019 13:44:38 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 3 +- pages/topics/index.js | 16 ++++- pages/user/index.js | 43 ++------------ pages/user/index.wxml | 13 +---- pages/user/index.wxss | 2 - pages/user/myInfo/index.wxml | 2 +- pages/weChatAuth/index.js | 110 +++++++++++++++++++++++++++++++++++ pages/weChatAuth/index.json | 3 + pages/weChatAuth/index.wxml | 22 +++++++ pages/weChatAuth/index.wxss | 51 ++++++++++++++++ project.config.json | 11 ++++ 11 files changed, 220 insertions(+), 56 deletions(-) create mode 100644 pages/weChatAuth/index.js create mode 100644 pages/weChatAuth/index.json create mode 100644 pages/weChatAuth/index.wxml create mode 100644 pages/weChatAuth/index.wxss diff --git a/app.json b/app.json index 08cfe03..5656882 100644 --- a/app.json +++ b/app.json @@ -20,7 +20,8 @@ "pages/topics/interactive/submitTopic/index", "pages/topics/interactive/topicArticle/index", "pages/billboards/park/park-category/index", - "pages/billboards/park/park-detail/index" + "pages/billboards/park/park-detail/index", + "pages/weChatAuth/index" ], "window": { "backgroundTextStyle": "light", diff --git a/pages/topics/index.js b/pages/topics/index.js index 7b74a85..c68f45f 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -70,8 +70,20 @@ Page({ } } else { console.log('未绑定微信') - wx.switchTab({ - url: '/pages/user/index', + wx.showModal({ + title: '温馨提示', + content: '是否前往绑定微信?', + success(res) { + if (res.confirm) { + wx.redirectTo({ + url: '/pages/weChatAuth/index', + }) + } else if (res.cancel) { + wx.switchTab({ + url: '/pages/home/index', + }) + } + } }) } }, diff --git a/pages/user/index.js b/pages/user/index.js index 5ab282d..d0c75a4 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -15,16 +15,6 @@ Page({ */ data: { messageTotal: Number, - canIUse: wx.canIUse('button.open-type.getUserInfo'), - authType:0, - reAuth:false, - isAuth:false, - nickName:'', - avatarUrl:'', - userInfo:{ - type:Object, - value:{} - } }, @@ -35,31 +25,15 @@ Page({ }, onShow: function () { - this.getUserInfo() - }, - - // 授权登录 - bindGetUserInfo (e) { - //console.log(e.detail.userInfo) - if (e.detail.userInfo){ - let avatarUrl = e.detail.userInfo.avatarUrl - let nickName = e.detail.userInfo.nickName - store.saveUserInfo({ - nickName: nickName, - avatarUrl: avatarUrl, - phone: '' + if (store.hasBindUserInfo()) { + this.getUserInfo() + } else { + wx.redirectTo({ + url: '/pages/weChatAuth/index', }) - this.sendUserInfo(e.detail.userInfo) } }, - // 上传用户信息 - sendUserInfo(weChatInfo){ - userModel.sendUserInfo(weChatInfo, res => { - this.getUserInfo() - }) - }, - // 获取用户信息 getUserInfo () { userModel.getUserInfo(res => { @@ -73,8 +47,6 @@ Page({ userInfo: res.result, avatarUrl: res.result.avatarUrl, nickName: res.result.nickName, - reAuth: true, - isAuth: false },()=>{ if (store.hasPhone()) { //console.log('已经绑定手机号码') @@ -103,11 +75,6 @@ Page({ avatarUrl: res.result.avatarUrl, phone: res.result.phone || '' }) - } else { - //console.log('未授权') - this.setData({ - isAuth: true - }) } }) }, diff --git a/pages/user/index.wxml b/pages/user/index.wxml index b119844..c90c4c1 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -1,6 +1,6 @@ - + @@ -8,17 +8,6 @@ - - - - - - - - 请升级微信版本 - - - - + { + this.getUserInfo() + }) + }, + + // 获取用户信息 + getUserInfo() { + userModel.getUserInfo(res => { + console.log(res) + let nickName = res.result.nickName + let avatarUrl = res.result.avatarUrl + + if (nickName && avatarUrl) { + //console.log('已授权') + this.setData({ + userInfo: res.result, + avatarUrl: res.result.avatarUrl, + nickName: res.result.nickName, + reAuth: true, + isAuth: false + }, () => { + if (store.hasPhone()) { + //console.log('已经绑定手机号码') + } else { + //console.log('未绑定手机号码') + wx.showModal({ + title: '温馨提示', + content: '是否前往验证手机号码?', + success(res) { + if (res.confirm) { + wx.redirectTo({ + url: '/pages/register/index', + }) + } else if (res.cancel) { + wx.switchTab({ + url: '/pages/home/index', + }) + } + } + }) + } + }) + store.saveUserInfo({ + nickName: res.result.nickName, + avatarUrl: res.result.avatarUrl, + phone: res.result.phone || '' + }) + } else { + //console.log('未授权') + this.setData({ + isAuth: true + }) + } + }) + } +}) \ No newline at end of file diff --git a/pages/weChatAuth/index.json b/pages/weChatAuth/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/weChatAuth/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/weChatAuth/index.wxml b/pages/weChatAuth/index.wxml new file mode 100644 index 0000000..d9059a4 --- /dev/null +++ b/pages/weChatAuth/index.wxml @@ -0,0 +1,22 @@ + + + + + + + + 市北人才 + + + + + Hi,请登录~ + + + 授权后,可以更好的体验我们哦~ + + + + 请升级微信版本 + + diff --git a/pages/weChatAuth/index.wxss b/pages/weChatAuth/index.wxss new file mode 100644 index 0000000..106ae7c --- /dev/null +++ b/pages/weChatAuth/index.wxss @@ -0,0 +1,51 @@ +/* pages/weChatAuth/index.wxss */ +.container { + position: relative; + padding: 0 20px; + display: flex; + height: 100vh; + justify-items: center; + align-items: center; +} +.auth_cancel { + position: absolute; + padding: 10px; + width: 30px; + height: 30px; + top: 0; + right: 20px; +} +.page_bd { + height: 65vh; + width: 100%; +} +.image_view{ + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} +.img{ + width: 180px; + height: 120px; +} +.title{ + font-size: 20px; + padding: 10px; +} + +.description{ + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} +.h1{ + padding: 20px 0 10px; + font-size: 20px; + font-weight: bold; +} +.authBtn{ + background-color: rgb(32,192,100); + top: 40px; +} diff --git a/project.config.json b/project.config.json index f079d51..3aeea63 100644 --- a/project.config.json +++ b/project.config.json @@ -49,6 +49,10 @@ "currentL": -1, "list": [] }, + "gamePlugin": { + "current": -1, + "list": [] + }, "miniprogram": { "current": 7, "list": [ @@ -105,6 +109,13 @@ "id": -1, "name": "Topics", "pathName": "pages/topics/index", + "query": "", + "scene": null + }, + { + "id": -1, + "name": "pages/weChatAuth/index", + "pathName": "pages/weChatAuth/index", "scene": null } ]