|
@@ -1,25 +1,28 @@
|
|
|
const { request } = require('../api/request')
|
|
|
|
|
|
module.exports = {
|
|
|
- data: {
|
|
|
- searchForm: {
|
|
|
- key_words: ''
|
|
|
- },
|
|
|
- pagenum: 0,
|
|
|
- pagesize: 20,
|
|
|
- finished: false,
|
|
|
- isRefresh: false,
|
|
|
- isFetchLock: false,
|
|
|
- list: [],
|
|
|
- freshing: false
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ pagenum: 1,
|
|
|
+ pagesize: 20,
|
|
|
+ finished: false,
|
|
|
+ isRefresh: false,
|
|
|
+ isFetchLock: false,
|
|
|
+ listData: [],
|
|
|
+ freshing: false
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
handleKeyWords(event) {
|
|
|
- this.setData({
|
|
|
- 'searchForm.key_words': event.detail
|
|
|
- })
|
|
|
+ const { formkey } = event.target.dataset
|
|
|
+
|
|
|
+ if (formkey) {
|
|
|
+ this.setData({
|
|
|
+ [`searchForm.${formkey}`]: event.detail.value
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- async fetOrderList() {
|
|
|
+ async fetchOrderList() {
|
|
|
const that = this
|
|
|
const isRefresh = that.data.isRefresh
|
|
|
|
|
@@ -32,30 +35,30 @@ module.exports = {
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
- isFetchLock: true,
|
|
|
- pagenum: that.data.pagenum + 1
|
|
|
+ isFetchLock: true
|
|
|
})
|
|
|
try {
|
|
|
const { status, data, msg } = await request({
|
|
|
- url: that.data.api,
|
|
|
+ url: that.data.listUrl,
|
|
|
method: 'POST',
|
|
|
data: {
|
|
|
- 'page': that.data.pageNum,
|
|
|
- 'page_size': that.data.pageSize,
|
|
|
- key_words: that.data.searchForm.key_words
|
|
|
+ 'page': that.data.pagenum,
|
|
|
+ 'page_size': that.data.pagesize,
|
|
|
+ ...that.data.searchForm
|
|
|
},
|
|
|
showLoading: true
|
|
|
})
|
|
|
if (status) {
|
|
|
const { list } = data
|
|
|
if (Array.isArray(list)) {
|
|
|
- const _list = isRefresh ? [].concat(list) : that.data.list.concat(list)
|
|
|
+ const _list = isRefresh ? [].concat(list) : that.data.listData.concat(list)
|
|
|
|
|
|
that.setData({
|
|
|
- list: _list,
|
|
|
- finished: list.length < 10,
|
|
|
+ listData: _list,
|
|
|
+ finished: list.length < that.data.pagesize,
|
|
|
isRefresh: false,
|
|
|
- isFetchLock: false
|
|
|
+ isFetchLock: false,
|
|
|
+ pagenum: that.data.pagenum + 1
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
@@ -66,21 +69,23 @@ module.exports = {
|
|
|
}
|
|
|
} catch (e) {}
|
|
|
if (that.data.freshing) {
|
|
|
- that.data.freshing = false
|
|
|
+ that.setData({
|
|
|
+ freshing: false
|
|
|
+ })
|
|
|
}
|
|
|
if (isRefresh && wx.stopPullDownRefresh) {
|
|
|
wx.stopPullDownRefresh()
|
|
|
}
|
|
|
},
|
|
|
- refresh() {
|
|
|
+ refreshOrderList() {
|
|
|
this.setData({
|
|
|
- pagenum: 0,
|
|
|
+ pagenum: 1,
|
|
|
pagesize: 20,
|
|
|
finished: false,
|
|
|
isRefresh: true,
|
|
|
isFetchLock: false
|
|
|
}, () => {
|
|
|
- this.fetOrderList()
|
|
|
+ this.fetchOrderList()
|
|
|
})
|
|
|
}
|
|
|
}
|