kitchendDevice/pages/index/index.vue

569 lines
11 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
2025-11-08 16:50:26 +08:00
<view class="content">
2025-11-25 14:21:22 +08:00
<view class="box1 box" v-if="!token" @click="handleLogin">
<view class="info2">
未登录点击登录
</view>
</view>
2025-11-08 16:50:26 +08:00
<!-- 个人资料 -->
<view v-if="token" class="content-box">
2025-11-26 17:32:18 +08:00
<view class="box" v-if="info.aud_id!=''">
2025-11-25 14:21:22 +08:00
<view class="info">
<!-- /pageTwo/me/userEdit -->
2025-11-26 17:32:18 +08:00
<view class="name" @click="navTo('/pageTwo/me/userEdit')">
2025-11-25 14:21:22 +08:00
<image :src="info.head_pic"></image>
<text class="bold">{{info.nickname}}</text>
2025-11-08 16:50:26 +08:00
<text>{{info.gender=='1'?'男':'女'}}</text>
2025-11-25 14:21:22 +08:00
</view>
2025-11-26 17:32:18 +08:00
<view class="edit" @click="navTo('/pageTwo/me/userEdit')">
2025-11-08 16:50:26 +08:00
<image src="/static/26.png"></image>
</view>
2025-11-25 14:21:22 +08:00
</view>
<view class="age">
<view class="age-item">
<view><text>{{info.age}}</text></view>
<view>年龄</view>
</view>
<view class="age-item age-item2">
<view><text>{{info.weight}}</text>kg</view>
<view>体重</view>
</view>
<view class="age-item">
<view><text>{{info.height}}</text>cm</view>
<view>身高</view>
2025-11-08 16:50:26 +08:00
</view>
</view>
</view>
2025-11-25 14:21:22 +08:00
<view class="box1 box" v-else @click="navTo('/pageTwo/me/userEdit')">
2025-11-08 16:50:26 +08:00
<view class="info2">
完善资料后记录更准确哦
</view>
</view>
</view>
<!-- 计食器 -->
<view class="jishiqi">
2025-11-25 14:21:22 +08:00
<view class="top">
<view class="date">{{foodInfo.date}}</view>
<view class="detail" @click="handleEveryDay">查看详情</view>
</view>
2025-11-08 16:50:26 +08:00
<view class="left">
2025-11-25 14:21:22 +08:00
<view class="chart-wrap">
2025-11-26 17:32:18 +08:00
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280" :canvas2d="true"
canvasId="home1" />
2025-11-08 16:50:26 +08:00
<view class="center">
2025-11-25 14:21:22 +08:00
摄入
<text>{{foodInfo.nutrients_four[0].today_intake}}</text>
<view class="unit">Kcal</view>
2025-11-08 16:50:26 +08:00
</view>
</view>
2025-11-25 14:21:22 +08:00
<view class="mubiao">
目标<text>{{foodInfo.nutrients_four[0].suggestion}}</text>kcal
2025-11-08 16:50:26 +08:00
</view>
2025-11-25 14:21:22 +08:00
</view>
<view class="right">
<view class="item" v-for="(ite,ind) in foodInfo.nutrients_four.slice(1)">
<view class="left-icon">
<image :src="ite.icon"></image>
<view class="val" :style="{color:ite.color}">{{ite.proportion_fp||0}}%</view>
</view>
<view class="right-info">
<view class="right-info-top">
<text class="name">{{ite.name}}</text>
<text class="">
{{ite.today_intake||0}}/{{ite.suggestion||0}}g
</text>
</view>
<view class="right-info-bottom">
<view class="val" :style="{ width: ite.proportion + '%',background:ite.color}">
</view>
</view>
</view>
2025-11-08 16:50:26 +08:00
</view>
</view>
</view>
<!-- 早午餐 -->
<view class="tools">
2025-11-25 14:21:22 +08:00
<view class="tools-item" v-for="(ite,ind) in foodInfo.list">
2025-11-08 16:50:26 +08:00
<view class="title">
<image :src="ite.icon"></image>
2025-11-25 14:21:22 +08:00
<text>{{ite.name}}</text>
2025-11-08 16:50:26 +08:00
</view>
<view class="kcal">
2025-11-25 14:21:22 +08:00
<text>{{ite.val}}</text>kcal
</view>
<view class="tools-btn" @click="handleAddFood(ite.name)">添加</view>
<view class="add" @click="handledetail(ind)">
<!-- <uni-icons type="forward" size="18" color="#999"></uni-icons> -->
<image src="/static/xiangqing.png"></image>
2025-11-08 16:50:26 +08:00
</view>
</view>
</view>
<!-- 搜索 -->
<view class="serachBox">
<view class="title">
2025-11-25 14:21:22 +08:00
<view class="quan mr-5"></view>教你做
2025-11-08 16:50:26 +08:00
</view>
<view class="searchInput">
2025-11-25 14:21:22 +08:00
<div class="search-wrap" @click="navTo('/pages/search/search')">
2025-11-08 16:50:26 +08:00
<text>输入食材快速搜索菜谱</text>
<image src="/static/28.png"></image>
</div>
</view>
</view>
<!-- 轮播 -->
<view class="f_banner footbox" v-if="configInfo.banner_data.length">
<swiper class="swiper" circular="true">
<swiper-item v-for="(ite,index) in configInfo.banner_data" @click="$tools.NewsPtype(ite)">
<image :src="ite.pic" mode="aspectFill"></image>
</swiper-item>
</swiper>
</view>
</view>
2023-09-08 15:17:21 +08:00
</template>
<script>
2025-11-08 16:50:26 +08:00
import {
mapState
} from "vuex";
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts.vue';
export default {
data() {
return {
token: "",
2025-11-26 17:32:18 +08:00
foodInfo: [],
2025-11-08 16:50:26 +08:00
chartData: {
series: [{
2025-11-25 14:21:22 +08:00
data: 0,
color: "#3CB383"
2025-11-08 16:50:26 +08:00
}]
},
}
},
components: {
qiunDataCharts
},
computed: {
2025-11-26 17:32:18 +08:00
...mapState(["configInfo", "user", "countFoodInfo", "bleValue"]),
2025-11-08 16:50:26 +08:00
info() {
return this.user
},
kcalVal() {
return this.configInfo.kcal_data
},
2025-11-26 17:32:18 +08:00
// foodInfo() {
// let that = this
// return that.user.aud_id != "" ? that.user.food_count : that.configInfo.default_count_foot
// },
2025-11-08 16:50:26 +08:00
},
onLoad() {
let that = this
that.token = uni.getStorageSync('token')
that.$store.dispatch("getHomeConfig")
2025-11-26 17:32:18 +08:00
if (that.token) {
that.$ble.openBluetoothAdapter()
}
that.$ble.onBLEConnectionStateChange()
uni.onBluetoothAdapterStateChange(function(res) {
that.$store.commit("changeBluetooth", res.available);
})
},
watch: {
user: {
handler(newVal, oldVal) {
let that = this
that.foodInfo = newVal.aud_id != "" ? that.user.food_count : that.configInfo.default_count_foot
that.chartData.series[0].data = newVal.aud_id != "" ? newVal.food_count.nutrients_four[0].proportion /
100 : 0
},
immediate: true,
deep: true
},
bleValue: {
handler(newVal, oldVal) {
console.log("实时bleValue", newVal)
if (newVal.serviceId != '' && newVal.oldCountWeight != newVal.countWeight) {
uni.switchTab({
url: "/pages/count/count"
})
newVal.oldCountWeight = newVal.countWeight
}
},
deep: true
}
2025-11-08 16:50:26 +08:00
},
onPullDownRefresh() {
let that = this
that.index = 0
that.footlist = []
that.$store.dispatch("getHomeConfig")
setTimeout(function() {
uni.stopPullDownRefresh();
}, 500);
},
methods: {
// 登录
handleLogin() {
uni.reLaunch({
url: "/pageTwo/login/login"
})
},
2025-11-25 14:21:22 +08:00
handleAddFood(name) {
let that = this
if (!that.token) {
that.$tools.msg("登录后查看更多")
return
}
2025-11-08 16:50:26 +08:00
uni.navigateTo({
2025-11-25 14:21:22 +08:00
url: "/pageTwo/count/search?name=" + name + "&time=" + this.foodInfo.date
2025-11-08 16:50:26 +08:00
})
},
2025-11-25 14:21:22 +08:00
// 餐食详情
handledetail(ind) {
let that = this
if (!that.token) {
that.$tools.msg("登录后查看更多")
return
2025-11-08 16:50:26 +08:00
}
2025-11-25 14:21:22 +08:00
uni.navigateTo({
url: "/pageTwo/count/everyMeal?page=home&index=" + ind
})
2025-11-08 16:50:26 +08:00
},
2025-11-25 14:21:22 +08:00
handleEveryDay() {
2025-11-08 16:50:26 +08:00
let that = this
2025-11-25 14:21:22 +08:00
if (!that.token) {
that.$tools.msg("登录后查看更多")
return
2025-11-08 16:50:26 +08:00
}
2025-11-25 14:21:22 +08:00
uni.navigateTo({
url: "/pageTwo/count/everyDay?page=home"
})
2025-11-08 16:50:26 +08:00
},
// 功能页面跳转
navTo(url) {
2025-11-25 14:21:22 +08:00
if (!this.token) {
this.$tools.msg("登录后查看更多")
return
}
2025-11-08 16:50:26 +08:00
uni.navigateTo({
url
})
uni.switchTab({
url
})
},
}
}
2023-09-08 15:17:21 +08:00
</script>
<style lang="scss" scoped>
2025-11-08 16:50:26 +08:00
.headerbgimg {
position: absolute;
2025-11-25 14:21:22 +08:00
width: 400rpx;
height: 360rpx;
2025-11-08 16:50:26 +08:00
top: 0;
right: -15%;
}
.content-box {
width: 100%;
position: relative;
overflow: hidden;
}
2025-11-25 14:21:22 +08:00
.chart-wrap {
position: relative;
width: 250rpx;
height: 250rpx;
margin-top: -30rpx;
margin-left: -5px;
display: flex;
flex-wrap: wrap;
.center {
border: none;
width: 280rpx;
height: 210rpx;
position: absolute;
top: 64rpx;
}
}
2025-11-08 16:50:26 +08:00
.box {
2025-11-25 14:21:22 +08:00
width: calc(100% - 100rpx);
2025-11-08 16:50:26 +08:00
background: $maincolor;
display: flex;
padding: 30rpx 20rpx;
align-items: center;
overflow: hidden;
2025-11-25 14:21:22 +08:00
margin: 15px 15px 0;
border-radius: 10px;
flex-wrap: wrap;
2025-11-08 16:50:26 +08:00
.info {
color: #fff;
2025-11-25 14:21:22 +08:00
width: 100%;
display: flex;
align-items: center;
2025-11-08 16:50:26 +08:00
.name {
2025-11-25 14:21:22 +08:00
width: 80%;
2025-11-08 16:50:26 +08:00
display: flex;
font-size: 32rpx;
2025-11-25 14:21:22 +08:00
float: left;
align-items: center;
2025-11-08 16:50:26 +08:00
2025-11-25 14:21:22 +08:00
text {
2025-11-08 16:50:26 +08:00
margin-right: 30rpx;
}
2025-11-25 14:21:22 +08:00
image {
width: 35px;
height: 35px;
margin-right: 15px;
2025-11-08 16:50:26 +08:00
}
2025-11-25 14:21:22 +08:00
}
.edit {
width: 20%;
text-align: right;
float: left;
2025-11-08 16:50:26 +08:00
image {
2025-11-25 14:21:22 +08:00
width: 22px;
height: 22px;
2025-11-08 16:50:26 +08:00
}
}
2025-11-25 14:21:22 +08:00
}
2025-11-08 16:50:26 +08:00
2025-11-25 14:21:22 +08:00
.age {
display: flex;
width: 100%;
justify-content: space-between;
color: #fff;
margin-top: 15px;
.age-item {
width: 33.3%;
text-align: center;
text {
font-size: 20px;
margin-right: 5px;
display: inline-block;
2025-11-08 16:50:26 +08:00
}
}
2025-11-25 14:21:22 +08:00
.age-item2 {
position: relative;
}
.age-item2::after {
content: "";
position: absolute;
left: 0;
top: 10px;
bottom: 10px;
width: 1px;
background-color: #9CDCBF;
}
.age-item2::before {
content: "";
position: absolute;
right: 0;
top: 10px;
bottom: 10px;
width: 1px;
background-color: #9CDCBF;
}
2025-11-08 16:50:26 +08:00
}
}
2025-11-25 14:21:22 +08:00
.jishiqi {
width: calc(100% - 50px);
background: #fff;
padding: 10px 10px 15px;
border-radius: 10px;
margin: 15px;
height: auto;
overflow: hidden;
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
.top {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.date {
font-size: 14px;
font-weight: bold;
}
.detail {
color: #fff;
width: auto;
padding: 5px 20px;
background: $yellowcolor;
border-radius: 10px;
}
}
2025-11-08 16:50:26 +08:00
.box1 {
.header {
width: 100rpx;
height: 100rpx;
background: #fff;
text-align: center;
line-height: 100rpx;
image {
width: 80rpx;
height: 80rpx;
color: #fff;
margin-top: 10rpx;
}
}
.info2 {
color: #fff;
font-size: 36rpx;
font-weight: bold;
}
}
.tools {
2025-11-25 14:21:22 +08:00
margin: 0 30rpx 0;
2025-11-08 16:50:26 +08:00
display: flex;
flex-wrap: wrap;
width: calc(100% - 60rpx);
justify-content: space-between;
.tools-item {
width: 42%;
background: #fff;
position: relative;
2025-11-25 14:21:22 +08:00
padding: 10rpx 20rpx;
height: 240rpx;
2025-11-08 16:50:26 +08:00
overflow: hidden;
border-radius: 20rpx;
margin-bottom: 30rpx;
2025-11-25 14:21:22 +08:00
display: flex;
flex-direction: column;
justify-content: space-around;
2025-11-08 16:50:26 +08:00
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
.title {
display: flex;
align-items: center;
font-size: 28rpx;
image {
2025-11-25 14:21:22 +08:00
width: 50rpx;
height: 50rpx;
2025-11-08 16:50:26 +08:00
margin-right: 5px;
}
}
.kcal {
text-align: center;
text {
font-size: 56rpx;
font-weight: bold;
margin-right: 20rpx;
}
}
.tools-btn {
2025-11-25 14:21:22 +08:00
border: 1px solid #9CDCBF;
2025-11-08 16:50:26 +08:00
text-align: center;
border-radius: 20rpx;
width: 60%;
margin-left: 20%;
color: $maincolor;
padding: 3px 0;
}
.add {
2025-11-25 14:21:22 +08:00
width: 48rpx;
height: 48rpx;
2025-11-08 16:50:26 +08:00
position: absolute;
top: 20rpx;
2025-11-08 17:31:03 +08:00
right: 20rpx;
2025-11-08 16:50:26 +08:00
z-index: 999;
2025-11-25 14:21:22 +08:00
image {
width: 100%;
height: 100%;
}
2025-11-08 16:50:26 +08:00
}
.bgimg {
width: 180rpx;
height: 180rpx;
position: absolute;
top: 20rpx;
right: -50rpx;
2025-11-25 14:21:22 +08:00
opacity: 0.6;
2025-11-08 16:50:26 +08:00
}
}
}
.serachBox {
width: calc(100% - 60rpx);
.title {
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: bold;
}
.searchInput {
width: calc(100% - 60rpx);
2025-11-25 14:21:22 +08:00
background-color: #fff;
2025-11-08 16:50:26 +08:00
padding: 30rpx;
margin-top: 20rpx;
border-radius: 20rpx;
}
.search-wrap {
height: 80rpx;
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid $maincolor;
border-radius: 30rpx;
padding: 0 20rpx;
background: #fff;
image {
2025-11-25 14:21:22 +08:00
width: 50rpx;
height: 50rpx;
2025-11-08 16:50:26 +08:00
}
}
}
.f_banner {
width: 100% !important;
height: 450rpx;
2025-11-25 14:21:22 +08:00
margin: 30rpx auto;
2025-11-08 16:50:26 +08:00
/deep/swiper {
height: 450rpx;
}
image {
width: 100%;
height: 100%;
background-size: 100%;
position: relative;
}
}
2025-03-25 10:17:30 +08:00
</style>