补充图片
This commit is contained in:
@@ -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();
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user