第一版

This commit is contained in:
17792275749
2025-03-25 20:52:15 +08:00
commit 04d373b84e
88 changed files with 4539 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
import $ from "../../utils/request";
Page({
data: {
token: null,
userInfo: null,
deviceList: []
},
onShow() {
let token = wx.getStorageSync("token") || null;
let userInfo = wx.getStorageSync("userInfo") || null;
this.setData({
token: token,
userInfo: userInfo
})
if(token && userInfo) {
this.getDevice();
}
},
// 点击登录或注册
openLoginOrReg() {
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)
}
})
},
// 获取已经绑定的设备列表
getDevice() {
let params = {};
$.ajax("weighingScale/list/device", params, "GET", true, "获取设备列表").then((res) => {
this.setData({
deviceList: res.result
})
})
},
// 添加设备
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: "请先登录"
})
}
}
})
+5
View File
@@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationStyle": "custom",
"disableScroll": true
}
+37
View File
@@ -0,0 +1,37 @@
<view class="bg">
<image src="/images/home/bg.jpg"/>
</view>
<view class="home">
<view class="title">
<view>
<view>
<block wx:if="{{userInfo && userInfo.avatar}}">
<image src="{{userInfo.avatar}}" />
</block>
<block wx:else>
<image src="/images/home/user.png" />
</block>
</view>
<block wx:if="{{userInfo && token}}">
<view>{{userInfo.realname}}</view>
</block>
<block wx:else>
<view class="arrowAfter" bind:tap="openLoginOrReg">登录/注册</view>
</block>
</view>
<view>智能体脂秤</view>
<view>注重更好的健康生活品质</view>
<view></view>
</view>
<view class="device">
<view>请添加设备</view>
<view>添加设备后,解锁更多体验</view>
<block wx:if="{{userInfo && token}}">
<view bind:tap="openSearchDevice">添加设备</view>
</block>
<block wx:else>
<view bind:tap="openLoginOrReg">登录/注册</view>
</block>
</view>
</view>
+118
View File
@@ -0,0 +1,118 @@
.bg {
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
.home {
position: relative;
z-index: 2;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 215rpx 60rpx 120rpx;
box-sizing: border-box;
}
.title {
width: 100%;
}
.title>view:nth-of-type(1) {
width: 100%;
height: 80rpx;
display: flex;
flex-wrap: nowrap;
margin-bottom: 56rpx;
}
.title>view:nth-of-type(1)>view:first-of-type {
width: 80rpx;
height: 80rpx;
overflow: hidden;
border-radius: 50%;
margin-right: 20rpx;
}
.title>view:nth-of-type(1)>view:last-of-type {
color: #FFFFFF;
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
font-weight: bold;
padding-right: 26rpx;
}
.title>view:nth-of-type(1)>view:last-of-type::after {
border-left: 5rpx solid #ffffff;
border-top: 5rpx solid #ffffff;
}
.title>view:nth-of-type(2) {
color: #FFFFFF;
height: 58rpx;
font-size: 58rpx;
font-weight: bold;
line-height: 58rpx;
margin-bottom: 34rpx;
}
.title>view:nth-of-type(3) {
color: #FFFFFF;
height: 32rpx;
font-size: 32rpx;
line-height: 32rpx;
margin-bottom: 48rpx;
}
.title>view:nth-of-type(4) {
width: 120rpx;
height: 6rpx;
border-radius: 3rpx;
background-color: #FFFFFF;
}
.device {
width: 580rpx;
margin: 0 auto;
}
.device>view:nth-of-type(1) {
color: #FFFFFF;
width: 100%;
height: 36rpx;
font-size: 36rpx;
font-weight: bold;
text-align: center;
line-height: 36rpx;
margin-bottom: 30rpx;
}
.device>view:nth-of-type(2) {
color: #FFFFFF;
width: 100%;
height: 30rpx;
font-size: 30rpx;
text-align: center;
line-height: 30rpx;
margin-bottom: 80rpx;
}
.device>view:nth-of-type(3) {
color: #FFFFFF;
width: 100%;
height: 106rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
line-height: 106rpx;
border-radius: 16rpx;
border: 1rpx solid #FFFFFF;
}