import { useLoading } from '../../../behaviors/loading'; import { searchScene } from '../../../services/inspection/fetchScene'; // 现场巡查监管场景信息管理 Page({ behaviors: [useLoading], data: { placeholder: '输入关键字搜索场景', sceneList: [], area: {}, }, onLoad(options) {}, onShow() { this.getTabBar().init(); }, onReachBottom() { this._loadMore(); }, _fetchData(page) { const { area, onlineValue, sceneValue } = this.data; if (!onlineValue || !sceneValue) return; area.scensetypeid = sceneValue[0]; area.online = onlineValue[0]; return searchScene(area, page).then(res => { if (res.success) { this.setData({ sceneList: page == 1 ? res.data : this.data.sceneList.concat(res.data), }); } else { this.setData({ sceneList: [], }); } return res.head; }); }, onOnlineChange(e) { const { onlineText, onlineValue } = e.detail; this.setData({ onlineText, onlineValue }); this._startLoad(); }, onLocationChange(e) { const { area } = this.data; area.provincename = e.detail.provinceText; area.cityname = e.detail.cityText; area.districtname = e.detail.districtText; area.townname = e.detail.townText; area.provincecode = e.detail.provinceValue; area.citycode = e.detail.cityValue; area.districtcode = e.detail.districtValue; area.towncode = e.detail.townValue; area.locationValue = e.detail.locationValue; this.setData({ area }); this._startLoad(); }, onScenePickerConfirm(e) { const { sceneText, sceneValue } = e.detail; this.setData({ sceneText, sceneValue }); this._startLoad(); }, navToSearchPage() { wx.navigateTo({ url: '/pages/inspection/scene/search/index', success: result => {}, fail: res => {}, complete: res => {}, }); }, navToDetail(e) { const { index } = e.currentTarget.dataset; const scene = this.data.sceneList[index]; wx.navigateTo({ url: '/pages/inspection/scene/info/index', success: result => { result.eventChannel.emit('acceptSceneData', { scene: scene, }); }, }); }, });