[更新发现]

This commit is contained in:
zhangmanman
2022-01-13 13:56:32 +08:00
parent 9af54bc24a
commit c82f40ee09
27 changed files with 1274 additions and 295 deletions

View File

@@ -1,13 +1,13 @@
<template>
<view class="content">
<view class="modular goods">
<image class="img" src="/static/find/menu_0.jpg" mode="aspectFill"></image>
<image class="img" :src="foodDate.cover" mode="aspectFill"></image>
<view class="title">
<view class="name">
白粉桃
{{ foodDate.name }}
</view>
<view class="text">
295千卡/100
{{ foodDate.heat }}
</view>
</view>
</view>
@@ -15,11 +15,11 @@
<view class="modular foods">
<view class="title">
<view class="name">
推荐搭配
食物价值
</view>
</view>
<view class="text">
白粉桃富含蛋白质脂肪维生素挥发油有机酸矿物质粗纤维和水化合物等多种成份有解饥消渴补养身体且有增进人体胆汁分泌促进消化和治疗便秘等功效
{{ foodDate.recom_text }}
</view>
</view>
@@ -39,7 +39,7 @@
</view>
<view class="energy">
<view class="number">
<text>113</text>千卡
<text>{{ calory }}</text>{{ current == 0 ? '千卡' : '千焦'}}
</view>
<view class="tips">
每100克可食用部分
@@ -65,41 +65,41 @@
含量
</view>
<view class="tabs-title">
NPV%
NRV%
</view>
</view>
<view class="list">
<view class="label">
<view class="label" v-if="nutrition.protein">
<view class="label-name">
蛋白质
</view>
<view class="label-name">
0.1
{{ nutrition.protein.value }}
</view>
<view class="label-name">
0.1%
{{ nutrition.protein.nrv }}%
</view>
</view>
<view class="label">
<view class="label" v-if="nutrition.cellulose">
<view class="label-name">
脂肪
</view>
<view class="label-name">
0.4
{{ nutrition.cellulose.value }}
</view>
<view class="label-name">
0.7%
{{ nutrition.cellulose.nrv }}%
</view>
</view>
<view class="label">
<view class="label" v-if="nutrition.carbohydrate">
<view class="label-name">
碳水化合物
</view>
<view class="label-name">
0.2
{{ nutrition.carbohydrate.nrv }}
</view>
<view class="label-name">
0.1%
{{ nutrition.carbohydrate.nrv }}%
</view>
</view>
</view>
@@ -109,20 +109,20 @@
</view>
</view>
<view class="modular foods">
<view class="modular foods" v-if="goodsArr.length > 0">
<view class="title">
<view class="name">
相关商品
</view>
</view>
<view class="item">
<image class="item-cover" src="http://api.zh.shangkelian.cn/storage/images/2022/01/06/fc143605e2a1557989e96652d990579f.png" mode="aspectFill"></image>
<view class="item" v-for="(item, index) in goodsArr" :key="index">
<image class="item-cover" :src="item.cover ? item.cover : '/static/find/default_img.png'" mode="aspectFill"></image>
<view class="item-title">
<view class="nowrap item-name">
黑果枸杞
{{ item.name }}
</view>
<view class="item-price">
99.00
{{ item.price }}
</view>
</view>
<view class="item-btn">
@@ -134,16 +134,40 @@
</template>
<script>
export default {
import { foodDet } from '@/apis/interfaces/ranking'
export default {
data() {
return {
current: 0
foodDate : '',
goodsArr : [],
calory : '',
nutrition : '',
current : 0
}
},
onLoad() {},
mounted() {
this.foodRank()
},
methods: {
// 分类-食物
foodRank(){
foodDet(this.$Route.query.id).then(res => {
this.foodDate = res
this.goodsArr = res.goods
this.nutrition = res.data
this.calory = res.calory
})
},
// 热量切换
switchTab(val) {
this.current = val
if(val == 0) {
this.calory = this.foodDate.calory
return
}else {
this.calory = this.foodDate.joule
}
}
}
};

View File

@@ -8,7 +8,7 @@
<view class="right">
<view class="goods">
<view class="list" @click="$Router.push({name: 'rankingList', params: {id: item.category_id, name: item.name}})" v-for="(item, index) in listArr" :key="index">
<image class="logo" :src="item.cover" mode="aspectFill"></image>
<image class="logo" :src="item.cover ? item.cover : '/static/find/default_img.png'" mode="aspectFill"></image>
<view class="name">
{{ item.name }}
</view>

View File

@@ -11,8 +11,12 @@
:lists="menuArr"
:btnStyle="{'margin-top': '30rpx'}"
:isNumber="true"
@onMenu="$Router.push({ name: 'rankingDetails', params: {id: $event.id, title: $event.name }})"
isType="rank"
@onMenu="$Router.push({ name: 'rankingDetails', params: {id: $event.food_id, title: $event.name }})"
/>
<block v-if="page.total_page > 1">
<u-loadmore :status="status" />
</block>
</view>
</view>
</template>
@@ -23,7 +27,9 @@
data() {
return {
name : this.$Route.query.name,
menuArr : []
menuArr : [],
status : 'loadmore',
page : ''
}
},
mounted() {
@@ -31,11 +37,30 @@
},
methods: {
// 分类-食物
getRank(){
foods({category_id: this.$Route.query.id}).then(res => {
this.menuArr = res.data
getRank(pages){
foods({
category_id: this.$Route.query.id,
page: pages
}).then(res => {
if(res.page.current == 1){
this.menuArr = []
}
this.menuArr = this.menuArr.concat(res.data)
this.status = this.page.has_more ? 'loadmore': 'nomore'
this.page = res.page
})
}
},
// 下拉加载
onReachBottom() {
if(this.page.has_more){
this.status = 'loading'
let pages = this.page.current + 1
// 获取列表
this.getRank(pages)
return
}
this.status = 'nomore'
}
};
</script>