流程改版
This commit is contained in:
+21
-36
@@ -9,23 +9,25 @@ Page({
|
||||
},
|
||||
|
||||
onShow() {
|
||||
let token = wx.getStorageSync("token") || null;
|
||||
let userInfo = wx.getStorageSync("userInfo") || null;
|
||||
let token = wx.getStorageSync("token") || null;
|
||||
this.setData({
|
||||
token: token,
|
||||
userInfo: userInfo
|
||||
userInfo: userInfo,
|
||||
deviceList: []
|
||||
})
|
||||
if(token && userInfo) {
|
||||
if(token) {
|
||||
this.getDevice();
|
||||
}
|
||||
},
|
||||
|
||||
// 点击登录或注册
|
||||
openLoginOrReg() {
|
||||
openLoginOrReg(e) {
|
||||
let bol = e.currentTarget.dataset.bol;
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
this.checkOpenIdLogin(res.code);
|
||||
this.checkOpenIdLogin(res.code, bol);
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: "none",
|
||||
@@ -37,30 +39,21 @@ Page({
|
||||
},
|
||||
|
||||
// 微信一键登录
|
||||
checkOpenIdLogin(code) {
|
||||
checkOpenIdLogin(code, bol) {
|
||||
let params = {
|
||||
code: code
|
||||
};
|
||||
$.ajax("weighingScale/checkOpenIdLogin", params, "POST", true, "登录中...").then((res) => {
|
||||
$.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)
|
||||
}
|
||||
this.setData({
|
||||
token: res.result.token,
|
||||
userInfo: res.result.user
|
||||
})
|
||||
|
||||
if(bol) {
|
||||
this.openSearchDevice();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -76,20 +69,12 @@ Page({
|
||||
|
||||
// 添加设备
|
||||
openSearchDevice() {
|
||||
// let token = this.data.token;
|
||||
// let userInfo = this.data.userInfo;
|
||||
// if (token && userInfo) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/searchDevice/searchDevice"
|
||||
})
|
||||
// } else {
|
||||
// wx.showToast({
|
||||
// icon: "none",
|
||||
// title: "请先登录"
|
||||
// })
|
||||
// }
|
||||
wx.navigateTo({
|
||||
url: "/pages/searchDevice/searchDevice"
|
||||
})
|
||||
},
|
||||
|
||||
// 打开设备详情
|
||||
openDeviceInfo() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/deviceInfo/deviceInfo"
|
||||
|
||||
Reference in New Issue
Block a user