2025年12月3日14:14:55
This commit is contained in:
@@ -10,10 +10,12 @@ App({
|
||||
|
||||
// 秤的所有信息
|
||||
ppScale: {
|
||||
version: "",
|
||||
|
||||
plugin: null,
|
||||
activeProtocol: null,
|
||||
domain: "http://device.shuziweidao.com:80/gateway",
|
||||
// domain: "http://192.168.1.12:8889",
|
||||
domain1: "http://device.shuziweidao.com:80/gateway", // 老版本 没有鉴权
|
||||
domain2: "http://device.shuziweidao.com:80/weight", // 新版本 有鉴权
|
||||
wifi: {
|
||||
ssid: "",
|
||||
password: ""
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
"style": "v2",
|
||||
"plugins": {
|
||||
"ppScale-plugin": {
|
||||
"version": "1.2.15",
|
||||
"provider": "wx0ffb48417ce6345c"
|
||||
"version": "0.0.16",
|
||||
"provider": "wx0826af4e4908f524"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
|
||||
@@ -61,89 +61,98 @@ Component({
|
||||
progress: 2
|
||||
})
|
||||
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork", res);
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6",
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
if(res === 23) {
|
||||
app.globalData.ppScale.wifi.ssid = this.data.selectWifi.ssid;
|
||||
app.globalData.ppScale.wifi.password = this.data.selectWifiPWD;
|
||||
|
||||
let mac = app.globalData.ppScale.device.mac;
|
||||
let deviceId = app.globalData.ppScale.device.connection.deviceId;
|
||||
if(mac && deviceId) {
|
||||
let scaleDeviceId = mac.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentName: app.globalData.ppScale.device.name,
|
||||
scaleDeviceId: scaleDeviceId,
|
||||
deviceId: deviceId
|
||||
};
|
||||
$.ajax("weighingScale/binding/device", params, "POST").then(res => {
|
||||
if (res.success) {
|
||||
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
|
||||
console.log("setNetwork.js codeSetBindingState", res);
|
||||
netWorkCallBack(res) {
|
||||
if(res === 23) {
|
||||
app.globalData.ppScale.wifi.ssid = this.data.selectWifi.ssid;
|
||||
app.globalData.ppScale.wifi.password = this.data.selectWifiPWD;
|
||||
|
||||
if(res == 0) {
|
||||
this.triggerEvent('deviceEvent', {
|
||||
status: true
|
||||
});
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
title: "绑定失败,请重试。",
|
||||
icon: "none"
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: res.message
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
let mac = app.globalData.ppScale.device.mac;
|
||||
let deviceId = app.globalData.ppScale.device.connection.deviceId;
|
||||
if(mac && deviceId) {
|
||||
let scaleDeviceId = mac.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentName: app.globalData.ppScale.device.name,
|
||||
scaleDeviceId: scaleDeviceId,
|
||||
deviceId: deviceId
|
||||
};
|
||||
$.ajax("weighingScale/binding/device", params, "POST").then(res => {
|
||||
if (res.success) {
|
||||
app.globalData.ppScale.activeProtocol.codeSetBindingState((res) => {
|
||||
console.log("setNetwork.js codeSetBindingState", res);
|
||||
|
||||
if(res == 0) {
|
||||
this.triggerEvent('deviceEvent', {
|
||||
status: true
|
||||
});
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
title: "绑定失败,请重试。",
|
||||
icon: "none"
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
}).catch(err => {
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: err.message
|
||||
title: res.message
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
})
|
||||
} else {
|
||||
}
|
||||
}).catch(err => {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
|
||||
title: err.message
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配网失败,错误码:" + res
|
||||
title: "Mac 地址与 deviceId 获取失败,请重新绑定"
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
@@ -151,7 +160,18 @@ Component({
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配网失败,错误码:" + res
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -32,42 +32,62 @@ Component({
|
||||
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);
|
||||
let version = app.globalData.ppScale.version;
|
||||
if (version === 'domain1') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigNetWork({
|
||||
domain: app.globalData.ppScale.domain1,
|
||||
ssid: this.data.selectWifi.ssid,
|
||||
password: this.data.selectWifiPWD
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigNetWork 1", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
}
|
||||
if (version === 'domain2') {
|
||||
app.globalData.ppScale.activeProtocol.dataConfigUserNetWork({
|
||||
domain: app.globalData.ppScale.domain2,
|
||||
ssid: ssid,
|
||||
password: password,
|
||||
userName: "apiUser",
|
||||
userPassword: "3acebb95eb49577e9c2a2082589b9bd6"
|
||||
}, (res) => {
|
||||
console.log("setNetwork.js dataConfigUserNetWork 2", res);
|
||||
|
||||
this.netWorkCallBack(res);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
if(res === 23) {
|
||||
app.globalData.ppScale.wifi.ssid = ssid;
|
||||
app.globalData.ppScale.wifi.password = password;
|
||||
netWorkCallBack(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(() => {
|
||||
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: false
|
||||
status: true
|
||||
});
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
app.globalData.ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "配网失败,错误码:" + res
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.triggerEvent('wifiEvent', {
|
||||
status: false
|
||||
});
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -13,109 +13,110 @@ Page({
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
ppScale.plugin.bus.subscribe("devicesModel", (res) => {
|
||||
console.log("===》devicesModel", res);
|
||||
ppScale.device.mac = res.deviceMac;
|
||||
ppScale.plugin.bus.subscribe("deviceInfo", (res) => {
|
||||
console.log("===》deviceInfo", res);
|
||||
ppScale.device.mac = res.serialNumber;
|
||||
});
|
||||
|
||||
ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||
console.log('===》deviceConnect', res);
|
||||
|
||||
ppScale.plugin.ScaleAction.startDataProgress(true);
|
||||
ppScale.activeProtocol = ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||
|
||||
ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||
console.log("===》codeUpdateMTU", res);
|
||||
|
||||
ppScale.activeProtocol.codeFetchBindingState((res) => {
|
||||
console.log("===》codeFetchBindingState", res);
|
||||
ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||
console.log('===》deviceConnect', res);
|
||||
|
||||
ppScale.activeProtocol.codeSyncTime((codeSyncTime) => {
|
||||
console.log("===》codeSyncTime", codeSyncTime)
|
||||
ppScale.plugin.ScaleAction.startDataProgress(true);
|
||||
ppScale.activeProtocol = ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||
|
||||
wx.hideLoading();
|
||||
if (res === 1) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前设备已被绑定,你确定要覆盖绑定吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({
|
||||
title: "正在初始化设备...",
|
||||
mask: true
|
||||
});
|
||||
ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||
console.log("deviceInfo === codeClearDeviceData", res);
|
||||
wx.hideLoading();
|
||||
|
||||
if(res === 0) {
|
||||
let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentCode: scaleDeviceId,
|
||||
};
|
||||
$.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
|
||||
ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "设备初始化成功,请重新绑定。",
|
||||
})
|
||||
// device.list = [];
|
||||
// device.mac = null;
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1500);
|
||||
});
|
||||
} else {
|
||||
ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||
console.log("===》codeUpdateMTU", res);
|
||||
|
||||
ppScale.activeProtocol.codeFetchBindingState((res) => {
|
||||
console.log("===》codeFetchBindingState", res);
|
||||
|
||||
ppScale.activeProtocol.codeSyncTime((codeSyncTime) => {
|
||||
console.log("===》codeSyncTime", codeSyncTime)
|
||||
|
||||
wx.hideLoading();
|
||||
if (res === 1) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '当前设备已被绑定,你确定要覆盖绑定吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.showLoading({
|
||||
title: "正在初始化设备...",
|
||||
mask: true
|
||||
});
|
||||
ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||
console.log("deviceInfo === codeClearDeviceData", res);
|
||||
wx.hideLoading();
|
||||
|
||||
if(res === 0) {
|
||||
let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentCode: scaleDeviceId,
|
||||
};
|
||||
$.ajax("weighingScale/del/device", params, "POST", true, "正在初始化设备...").then(res => {
|
||||
ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "设备初始化失败。",
|
||||
title: "设备初始化成功,请重新绑定。",
|
||||
})
|
||||
}
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
// device.mac = null;
|
||||
ppScale.plugin.Blue.stop();
|
||||
}
|
||||
// device.list = [];
|
||||
// device.mac = null;
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 1500);
|
||||
});
|
||||
} else {
|
||||
ppScale.plugin.Blue.stop();
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "设备初始化失败。",
|
||||
})
|
||||
}
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
// device.mac = null;
|
||||
ppScale.plugin.Blue.stop();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ppScale.device.name = this.data.device.name;
|
||||
ppScale.device.connection = this.data.device;
|
||||
if(this.data.progressNext) {
|
||||
let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
|
||||
let params = {
|
||||
sn: scaleDeviceId,
|
||||
};
|
||||
$.ajax("weighingScale/getUserInfoBySn", params, "GET", true, "正在同步用户信息...").then(res => {
|
||||
if(res.result) {
|
||||
wx.setStorageSync("userInfo", res.result);
|
||||
this.setProgress();
|
||||
} else {
|
||||
wx.removeStorageSync("userInfo");
|
||||
wx.showToast({
|
||||
title: "暂无用户信息,请手动补充",
|
||||
icon: "none"
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.setProgress();
|
||||
}, 1500)
|
||||
}
|
||||
}).catch(() => {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ppScale.device.name = this.data.device.name;
|
||||
ppScale.device.connection = this.data.device;
|
||||
ppScale.version = this.data.device.name.includes("YX") ? "domain2" : "domain1";
|
||||
if(this.data.progressNext) {
|
||||
let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
|
||||
let params = {
|
||||
sn: scaleDeviceId,
|
||||
};
|
||||
$.ajax("weighingScale/getUserInfoBySn", params, "GET", true, "正在同步用户信息...").then(res => {
|
||||
if(res.result) {
|
||||
wx.setStorageSync("userInfo", res.result);
|
||||
this.setProgress();
|
||||
} else {
|
||||
wx.removeStorageSync("userInfo");
|
||||
wx.showToast({
|
||||
title: "用户信息同步失败,请手动补充",
|
||||
title: "暂无用户信息,请手动补充",
|
||||
icon: "none"
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.setProgress();
|
||||
}, 1500)
|
||||
}
|
||||
}).catch(() => {
|
||||
wx.showToast({
|
||||
title: "用户信息同步失败,请手动补充",
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.setProgress();
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -27,9 +27,8 @@ Page({
|
||||
},
|
||||
|
||||
delDevice() {
|
||||
let scaleDeviceId = this.data.deviceInfo.macAddress.replace(/:/g, '');
|
||||
let params = {
|
||||
equipmentCode: scaleDeviceId,
|
||||
equipmentCode: this.data.deviceInfo.equipmentCode,
|
||||
};
|
||||
$.ajax("weighingScale/del/device", params, "POST", true, "正在解绑设备...").then(res_ => {
|
||||
wx.showToast({
|
||||
|
||||
@@ -36,6 +36,7 @@ Page({
|
||||
|
||||
app.globalData.ppScale.device.name = this.data.device.name;
|
||||
app.globalData.ppScale.device.connection = this.data.device;
|
||||
app.globalData.ppScale.version = this.data.device.name.includes("YX") ? "domain2" : "domain1";
|
||||
|
||||
wx.hideLoading();
|
||||
this.selectComponent('#replaceNetwork1Component').getWiFiList();
|
||||
|
||||
+22
-22
@@ -1,24 +1,24 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "bodyWeight",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false,
|
||||
"bigPackageSizeSupport": true,
|
||||
"coverView": true,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"skylineRenderEnable": false,
|
||||
"preloadBackgroundData": false,
|
||||
"autoAudits": false,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"useStaticServer": false,
|
||||
"useLanDebug": false,
|
||||
"showES6CompileOption": false,
|
||||
"checkInvalidKey": true,
|
||||
"ignoreDevUnusedFiles": true
|
||||
},
|
||||
"libVersion": "3.8.6",
|
||||
"condition": {}
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"projectname": "bodyWeight",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false,
|
||||
"bigPackageSizeSupport": true,
|
||||
"coverView": true,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"skylineRenderEnable": false,
|
||||
"preloadBackgroundData": false,
|
||||
"autoAudits": false,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"useStaticServer": false,
|
||||
"useLanDebug": false,
|
||||
"showES6CompileOption": false,
|
||||
"checkInvalidKey": true,
|
||||
"ignoreDevUnusedFiles": true
|
||||
},
|
||||
"libVersion": "3.11.3",
|
||||
"condition": {}
|
||||
}
|
||||
Reference in New Issue
Block a user