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.
96 lines
3.0 KiB
96 lines
3.0 KiB
// pages/message/index.js
|
|
import { getInformationList } from "../../../api/moment"
|
|
const util = require('../../../utils/util')
|
|
const area = require("../../../const/area.js")
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
height: { type: Number, value: 0 }
|
|
},
|
|
data: {
|
|
tabList: [ '全部', '华东', '华中', '华南', '西部', '北部'],
|
|
tabIndex: 0,
|
|
proviceList: [],
|
|
pIndex: 0,
|
|
form: {
|
|
proviceId: '',
|
|
byQueryType: 2,
|
|
pageNum: 1,
|
|
pageSize: 10
|
|
},
|
|
loading: true,
|
|
requesting: false,
|
|
finished: false,
|
|
orderList: []
|
|
},
|
|
methods: {
|
|
onRestart: function () {
|
|
if(!this.data.firstShow){
|
|
var min = new Date()
|
|
min.setHours(0, 0, 0)
|
|
this.data.form.date = util.formatDate(min, 'Y-M-D')
|
|
setTimeout(() => {
|
|
this.setData({ tabIndex: 0, firstShow: true, proviceList: this.getProviceListByIndex(this.data.tabIndex) })
|
|
}, 100)
|
|
this.fetchList()
|
|
}
|
|
},
|
|
getProviceListByIndex: function(tabIndex){
|
|
var proviceList = []
|
|
for (let index = 0; index < area.list[tabIndex].data.length; index++) {
|
|
proviceList.push(area.list[tabIndex].data[index].name)
|
|
}
|
|
return proviceList
|
|
},
|
|
onTabChange: function({ detail }){
|
|
if (this.data.tabIndex == Number(detail.index)) {
|
|
return
|
|
}
|
|
this.data.tabIndex = Number(detail.index)
|
|
this.data.form.proviceId = area.list[this.data.tabIndex].data[this.data.pIndex].code
|
|
this.setData({ pIndex: 0, proviceList: this.getProviceListByIndex(this.data.tabIndex), orderList: [], ['form.pageNum']: 1, finished: false, loading: true })
|
|
this.fetchList()
|
|
},
|
|
onProviceChange: function({ detail }){
|
|
if (this.data.pIndex == Number(detail.index)) {
|
|
return
|
|
}
|
|
this.data.pIndex = Number(detail.index)
|
|
this.data.form.proviceId = area.list[this.data.tabIndex].data[this.data.pIndex].code
|
|
this.onRefreshList()
|
|
},
|
|
onRefreshList: function(){
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
this.setData({ orderList: [], ['form.pageNum']: 1, finished: false, loading: true })
|
|
this.fetchList()
|
|
},
|
|
fetchList: function(){
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
this.setData({ requesting: true })
|
|
getInformationList(this.data.form).then(result => {
|
|
if (result.data && 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, ['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)
|
|
})
|
|
}
|
|
}
|
|
|
|
})
|