流程改版
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"
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
<view>
|
||||
<image src="/images/home/user.png" />
|
||||
</view>
|
||||
<block wx:if="{{userInfo && token}}">
|
||||
<view>{{userInfo.realname}}</view>
|
||||
<block wx:if="{{userInfo || token}}">
|
||||
<view>{{userInfo ? userInfo.realname : '已登录'}}</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="arrowAfter" bind:tap="openLoginOrReg">登录/注册</view>
|
||||
<view class="arrowAfter" data-bol="{{false}}" bind:tap="openLoginOrReg">登录/注册</view>
|
||||
</block>
|
||||
</view>
|
||||
<view>智能体脂秤</view>
|
||||
<view>智能蓝牙秤</view>
|
||||
<view>注重更好的健康生活品质</view>
|
||||
<view></view>
|
||||
</view>
|
||||
@@ -31,12 +31,12 @@
|
||||
<view class="addDevice">
|
||||
<view>请添加设备</view>
|
||||
<view>添加设备后,解锁更多体验</view>
|
||||
<!-- <block wx:if="{{userInfo && token}}"> -->
|
||||
<block wx:if="{{userInfo && token}}">
|
||||
<view bind:tap="openSearchDevice">添加设备</view>
|
||||
<!-- </block>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view bind:tap="openLoginOrReg">登录/注册</view>
|
||||
</block> -->
|
||||
<view data-bol="{{true}}" bind:tap="openLoginOrReg">添加设备</view>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
@@ -86,7 +86,7 @@
|
||||
.device>view:nth-of-type(1) {
|
||||
width: 500rpx;
|
||||
height: 500rpx;
|
||||
margin: 0 auto;
|
||||
margin: 0 auto 16rpx;
|
||||
}
|
||||
|
||||
.device>view:nth-of-type(2) {
|
||||
|
||||
Reference in New Issue
Block a user