diff --git a/pages/topics/index.js b/pages/topics/index.js index 930d4e2..302060a 100644 --- a/pages/topics/index.js +++ b/pages/topics/index.js @@ -25,7 +25,7 @@ Page({ */ onLoad: function () { - if (store.hasPhone()) { + if (!store.hasPhone()) { console.log('已经绑定手机号码') } else { console.log('未绑定手机号码') diff --git a/pages/topics/interactive/topicArticle/index.js b/pages/topics/interactive/topicArticle/index.js index d4cf630..383f6a5 100644 --- a/pages/topics/interactive/topicArticle/index.js +++ b/pages/topics/interactive/topicArticle/index.js @@ -25,7 +25,6 @@ Page({ star: '/images/common/star_light.png', isStar:false, topicId:String, - collectionId:String, isCollect:Number, currPage: 1, commentList: [], @@ -61,7 +60,7 @@ Page({ console.log(res) let data = res.result this.setData({ - collectionId: data.collectionId, + topicId: data.id, isCollect: data.isCollect, title:data.title, time: data.createTime, @@ -136,8 +135,8 @@ Page({ }, fetchTopicUnCollect(){ - let collectionId = this.data.collectionId - topicModel.topicUnCollect(collectionId, res => { + let topicId = this.data.topicId + topicModel.topicUnCollect(topicId, res => { console.log('取消收藏') console.log(res) if (res.code === 200) { diff --git a/pages/user/index.js b/pages/user/index.js index fc47da9..e76ece6 100644 --- a/pages/user/index.js +++ b/pages/user/index.js @@ -16,7 +16,11 @@ Page({ data: { messageTotal: Number, canIUse: wx.canIUse('button.open-type.getUserInfo'), - authType: 0 + authType: 0, + reAuth: false, + isAuth: false, + nickName: '', + avatarUrl: '', }, /** @@ -24,7 +28,6 @@ Page({ */ onLoad: function (options) { this.getUserInfo() - this.isAuthUserInfo() }, isAuthUserInfo () { let that = this @@ -43,18 +46,25 @@ Page({ // 已经授权,可以直接调用 getUserInfo 获取头像昵称 wx.getUserInfo({ success: function (res) { - console.log(res.userInfo) + // console.log(res.userInfo) let nickName = res.userInfo.nickName let avatarUrl = res.userInfo.avatarUrl - console.log(nickName, avatarUrl) + + store.saveUserInfo({ + nickName: nickName, + avatarUrl: avatarUrl, + phone: '' + }) + if (nickName && avatarUrl) { that.setData({ - authType: 2 + isAuth: false }, () => { wx.hideLoading() }) } + that.getUserInfo() } }) } @@ -79,12 +89,30 @@ Page({ }, updateUserInfo (avatarUrl, city, country, gender, nickName, province) { userModel.updateUserInfo(avatarUrl, city, country, gender, nickName, province, res => { - console.log(res) + }) }, getUserInfo () { userModel.getUserInfo(res => { - console.log(res) + let nickName = res.result.nickName + let avatarUrl = res.result.avatarUrl + if (nickName && avatarUrl) { + this.setData({ + avatarUrl: res.result.avatarUrl, + nickName: res.result.nickName, + reAuth: true + }) + store.saveUserInfo({ + nickName: res.result.nickName, + avatarUrl: res.result.avatarUrl, + phone: res.result.phone === null ? '' : res.result.phone + }) + } else { + console.log('未授权') + this.setData({ + isAuth: true + }) + } }) }, @@ -102,10 +130,5 @@ Page({ wx.navigateTo({ url: `/pages/user/${type}/index`, }) - // if(type != 'myInfo'){ - // wx.navigateTo({ - // url: `/pages/user/${type}/index`, - // }) - // } }, }) \ No newline at end of file diff --git a/pages/user/index.wxml b/pages/user/index.wxml index 5c446b5..6245c1c 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -1,19 +1,17 @@ - + - - - - - + + + {{nickName}} - + - +