补充图片

This commit is contained in:
17792275749
2025-04-24 19:59:00 +08:00
parent 4ad8d2a841
commit 230490b995
15 changed files with 178 additions and 102 deletions
+37
View File
@@ -68,8 +68,12 @@ Page({
},
onShow() {
let token = wx.getStorageSync("token") || null;
let userInfo = wx.getStorageSync("userInfo") || null;
let deviceSelect = app.globalData.ppScale.device.connection;
this.setData({
token: token,
userInfo: userInfo,
name: deviceSelect.name,
deviceSelect: deviceSelect
})
@@ -83,6 +87,27 @@ Page({
// 配对
openConnectionSuccessful() {
let token = this.data.token;
let userInfo = this.data.userInfo;
if (token && userInfo) {
this.starConnection();
} else {
wx.login({
success: (res) => {
if (res.code) {
this.checkOpenIdLogin(res.code);
} else {
wx.showToast({
icon: "none",
title: "登录失败,请稍后再试!",
})
}
}
})
}
},
starConnection() {
let deviceSelect = this.data.deviceSelect;
if (deviceSelect) {
let name = this.data.name;
@@ -106,4 +131,16 @@ Page({
})
}
},
// 微信一键登录
checkOpenIdLogin(code) {
let params = {
code: code
};
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
wx.setStorageSync("userInfo", res.result.user);
wx.setStorageSync("token", res.result.token);
this.starConnection();
})
},
})