import Api from "../../model/api"; import Config from "../../model/config"; import {showLoading, toast} from "../../utils/utils"; import {verifyTypes} from "../../model/enum"; Page({ data: { wifiOk: false, current: '', wifi: {}, isOk: false, name: '', type: '', title: '', cId: '', teamId: '', eId: '' }, async onLoad(options) { const {title, type, name, cId, teamId, eId} = options; wx.setNavigationBarTitle({title}) this.setData({ type, name, title, cId, teamId, eId, }) await this.getData(); }, async getData() { const data = await Api.getPulishDict(Config.DICT.WIFI, true); this.setData({ wifi: data.data[0], }) }, async clickBtn(e) { if (this.data.isOk) { return } showLoading(); try { const wifiData = await wx.startWifi(); const res = await wx.getConnectedWifi(); let msg = res.wifi.SSID; let flag = (msg == this.data.wifi.dictLabel); this.setData({ wifiOk: flag, current: msg }) } catch (e) { console.log(e); toast("请检查手机WIFI和GPS定位是否打开后重试") return; } let res; if (this.data.type == verifyTypes.REPORT) { res = await Api.report({ id: this.data.teamId, eStuId: this.data.eId, wifiName: this.data.current, // wifiName: this.data.wifi.dictLabel, wifiPassword: this.data.wifi.dictValue, }); } else if (this.data.type == verifyTypes.CHECK_IN) { res = await Api.checkIn(this.data.cId, this.data.eId, this.data.current) } if (!res) { return; } this.setData({isOk: true}); const eventChannel = this.getOpenerEventChannel() eventChannel.emit('check'); wx.hideLoading(); } })