import request from "../../../config/rerquest"; import { gnameSubstring } from "@utils/util"; var app = getApp(); Page({ data: { hasChose: false, //isAuthorized: 0, selectedarea: false, gridName: "", gridList: [], region: ["山东省", "青岛市", "市北区"], currentAddress: "无法获取您的位置信息", }, onLoad() { this.setData({ gridName: gnameSubstring(wx.getStorageSync("gridName")), }); this.getMyGrids(); }, getMyGridsData() { return request({ method: "POST", url: "resi/mine/mygrid/allgrids", options: {}, ifToken: true, }); }, getMyGrids() { let that = this; this.getMyGridsData().then(function (res: { data: any }) { that.setData({ gridList: res.data, }); }); }, enterGridData(customerId: string, gridId: string) { return request({ method: "POST", url: "resi/guide/user/entergrid", options: { customerId: customerId, gridId: gridId, }, ifToken: true, }); }, loginGrid(e) { console.log(e.currentTarget.dataset.cid); let gid = e.currentTarget.dataset.gid; let cid = e.currentTarget.dataset.cid; let self = this; self.enterGridData(cid, gid).then(function (res: { data: any }) { // 更新网格缓存数据 wx.setStorageSync("userRoleList", res.data.userRoleList); wx.setStorageSync("gridName", res.data.currentGridName); app.globalData.userRoleList = res.data.userRoleList; app.globalData.currentGridName = res.data.currentGridName; app.globalData.userInfo.nickname = res.data.nickname; app.globalData.userInfo.userHeadPhoto = res.data.userHeadPhoto; app.globalData.customerId = cid; app.globalData.gridId = gid; wx.reLaunch({ url: "/pages/main/index", }); }); }, async loginGrid2(e) { console.log(e.currentTarget.dataset.cid); app.globalData.gridId = e.currentTarget.dataset.gid; app.globalData.customerId = e.currentTarget.dataset.cid; let res = await app.enterGridData(); if (res) { wx.reLaunch({ url: "/pages/main/index", }); } }, methods: {}, });