第一版
This commit is contained in:
+112
@@ -0,0 +1,112 @@
|
||||
import $ from "../../utils/request";
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
|
||||
deviceInfo: null
|
||||
},
|
||||
|
||||
onShow() {
|
||||
let token = wx.getStorageSync("token") || null;
|
||||
let userInfo = wx.getStorageSync("userInfo") || null;
|
||||
this.setData({
|
||||
userInfo: userInfo
|
||||
})
|
||||
if(token && userInfo) {
|
||||
this.getDevice();
|
||||
}
|
||||
},
|
||||
|
||||
// 打开用户信息
|
||||
openUserInfo() {
|
||||
if(this.data.userInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/userInfo/userInfo?initBluetooth=1&customerType=1"
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "请先登录"
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 打开设备详情
|
||||
openDeviceInfo() {
|
||||
if(this.data.userInfo) {
|
||||
let deviceInfo = this.data.deviceInfo;
|
||||
if(deviceInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/deviceInfo/deviceInfo"
|
||||
})
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "当前暂未绑定设备,需要绑定吗?",
|
||||
confirmText: "去绑定",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/searchDevice/searchDevice"
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "请先登录"
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 打开成员管理
|
||||
openFamilyMembers() {
|
||||
if(this.data.userInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/familyMembers/familyMembers"
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: "请先登录"
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 获取已经绑定的设备列表
|
||||
getDevice() {
|
||||
let params = {};
|
||||
$.ajax("weighingScale/list/device", params, "GET", false).then((res) => {
|
||||
this.setData({
|
||||
deviceInfo: res.result && res.result.length ? res.result[0] : null
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 退出登录
|
||||
exitLogin() {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "你确定要退出登录吗?",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
$.ajax("weighingScale/logout", {}, "POST", true, "正在退出登录...").then(res => {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
title: res.message
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.clearStorageSync();
|
||||
wx.switchTab({
|
||||
url: "/pages/home/home"
|
||||
})
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user