|
|
@@ -13,9 +13,38 @@ Page({
|
|
|
publisherName: ""
|
|
|
},
|
|
|
|
|
|
- bindGetUserInfo: function (e) {
|
|
|
- app.globalData.userInfo = e.detail.userInfo
|
|
|
- this.onShow()
|
|
|
+ // bindGetUserInfo: function (e) {
|
|
|
+ // app.globalData.userInfo = e.detail.userInfo
|
|
|
+ // this.onShow()
|
|
|
+ // },
|
|
|
+
|
|
|
+ getUserProfile: function () {
|
|
|
+ wx.getUserProfile({
|
|
|
+ desc: '用于完善个人信息',
|
|
|
+ success: (res) => {
|
|
|
+ app.globalData.userInfo = {
|
|
|
+ name: res.userInfo.nickName,
|
|
|
+ avatar: res.userInfo.avatarUrl,
|
|
|
+ gender: res.userInfo.gender
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.userInfo,
|
|
|
+ hasUserInfo: true
|
|
|
+ })
|
|
|
+ wx.cloud.callFunction({
|
|
|
+ name: 'updateUser',
|
|
|
+ data: app.globalData.userInfo
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ previewAvatar: function () {
|
|
|
+ if (this.data.hasUserInfo) {
|
|
|
+ wx.previewImage({
|
|
|
+ urls: [this.data.userInfo.avatar]
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
publisherLogin: function () {
|
|
|
@@ -70,48 +99,48 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- wx.showNavigationBarLoading()
|
|
|
- if (app.globalData.userInfo && app.globalData.publisherId) {
|
|
|
- this.setData({
|
|
|
- userInfo: app.globalData.userInfo,
|
|
|
- hasUserInfo: true,
|
|
|
- publisherId: app.globalData.publisherId
|
|
|
- })
|
|
|
- if (this.data.publisherId.length != 0) {
|
|
|
- const db = wx.cloud.database()
|
|
|
- db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
- success: function (res) {
|
|
|
- this.setData({
|
|
|
- publisherName: res.data.publisherName
|
|
|
- })
|
|
|
- wx.hideNavigationBarLoading()
|
|
|
- }.bind(this)
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.hideNavigationBarLoading()
|
|
|
- }
|
|
|
- } else {
|
|
|
- app.userInfoReadyCallback = res => {
|
|
|
- this.setData({
|
|
|
- userInfo: res.userInfo,
|
|
|
- hasUserInfo: true,
|
|
|
- publisherId: app.globalData.publisherId
|
|
|
- })
|
|
|
- if (this.data.publisherId.length != 0) {
|
|
|
- const db = wx.cloud.database()
|
|
|
- db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
- success: function (res) {
|
|
|
- this.setData({
|
|
|
- publisherName: res.data.publisherName
|
|
|
- })
|
|
|
- wx.hideNavigationBarLoading()
|
|
|
- }.bind(this)
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.hideNavigationBarLoading()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // wx.showNavigationBarLoading()
|
|
|
+ // if (app.globalData.userInfo && app.globalData.publisherId) {
|
|
|
+ // this.setData({
|
|
|
+ // userInfo: app.globalData.userInfo,
|
|
|
+ // hasUserInfo: true,
|
|
|
+ // publisherId: app.globalData.publisherId
|
|
|
+ // })
|
|
|
+ // if (this.data.publisherId.length != 0) {
|
|
|
+ // const db = wx.cloud.database()
|
|
|
+ // db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
+ // success: function (res) {
|
|
|
+ // this.setData({
|
|
|
+ // publisherName: res.data.publisherName
|
|
|
+ // })
|
|
|
+ // wx.hideNavigationBarLoading()
|
|
|
+ // }.bind(this)
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.hideNavigationBarLoading()
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // app.userInfoReadyCallback = res => {
|
|
|
+ // this.setData({
|
|
|
+ // userInfo: res.userInfo,
|
|
|
+ // hasUserInfo: true,
|
|
|
+ // publisherId: app.globalData.publisherId
|
|
|
+ // })
|
|
|
+ // if (this.data.publisherId.length != 0) {
|
|
|
+ // const db = wx.cloud.database()
|
|
|
+ // db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
+ // success: function (res) {
|
|
|
+ // this.setData({
|
|
|
+ // publisherName: res.data.publisherName
|
|
|
+ // })
|
|
|
+ // wx.hideNavigationBarLoading()
|
|
|
+ // }.bind(this)
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // wx.hideNavigationBarLoading()
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -125,42 +154,56 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- const db = wx.cloud.database()
|
|
|
- db.collection("userInfoData").get({
|
|
|
- success: function (res) {
|
|
|
- if (res.data.length == 0) {
|
|
|
- db.collection("userInfoData").add({
|
|
|
- data: {
|
|
|
- publisherId: []
|
|
|
- },
|
|
|
- success: function (res) {
|
|
|
- app.globalData.publisherId = []
|
|
|
- this.setData({
|
|
|
- userInfo: app.globalData.userInfo,
|
|
|
- hasUserInfo: true,
|
|
|
- publisherId: app.globalData.publisherId
|
|
|
- })
|
|
|
- }.bind(this)
|
|
|
- })
|
|
|
- } else {
|
|
|
- app.globalData.publisherId = res.data[0].publisherId
|
|
|
- this.setData({
|
|
|
- userInfo: app.globalData.userInfo,
|
|
|
- hasUserInfo: true,
|
|
|
- publisherId: app.globalData.publisherId
|
|
|
- })
|
|
|
- if (this.data.publisherId.length != 0) {
|
|
|
- db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
- success: function (res) {
|
|
|
- this.setData({
|
|
|
- publisherName: res.data.publisherName
|
|
|
- })
|
|
|
- }.bind(this)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }.bind(this)
|
|
|
- })
|
|
|
+ // const db = wx.cloud.database()
|
|
|
+ // db.collection("userInfoData").get({
|
|
|
+ // success: function (res) {
|
|
|
+ // if (res.data.length == 0) {
|
|
|
+ // db.collection("userInfoData").add({
|
|
|
+ // data: {
|
|
|
+ // publisherId: []
|
|
|
+ // },
|
|
|
+ // success: function (res) {
|
|
|
+ // app.globalData.publisherId = []
|
|
|
+ // this.setData({
|
|
|
+ // userInfo: app.globalData.userInfo,
|
|
|
+ // hasUserInfo: true,
|
|
|
+ // publisherId: app.globalData.publisherId
|
|
|
+ // })
|
|
|
+ // }.bind(this)
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // app.globalData.publisherId = res.data[0].publisherId
|
|
|
+ // this.setData({
|
|
|
+ // userInfo: app.globalData.userInfo,
|
|
|
+ // hasUserInfo: true,
|
|
|
+ // publisherId: app.globalData.publisherId
|
|
|
+ // })
|
|
|
+ // if (this.data.publisherId.length != 0) {
|
|
|
+ // db.collection("publisherInfoData").doc(this.data.publisherId[0]).get({
|
|
|
+ // success: function (res) {
|
|
|
+ // this.setData({
|
|
|
+ // publisherName: res.data.publisherName
|
|
|
+ // })
|
|
|
+ // }.bind(this)
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }.bind(this)
|
|
|
+ // })
|
|
|
+
|
|
|
+ if (app.globalData.userInfo) {
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.userInfo,
|
|
|
+ hasUserInfo: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ app.onUserInfoReady = () => {
|
|
|
+ this.setData({
|
|
|
+ userInfo: app.globalData.userInfo,
|
|
|
+ hasUserInfo: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|