const app = getApp(); import $ from "../../utils/request"; Component({ properties: { ssid: { type: String, value: "" }, password: { type: String, value: "" } }, data: { }, // 生命周期方法 lifetimes: { attached() { this.setNerwork(); }, detached() { } }, // 组件的方法 methods: { setNerwork() { let ssid = this.properties.ssid; let password = this.properties.password; app.globalData.ppScale.activeProtocol.dataConfigNetWork({ domain: app.globalData.ppScale.domain, ssid: ssid, password: password }, (res) => { console.log("setNetwork.js dataConfigNetWork", res); if(res === 23) { app.globalData.ppScale.wifi.ssid = ssid; app.globalData.ppScale.wifi.password = password; let scaleDeviceId = app.globalData.ppScale.device.mac.replace(/:/g, ''); if(scaleDeviceId) { let params = { equipmentCode: scaleDeviceId, wifiName: ssid }; $.ajax("weighingScale/edit/device", params, "POST").then((res) => { this.triggerEvent('wifiEvent', { status: true }); }) } } else { app.globalData.ppScale.plugin.Blue.stop(); wx.showToast({ icon: "none", title: "配网失败,错误码:" + res }) setTimeout(() => { this.triggerEvent('wifiEvent', { status: false }); }, 1500) } }) } } });