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.
127 lines
3.2 KiB
127 lines
3.2 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: {
|
|
height: app.globalData.fragmentHeight - 100,
|
|
loading: true,
|
|
requesting: false,
|
|
finished: false,
|
|
tabList: [
|
|
{id: 1, name: '预约单'},
|
|
{id: 2, name: '待确认'},
|
|
{id: 3, name: '待结算'},
|
|
{id: 4, name: '已完成'},
|
|
{id: 5, name: '已取消'}
|
|
],
|
|
orderList: [],
|
|
form: {
|
|
status: 1,
|
|
pageNum: 1
|
|
}
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
attached: function () {
|
|
this.setData({
|
|
height: app.globalData.fragmentHeight - 100
|
|
})
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
detached: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
},
|
|
methods: {
|
|
onRestart: function () {
|
|
// this.fetchMessageNumber()
|
|
if (!this.data.firstShow) {
|
|
this.fetchOrderList()
|
|
}
|
|
this.setData({
|
|
firstShow: true
|
|
})
|
|
},
|
|
onEvent: function (message) {
|
|
if (message.what == 13) {
|
|
this.onRefreshList()
|
|
}
|
|
},
|
|
onRefreshList: function () {
|
|
this.setData({
|
|
orderList: [],
|
|
['form.status']: this.data.form.status,
|
|
['form.pageNum']: 1,
|
|
loading: true,
|
|
finished: false
|
|
})
|
|
this.fetchOrderList()
|
|
},
|
|
fetchOrderList: function () {
|
|
if (this.data.requesting || this.data.finished) {
|
|
return
|
|
}
|
|
if (this.data.loading) {
|
|
this.data.requesting = true
|
|
} else {
|
|
this.setData({
|
|
requesting: true
|
|
})
|
|
}
|
|
// /product/cheapList特价产品列表
|
|
request.get('/saas-trade/receive/v150/orderListR', this.data.form).then(result => {
|
|
//成功回调
|
|
if (result.data.records.length) {
|
|
var respList = result.data.records
|
|
let nowList = `orderList[${this.data.orderList.length}]`
|
|
var num = this.data.form.pageNum
|
|
var finished = this.data.form.pageNum >= result.data.pages
|
|
this.setData({
|
|
[nowList]: respList,
|
|
total: result.data.total,
|
|
['form.pageNum']: (num + 1),
|
|
finished,
|
|
requesting: false,
|
|
loading: false
|
|
})
|
|
} else {
|
|
this.setData({
|
|
finished: true,
|
|
requesting: false,
|
|
loading: false
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
//异常回调
|
|
this.setData({
|
|
requesting: false,
|
|
loading: false
|
|
})
|
|
util.showToast(err)
|
|
})
|
|
},
|
|
lookItem: function (e) {
|
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
|
|
wx.navigateTo({
|
|
url: '/pages/order/detail/index?id=' + item.id + '&type=' + item.receiveType
|
|
})
|
|
},
|
|
onTabChange: function (e) {
|
|
if (this.data.form.status == e.detail.key) {
|
|
return
|
|
}
|
|
this.data.form.status = e.detail.key
|
|
this.onRefreshList()
|
|
}
|
|
}
|
|
})
|