|
|
|
@ -32,15 +32,16 @@ Page({ |
|
|
|
this.checkLogin() |
|
|
|
this.setData({ |
|
|
|
height: app.globalData.fragmentHeight, |
|
|
|
CustomBar: app.globalData.CustomBar |
|
|
|
CustomBar: app.globalData.CustomBar, |
|
|
|
token: app.globalData.token |
|
|
|
}) |
|
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
|
}, |
|
|
|
|
|
|
|
// 事件通知
|
|
|
|
onEvent: function (message) { |
|
|
|
console.log('mall>>index>>onEvent', message) |
|
|
|
console.log('shops>>index>>onEvent', message) |
|
|
|
if(message.what == 1 && util.isEmpty(this.data.token)){ |
|
|
|
// this.setData({ token: app.globalData.token })
|
|
|
|
this.setData({ token: app.globalData.token }) |
|
|
|
} |
|
|
|
}, |
|
|
|
/** |
|
|
|
@ -48,33 +49,37 @@ Page({ |
|
|
|
*/ |
|
|
|
onReady: function () { |
|
|
|
if (!this.data.firstShow) { |
|
|
|
this.setData({ |
|
|
|
token: app.globalData.token |
|
|
|
}) |
|
|
|
this.fetchCheapList() |
|
|
|
this.fetchTaskList() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
onRefreshList: function(){ |
|
|
|
this.setData({ |
|
|
|
cheapList: [], |
|
|
|
taskList: [], |
|
|
|
['form.pageNum']: 1, |
|
|
|
loading: true, |
|
|
|
finished: false |
|
|
|
}) |
|
|
|
this.fetchCheapList() |
|
|
|
this.fetchTaskList() |
|
|
|
}, |
|
|
|
// 获取特价列表
|
|
|
|
fetchCheapList: function () { |
|
|
|
request.get('/bxe-mall/product/cheapList').then(result => { |
|
|
|
//成功回调
|
|
|
|
this.setData({ loading: false, cheapList: result.data }) |
|
|
|
|
|
|
|
}).catch(err => { |
|
|
|
//异常回调
|
|
|
|
this.setData({ loading: false }) |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取团购列表
|
|
|
|
fetchTaskList: function () { |
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.data.form.pageNum == 1 && this.data.taskList.length == 0) { |
|
|
|
this.setData({ loading: true }) |
|
|
|
} |
|
|
|
this.data.requesting = true |
|
|
|
// /product/cheapList特价产品列表
|
|
|
|
request.get('/bxe-mall/product/groupList', this.data.form).then(result => { |
|
|
|
@ -98,20 +103,20 @@ Page({ |
|
|
|
util.showToast(err) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 进入搜索页
|
|
|
|
searchList: function (e) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/mall/search-list/index' |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 查看团购Item
|
|
|
|
lookGroupItem: function (e) { |
|
|
|
var item = this.data.taskList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/mall/order-info/index?id=' + item.id |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 查看特价Item
|
|
|
|
lookCheapItem: function (e) { |
|
|
|
var item = this.data.cheapList[e.currentTarget.dataset.index] |
|
|
|
wx.navigateTo({ |
|
|
|
|