xhj 3 年 前
コミット
02cc47199b

+ 87 - 3
src/App.vue

@@ -32,7 +32,7 @@
         </div>
         <ul>
           <div class="title">组件选择</div>
-          <li v-for="(val, index) in typeList" :key="index + 1" @click="clickType(val)">
+          <li v-for="(val, index) in typeList" :key="index + 1" @click="clickType(val)" v-if="!val.hideShow">
             <img :src="require('./assets/images/' + val.icon)">
             <!-- <img src="./assets/images/l-kefu.png"> -->
             <!-- <span :class="val.icon"></span> -->
@@ -62,12 +62,22 @@
                 </el-tooltip>
               </div>
             </div>
-            <div v-if="item.isHover" :data-index="index" :key="index" class="item nobackground" :class="item.position"
+            <div v-if="item.isHover&&item.key!='fixedNode'" :data-index="index" :key="index" class="item nobackground" :class="item.position"
               :style="'width:' + (item.width ? item.width : 100) + 'px;height:' + (item.height ? item.height : 100) + 'px;'"
               @click="selectType(item)">
               <component :is="item.com" :data="item" :key="index + '_'"></component>
               <i @click="deleteItem($event, index)" class="el-icon-error"></i>
             </div>
+            <div v-if="item.isHover&&item.key=='fixedNode'" :data-index="index" :key="index" class="item" :class="item.position" style="z-index:2"
+             >
+              <component :is="item.com" :data="item" :key="index + '_'"></component>
+              <i @click="deleteItemFixed($event, index)" class="el-icon-error"></i>
+            </div>
+            <div v-if="item.isHover&&item.key=='fixedNode'" :data-index="index" :key="index+'hide'" class="item nobackground" :class="item.position" style="position: relative !important;visibility: hidden;"
+             >
+              <component :is="item.com" :data="item" :key="index + '_'"></component>
+              <i @click="deleteItemFixed($event, index)" class="el-icon-error"></i>
+            </div>
           </div>
         </div>
       </section>
@@ -108,6 +118,7 @@ import editorRecharge from '@/components/View/editorRecharge'
 import settingRecharge from '@/components/setting/settingRecharge'
 import editorCoupon from '@/components/View/editorCoupon'
 import settingCoupon from '@/components/setting/settingCoupon'
+import editorFixedNode from '@/components/View/editorFixedNode'
 export default {
   components: {
     editorImage,
@@ -126,6 +137,7 @@ export default {
     settingRecharge,
     editorCoupon,
     settingCoupon,
+    editorFixedNode,
 
     materialManage
   },
@@ -168,6 +180,7 @@ export default {
           com: 'editorApplicationForm',
           setCom: 'settingApplicationForm',
           value: {
+            isFixedNode:false,
             title: { value: '报名表', isShow: true },
             database: '',
             formItemList: [{
@@ -211,6 +224,7 @@ export default {
           com: 'editorRecharge',
           setCom: 'settingRecharge',
           value: {
+            isFixedNode:false,
             rechargeTitle:'在线充值线下使用有优惠',
             mainColor:'#fe0419',
             showSymbol:true,
@@ -232,6 +246,19 @@ export default {
             btnBackground:['#009AFF','#3FBDFB'],
             buttonName:'立即领取',
           }
+        }, {
+          name: '悬浮节点',
+          key: 'fixedNode',
+          icon: 'l-youhuiquan.png',
+          hideShow:true,
+          com: 'editorFixedNode',
+          setCom: '',
+          isHover: true,
+          position: 'bottom',//left-top
+          value: {
+            type:null,
+            contentObj:{}
+          }
         }],
       view: [],
       type: '',
@@ -335,8 +362,11 @@ export default {
       return this.view.filter((item) => { return item.isHover == true })
     },
     clickType(val) {
-      this.view.push(JSON.parse(JSON.stringify(val)))
+      let pushObj = JSON.parse(JSON.stringify(val))
+      pushObj.id = pushObj.key+(new Date().getTime())
+      this.view.push(pushObj)
       this.position()
+      console.log(this.view)
     },
     deleteItem(e, index) {
       e.preventDefault()
@@ -344,7 +374,15 @@ export default {
       this.view.splice(index, 1)
       this.isRight = false
       this.propsData = {}
+      this.updataFixedNodeContent()
+      this.position()
+    },
+    deleteItemFixed(e, index) {
+      e.preventDefault()
+      e.stopPropagation()
+      this.view.splice(index, 1)
       this.position()
+      this.selectType(this.view.filter(item=>{return item.id == this.propsData.id})[0])
     },
     selectType(val) {
       this.isRight = false
@@ -356,10 +394,49 @@ export default {
     },
     updataContent(val) {
       this.$set(this.view, val.index, JSON.parse(JSON.stringify(val)))
+      this.updataFixedNodeContent()
+      console.log('updataContent',this.view)
       // this.view.forEach(item => {
       //   if(item.key==val.key&&item.index==val.index) item = JSON.parse(JSON.stringify(val))
       // });
     },
+    // 实时更新悬浮节点内容
+    updataFixedNodeContent(){
+      console.log('updataFixedNodeContent')
+      let fixedNode = this.view.filter(item=>{ return item.key=='fixedNode' })
+      if(fixedNode.length>0){
+        fixedNode.map(item=>{
+          let isHave = false
+          this.view.map(it=>{
+            if(it.id==item.value.contentObj.id) {
+              isHave=true
+              item.value.contentObj = it
+            }
+          })
+          if(!isHave) {
+            this.view = this.view.filter(it=>{return it.key!='fixedNode'||(it.key=='fixedNode' && it.value.contentObj.id != item.value.contentObj.id) })
+          }
+        })
+      }
+    },
+    // 设置悬浮节点内容
+    setFixedNodeContent(val,type,isDelete){
+      if(isDelete){
+        this.view = this.view.filter(it=>{return it.key!='fixedNode'||(it.key=='fixedNode' && val.id != it.value.contentObj.id) })
+        console.log(this.view)
+      }else{
+        let fixedNode = this.view.filter(item=> item.key=='fixedNode')
+        if(fixedNode.length>0){
+          console.log('已存在悬浮节点')
+          fixedNode[0].value.contentObj = JSON.parse(JSON.stringify(val))
+          fixedNode[0].value.type = type
+          console.log('设置悬浮节点内容',this.view)
+        }else{
+          console.log('未存在悬浮节点')
+          return false
+        }
+      }
+    },
     lookJson() {
       this.$alert(JSON.stringify(this.view), 'JSON', {
         confirmButtonText: '确定'
@@ -964,4 +1041,11 @@ ul p {
   right: 20px;
   z-index: 200;
 }
+
+.bottom{
+  position: absolute;
+  bottom: 0;
+  left: 0;
+  right: 0;
+}
 </style>

+ 245 - 0
src/components/View/editorFixedNode.vue

@@ -0,0 +1,245 @@
+<template>
+    <div>
+       <div>
+            <div v-if="data.value.type=='applicationForm'" style="margin: 10px 20px;box-sizing: border-box;">
+                <el-button style="width: 100%;" type="primary">
+                    {{ data.value.contentObj.value.buttonName?data.value.contentObj.value.buttonName:'请填写按钮内容' }}</el-button>
+            </div>
+            <div v-if="data.value.type=='recharge'" style="margin: 10px 20px;box-sizing: border-box;">
+                <el-button type="primary" :style="'background-color: '+(data.value.contentObj.value.mainColor?data.value.contentObj.value.mainColor:'#fe0419')+';border: 1px solid '+(data.value.contentObj.value.mainColor?data.value.contentObj.value.mainColor:'#fe0419')+';width: 100%;'">
+                    {{ data.value.contentObj.value.buttonName?data.value.contentObj.value.buttonName:'请填写按钮内容' }}</el-button>
+            </div>
+            <div v-if="data.value.type=='product'" style="margin: 10px 20px;box-sizing: border-box;">
+                <div class="product-item" v-for="(item, index) in data.value.contentObj.value.productList.filter(it=>{return it.isFixedNode})" :key="index">
+                    <div class="image">
+                        <img :src="item.pic">
+                    </div>
+                    <div class="info">
+                        <p class="name">{{ item.title }}</p>
+                        <p class="price">
+                            <span>¥<span>{{ item.minSalePrice?item.minSalePrice:0 }}</span>
+                            </span>
+                            <span v-if="data.value.contentObj.value.showOriginalPrice">¥{{ item.originalPrice }}</span>
+                        </p>
+                    </div>
+                </div>
+            </div>
+            <div v-if="data.value.type=='coupon'" style="margin: 10px 20px;box-sizing: border-box;">
+                <div class="coupon-box" v-for="item in data.value.contentObj.value.couponList.filter(it=>{return it.isFixedNode})" :key="item.id">
+                    <div class="coupon-info">
+                        <img :src="item.couponIcon" class="coupon-pic"/>
+                        <div class="coupon-content">
+                            <div class="coupon-content-title">{{ item.couponTitle }}</div>
+                            <div class="coupon-content-date">{{getDateFormat(item.couponStart)}}-{{ getDateFormat(item.couponEnd) }}</div>
+                        </div>
+                        <div class="coupon-use">
+                            <div style="margin: auto;">
+                                <span class="coupon-symbol">¥</span>
+                                <span class="coupon-userMoney">{{ item.couponAmount }}</span>
+                            </div>
+                            <div class="coupon-useBreif">{{ item.couponBrief }}</div>
+                        </div>
+                    </div>
+                    <div class="coupon-option">
+                        <div class="coupon-option-left">
+                            <div>查看详情</div>
+                            <img src="../../assets/images/arrow.png"/>
+                        </div>
+                        <div v-if="data.value.contentObj.value.btnBackground.length==2" class="coupon-option-btn" :style="'background: linear-gradient(90deg, '+data.value.contentObj.value.btnBackground[0]+' 0%, '+data.value.contentObj.value.btnBackground[1]+' 100%);'">{{ data.value.contentObj.value.buttonName }}</div>
+                        <div v-else-if="data.value.contentObj.value.btnBackground.length==1" class="coupon-option-btn" :style="'background: '+data.value.contentObj.value.btnBackground[0]+';'">{{ data.value.contentObj.value.buttonName }}</div>
+                        <div v-else class="coupon-option-btn" style="background: linear-gradient(90deg, #009AFF 0%, #3FBDFB 100%);">{{ data.value.contentObj.value.buttonName }}</div>
+                    </div>
+                </div>
+            </div>
+       </div>
+    </div>
+
+</template>
+
+<script>
+import {dateFormat} from '@/utlis/utli'
+export default {
+    name: 'editorFixedNode',
+    props: ['data', 'className'],
+    data() {
+        return {
+            content: this.data,
+        }
+    },
+    // watch: {
+    //     data: {
+    //         deep: true,
+    //         handler(val) {
+    //             this.content = val;
+    //         },
+    //     },
+    // },
+    methods: {
+        // dateFormat时间格式化
+        getDateFormat(date){
+            return dateFormat(new Date(date)).v6
+        }
+    }
+}
+</script>
+
+<style  scoped>
+.text{
+    margin: auto;
+    text-align: center;
+}
+img{
+    border-radius: 50%;
+}
+
+
+/* 一行单个商品 */
+.product-item {
+    width: 100%;
+    padding: 10px;
+    display: flex;
+    border-bottom: 1px dashed #eee;
+}
+
+.product-item .image {
+    width: 100px;
+    height: 100px;
+    border-radius: 5px;
+    overflow: hidden;
+    margin-right: 10px;
+}
+
+.product-item .image img {
+    max-width: 100%;
+    max-height: 100%;
+    border-radius: 0;
+}
+
+.product-item .info {
+    padding: 0 5px;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-between;
+    flex: 1;
+}
+
+.product-item .info .price {
+    font-size: 20px;
+    margin: 0;
+}
+
+.product-item .info .num {
+    margin: 12px 0 0;
+}
+.product-item .info .price span:nth-of-type(1) {
+    color: red;
+}
+
+.product-item .info .price span:nth-of-type(2) {
+    color: #b5b5b5;
+    font-weight: 400;
+    font-size: 12px;
+    margin-left: 4px;
+    text-decoration: line-through;
+}
+
+.coupon-box{
+    box-shadow: 0px 0px 32px 1px rgba(0,0,0,0.04);
+    border-radius: 6px;
+    margin-bottom: 10px;
+}
+.coupon-info{
+    position: relative;
+    display: flex;
+    align-items: center;
+    padding: 20px;
+    justify-content: space-between;
+    border-bottom:1px  dotted #E9E9E9;
+}
+.coupon-info::before{
+    position: absolute;
+    content: '';
+    width: 6px;
+    height: 12px;
+    bottom: 0;
+    left: 0;
+    transform: translate(0,50%);
+    background-color: #fbfbfb;
+    border-radius: 0 100px 100px 0;
+}
+.coupon-info::after{
+    position: absolute;
+    content: '';
+    width: 6px;
+    height: 12px;
+    bottom: 0;
+    right: 0;
+    transform: translate(0,50%);
+    background-color: #fbfbfb;
+    border-radius: 100px 0px 0px 100px;
+}
+.coupon-pic{
+    width: 60px;
+    height: 60px;
+    border-radius: 4px;
+    margin-right: 10px;
+}
+.coupon-content{
+    flex: 1;
+}
+.coupon-content-title{
+    font-size: 16px;
+    font-weight: bold;
+}
+.coupon-content-date{
+    font-size: 13px;
+    color:#999;
+    margin-top: 10px;
+}
+.coupon-use{
+    width: 70px;
+    text-align: center;
+    margin-left: 10px;
+}
+.coupon-symbol{
+    font-size: 14px;
+    color: #EB0000;
+}
+.coupon-userMoney{
+    font-size: 24px;
+    font-weight: bold;
+    color: #EB0000;
+}
+.coupon-useBreif{
+    font-size: 13px;
+    color: #999999;
+}
+.coupon-option{
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    padding:10px 20px;
+}
+.coupon-option-left{
+    display: flex;
+    align-items: center;
+    color: #666666;
+    font-size: 14px;
+}
+.coupon-option-left img{
+    width: 5px;
+    height: 10px;
+    margin-left: 5px;
+    margin-top: 2px;
+}
+.coupon-option-btn{
+    width: 90px;
+    height: 30px;
+    line-height: 30px;
+    border-radius: 28px 28px 28px 28px;
+    opacity: 1;
+    text-align: center;
+    color: #fff;
+    font-size: 14px;
+}
+</style>

+ 52 - 2
src/components/setting/settingApplicationForm.vue

@@ -27,7 +27,15 @@
                         </el-option>
                     </el-select>
                 </el-form-item>
-                <el-form-item style="margin-bottom: 0;" label="按钮名称">
+                <el-form-item style="margin-bottom: 0;" label="">
+                    <div class="text-setting">
+                        <span>按钮名称</span>
+                        <span>是否悬浮
+                            <el-switch size="mini" @change="fixedNodeChange" v-model="content.value.isFixedNode"
+                                :active-value="true" :inactive-value="false">
+                            </el-switch>
+                        </span>
+                    </div>
                     <el-input size="mini" @input="handleDate" v-model="content.value.buttonName"></el-input>
                 </el-form-item>
                 <div>
@@ -144,6 +152,7 @@ export default {
         if(this.content.value.database){
             this.getFormColumn(this.content.value.database)
         }
+        this.content.value.isFixedNode = this.getFixedState()
     },
     methods: {
         handleDate() {
@@ -222,7 +231,48 @@ export default {
                 this.formColumnList = res.data.data;
             }).catch(function () {
             });
-        }
+        },
+        // 悬浮节点切换判断
+        fixedNodeChange(val){
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode')
+            if(fixedNode.length>0){
+                console.log('已存在悬浮节点')
+                if(val){
+                    console.log('切换悬浮节点')
+                    this.$confirm('当前已存在悬浮组件, 是否替换?', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                        }).then(() => {
+                            this.$parent.setFixedNodeContent(this.content,this.content.key)
+                            this.content.value.isFixedNode = this.getFixedState()
+                            this.handleDate()
+                        }).catch(() => {
+                            this.content.value.isFixedNode = this.getFixedState()
+                        });
+                }else{
+                    this.$parent.setFixedNodeContent(this.content,this.content.key,true)
+                    this.content.value.isFixedNode = this.getFixedState()
+                    this.handleDate()
+                }
+            }else{
+                console.log('未存在悬浮节点')
+                this.$parent.clickType(this.$parent.typeList.filter(item=> item.key=='fixedNode')[0])
+                this.$parent.setFixedNodeContent(this.content,this.content.key)
+                this.content.value.isFixedNode = this.getFixedState()
+                this.handleDate()
+            }
+        },
+        getFixedState(){
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode'&&item.value.type==this.content.key)
+            if(fixedNode.length>0){
+                for(var i=0;i<fixedNode.length;i++){
+                    let item = fixedNode[i]
+                    if(this.content.id==item.value.contentObj.id) return true
+                }
+            }
+            return false
+        },
 
     }
 }

+ 170 - 2
src/components/setting/settingCoupon.vue

@@ -1,5 +1,5 @@
 <template>
-    <div class="panel">
+    <div class="panel product-content">
         <div class="panel-header">
             <h3 class="header-title">{{ data.name }}设置</h3>
             <a class="el-icon-close close-btn" @click="closeRightTemplateHandle"></a>
@@ -31,6 +31,26 @@
                     <el-color-picker @change="changeBgColor" v-model="btnBackground[0]"></el-color-picker>
                     <el-color-picker style="margin-left: 20px;" @change="changeBgColor" v-model="btnBackground[1]"></el-color-picker>
                 </el-form-item>
+                <el-form-item style="margin-bottom: 0;" label="设置" v-if="content.value.couponList && content.value.couponList.length > 0">
+                    <template>
+                        <ul class="list" v-if="content.value.couponList && content.value.couponList.length > 0">
+                            <div v-for="(item, index) in content.value.couponList" :key="index" style="display: flex;">
+                                <li class="item" style="margin-right: 10px !important;">
+                                    <img :src="item.couponIcon">
+                                    <!-- <i class="el-icon-error" @click="deleteItem(index)"></i> -->
+                                </li>
+                                <div style="flex: 1;min-width: 0;">
+                                    <div style="flex: 1;" class="tover">{{ item.couponTitle }}</div>
+                                    <div style="display: flex;margin-top: 10px;align-items: center;">
+                                        <div style="margin-right: 10px;">是否悬浮</div>
+                                        <el-switch v-model="item.isFixedNode" @change="fixedNodeChange($event,item)" :active-value="true" :inactive-value="false">
+                                    </el-switch>
+                                    </div>
+                                </div>
+                            </div>
+                        </ul>
+                    </template>
+                </el-form-item>
             </el-form>
         </div>
     </div>
@@ -65,6 +85,7 @@ export default {
         if(this.content.value.btnBackground[1]){
             this.btnBackground[1] = this.content.value.btnBackground[1]
         }
+        this.content.value.isFixedNode = this.getFixedState()
     },
     methods: {
         // 获取优惠券列表
@@ -85,6 +106,10 @@ export default {
                 list.push(item)
             })
             this.content.value.couponList = list
+            if(this.content.value.couponList.filter(item=>{return item.isFixedNode}).length==0){
+                this.$parent.setFixedNodeContent(this.content,this.content.key,true)
+            }
+            this.getFixedState()
             this.handleDate()
         },
         changeBgColor(val){
@@ -98,7 +123,75 @@ export default {
         },
         closeRightTemplateHandle() {
             this.$emit('closeRightTemplateHandle', false)
-        }
+        },
+
+         // 悬浮节点切换判断
+         fixedNodeChange(val,pitem){
+            console.log(val,pitem)
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode')
+            if(fixedNode.length>0){
+                console.log('已存在悬浮节点')
+                if(val){
+                    console.log('切换悬浮节点')
+                    this.$confirm('当前已存在悬浮组件, 是否替换?', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                        }).then(() => {
+
+                            this.content.value.couponList.map(item=>{item.isFixedNode = false})
+                            pitem.isFixedNode = true
+
+                            this.$parent.setFixedNodeContent(this.content,this.content.key)
+                            this.content.value.isFixedNode = this.getFixedState()
+                            this.handleDate()
+                        }).catch(() => {
+                            this.content.value.isFixedNode = this.getFixedState()
+                        });
+                }else{
+                    this.content.value.couponList.map(item=>{item.isFixedNode = false})
+
+                    this.$parent.setFixedNodeContent(this.content,this.content.key,true)
+                    this.content.value.isFixedNode = this.getFixedState()
+                    this.handleDate()
+                }
+            }else{
+                console.log('未存在悬浮节点')
+                this.$parent.clickType(this.$parent.typeList.filter(item=> item.key=='fixedNode')[0])
+
+                this.content.value.couponList.map(item=>{item.isFixedNode = false})
+                pitem.isFixedNode = true
+
+                this.$parent.setFixedNodeContent(this.content,this.content.key)
+                this.content.value.isFixedNode = this.getFixedState()
+                this.handleDate()
+            }
+        },
+        getFixedState(){
+            console.log('getFixedState')
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode'&&item.value.type==this.content.key)
+            if(fixedNode.length>0){
+                for(var i=0;i<fixedNode.length;i++){
+                    let item = fixedNode[i]
+                    console.log(this.content)
+                    if(this.content.id==item.value.contentObj.id) {
+                        this.content.value.couponList.map(citem=>{
+                            item.value.contentObj.value.couponList.map(it=>{
+                                if(it.id==citem.id) citem.isFixedNode = it.isFixedNode
+                            })
+                        })
+                        this.content = JSON.parse(JSON.stringify(this.content))
+                        return true
+                    }
+                }
+            }else{
+                this.content.value.couponList.map(citem=>{
+                    citem.isFixedNode = false
+                })
+                this.content = JSON.parse(JSON.stringify(this.content))
+                return false
+            }
+        },
     }
 }
 </script>
@@ -164,4 +257,79 @@ export default {
     justify-content: space-between;
     margin: 10px 0;
 }
+
+
+.product-content .list {
+    padding: 12px;
+    margin: 0;
+}
+
+.product-content .list .item {
+    width: 70px;
+    height: 70px;
+    border-radius: 6px;
+    margin: 4px;
+    position: relative;
+    transition: all .3s;
+    list-style: none;
+}
+
+.product-content .list .item img {
+    width: 100%;
+    height: 100%;
+    border-radius: 4px;
+}
+
+.product-content .list .item i {
+    position: absolute;
+    top: -6px;
+    right: -6px;
+    cursor: pointer;
+    opacity: 0;
+    transition: all .3s;
+    color: red;
+}
+
+.product-content .list .item::before {
+    content: '';
+    height: 100%;
+    width: 100%;
+    position: absolute;
+    top: 0;
+    right: 0;
+    background: rgba(0, 0, 0, 0.4);
+    border-radius: 4px;
+    opacity: 0;
+    transition: all .3s;
+}
+
+.product-content .list .item:hover {
+    cursor: grab;
+}
+
+.product-content .list .item:hover::before,
+.product-content .list .item:hover i {
+    opacity: 1;
+}
+
+.product-content .options {
+    padding: 15px;
+    border-radius: 6px;
+}
+
+.product-content .options .el-form {
+    background: #f7f8f9;
+    overflow: hidden;
+    padding: 10px 0;
+}
+
+.product-content .options .el-form .el-form-item {
+    margin: 0;
+}
+
+.product-content .options .el-form .el-form-item label {
+    font-size: 12px;
+}
+
+.tover{text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
 </style>

+ 92 - 41
src/components/setting/settingProduct.vue

@@ -14,10 +14,20 @@
         </el-button>
         <template v-if="content.value.productList && content.value.productList.length > 0">
             <ul class="list" v-if="content.value.productList && content.value.productList.length > 0">
-                <li class="item" v-for="(item, index) in content.value.productList" :key="index">
-                    <img :src="item.pic">
-                    <i class="el-icon-error" @click="deleteItem(index)"></i>
-                </li>
+                <div v-for="(item, index) in content.value.productList" :key="index" style="display: flex;">
+                    <li class="item" style="margin-right: 10px !important;">
+                        <img :src="item.pic">
+                        <i class="el-icon-error" @click="deleteItem(index)"></i>
+                    </li>
+                    <div style="flex: 1;min-width: 0;">
+                        <div style="flex: 1;" class="tover">{{ item.title }}</div>
+                        <div style="display: flex;margin-top: 10px;">
+                            <div style="margin-right: 10px;">是否悬浮</div>
+                            <el-switch v-model="item.isFixedNode" @change="fixedNodeChange($event,item)" :active-value="true" :inactive-value="false">
+                        </el-switch>
+                        </div>
+                    </div>
+                </div>
             </ul>
         </template>
 
@@ -92,6 +102,9 @@ export default {
     //         },
     //     },
     // },
+    created() {
+        this.content.value.isFixedNode = this.getFixedState()
+    },
     methods: {
         handleDate() {
             this.$emit('updataContent', this.content)
@@ -107,6 +120,8 @@ export default {
         },
 
         deleteItem(index) {
+            if(this.content.value.productList[index].isFixedNode)
+                this.$parent.setFixedNodeContent(this.content,this.content.key,true)
             this.content.value.productList.splice(index, 1)
             this.handleDate()
         },
@@ -139,44 +154,78 @@ export default {
             val.forEach(item => {
                 this.content.value.productList.push(item)
             });
+            
+            let map = new Map()
+            this.content.value.productList =  this.content.value.productList.filter((item) => !map.has(item.id.toString()) && map.set(item.id.toString()))
             this.handleDate()
-        }
+        },
+        // 悬浮节点切换判断
+        fixedNodeChange(val,pitem){
+            console.log(val,pitem)
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode')
+            if(fixedNode.length>0){
+                console.log('已存在悬浮节点')
+                if(val){
+                    console.log('切换悬浮节点')
+                    this.$confirm('当前已存在悬浮组件, 是否替换?', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                        }).then(() => {
+
+                            this.content.value.productList.map(item=>{item.isFixedNode = false})
+                            pitem.isFixedNode = true
+
+                            this.$parent.setFixedNodeContent(this.content,this.content.key)
+                            this.content.value.isFixedNode = this.getFixedState()
+                            this.handleDate()
+                        }).catch(() => {
+                            this.content.value.isFixedNode = this.getFixedState()
+                        });
+                }else{
+                    this.content.value.productList.map(item=>{item.isFixedNode = false})
+
+                    this.$parent.setFixedNodeContent(this.content,this.content.key,true)
+                    this.content.value.isFixedNode = this.getFixedState()
+                    this.handleDate()
+                }
+            }else{
+                console.log('未存在悬浮节点')
+                this.$parent.clickType(this.$parent.typeList.filter(item=> item.key=='fixedNode')[0])
+
+                this.content.value.productList.map(item=>{item.isFixedNode = false})
+                pitem.isFixedNode = true
+
+                this.$parent.setFixedNodeContent(this.content,this.content.key)
+                this.content.value.isFixedNode = this.getFixedState()
+                this.handleDate()
+            }
+        },
+        getFixedState(){
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode'&&item.value.type==this.content.key)
+            if(fixedNode.length>0){
+                for(var i=0;i<fixedNode.length;i++){
+                    let item = fixedNode[i]
+                    if(this.content.id==item.value.contentObj.id) {
+                        this.content.value.productList.map(citem=>{
+                            item.value.contentObj.value.productList.map(it=>{
+                                if(it.id==citem.id) citem.isFixedNode = it.isFixedNode
+                            })
+                        })
+                        return true
+                    }
+                }
+            }else{
+                this.content.value.productList.map(citem=>{
+                    citem.isFixedNode = false
+                })
+                this.content = JSON.parse(JSON.stringify(this.content))
+                return false
+            }
+        },
     }
 }
-// 模拟产品列表
-var productList = [{
-    "productId": 3601,
-    "productName": "驼大大新疆正宗骆驼奶粉初乳骆驼乳粉蓝罐礼盒装120g*4罐",
-    "productImg": "https://img.quanminyanxuan.com/excel/f6860885547648d9996474bbf21fdca9.jpg",
-    "productPrice": 299,
-    "originalPrice": 598,
-    "volumeStr": "741",
-    "goodRatio": 98
-}, {
-    "productId": 3268,
-    "productName": "百合28件套新骨质瓷餐具",
-    "productImg": "https://img.quanminyanxuan.com/excel/185e7365f65543f2b4ebc67036d6a78f.jpg",
-    "productPrice": 370,
-    "originalPrice": 1388,
-    "volumeStr": "400",
-    "goodRatio": 99
-}, {
-    "productId": 3343,
-    "productName": "和商臻品槐花蜜250克/瓶",
-    "productImg": "https://img.quanminyanxuan.com/excel/4626c8c628d04935b0262d04991416b2.jpg",
-    "productPrice": 34.5,
-    "originalPrice": 72,
-    "volumeStr": "258",
-    "goodRatio": 98
-}, {
-    "productId": 3330,
-    "productName": "鲍参翅肚浓羹350g袋装",
-    "productImg": "https://img.quanminyanxuan.com/excel/58a0c968dc7d42c3ac21e09d1862aa6f.jpg",
-    "productPrice": 75,
-    "originalPrice": 128,
-    "volumeStr": "258",
-    "goodRatio": 98
-},]
+
 </script>
 
 <style lang="scss" scoped>
@@ -287,8 +336,8 @@ var productList = [{
 }
 
 .product-content .list {
-    display: flex;
-    flex-wrap: wrap;
+    // display: flex;
+    // flex-wrap: wrap;
     padding: 12px;
     margin: 0;
 }
@@ -359,4 +408,6 @@ var productList = [{
 .product-content .options .el-form .el-form-item label {
     font-size: 12px;
 }
+
+.tover{text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
 </style>

+ 54 - 2
src/components/setting/settingRecharge.vue

@@ -22,7 +22,15 @@
                         v-model="content.value.placeholderText">
                     </el-input>
                 </el-form-item>
-                <el-form-item style="margin-bottom: 0;" label="输入按钮名称">
+                <el-form-item style="margin-bottom: 0;" label="">
+                    <div class="text-setting">
+                        <span>输入按钮名称</span>
+                        <span>是否悬浮
+                            <el-switch size="mini" @change="fixedNodeChange" v-model="content.value.isFixedNode"
+                                :active-value="true" :inactive-value="false">
+                            </el-switch>
+                        </span>
+                    </div>
                     <el-input size="mini" @input="handleDate" v-model="content.value.buttonName"></el-input>
                 </el-form-item>
                 <el-form-item style="margin-bottom: 0;">
@@ -72,6 +80,9 @@ export default {
             content: JSON.parse(JSON.stringify(this.data)),
         }
     },
+    created() {
+        this.content.value.isFixedNode = this.getFixedState()
+    },
     methods: {
         addFastItem(){
             this.content.value.fastRechargeList.push('100')
@@ -87,7 +98,48 @@ export default {
         },
         closeRightTemplateHandle() {
             this.$emit('closeRightTemplateHandle', false)
-        }
+        },
+        // 悬浮节点切换判断
+        fixedNodeChange(val){
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode')
+            if(fixedNode.length>0){
+                console.log('已存在悬浮节点')
+                if(val){
+                    console.log('切换悬浮节点')
+                    this.$confirm('当前已存在悬浮组件, 是否替换?', '提示', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                        }).then(() => {
+                            this.$parent.setFixedNodeContent(this.content,this.content.key)
+                            this.content.value.isFixedNode = this.getFixedState()
+                            this.handleDate()
+                        }).catch(() => {
+                            this.content.value.isFixedNode = this.getFixedState()
+                        });
+                }else{
+                    this.$parent.setFixedNodeContent(this.content,this.content.key,true)
+                    this.content.value.isFixedNode = this.getFixedState()
+                    this.handleDate()
+                }
+            }else{
+                console.log('未存在悬浮节点')
+                this.$parent.clickType(this.$parent.typeList.filter(item=> item.key=='fixedNode')[0])
+                this.$parent.setFixedNodeContent(this.content,this.content.key)
+                this.content.value.isFixedNode = this.getFixedState()
+                this.handleDate()
+            }
+        },
+        getFixedState(){
+            let fixedNode = this.$parent.view.filter(item=> item.key=='fixedNode'&&item.value.type==this.content.key)
+            if(fixedNode.length>0){
+                for(var i=0;i<fixedNode.length;i++){
+                    let item = fixedNode[i]
+                    if(this.content.id==item.value.contentObj.id) return true
+                }
+            }
+            return false
+        },
     }
 }
 </script>