From 51a9c5c79879fa0acc463f0dea6ff99a6a918495 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Wed, 24 Mar 2021 17:16:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BD=93=E5=A4=A9=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/recipesBuild/InfoView/index.vue | 5 - .../custom/recipesShow/MenuDetail/index.vue | 49 ++++++++- .../PlanDrawer/ShoppingPlanDrawer/index.vue | 103 +++++++++--------- 3 files changed, 96 insertions(+), 61 deletions(-) diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue index 894a09f20..4374dfe21 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/index.vue @@ -68,11 +68,6 @@ export default { ]), ...mapGetters(["analyseData"]), }, - watch: { - healthyData(val) { - console.log({ val }); - }, - }, methods: { handleOnTabClick(tab) { this.activeName = tab.name; diff --git a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue index 726dfd36d..7d3f35f54 100644 --- a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue @@ -3,7 +3,16 @@
- logo + +
@@ -34,6 +43,8 @@ + + @@ -106,8 +130,27 @@ export default { .menu_detail_wrapper { padding: 0 12px 12px 12px; .top { - text-align: center; - padding: 10px 14px; + height: 50px; + position: relative; + .logo { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + + .shopping_cart { + position: absolute; + right: 5px; + top: 10px; + display: flex; + align-items: center; + &::after { + margin-left: 2px; + content: "采购"; + font-size: 12px; + } + } } .header_style { diff --git a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue index 0134ba2e0..83b27cf0f 100644 --- a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue @@ -74,17 +74,19 @@ export default { }; }, methods: { - showDrawer(data) { - // console.log(data); - const { recipesId, num, label } = data; + showDrawer(obj) { + const { recipesId, num, label, data } = obj; + console.log(obj); this.label = label; // num < 0 全部计算 this.title = `${ num === 3 ? "前3" : num === 4 ? "后4" : Math.abs(num) }天采购计划`; this.visible = true; - if (this.recipes[recipesId]) { - this.processShoppingCart(num, recipesId); + if (data) { + this.processShoppingCart(num, data); + } else if (this.recipes[recipesId]) { + this.processShoppingCart(num, this.recipes[recipesId]); } else { this.loading = true; this.fetchFullRecipes({ @@ -92,61 +94,56 @@ export default { }).then(() => { this.loading = false; setTimeout(() => { - this.processShoppingCart(num, recipesId); + this.processShoppingCart(num, this.recipes[recipesId]); }, 0); }); } }, - processShoppingCart(num, recipesId) { - this.shoppingCart = (this.recipes[recipesId] || []).reduce( - (obj, cur, idx) => { - if ( - num < 0 || // 全部计算 - num === 7 || - (num === 3 && num > idx) || - (num === 4 && idx > 2) - ) { - cur.dishes.forEach((dObj) => { - dObj.igdList.forEach((iObj) => { - const tarTypeName = this.idgTypeDict[iObj.type]; - const tarObj = obj[tarTypeName]; - if (tarObj) { - const tarIObj = tarObj.find( - (zObj) => zObj.name === iObj.name - ); - if (tarIObj) { - tarIObj.weight += this.igdUnitDict[iObj.name] - ? iObj.cusWeight - : iObj.weight; - } else { - tarObj.push({ - type: iObj.type, - name: iObj.name, - weight: this.igdUnitDict[iObj.name] - ? iObj.cusWeight - : iObj.weight, - unit: this.igdUnitDict[iObj.name] || "g", - }); - } + processShoppingCart(num, data = []) { + this.shoppingCart = data.reduce((obj, cur, idx) => { + if ( + num < 0 || // 全部计算 + num === 7 || + (num === 3 && num > idx) || + (num === 4 && idx > 2) + ) { + cur.dishes.forEach((dObj) => { + dObj.igdList.forEach((iObj) => { + const tarTypeName = this.idgTypeDict[iObj.type]; + const tarObj = obj[tarTypeName]; + if (tarObj) { + const tarIObj = tarObj.find((zObj) => zObj.name === iObj.name); + if (tarIObj) { + tarIObj.weight += this.igdUnitDict[iObj.name] + ? iObj.cusWeight + : iObj.weight; } else { - obj[tarTypeName] = [ - { - type: iObj.type, - name: iObj.name, - weight: this.igdUnitDict[iObj.name] - ? iObj.cusWeight - : iObj.weight, - unit: this.igdUnitDict[iObj.name] || "g", - }, - ]; + tarObj.push({ + type: iObj.type, + name: iObj.name, + weight: this.igdUnitDict[iObj.name] + ? iObj.cusWeight + : iObj.weight, + unit: this.igdUnitDict[iObj.name] || "g", + }); } - }); + } else { + obj[tarTypeName] = [ + { + type: iObj.type, + name: iObj.name, + weight: this.igdUnitDict[iObj.name] + ? iObj.cusWeight + : iObj.weight, + unit: this.igdUnitDict[iObj.name] || "g", + }, + ]; + } }); - } - return obj; - }, - {} - ); + }); + } + return obj; + }, {}); // console.log(this.shoppingCart); }, handleOnBackClick() {