|
@@ -1,5 +1,6 @@
|
|
//index.js
|
|
//index.js
|
|
//获取应用实例
|
|
//获取应用实例
|
|
|
|
+const getReq = require('./../../config.js').getReq
|
|
const app = getApp()
|
|
const app = getApp()
|
|
|
|
|
|
Page({
|
|
Page({
|
|
@@ -10,18 +11,26 @@ Page({
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
|
},
|
|
},
|
|
//事件处理函数
|
|
//事件处理函数
|
|
- bindViewTap: function() {
|
|
|
|
|
|
+ bindViewTap: function () {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: '../logs/logs'
|
|
url: '../logs/logs'
|
|
})
|
|
})
|
|
},
|
|
},
|
|
onLoad: function () {
|
|
onLoad: function () {
|
|
|
|
+ getReq({
|
|
|
|
+ goods_id: '4565',
|
|
|
|
+ act: 'goods_common',
|
|
|
|
+ op: 'index',
|
|
|
|
+ }, function (res) {
|
|
|
|
+ console.log(res)
|
|
|
|
+ })
|
|
|
|
+
|
|
if (app.globalData.userInfo) {
|
|
if (app.globalData.userInfo) {
|
|
this.setData({
|
|
this.setData({
|
|
userInfo: app.globalData.userInfo,
|
|
userInfo: app.globalData.userInfo,
|
|
hasUserInfo: true
|
|
hasUserInfo: true
|
|
})
|
|
})
|
|
- } else if (this.data.canIUse){
|
|
|
|
|
|
+ } else if (this.data.canIUse) {
|
|
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
// 所以此处加入 callback 以防止这种情况
|
|
// 所以此处加入 callback 以防止这种情况
|
|
app.userInfoReadyCallback = res => {
|
|
app.userInfoReadyCallback = res => {
|
|
@@ -43,7 +52,7 @@ Page({
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- getUserInfo: function(e) {
|
|
|
|
|
|
+ getUserInfo: function (e) {
|
|
console.log(e)
|
|
console.log(e)
|
|
app.globalData.userInfo = e.detail.userInfo
|
|
app.globalData.userInfo = e.detail.userInfo
|
|
this.setData({
|
|
this.setData({
|