"version": "1.2.19"
This commit is contained in:
@@ -32,8 +32,8 @@
|
|||||||
"style": "v2",
|
"style": "v2",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"ppScale-plugin": {
|
"ppScale-plugin": {
|
||||||
"version": "0.0.19",
|
"version": "1.2.19",
|
||||||
"provider": "wx0826af4e4908f524"
|
"provider": "wx0ffb48417ce6345c"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"permission": {
|
"permission": {
|
||||||
|
|||||||
@@ -150,6 +150,10 @@ Component({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setUserInfo() {
|
setUserInfo() {
|
||||||
|
// app.globalData.ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||||
|
// console.log("deviceInfo === codeClearDeviceData", res);
|
||||||
|
// })
|
||||||
|
|
||||||
if(this.data.connectState == this.data.BLUE_STATE.CONNECTSUCCESS) {
|
if(this.data.connectState == this.data.BLUE_STATE.CONNECTSUCCESS) {
|
||||||
if(this.data.userId) {
|
if(this.data.userId) {
|
||||||
app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
|
app.globalData.ppScale.activeProtocol.dataSyncUserInfo({
|
||||||
|
|||||||
@@ -3,193 +3,194 @@ import $ from "../../utils/request";
|
|||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
progress: {
|
progress: {
|
||||||
index: 0,
|
index: 0,
|
||||||
data: ['配置蓝牙', '初始化用户信息', '配备网络', '完成']
|
data: ['配置蓝牙', '初始化用户信息', '配备网络', '完成']
|
||||||
},
|
},
|
||||||
|
|
||||||
progressNext: false,
|
progressNext: false,
|
||||||
device: null
|
device: null
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad() {
|
|
||||||
ppScale.plugin.bus.subscribe("deviceInfo", (res) => {
|
|
||||||
console.log("===》deviceInfo", res);
|
|
||||||
ppScale.device.mac = res.serialNumber;
|
|
||||||
});
|
|
||||||
|
|
||||||
ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
onLoad() {
|
||||||
console.log('===》deviceConnect', res);
|
ppScale.plugin.bus.subscribe("deviceInfo", (res) => {
|
||||||
|
console.log("===》deviceInfo", res);
|
||||||
|
ppScale.device.mac = res.serialNumber;
|
||||||
|
});
|
||||||
|
|
||||||
ppScale.plugin.ScaleAction.startDataProgress(true);
|
ppScale.plugin.bus.subscribe("deviceConnect", (res) => {
|
||||||
ppScale.activeProtocol = ppScale.plugin.ScaleAction.getActiveProtocol();
|
console.log('===》deviceConnect', res);
|
||||||
|
|
||||||
ppScale.activeProtocol.codeUpdateMTU((res) => {
|
ppScale.plugin.ScaleAction.startDataProgress(true);
|
||||||
console.log("===》codeUpdateMTU", res);
|
ppScale.activeProtocol = ppScale.plugin.ScaleAction.getActiveProtocol();
|
||||||
|
|
||||||
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: "设备初始化成功,请重新绑定。",
|
|
||||||
})
|
|
||||||
// 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;
|
|
||||||
const nameArr = this.data.device.name.split("-");
|
|
||||||
ppScale.version = nameArr.length === 5 ? "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: "暂无用户信息,请手动补充",
|
|
||||||
icon: "none"
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
this.setProgress();
|
|
||||||
}, 1500)
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
wx.showToast({
|
|
||||||
title: "用户信息同步失败,请手动补充",
|
|
||||||
icon: "none"
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
this.setProgress();
|
|
||||||
}, 1500)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
// 选择了某个设备
|
ppScale.activeProtocol.codeUpdateMTU((res) => {
|
||||||
deviceChange(e) {
|
console.log("===》codeUpdateMTU", res);
|
||||||
let status = e.detail.status;
|
|
||||||
if(status) {
|
|
||||||
wx.showLoading({
|
|
||||||
title: "蓝牙配对中...",
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
this.setData({
|
|
||||||
progressNext: true
|
|
||||||
})
|
|
||||||
let device = e.detail.device;
|
|
||||||
this.connectedDevice_(device);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
connectedDevice(e) {
|
ppScale.activeProtocol.codeFetchBindingState((res) => {
|
||||||
wx.showLoading({
|
console.log("===》codeFetchBindingState", res);
|
||||||
title: "正在尝试连接...",
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
this.setData({
|
|
||||||
progressNext: false
|
|
||||||
})
|
|
||||||
let device = e.detail.device;
|
|
||||||
this.connectedDevice_(device);
|
|
||||||
},
|
|
||||||
|
|
||||||
connectedDevice_(device) {
|
ppScale.activeProtocol.codeSyncTime((codeSyncTime) => {
|
||||||
if(device) {
|
console.log("===》codeSyncTime", codeSyncTime)
|
||||||
this.setData({
|
|
||||||
device: device
|
|
||||||
})
|
|
||||||
ppScale.plugin.Blue.createBLEConnection(device);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setDeviceUserInfo(e) {
|
wx.hideLoading();
|
||||||
this.setData({
|
if (res === 1) {
|
||||||
progressNext: true
|
wx.showModal({
|
||||||
})
|
title: '提示',
|
||||||
let status = e.detail.status;
|
content: '当前设备已被绑定,你确定要覆盖绑定吗?',
|
||||||
if(status) {
|
success: (res) => {
|
||||||
this.setProgress();
|
if (res.confirm) {
|
||||||
}
|
wx.showLoading({
|
||||||
},
|
title: "正在初始化设备...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
ppScale.activeProtocol.codeClearDeviceData("00", (res) => {
|
||||||
|
console.log("deviceInfo === codeClearDeviceData", res);
|
||||||
|
wx.hideLoading();
|
||||||
|
|
||||||
setDeviceConfig(e) {
|
if (res === 0) {
|
||||||
let status = e.detail.status;
|
let scaleDeviceId = ppScale.device.mac.replace(/:/g, '');
|
||||||
if(status) {
|
let params = {
|
||||||
this.setProgress();
|
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.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;
|
||||||
|
const nameArr = this.data.device.name.split("-");
|
||||||
|
ppScale.version = nameArr.length === 5 ? "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: "暂无用户信息,请手动补充",
|
||||||
|
icon: "none"
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
this.setProgress();
|
||||||
|
}, 1500)
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
wx.showToast({
|
||||||
|
title: "用户信息同步失败,请手动补充",
|
||||||
|
icon: "none"
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
this.setProgress();
|
||||||
|
}, 1500)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
setConfigSuccessful() {
|
// 选择了某个设备
|
||||||
ppScale.plugin.Blue.stop();
|
deviceChange(e) {
|
||||||
wx.switchTab({
|
let status = e.detail.status;
|
||||||
url: "/pages/home/home"
|
if (status) {
|
||||||
})
|
wx.showLoading({
|
||||||
},
|
title: "蓝牙配对中...",
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
progressNext: true
|
||||||
|
})
|
||||||
|
let device = e.detail.device;
|
||||||
|
this.connectedDevice_(device);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setProgress() {
|
connectedDevice(e) {
|
||||||
this.setData({
|
ppScale.plugin.Blue.stop();
|
||||||
["progress.index"]: this.data.progress.index + 1
|
wx.showLoading({
|
||||||
})
|
title: "正在尝试连接...",
|
||||||
},
|
mask: true
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
progressNext: false
|
||||||
|
})
|
||||||
|
let device = e.detail.device;
|
||||||
|
this.connectedDevice_(device);
|
||||||
|
},
|
||||||
|
|
||||||
onUnload() {
|
connectedDevice_(device) {
|
||||||
ppScale.plugin.Blue.stop();
|
if (device) {
|
||||||
}
|
this.setData({
|
||||||
|
device: device
|
||||||
|
})
|
||||||
|
ppScale.plugin.Blue.createBLEConnection(device);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setDeviceUserInfo(e) {
|
||||||
|
this.setData({
|
||||||
|
progressNext: true
|
||||||
|
})
|
||||||
|
let status = e.detail.status;
|
||||||
|
if (status) {
|
||||||
|
this.setProgress();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setDeviceConfig(e) {
|
||||||
|
let status = e.detail.status;
|
||||||
|
if (status) {
|
||||||
|
this.setProgress();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setConfigSuccessful() {
|
||||||
|
ppScale.plugin.Blue.stop();
|
||||||
|
wx.switchTab({
|
||||||
|
url: "/pages/home/home"
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
setProgress() {
|
||||||
|
this.setData({
|
||||||
|
["progress.index"]: this.data.progress.index + 1
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onUnload() {
|
||||||
|
ppScale.plugin.Blue.stop();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user