|
|
|
@ -27,6 +27,11 @@ Page({ |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
if(getCurrentPages().length == 1){ |
|
|
|
this.setData({ |
|
|
|
backStr: '首页' |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ token: app.globalData.token }) |
|
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
|
if (options.id) { |
|
|
|
@ -37,22 +42,17 @@ Page({ |
|
|
|
// /product/{id}产品详情
|
|
|
|
request.get('/bxe-mall/product/' + options.id).then(result => { |
|
|
|
//成功回调
|
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ |
|
|
|
['form.productId']: options.id, |
|
|
|
orderInfo: result.data |
|
|
|
}) |
|
|
|
wx.hideLoading() |
|
|
|
}).catch(err => { |
|
|
|
//异常回调
|
|
|
|
wx.hideLoading() |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
} |
|
|
|
if(getCurrentPages().length == 1){ |
|
|
|
this.setData({ |
|
|
|
backStr: '首页' |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 事件处理
|
|
|
|
onEvent: function (message) { |
|
|
|
@ -207,5 +207,14 @@ Page({ |
|
|
|
// event的unregister
|
|
|
|
onUnload: function(){ |
|
|
|
event.remove('EventMessage', this) |
|
|
|
if(getCurrentPages().length == 1){ |
|
|
|
this.toHome() |
|
|
|
} |
|
|
|
}, |
|
|
|
// 返回到主页
|
|
|
|
toHome(){ |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/mall/shops/index', |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |