import { wxRequestPost, wxNavigateTo } from "@utils/promise-wx-api"; const app = getApp(); Page({ data: { iniLoaded: false, badgeList: [ // { // isLighted: "fkZmROEhaC", // isCertificated: "km8C85iG3y", // isReject: "5OD3FakDoQ", // badgeId: "62628", // badgeName: 9009, // badgeIcon: "lk9oD7epp3", // badgeType: "", //徽章类型: party:党员认证【目前只有党员认证】 // }, ], }, async onShow() { // 更新角色权限,这里他应该已经是居民了 await app.doAfterLogin(); await this.getBadgeList(); this.setData({ iniLoaded: true, }); }, handleTapBadge(e) { console.log(e); const { currentTarget: { dataset: { index }, }, } = e; const { badgeList } = this.data; const item = badgeList[index]; if (item.isCertificated == "yes") { // 已认证 this.lighten(index); } else { if (item.badgeType !== "party") { wxNavigateTo("apply/index", { badgeId: item.badgeId, }); } else { wxNavigateTo("/subpages/mine/pages/register/communist/index", { from: "badge", }); } } }, async lighten(index) { const customerId = app.globalData.customerId; const { badgeList } = this.data; const { badgeId, isLighted } = badgeList[index]; wx.showLoading({ title: "提交中", }); const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "resi/mine/badge/openedorclosed", { customerId, badgeId, }, { // isMock: true, // isQuiet: false, } ); wx.hideLoading(); if (msg === "success" && code === 0) { badgeList[index].isLighted = isLighted == "yes" ? "no" : "yes"; this.setData({ badgeList, }); wx.showToast({ title: "操作成功", icon: "none", duration: 1500, }); } }, async getBadgeList() { let customerId = app.globalData.customerId; const { data: { data: { code, data }, }, msg, } = await wxRequestPost( "resi/mine/badge/operlist", { customerId, }, { // isMock: true, // isQuiet: false, } ); if (msg === "success" && code === 0) { this.setData({ badgeList: data, }); } }, });