|
@@ -8,7 +8,8 @@ Page({
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- index: undefined
|
|
|
|
|
|
+ index: undefined,
|
|
|
|
+ canIUseGetUserProfile: false
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -16,11 +17,52 @@ Page({
|
|
*/
|
|
*/
|
|
|
|
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
- if(options.index){
|
|
|
|
|
|
+ if (options.index) {
|
|
this.setData({
|
|
this.setData({
|
|
index: options.index
|
|
index: options.index
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ if (wx.getUserProfile) {
|
|
|
|
+ this.setData({
|
|
|
|
+ canIUseGetUserProfile: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ getUserProfile: function (e) {
|
|
|
|
+ wx.getUserProfile({
|
|
|
|
+ desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log('getUserProfile',res);
|
|
|
|
+ getOpenidSessionKey((res) => {
|
|
|
|
+ console.log('getUserProfilegetUserProfile',res)
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '登录成功',
|
|
|
|
+ icon: 'fail',
|
|
|
|
+ duration: 1000,
|
|
|
|
+ success: () => {
|
|
|
|
+ const pages = getCurrentPages();
|
|
|
|
+ const prevPage = pages[pages.length - 2];
|
|
|
|
+ prevPage.setData({
|
|
|
|
+ fromLoginIndex: this.data.index, // 有id就塞到第一位
|
|
|
|
+ }, () => {
|
|
|
|
+ wx.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }, (error) => {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '登录失败',
|
|
|
|
+ icon: 'fail',
|
|
|
|
+ duration: 1000,
|
|
|
|
+ success: () => {
|
|
|
|
+ wx.navigateBack()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
impower: function (e) {
|
|
impower: function (e) {
|
|
console.log(e)
|
|
console.log(e)
|
|
@@ -36,11 +78,11 @@ Page({
|
|
const pages = getCurrentPages();
|
|
const pages = getCurrentPages();
|
|
const prevPage = pages[pages.length - 2];
|
|
const prevPage = pages[pages.length - 2];
|
|
prevPage.setData({
|
|
prevPage.setData({
|
|
- fromLoginIndex: this.data.index, // 有id就塞到第一位
|
|
|
|
|
|
+ fromLoginIndex: this.data.index, // 有id就塞到第一位
|
|
}, () => {
|
|
}, () => {
|
|
- wx.navigateBack({
|
|
|
|
- delta: 1
|
|
|
|
- })
|
|
|
|
|
|
+ wx.navigateBack({
|
|
|
|
+ delta: 1
|
|
|
|
+ })
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|