Browse Source

合并个人中心冲突

master
lqq 6 years ago
parent
commit
37527dd192
  1. 2
      pages/topics/index.js
  2. 7
      pages/topics/interactive/topicArticle/index.js
  3. 47
      pages/user/index.js
  4. 14
      pages/user/index.wxml

2
pages/topics/index.js

@ -25,7 +25,7 @@ Page({
*/
onLoad: function () {
if (store.hasPhone()) {
if (!store.hasPhone()) {
console.log('已经绑定手机号码')
} else {
console.log('未绑定手机号码')

7
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) {

47
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`,
// })
// }
},
})

14
pages/user/index.wxml

@ -1,19 +1,17 @@
<!--pages/user/index.wxml-->
<view class="container">
<mp-cells ext-class="page_hd" wx:if="{{authType === 2}}">
<mp-cells ext-class="page_hd" wx:if="{{reAuth}}">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<view class="user_hd">
<!-- <image slot="icon" class="user_logo" src=""/> -->
<open-data class="user_logo" slot="icon" type="userAvatarUrl"></open-data>
<!-- <view slot="title" class="user_name">啦啦啦拉两岸啦啦啦啦啦靓阿拉啦啦啦</view> -->
<open-data class="user_name" type="userNickName" lang="zh_CN"></open-data>
<view class="user_hd" wx:if="{{avatarUrl && nickName}}">
<image slot="icon" class="user_logo" src="{{avatarUrl}}"/>
<view slot="title" class="user_name">{{nickName}}</view>
</view>
</mp-cell>
</mp-cells>
<mp-cells ext-class="page_hd" wx:if="{{authType === 1}}">
<mp-cells ext-class="page_hd" wx:if="{{isAuth}}">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<view class="user_auth_hd">
<open-data class="user_logo" type="userAvatarUrl"></open-data>
<!-- <open-data class="user_logo" type="userAvatarUrl"></open-data> -->
<open-data class="user_auth_name" type="userNickName"></open-data>
<!-- 需要使用 button 来授权登录 -->
<button class="authBtn" size="mini" wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录</button>

Loading…
Cancel
Save