import { wxRequestPost } from "@utils/promise-wx-api"; let tempReslove = () => {}; const app = getApp(); Component({ behaviors: [], properties: { }, data: { hidden: true, id: '', type: '', loading: false, unReadList: [], readList: [], unReadCount: 0, readCount: 0, }, lifetimes: { aattached() { }, detached() {}, }, methods: { show(obj) { const {id, type} = obj; this.setData({ id, type, hidden: false, loading: true, }); this.getApiData(); return new Promise((reslove) => { tempReslove = reslove; }); }, hide() { this.setData({ hidden: true }); }, cancel() { this.hide(); return tempReslove({ unReadCount: this.data.unReadCount }); }, getApiData(){ const {id, type} = this.data; if(type === 'topic'){ // 暂无 } else if(type === 'notice'){ this.getNoticeList(id); } else if(type === 'act'){ this.getActList(id); } }, // 获取当前组织信息 async getNoticeList(noticeId) { const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "resi/group/noticereafdrecord/noticereadlist", { noticeId }, { // isMock: true, // isQuiet: true } ); this.setData({ loading: false, }); if (msg === "success" && code === 0) { this.setData({ readCount: data.readCount, unReadCount: data.unReadCount, readList: data.readList, unReadList: data.unReadList, }); } }, // 获取当前组织信息 async getActList(groupActId) { const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "resi/group/act/readlist", { groupActId }, { // isMock: true, // isQuiet: true } ); this.setData({ loading: false, }); if (msg === "success" && code === 0) { this.setData({ readCount: data.readCount, unReadCount: data.unReadCount, readList: data.readList, unReadList: data.unReadList, }); } }, }, });