// subpages/work/pages/workguide/index.js import { inputSync } from "@utils/tools"; import { wxRequestPost, wxNavigateTo } from "@utils/promise-wx-api"; // import authBehavior from "@mixins/operate-auth"; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { iniLoading: false, //初始化加载数据 showMask: false, refresh: true, noMore: false, //没有更多了 isFocus: false, customerId: "", agencyId: "", agencyName: "", toTabs: 'index0', tabsCurrent: 0, tabsList: [], statusIndex: 0, issueType: "voting", issueListType: "", gridIdList: [], gridShowName: "", total: 0, issueList: [], guideList: [], pageNo: 1, pageSize: 20, triggered: false, refresherIsTriggered: false, categoryId: '', guideTitle: '', agencyInfo: {} }, // behaviors: [authBehavior], /** * 生命周期函数--监听页面加载 */ async onLoad() { await app.doAfterLogin(); await this.getApiData(); this.setData({ iniLoading: true, }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, inputSync, async getApiData() { await this.getAgencyList() await this.getCateList() await this.getGuideList() // this.bindFilterNew(); }, async onRefreshs() { if (this._freshing) return this._freshing = true setTimeout(() => { this.setData({ triggered: false }) // this.triggered = false this._freshing = false }, 1500) await this.getGuideList(this.data.tabsList[0].categoryCode) }, onRestore() { // this.triggered = 'restore'; // 需要重置 this.setData({ triggered: false }) console.log("onRestore"); }, handleInput(e) { this.setData({ guideTitle: e.detail.value }) }, handleSearch() { this.setData({ // isFocus: false, pageNo: 1, noMore: false }) this.getGuideList() }, handleFocus() { this.setData({ isFocus: !this.data.isFocus }) }, handleCancle() { this.setData({ guideTitle: '', isFocus: false, noMore: false, pageNo: 1 }) this.getGuideList() } statusPickerChange(e) { this.setData({ statusIndex: e.detail.value, }); }, handleTabs(e) { console.log('eeeee', e.currentTarget.dataset) const { index, id } = e.currentTarget.dataset this.setData({ tabsCurrent: index, pageNo: 1, noMore: false, categoryId: id }) console.log('tabsCurrent', index, this.data.tabsCurrent) this.getGuideList() }, handleDownFilter(e) { const { index, id} = e.currentTarget.dataset this.setData({ tabsCurrent: index, toTabs: 'index' + index, showMask: false, pageNo: 1, noMore: false, categoryId: id }) this.getGuideList() }, handleDown() { this.setData({ showMask: !this.data.showMask }) }, //选择要查看的组织 async selectAgency() { const $selectGrid = this.selectComponent("#selectGrid"); const { type, data } = await $selectGrid.show(); if (type == "confirm") { const { gridIdList, showName, gridInfo } = data; console.log('gridInfo', gridInfo); this.setData({ gridIdList, gridShowName: showName, agencyId: gridInfo.agencyId, pageNo: 1 }); this.getGuideList() } }, //点击筛选按钮 bindFilterNew() { const { statusArray, statusIndex } = this.data; this.setData({ pageNo: 1, pageSize: 20, issueType: statusArray[statusIndex].id, refresh: true, noMore: false, // issueList:[] }); this.bindFilter(); }, selectIssue(e) { // const { issueListType: status } = this.data; const { currentTarget: { dataset: { id, gid, aid }, }, } = e; wxNavigateTo("/subpages/index/pages/workguide/detail", { guideId: id }); }, async getAgencyList() { const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "gov/org/customeragency/agencylist", {}, { // isMock: true, // isQuiet: true } ); if (msg === "success" && code === 0) { this.setData({ agencyInfo: data, agencyId: data.agencyId, agencyName: data.agencyName, gridIdList: [data.agencyId] }) } else { wx.showToast({ title: msg, icon: 'none', duration: 1500 }) } }, async getCateList() { const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "gov/voice/guidecategory/getcategory", { queryOrigin: 'query' }, { // isMock: true, // isQuiet: true } ); if (msg === "success" && code === 0) { this.setData({ tabsList: data, categoryId: data[0].categoryCode }) } else { wx.showToast({ title: msg, icon: 'none', duration: 1500 }) } }, async getGuideList() { let { pageNo, pageSize, agencyId, noMore, guideTitle, guideList, total, refresh, categoryId } = this.data if (pageNo !== 1 && noMore) return; const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "gov/voice/guide/list", { categoryCode: categoryId, agencyId, guideTitle, pageNo, pageSize }, { // isMock: true, // isQuiet: true } ); if (msg === "success" && code === 0) { // this.setData({ // guideList: data.list // }) total = data.total; if (pageNo == 1) { guideList = data.list; } else { guideList = guideList.concat(data.list); } pageNo = pageNo + 1; if (data.list.length < pageSize) { noMore = true; } else { noMore = false; } if (refresh) { refresh = false; } this.setData({ guideList, pageSize, pageNo, total, refresh, noMore, }); } else { wx.showToast({ title: msg, icon: 'none', duration: 1500 }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })