You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

// pages/stock/index.js
const request = require('../../../utils/request');//导入模块
const util = require('../../../utils/util');
const event = require('../../../utils/event.js')
const app = getApp()
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
/**
* 页面的初始数据
*/
data: {
firstShow: false,
token: app.globalData.token,
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
event.remove('EventMessage', this)
}
},
methods: {
// resume的处理;
onRestart: function () {
if (!this.data.firstShow) {
this.setData({ token: app.globalData.token })
}
this.fetchUserInfo()
this.data.firstShow = true
},
onEvent: function (message) {
console.log('home>>index>>onEvent', message)
if(message.what == 1 && util.isEmpty(this.data.token)){
this.setData({ token: app.globalData.token })
}
},
onGotPhoneNumber: function (e) {
request.loginWechat(e.detail).then(data => {
wx.navigateTo({
url: '/pages/mall/order-list/index?index=0'
})
})
},
fetchUserInfo: function () {
}
}
})