From 744567e8de21afd045b859682a41ed9e94f13e91 Mon Sep 17 00:00:00 2001 From: paulGao Date: Mon, 18 Apr 2022 09:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A5=BC=E5=B1=82=E8=A3=85?= =?UTF-8?q?=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/lili-floor-renovation/wap/index.vue | 110 +++++++++++++----- 1 file changed, 81 insertions(+), 29 deletions(-) diff --git a/manager/src/views/lili-floor-renovation/wap/index.vue b/manager/src/views/lili-floor-renovation/wap/index.vue index b0f82171..36fd57e5 100644 --- a/manager/src/views/lili-floor-renovation/wap/index.vue +++ b/manager/src/views/lili-floor-renovation/wap/index.vue @@ -15,7 +15,7 @@ >
  • @@ -77,7 +77,8 @@ import templates from "./template/index"; import Draggable from "vuedraggable"; import { modelData } from "./config"; import decorate from "./decorate"; -import * as API_Other from '@/api/other' +import * as API_Other from "@/api/other"; +import * as API_Promotions from "@/api/promotion"; export default { components: { Draggable, @@ -89,10 +90,12 @@ export default { modelData, // 装修模型 qrcode: "", // 二维码 selected: 0, // 已选下标 - contentData: { // 总数据 + contentData: { + // 总数据 list: [], }, decorateData: "", // 装修数据 + decoratePromotionsData: "", // 装修数据 }; }, watch: { @@ -108,21 +111,14 @@ export default { }, methods: { - - enableBindGoodsShow(){ - - }, - - // 初始化数据 init() { if (!this.$route.query.id) return false; - API_Other.getHomeData(this.$route.query.id).then(res=>{ - this.contentData = JSON.parse(res.result.pageData) + API_Other.getHomeData(this.$route.query.id).then((res) => { + this.contentData = JSON.parse(res.result.pageData); - - this.handleComponent( this.contentData.list[0], 0) - }) + this.handleComponent(this.contentData.list[0], 0); + }); }, // 中间组件拖动,右侧数据绑定不变 @@ -136,7 +132,6 @@ export default { this.$nextTick(() => { this.decorateData = ""; - console.log(this.contentData.list.length); // 如果当前楼层不为一 if (this.contentData.list.length > 1) { // 如果当前最底层 给下一层赋值 @@ -156,29 +151,86 @@ export default { // 点击楼层装修 handleComponent(val, index) { - console.warn(val) this.selected = index; this.$set(this, "decorateData", val); }, // 右侧栏回调 handleDrawer(val) { - let newIndex = this.selected; + if (val.promotionsType) { + if (this.contentData.list[newIndex].options.list.length >= 2) { + this.$Message.error("最多只能展示两个活动"); + return; + } + if (val.promotionsType === "LIVE") { + API_Promotions.getLiveList({ + status: "START", + pageSize: 1, + }).then((res) => { + if (res.success && res.result.size > 0) { + API_Promotions.getLiveInfo(res.result.records[0].id).then( + (res) => { + if (res.success) { + this.contentData.list[newIndex].options.list.push({ + type: val.promotionsType, + title: val.name, + title1: val.subName, + color1: val.subColor, + bk_color: val.subBkColor, + data: res.result.commodityList + ? res.result.commodityList + : [], + }); + } + } + ); + } + }); + } else { + API_Promotions.getAllPromotion().then((res) => { + let exist = this.contentData.list[newIndex].options.list.find( + (i) => i.type === val.promotionsType + ); - this.decorateData = ""; + if (res.success && !exist) { + this.contentData.list[newIndex].options.list.push({ + data: res.result[val.promotionsType] + ? res.result[val.promotionsType] + : [], + type: val.promotionsType, + title1: val.subName, + color1: val.subColor, + bk_color: val.subBkColor, + title: val.name, + }); + } + }); + } + this.$set(this.contentData.list, newIndex, { + ...val, + options: { + ...this.contentData.list[newIndex].options, + }, + // 绑定键值 + model: val.type, + }); + } else { + this.decorateData = ""; - this.$set(this.contentData.list, newIndex, { - ...val, - options: { - ...val.options, - }, + this.$set(this.contentData.list, newIndex, { + ...val, + options: { + ...val.options, + }, - // 绑定键值 - model: val.type, - }); - this.contentData.list = JSON.parse(JSON.stringify(this.contentData.list)); - - this.$set(this, "decorateData", this.contentData.list[newIndex]); + // 绑定键值 + model: val.type, + }); + this.contentData.list = JSON.parse( + JSON.stringify(this.contentData.list) + ); + this.$set(this, "decorateData", this.contentData.list[newIndex]); + } }, // 封装拖拽参数