539 lines
10 KiB
Vue
539 lines
10 KiB
Vue
<template>
|
|
<view class="content">
|
|
<view class="box1 box" v-if="!token" @click="handleLogin">
|
|
<view class="info2">
|
|
未登录,点击登录
|
|
</view>
|
|
</view>
|
|
<!-- 个人资料 -->
|
|
<view v-if="token" class="content-box">
|
|
<view class="box" v-if="info.aud_id">
|
|
<view class="info">
|
|
<!-- /pageTwo/me/userEdit -->
|
|
<view class="name" @click="navTo('/pageTwo/count/setting')">
|
|
<image :src="info.head_pic"></image>
|
|
<text class="bold">{{info.nickname}}</text>
|
|
<text>{{info.gender=='1'?'男':'女'}}</text>
|
|
</view>
|
|
<view class="edit">
|
|
<image src="/static/26.png"></image>
|
|
</view>
|
|
</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>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="box1 box" v-else @click="navTo('/pageTwo/me/userEdit')">
|
|
<view class="info2">
|
|
完善资料后,记录更准确哦!
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 计食器 -->
|
|
<view class="jishiqi">
|
|
<view class="top">
|
|
<view class="date">{{foodInfo.date}}</view>
|
|
<view class="detail" @click="handleEveryDay">查看详情</view>
|
|
</view>
|
|
<view class="left">
|
|
<view class="chart-wrap">
|
|
<qiun-data-charts type="arcbar" :chartData="chartData" :cHeight="280" :cWidth="280"
|
|
:canvas2d="true" canvasId="home1"/>
|
|
<view class="center">
|
|
摄入
|
|
<text>{{foodInfo.nutrients_four[0].today_intake}}</text>
|
|
<view class="unit">Kcal</view>
|
|
</view>
|
|
</view>
|
|
<view class="mubiao">
|
|
目标:<text>{{foodInfo.nutrients_four[0].suggestion}}</text>kcal
|
|
</view>
|
|
</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>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- 早午餐 -->
|
|
<view class="tools">
|
|
<view class="tools-item" v-for="(ite,ind) in foodInfo.list">
|
|
<view class="title">
|
|
<image :src="ite.icon"></image>
|
|
<text>{{ite.name}}</text>
|
|
</view>
|
|
<view class="kcal">
|
|
<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>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 搜索 -->
|
|
<view class="serachBox">
|
|
<view class="title">
|
|
<view class="quan mr-5"></view>教你做
|
|
</view>
|
|
<view class="searchInput">
|
|
<div class="search-wrap" @click="navTo('/pages/search/search')">
|
|
<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>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from "vuex";
|
|
import qiunDataCharts from '@/uni_modules/qiun-data-charts/components/qiun-data-charts.vue';
|
|
export default {
|
|
data() {
|
|
return {
|
|
token: "",
|
|
chartData: {
|
|
series: [{
|
|
data: 0,
|
|
color: "#3CB383"
|
|
}]
|
|
},
|
|
}
|
|
},
|
|
components: {
|
|
qiunDataCharts
|
|
},
|
|
computed: {
|
|
...mapState(["configInfo", "user", "countFoodInfo"]),
|
|
info() {
|
|
return this.user
|
|
},
|
|
kcalVal() {
|
|
return this.configInfo.kcal_data
|
|
},
|
|
foodInfo() {
|
|
let that = this
|
|
that.chartData.series[0].data = that.user.aud_id ? that.user.food_count.nutrients_four[0].proportion /
|
|
100 : 0
|
|
return uni.getStorageSync('token') ? that.user.food_count : that.configInfo.food_count
|
|
},
|
|
},
|
|
onLoad() {
|
|
let that = this
|
|
that.token = uni.getStorageSync('token')
|
|
that.$store.dispatch("getHomeConfig")
|
|
},
|
|
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"
|
|
})
|
|
},
|
|
handleAddFood(name) {
|
|
let that = this
|
|
if (!that.token) {
|
|
that.$tools.msg("登录后查看更多")
|
|
return
|
|
}
|
|
uni.navigateTo({
|
|
url: "/pageTwo/count/search?name=" + name + "&time=" + this.foodInfo.date
|
|
})
|
|
},
|
|
// 餐食详情
|
|
handledetail(ind) {
|
|
let that = this
|
|
if (!that.token) {
|
|
that.$tools.msg("登录后查看更多")
|
|
return
|
|
}
|
|
uni.navigateTo({
|
|
url: "/pageTwo/count/everyMeal?page=home&index=" + ind
|
|
})
|
|
},
|
|
handleEveryDay() {
|
|
let that = this
|
|
if (!that.token) {
|
|
that.$tools.msg("登录后查看更多")
|
|
return
|
|
}
|
|
uni.navigateTo({
|
|
url: "/pageTwo/count/everyDay?page=home"
|
|
})
|
|
},
|
|
// 功能页面跳转
|
|
navTo(url) {
|
|
if (!this.token) {
|
|
this.$tools.msg("登录后查看更多")
|
|
return
|
|
}
|
|
uni.navigateTo({
|
|
url
|
|
})
|
|
uni.switchTab({
|
|
url
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.headerbgimg {
|
|
position: absolute;
|
|
width: 400rpx;
|
|
height: 360rpx;
|
|
top: 0;
|
|
right: -15%;
|
|
}
|
|
|
|
.content-box {
|
|
width: 100%;
|
|
position: relative;
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.box {
|
|
width: calc(100% - 100rpx);
|
|
background: $maincolor;
|
|
display: flex;
|
|
padding: 30rpx 20rpx;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
margin: 15px 15px 0;
|
|
border-radius: 10px;
|
|
flex-wrap: wrap;
|
|
|
|
.info {
|
|
color: #fff;
|
|
width: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.name {
|
|
width: 80%;
|
|
display: flex;
|
|
font-size: 32rpx;
|
|
float: left;
|
|
align-items: center;
|
|
|
|
text {
|
|
margin-right: 30rpx;
|
|
}
|
|
|
|
image {
|
|
width: 35px;
|
|
height: 35px;
|
|
margin-right: 15px;
|
|
}
|
|
}
|
|
|
|
.edit {
|
|
width: 20%;
|
|
text-align: right;
|
|
float: left;
|
|
|
|
image {
|
|
width: 22px;
|
|
height: 22px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.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 {
|
|
margin: 0 30rpx 0;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
width: calc(100% - 60rpx);
|
|
justify-content: space-between;
|
|
|
|
.tools-item {
|
|
width: 42%;
|
|
background: #fff;
|
|
position: relative;
|
|
padding: 10rpx 20rpx;
|
|
height: 240rpx;
|
|
overflow: hidden;
|
|
border-radius: 20rpx;
|
|
margin-bottom: 30rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-around;
|
|
box-shadow: 0px 1px 5px 2px #dfe2e1fc;
|
|
|
|
.title {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 28rpx;
|
|
|
|
image {
|
|
width: 50rpx;
|
|
height: 50rpx;
|
|
margin-right: 5px;
|
|
}
|
|
}
|
|
|
|
.kcal {
|
|
text-align: center;
|
|
|
|
text {
|
|
font-size: 56rpx;
|
|
font-weight: bold;
|
|
margin-right: 20rpx;
|
|
}
|
|
}
|
|
|
|
.tools-btn {
|
|
border: 1px solid #9CDCBF;
|
|
text-align: center;
|
|
border-radius: 20rpx;
|
|
width: 60%;
|
|
margin-left: 20%;
|
|
color: $maincolor;
|
|
padding: 3px 0;
|
|
}
|
|
|
|
.add {
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
position: absolute;
|
|
top: 20rpx;
|
|
right: 20rpx;
|
|
z-index: 999;
|
|
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.bgimg {
|
|
width: 180rpx;
|
|
height: 180rpx;
|
|
position: absolute;
|
|
top: 20rpx;
|
|
right: -50rpx;
|
|
opacity: 0.6;
|
|
}
|
|
}
|
|
}
|
|
|
|
.serachBox {
|
|
width: calc(100% - 60rpx);
|
|
|
|
.title {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 32rpx;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.searchInput {
|
|
width: calc(100% - 60rpx);
|
|
background-color: #fff;
|
|
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 {
|
|
width: 50rpx;
|
|
height: 50rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.f_banner {
|
|
width: 100% !important;
|
|
height: 450rpx;
|
|
margin: 30rpx auto;
|
|
|
|
/deep/swiper {
|
|
height: 450rpx;
|
|
}
|
|
|
|
image {
|
|
width: 100%;
|
|
height: 100%;
|
|
background-size: 100%;
|
|
position: relative;
|
|
}
|
|
}
|
|
</style> |