import { wxNavigateTo } from "@utils/promise-wx-api"; //import nextTick from "@npm/dai-mp/tools/nextTick.js"; import commonBehavior from "@mixins/common"; import listBehavior from "@mixins/list"; const app = getApp(); Component({ behaviors: [commonBehavior, listBehavior], properties: { listParams: { type: Object, value: { gridId: "", }, }, listUrl: { type: String, value: "", }, type: { type: String, value: "", }, listIsMock: { type: Boolean, value: false, }, }, data: { iniLoaded: false, refresherIsTriggered: false, }, lifetimes: { ready() { this.init(); }, }, pageLifetimes: { async show() { await this.refreshData(); }, }, methods: { async init() { const { iniLoaded } = this.data; const $loading = this.selectComponent("#loading"); if (!iniLoaded) { $loading.show(); } await this.getApiData(); this.setData({ iniLoaded: true, }); $loading.hide(); }, // 刷新 async refreshData() { if (this.data.iniLoaded) { // 如果第一页,静默刷新 const { list } = this.data; if (list.page == 2) { list.page = 1; list.isNone = false; this.setData({ list }); await this.getApiData(); } } }, // 加载更多 getMore() { this.getApiData(); }, async getApiData() { await this.getList(); }, // 查看详情 handleTapItem(e) { const { currentTarget: { dataset: { id }, }, } = e; }, gotoGroup(e) { let gid = e.currentTarget.dataset.gid; wx.navigateTo({ url: "/subpages/group/pages/topic/topicIndex/topicIndex?gid=" + gid, }); }, previewImage(e) { app.globalData.previewImage = true; wx.previewImage({ urls: [e.currentTarget.dataset.src], }); }, }, });