记录模块接口对接
This commit is contained in:
@@ -13,18 +13,34 @@
|
||||
<view class="addGoods">
|
||||
<view class="add-btn">
|
||||
<span @click="close">取消</span>
|
||||
<view>新增食物</view>
|
||||
<view>{{title}}</view>
|
||||
<span @click="confirm">确认</span>
|
||||
</view>
|
||||
<!-- 商品详情 -->
|
||||
<goodsList
|
||||
:lists="selectGoods"
|
||||
type="dian-right"
|
||||
@tabGoodsInfo="tabGoodsInfo"
|
||||
@tabGoodsInfo="tabGoodsInfo(selectGoods)"
|
||||
class="goodsList"
|
||||
/>
|
||||
<view
|
||||
class="delThis"
|
||||
@click="delThis"
|
||||
v-if="deleteThis!==''"
|
||||
>
|
||||
<u-icon
|
||||
name="trash"
|
||||
color="#999"
|
||||
size="20"
|
||||
:label="deleteThis"
|
||||
labelPos="right"
|
||||
labelSize="13"
|
||||
labelColor="#999"
|
||||
/>
|
||||
</view>
|
||||
<!-- 输入 -->
|
||||
<view class="add-input">
|
||||
<view class="left"><span>0千卡</span>0克</view>
|
||||
<view class="left"><span>{{total}}千卡</span>{{Number(inputValue.join("")) || '0.0'}}克</view>
|
||||
<view class="total">{{inputValue.join("") || '0.0'}}<span>克</span></view>
|
||||
<u-icon
|
||||
name="hourglass-half-fill"
|
||||
@@ -72,6 +88,9 @@ export default {
|
||||
activeKey: "",
|
||||
inputValue: ["1", "0", "0", ".", "0"],
|
||||
result: "100.0",
|
||||
calory: 1, // 千卡值
|
||||
title: "", // 弹窗 title
|
||||
deleteThis: "", // 删除这条数据,为空不有删除功能
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@@ -113,6 +132,19 @@ export default {
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
created() {
|
||||
// 获取每一百克的看千卡值
|
||||
this.calory = this.selectGoods[0].calory;
|
||||
if (this.selectGoods[0].weight) {
|
||||
let weight = this.selectGoods[0].weight + "";
|
||||
this.inputValue = weight.split("");
|
||||
this.title = "修改食物信息";
|
||||
this.deleteThis = "删除这条数据";
|
||||
return;
|
||||
}
|
||||
this.title = "新增食物信息";
|
||||
this.inputValue = ["1", "0", "0", ".", "0"];
|
||||
},
|
||||
computed: {
|
||||
keyboardList() {
|
||||
return this.decimals
|
||||
@@ -145,6 +177,13 @@ export default {
|
||||
"删除",
|
||||
];
|
||||
},
|
||||
// 根据输入的值计算 总能量
|
||||
total() {
|
||||
return (
|
||||
(Number(this.inputValue.join("")) * Number(this.calory)) /
|
||||
100
|
||||
).toFixed(0);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
@@ -173,9 +212,6 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
tabGoodsInfo(e) {
|
||||
console.log("父组件监听到了子组件的商品详情页面", e);
|
||||
},
|
||||
setValue(data) {
|
||||
this.activeKey = data;
|
||||
// let timer = setTimeout(() => {
|
||||
@@ -261,6 +297,15 @@ export default {
|
||||
this.animationData1 = this.animation1.export();
|
||||
this.animationData2 = this.animation2.export();
|
||||
},
|
||||
// 删除这条数据
|
||||
delThis(item) {
|
||||
this.$emit("delThis");
|
||||
},
|
||||
// 跳转到食品详情
|
||||
tabGoodsInfo(e) {
|
||||
console.log("父组件监听到了子组件的商品详情页面", e);
|
||||
this.$emit("tabGoodsInfo", { title: e[0].name, id: e[0].food_id });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -352,7 +397,12 @@ export default {
|
||||
.addGoods {
|
||||
// min-height: 40vh;
|
||||
position: relative;
|
||||
|
||||
.goodsList {
|
||||
padding: $padding;
|
||||
}
|
||||
.delThis {
|
||||
padding: $padding;
|
||||
}
|
||||
.add-btn {
|
||||
padding: $padding;
|
||||
display: flex;
|
||||
@@ -4,49 +4,49 @@
|
||||
* @Author: Aimee·Zhang
|
||||
* @Date: 2022-01-11 12:08:34
|
||||
* @LastEditors: Aimee·Zhang
|
||||
* @LastEditTime: 2022-01-11 15:41:47
|
||||
* @LastEditTime: 2022-01-13 11:19:06
|
||||
-->
|
||||
|
||||
<template>
|
||||
<view class="foods--lists">
|
||||
<view
|
||||
class="foods-lists"
|
||||
v-for="item in lists"
|
||||
:key="item"
|
||||
v-for="foodsItem in lists"
|
||||
:key="foodsItem.food_id"
|
||||
>
|
||||
<view class="lists-left">
|
||||
<u-image
|
||||
:src="require('../../static/imgs/apple.png')"
|
||||
:src="foodsItem.cover?foodsItem.cover:require('../../static/imgs/apple.png')"
|
||||
:lazy-load="true"
|
||||
radius="10rpx"
|
||||
width="100rpx"
|
||||
height="100rpx"
|
||||
class="goods-img"
|
||||
/>
|
||||
<!-- 只有'点' -->
|
||||
<!-- 只有'点' 点击食物列表-->
|
||||
<view
|
||||
class="lists-right"
|
||||
v-if="type === 'dian'"
|
||||
@click="addGoods"
|
||||
@click="addGoods(foodsItem)"
|
||||
>
|
||||
<view class="lists-title">
|
||||
苹果
|
||||
<view class="des"><span>30.0</span> 千卡/100克</view>
|
||||
{{foodsItem.name}}
|
||||
<view class="des"><span>{{foodsItem.calory}}</span> 千卡/100克</view>
|
||||
</view>
|
||||
<view class="dian dian1"></view>
|
||||
<view :class="['dian', foodsItem.color === 'high'?'dian2':foodsItem.color === 'low'?'dian3':'dian1']"></view>
|
||||
</view>
|
||||
<!-- 有'点'和'右箭头' -->
|
||||
<view
|
||||
class="lists-right"
|
||||
v-else-if="type==='dian-right'"
|
||||
@click="tabGoodsInfo"
|
||||
@click="tabGoodsInfo(foodsItem)"
|
||||
>
|
||||
<view class="lists-title">
|
||||
苹果
|
||||
<view class="des"><span>30.0</span> 千卡/100克</view>
|
||||
{{foodsItem.name}}
|
||||
<view class="des"><span>{{foodsItem.calory}}</span> 千卡/100克</view>
|
||||
</view>
|
||||
<view class="dianlists">
|
||||
<view class="dian dian1"></view>
|
||||
<view :class="['dian', foodsItem.color === 'high'?'dian2':foodsItem.color === 'low'?'dian3':'dian1']"></view>
|
||||
<u-icon
|
||||
name="arrow-right"
|
||||
color="#ddd"
|
||||
@@ -59,15 +59,15 @@
|
||||
<view
|
||||
class="lists-right"
|
||||
v-else-if="type==='no-dian'"
|
||||
@click="editGoods"
|
||||
@click="editGoods(foodsItem)"
|
||||
>
|
||||
<view class="lists-title">
|
||||
苹果
|
||||
<view class="des">100克</view>
|
||||
{{foodsItem.name}}
|
||||
<view class="des">{{foodsItem.weight}}克</view>
|
||||
</view>
|
||||
|
||||
<view class="lists-right1">
|
||||
558<span class="dw">千卡</span>
|
||||
{{foodsItem.calory}}<span class="dw">千卡</span>
|
||||
<u-icon
|
||||
name="arrow-right"
|
||||
color="#ddd"
|
||||
@@ -105,16 +105,16 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
// 跳转到食品详情页面
|
||||
addGoods() {
|
||||
this.$emit("addGoods", "addGoods窜过来的值");
|
||||
addGoods(item) {
|
||||
this.$emit("addGoods", item);
|
||||
},
|
||||
// 跳转到食品详情
|
||||
tabGoodsInfo() {
|
||||
this.$emit("tabGoodsInfo", "tabGoodsInfo窜过来的值");
|
||||
tabGoodsInfo(item) {
|
||||
this.$emit("tabGoodsInfo", { title: item.name, id: item.food_id });
|
||||
},
|
||||
// 编辑食品
|
||||
editGoods() {
|
||||
this.$emit("editGoods", "editGoods窜过来的值");
|
||||
editGoods(item) {
|
||||
this.$emit("editGoods", item);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user