流程改版
This commit is contained in:
+32
-67
@@ -3,6 +3,7 @@ import $ from "../../utils/request";
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
token: null,
|
||||
|
||||
deviceInfo: null
|
||||
},
|
||||
@@ -11,66 +12,44 @@ Page({
|
||||
let token = wx.getStorageSync("token") || null;
|
||||
let userInfo = wx.getStorageSync("userInfo") || null;
|
||||
this.setData({
|
||||
userInfo: userInfo
|
||||
userInfo: userInfo,
|
||||
token: token
|
||||
})
|
||||
if(token && userInfo) {
|
||||
this.getDevice();
|
||||
}
|
||||
},
|
||||
|
||||
// 打开用户信息
|
||||
openUserInfo() {
|
||||
if(this.data.userInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/userInfo/userInfo?initBluetooth=1&customerType=1"
|
||||
})
|
||||
} else {
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
this.checkOpenIdLogin(res.code);
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "登录失败,请稍后再试!",
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 微信一键登录
|
||||
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);
|
||||
if(res.result.token && res.result.user) {
|
||||
this.setData({
|
||||
token: res.result.token,
|
||||
userInfo: res.result.user
|
||||
})
|
||||
this.getDevice();
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "请先补全个人信息"
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({
|
||||
url: "/pages/userInfo/userInfo?initBluetooth=0&customerType=1"
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
openLoginOrReg() {
|
||||
if(this.data.userInfo === null && this.data.token === null) {
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
let params = {
|
||||
code: res.code
|
||||
};
|
||||
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
|
||||
wx.setStorageSync("userInfo", res.result.user);
|
||||
wx.setStorageSync("token", res.result.token);
|
||||
this.setData({
|
||||
token: res.result.token,
|
||||
userInfo: res.result.user
|
||||
})
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "登录失败,请稍后再试!",
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 打开设备详情
|
||||
openDeviceInfo() {
|
||||
if(this.data.userInfo) {
|
||||
if(this.data.userInfo && this.data.token) {
|
||||
let deviceInfo = this.data.deviceInfo;
|
||||
if(deviceInfo) {
|
||||
wx.navigateTo({
|
||||
@@ -98,20 +77,6 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
// 打开成员管理
|
||||
openFamilyMembers() {
|
||||
if(this.data.userInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/familyMembers/familyMembers"
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "请先登录"
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取已经绑定的设备列表
|
||||
getDevice() {
|
||||
let params = {};
|
||||
|
||||
Reference in New Issue
Block a user