// pages/message/index.js 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: '' }, orderList: [] }, methods: { onRestart: function () { if(!this.data.firstShow){ 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) }) 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.fetchList() }, fetchList: function(){ console.log(this.data.form) } } })