2026-03-23 16:23:40 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="box">
|
|
|
|
|
|
<!-- 头部 -->
|
|
|
|
|
|
<view class="header" v-if="token">
|
|
|
|
|
|
<view class="top" v-if="userList.length">
|
|
|
|
|
|
<image :src="info.head_pic" class="headimg" @click="handleAddUser(1)"></image>
|
|
|
|
|
|
<view class="info" @click="handleAddUser(1)">
|
|
|
|
|
|
<view class="size18 bold">{{info.nickname}}</view>
|
|
|
|
|
|
<view class="mt-5">
|
|
|
|
|
|
<text class="mr-10">性别:{{info.gender==1?'男':info.gender==2?'女':'未知'}}</text>
|
|
|
|
|
|
<text class="ml-10">年龄:{{info.age}}岁</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="t-icon t-icon-qiehuan1" @click="$store.commit('changeDrawe', true)"></view>
|
|
|
|
|
|
</view>
|
2026-03-27 10:04:26 +08:00
|
|
|
|
<view class="top top2" v-else @click="handleAddUser(2)">
|
2026-03-23 16:23:40 +08:00
|
|
|
|
<view class="info">
|
|
|
|
|
|
暂无成员,请先添加~
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="add">
|
|
|
|
|
|
+
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- 蓝牙 -->
|
2026-03-25 17:27:29 +08:00
|
|
|
|
<view class="bluetooth" v-if="userList.length" :class="[bleValue.isConnectStatus==1?'activs':'']">
|
2026-03-23 16:23:40 +08:00
|
|
|
|
<view class="bleTips" @click="openBluetoothAdapter">
|
|
|
|
|
|
{{bleTipsText}}
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="header" v-else @click="handleLogin">
|
|
|
|
|
|
<view class="top top2">
|
|
|
|
|
|
登录后查看更多
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 数据 -->
|
|
|
|
|
|
<view class="toggle">
|
2026-03-25 17:27:29 +08:00
|
|
|
|
<view :class="{'active':toolsIndex==0}" class="toolsItem" @click="handleToolsIndex(0)">身体数据</view>
|
|
|
|
|
|
<view :class="{'active':toolsIndex==1}" class="toolsItem" @click="handleToolsIndex(1)">饮食数据</view>
|
|
|
|
|
|
<view :class="{'active':toolsIndex==2}" class="toolsItem" @click="handleToolsIndex(2)">健康工具</view>
|
2026-03-23 16:23:40 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view v-if="token">
|
2026-03-27 10:04:26 +08:00
|
|
|
|
<bodypage v-if="toolsIndex==0"></bodypage>
|
2026-03-23 16:23:40 +08:00
|
|
|
|
<food v-if="toolsIndex==1"></food>
|
|
|
|
|
|
<card v-if="toolsIndex==2"></card>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="nolist" v-else>
|
|
|
|
|
|
<image src="/static/none.png"></image>
|
|
|
|
|
|
<text>暂无数据</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- -->
|
2026-03-25 17:27:29 +08:00
|
|
|
|
<drawer @handleToolsIndex="handleToolsIndex(0)"></drawer>
|
2026-03-23 16:23:40 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import {
|
|
|
|
|
|
mapState
|
|
|
|
|
|
} from "vuex";
|
2026-03-27 10:04:26 +08:00
|
|
|
|
import bodypage from "@/components/bodyIndex/bodyHome.vue"
|
2026-03-23 16:23:40 +08:00
|
|
|
|
import food from "@/components/foodIndex/foodHome.vue"
|
|
|
|
|
|
import card from "@/components/cardIndex/cardHome.vue"
|
|
|
|
|
|
import drawer from "@/components/bodyIndex/drawer.vue"
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
token: "",
|
2026-03-25 17:27:29 +08:00
|
|
|
|
// toolsIndex: 0
|
2026-03-23 16:23:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
food,
|
2026-03-27 10:04:26 +08:00
|
|
|
|
bodypage,
|
2026-03-23 16:23:40 +08:00
|
|
|
|
card,
|
|
|
|
|
|
drawer,
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
2026-03-30 15:02:56 +08:00
|
|
|
|
...mapState(["user", "familayList", 'isBluetoothTyle', "isConnected", "configInfo", "bleValue",
|
|
|
|
|
|
"homeCardIndex"]),
|
2026-03-23 16:23:40 +08:00
|
|
|
|
info() {
|
|
|
|
|
|
return this.user
|
|
|
|
|
|
},
|
|
|
|
|
|
userList() {
|
|
|
|
|
|
return this.familayList
|
|
|
|
|
|
},
|
|
|
|
|
|
endDate() {
|
|
|
|
|
|
return this.$tools.getDate("start")
|
|
|
|
|
|
},
|
|
|
|
|
|
isConnection() {
|
|
|
|
|
|
return this.bleValue.isConnectStatus
|
|
|
|
|
|
},
|
|
|
|
|
|
bleTipsText() {
|
|
|
|
|
|
return this.bleValue.bleTipsText
|
2026-03-25 17:27:29 +08:00
|
|
|
|
},
|
2026-03-27 10:04:26 +08:00
|
|
|
|
toolsIndex() {
|
2026-03-25 17:27:29 +08:00
|
|
|
|
return this.homeCardIndex
|
2026-03-23 16:23:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.token = uni.getStorageSync("token")
|
2026-03-31 13:51:12 +08:00
|
|
|
|
console.log("token",that.token)
|
2026-03-27 10:04:26 +08:00
|
|
|
|
if (that.token && that.bleValue.isConnectStatus != 2) {
|
|
|
|
|
|
that.$ble.openBluetoothAdapter()
|
|
|
|
|
|
}
|
2026-03-23 16:23:40 +08:00
|
|
|
|
that.$ble.onBLEConnectionStateChange()
|
|
|
|
|
|
uni.onBluetoothAdapterStateChange(function(res) {
|
2026-03-27 10:04:26 +08:00
|
|
|
|
that.$store.commit("changeBluetooth", res.available);
|
2026-03-23 16:23:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
let that = this
|
2026-03-27 10:56:18 +08:00
|
|
|
|
that.$tools.handleUserList()
|
|
|
|
|
|
if (that.bleValue.isConnectStatus != 2) {
|
|
|
|
|
|
that.$ble.openBluetoothAdapter()
|
|
|
|
|
|
}
|
2026-03-23 16:23:40 +08:00
|
|
|
|
that.$ble.onBLEConnectionStateChange()
|
|
|
|
|
|
uni.stopPullDownRefresh()
|
|
|
|
|
|
},
|
2026-03-30 15:02:56 +08:00
|
|
|
|
onShow() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
that.token = uni.getStorageSync('token')
|
2026-03-31 13:51:12 +08:00
|
|
|
|
console.log("token",that.token)
|
2026-03-30 15:02:56 +08:00
|
|
|
|
uni.onBluetoothAdapterStateChange(function(res) {
|
|
|
|
|
|
that.$store.commit("changeBluetooth", res.available);
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2026-03-23 16:23:40 +08:00
|
|
|
|
watch: {
|
2026-03-27 10:04:26 +08:00
|
|
|
|
isBluetoothTyle() {
|
2026-03-23 16:23:40 +08:00
|
|
|
|
let that = this
|
2026-03-27 10:04:26 +08:00
|
|
|
|
if (!that.isBluetoothTyle) {
|
|
|
|
|
|
that.$store.commit("changeBluetoothValue", {
|
|
|
|
|
|
bleTipsText: "重新连接",
|
|
|
|
|
|
isConnectStatus: 1,
|
|
|
|
|
|
})
|
2026-03-30 15:02:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
isConnected: function() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (!that.isConnected) {
|
|
|
|
|
|
that.$store.commit("changeBluetoothValue", {
|
|
|
|
|
|
bleTipsText: "重新连接",
|
|
|
|
|
|
isConnectStatus: 1,
|
|
|
|
|
|
})
|
2026-03-23 16:23:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-03-25 17:27:29 +08:00
|
|
|
|
'bleValue.isFood'() {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (that.bleValue.isFood) {
|
|
|
|
|
|
that.$store.commit("changehomeCard", 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-03-23 16:23:40 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2026-03-30 15:02:56 +08:00
|
|
|
|
|
2026-03-23 16:23:40 +08:00
|
|
|
|
// 初始化蓝牙
|
|
|
|
|
|
openBluetoothAdapter() {
|
|
|
|
|
|
let that = this
|
2026-03-30 15:02:56 +08:00
|
|
|
|
if (that.isConnection == 2) return
|
2026-03-23 16:23:40 +08:00
|
|
|
|
that.$store.commit('changeBluetoothValue', {
|
|
|
|
|
|
deviceId: "",
|
|
|
|
|
|
serviceId: "",
|
2026-03-25 17:27:29 +08:00
|
|
|
|
isFood: false,
|
|
|
|
|
|
foodWeight: 100,
|
|
|
|
|
|
foodUnit: "g",
|
|
|
|
|
|
foodNotify: "",
|
|
|
|
|
|
foodWrite: "",
|
|
|
|
|
|
unitList: that.$json.unitMinus,
|
|
|
|
|
|
foodType: 1,
|
2026-03-23 16:23:40 +08:00
|
|
|
|
bleTipsText: "蓝牙搜索中",
|
|
|
|
|
|
isConnectStatus: 0,
|
|
|
|
|
|
})
|
|
|
|
|
|
that.$ble.openBluetoothAdapter()
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 添加成员
|
|
|
|
|
|
handleAddUser(ind) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
if (uni.getStorageSync('token')) {
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: ind == 1 ? "/body/my/userInfo?info=" + JSON.stringify(this.user) : "/body/my/userInfo"
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
that.$tools("登录后查看更多")
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-03-25 17:27:29 +08:00
|
|
|
|
handleToolsIndex(ind) {
|
|
|
|
|
|
this.$store.commit("changehomeCard", ind);
|
|
|
|
|
|
},
|
2026-03-23 16:23:40 +08:00
|
|
|
|
handleLogin() {
|
2026-03-31 13:51:12 +08:00
|
|
|
|
uni.navigateTo({
|
2026-03-25 17:27:29 +08:00
|
|
|
|
url: "/body/login/login"
|
2026-03-23 16:23:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2026-03-25 17:27:29 +08:00
|
|
|
|
.activs {
|
|
|
|
|
|
background: #ffc800 !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-23 16:23:40 +08:00
|
|
|
|
.header {
|
|
|
|
|
|
width: 100%;
|
2026-03-27 10:04:26 +08:00
|
|
|
|
padding: 15px 0;
|
2026-03-23 16:23:40 +08:00
|
|
|
|
background: $maincolor;
|
|
|
|
|
|
|
|
|
|
|
|
.top {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.top2 {
|
2026-03-27 10:04:26 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
margin: 0 15px;
|
2026-03-30 15:02:56 +08:00
|
|
|
|
padding: 10px 15px;
|
2026-03-27 10:04:26 +08:00
|
|
|
|
border-radius: 10px;
|
2026-03-23 16:23:40 +08:00
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.headimg {
|
|
|
|
|
|
width: 55px;
|
|
|
|
|
|
height: 55px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
margin: 0 10px;
|
|
|
|
|
|
float: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.info {
|
|
|
|
|
|
width: calc(100% - 120px);
|
|
|
|
|
|
float: left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.t-icon-qiehuan1 {
|
|
|
|
|
|
float: right;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bluetooth {
|
|
|
|
|
|
width: calc(100% - 20px);
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
padding: 8px 0;
|
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.toggle {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
width: calc(100% - 20px);
|
|
|
|
|
|
height: 40px;
|
|
|
|
|
|
line-height: 40px;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
.toolsItem {
|
|
|
|
|
|
color: #999;
|
|
|
|
|
|
margin: 0 10px;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.active {
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
position: relative
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.active:before {
|
|
|
|
|
|
content: "";
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
width: 20px;
|
|
|
|
|
|
height: 4px;
|
|
|
|
|
|
background: #54d87c;
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
left: calc(50% - 10px);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|