Browse Source

更新提示信息

master
lqq 6 years ago
parent
commit
0ad9e447de
  1. 62
      pages/topics/index.js
  2. 25
      pages/user/index.js

62
pages/topics/index.js

@ -25,43 +25,55 @@ Page({
*/
onLoad: function () {
if (store.hasBindUserInfo()){
},
onShow: function () {
if (store.hasBindUserInfo()) {
console.log('已经绑定微信')
if (store.hasPhone()) {
console.log('已经绑定手机号码')
// 页面出现在前台时执行
let segmentIndex = this.data.segmentIndex
if (segmentIndex === 0 || segmentIndex === 1) {
wx.pageScrollTo({
scrollTop: 0,
})
this.setData({
currPage: 1,
})
switch (this.data.segmentIndex) {
case 0:
return this.fetchTopicList()
case 1:
return this.fetchGoodIdeaList()
}
}
} else {
console.log('未绑定手机号码')
wx.redirectTo({
url: '/pages/register/index',
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',
})
}
}
})
}
} else {
console.log('未绑定微信')
wx.reLaunch({
wx.switchTab({
url: '/pages/user/index',
})
}
},
onShow: function () {
// 页面出现在前台时执行
let segmentIndex = this.data.segmentIndex
if (segmentIndex === 0 || segmentIndex === 1){
wx.pageScrollTo({
scrollTop: 0,
})
this.setData({
currPage: 1,
})
switch (this.data.segmentIndex) {
case 0:
return this.fetchTopicList()
case 1:
return this.fetchGoodIdeaList()
}
}
},
fetchTopicList () {
let page = this.data.currPage

25
pages/user/index.js

@ -44,6 +44,11 @@ Page({
if (e.detail.userInfo){
let avatarUrl = e.detail.userInfo.avatarUrl
let nickName = e.detail.userInfo.nickName
store.saveUserInfo({
nickName: nickName,
avatarUrl: avatarUrl,
phone: ''
})
this.sendUserInfo(e.detail.userInfo)
}
},
@ -51,15 +56,14 @@ Page({
// 上传用户信息
sendUserInfo(weChatInfo){
userModel.sendUserInfo(weChatInfo, res => {
if (res.code === 200) {
this.getUserInfo()
}
})
},
// 获取用户信息
getUserInfo () {
userModel.getUserInfo(res => {
console.log(res)
let nickName = res.result.nickName
let avatarUrl = res.result.avatarUrl
@ -70,14 +74,27 @@ Page({
avatarUrl: res.result.avatarUrl,
nickName: res.result.nickName,
reAuth: true,
isAuth: false
},()=>{
if (store.hasPhone()) {
//console.log('已经绑定手机号码')
this.getMsgStatus()
} else {
//console.log('未绑定手机号码')
wx.redirectTo({
url: '/pages/register/index',
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',
})
}
}
})
}
})

Loading…
Cancel
Save