|
@@ -1,4 +1,5 @@
|
|
// pages/person/person.js
|
|
// pages/person/person.js
|
|
|
|
+const app = getApp()
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -6,15 +7,22 @@ Page({
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
|
|
|
|
|
|
+ hasUserInfo: false
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onLoad: function (options) {
|
|
|
|
-
|
|
|
|
|
|
+ onLoad: async function (options) {
|
|
|
|
+ let userInfo = await app.getWxUserInfo()
|
|
|
|
+ if (userInfo) {
|
|
|
|
+ this.setData({
|
|
|
|
+ userInfo: userInfo,
|
|
|
|
+ hasUserInfo: true,
|
|
|
|
+ hasMobile: userInfo.mobile ? true : false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
@@ -25,8 +33,15 @@ Page({
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
- onShow: function () {
|
|
|
|
-
|
|
|
|
|
|
+ onShow: async function () {
|
|
|
|
+ let userInfo = await app.getWxUserInfo()
|
|
|
|
+ if (userInfo) {
|
|
|
|
+ this.setData({
|
|
|
|
+ userInfo: userInfo,
|
|
|
|
+ hasUserInfo: true,
|
|
|
|
+ hasMobile: userInfo.mobile ? true : false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -62,5 +77,63 @@ Page({
|
|
*/
|
|
*/
|
|
onShareAppMessage: function () {
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ getInfo: async function (e) {
|
|
|
|
+ const _self = this
|
|
|
|
+ let userInfo = e.detail.userInfo
|
|
|
|
+ userInfo['encryptedData'] = e.detail.encryptedData
|
|
|
|
+ userInfo['iv'] = e.detail.iv
|
|
|
|
+ let info = await app.wxLogin(userInfo);
|
|
|
|
+ let hasMobile = false;
|
|
|
|
+ if (info.mobile) {
|
|
|
|
+ hasMobile = true
|
|
|
|
+ }
|
|
|
|
+ _self.setData({
|
|
|
|
+ hasUserInfo: true,
|
|
|
|
+ userInfo: info,
|
|
|
|
+ hasMobile: hasMobile,
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ gotoCollection: async function (e) {
|
|
|
|
+
|
|
|
|
+ // const isAuth = await app.isAuth()
|
|
|
|
+ // if (!isAuth) {
|
|
|
|
+ // wx.redirectTo({
|
|
|
|
+ // url: '/pages/prompt/prompt?page=pages/collection/collection',
|
|
|
|
+ // })
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '../collection/collection',
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ gotoPersonInfo: function (e) {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '../personinfo/personinfo',
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ gotoOrder: function (e) {
|
|
|
|
+ wx.switchTab({
|
|
|
|
+ url: '../personorder/personorder',
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ getMobile: async function (params) {
|
|
|
|
+ console.log(params);
|
|
|
|
+ let _self = this
|
|
|
|
+ const data = {
|
|
|
|
+ encryptedData:params.detail.encryptedData,
|
|
|
|
+ iv: params.detail.iv
|
|
|
|
+ }
|
|
|
|
+ const userInfo = await app.getPhoneNumber(data)
|
|
|
|
+ console.log(userInfo)
|
|
|
|
+ let hasMobile = false
|
|
|
|
+ if (userInfo.mobile > 1) {
|
|
|
|
+ hasMobile:true
|
|
|
|
+ }
|
|
|
|
+ _self.setData({
|
|
|
|
+ hasMobile: hasMobile,
|
|
|
|
+ mobile: userInfo.mobile,
|
|
|
|
+ userInfo
|
|
|
|
+ })
|
|
|
|
+ },
|
|
})
|
|
})
|