Browse Source

浮层卡片

xiuli.gao 1 year ago
parent
commit
56c2bfd7fa

+ 105 - 23
src/components/businessMoudle/batchGdt/configArea/originalityBasic/components/floatingZoneStruct.vue

@@ -3,24 +3,48 @@
3 3
     <div class="form-block-item-title">浮层卡片</div>
4 4
     <div class="marT15 flex_1">
5 5
       <el-switch v-model="floating_zone_switch" @change="radioChange"/>
6
-      <div class="flex marT15" v-if="floating_zone_struct.child.type">
7
-        <div class="form-block-item-title" style="width:120px">浮层卡片类型</div>
8
-        <el-radio-group class="flex_1" v-model="type" size="default" @change="radioChange">
9
-          <template v-for="list_item in floating_zone_struct.child.type?.enum_property?.enumeration">
10
-            <el-radio-button :label="list_item.value" style="margin:2px 0;">{{ list_item.description }}</el-radio-button>
11
-          </template>
12
-        </el-radio-group>
13
-      </div>
14
-      <div class="flex marT15" v-if="floating_zone_struct.child?.name">
15
-        <div class="form-block-item-title" style="width:120px">文案一</div>
16
-        <div class="flex"><el-input v-model="name" placeholder="请输入文案一" max="10" style="width:300px" @input="radioChange"/><span
17
-          style="color:#666;font-size:14px;margin-left:4px;">{{ name?.length }}/10</span></div>
18
-      </div>
19
-      <div class="flex marT15" v-if="floating_zone_struct.child?.desc">
20
-        <div class="form-block-item-title" style="width:120px">文案二(选填)</div>
21
-        <div class="flex"><el-input v-model="desc" placeholder="请输入文案一" max="10" style="width:300px" @input="radioChange"/><span
22
-          style="color:#666;font-size:14px;margin-left:4px;">{{ desc?.length }}/14</span></div>
23
-      </div>
6
+      <template v-if="floating_zone_switch">
7
+        <div class="flex marT15" v-if="floating_zone_struct.child.type">
8
+          <div class="form-block-item-title" style="width:120px">浮层卡片类型</div>
9
+          <el-radio-group class="flex_1" v-model="type" size="default" @change="radioChange">
10
+            <template v-for="list_item in floating_zone_struct.child.type?.enum_property?.enumeration">
11
+              <el-radio-button :label="list_item.value" style="margin:2px 0;">{{ list_item.description }}</el-radio-button>
12
+            </template>
13
+          </el-radio-group>
14
+        </div>
15
+        <div class="flex marT15" v-if="floating_zone_struct.child?.image_id" style="align-items: flex-start;">
16
+          <div class="form-block-item-title" style="width:120px">创意图片</div>
17
+          <div class="upload-content">
18
+            <div class="upload-area">
19
+              <div class="upload-empty">
20
+                <el-icon size="18px"><UploadFilled /></el-icon>上传图片
21
+              </div>
22
+            </div>
23
+            <p class="card-tips">图片尺寸必须为800x800,小于400KB,格式:JPG/PNG</p>
24
+          </div>
25
+        </div>
26
+        <div class="flex marT15" v-if="floating_zone_struct.child?.name">
27
+          <div class="form-block-item-title" style="width:120px">文案一</div>
28
+          <div class="flex"><el-input v-model="name" placeholder="请输入文案一" max="10" style="width:300px" @input="radioChange"/><span
29
+            style="color:#666;font-size:14px;margin-left:4px;">{{ name?.length }}/10</span></div>
30
+        </div>
31
+        <div class="flex marT15" v-if="floating_zone_struct.child?.desc">
32
+          <div class="form-block-item-title" style="width:120px">文案二(选填)</div>
33
+          <div class="flex"><el-input v-model="desc" placeholder="请输入文案一" max="10" style="width:300px" @input="radioChange"/><span
34
+            style="color:#666;font-size:14px;margin-left:4px;">{{ desc?.length }}/14</span></div>
35
+        </div>
36
+        <div class="flex marT15" v-if="floating_zone_struct.child?.button_text">
37
+          <div class="form-block-item-title" style="width:120px">按钮文案(选填)</div>
38
+          <el-select v-model="selectValue" clearable placeholder="请选择" size="small" @change="radioChange">
39
+            <el-option
40
+              v-for="item in floating_zone_struct.child?.button_text?.enum_property?.enumeration"
41
+              :key="item.value"
42
+              :label="item.value"
43
+              :value="item.value"
44
+            />
45
+          </el-select>
46
+        </div>
47
+      </template>
24 48
     </div>
25 49
   </div>
26 50
 </template>
@@ -35,14 +59,16 @@ const props = defineProps({
35 59
   }
36 60
 })
37 61
 import { onBeforeMount, ref } from 'vue';
38
-const floating_zone_switch = ref(true)
62
+const floating_zone_switch = ref(false)
39 63
 const floating_zone_struct = ref()
40 64
 const type = ref('')
41 65
 const name = ref('')
42 66
 const desc = ref('')
67
+const selectValue = ref('')
43 68
 onBeforeMount(()=>{
44 69
   floating_zone_struct.value = props.adTemplateItem?.adcreative_elements?.floating_zone_struct;
45 70
   type.value = floating_zone_struct.value?.child.type?.enum_property?.default
71
+  selectValue.value = floating_zone_struct.value.child?.button_text?.enum_property?.enumeration[0]?.value
46 72
   radioChange()
47 73
 })
48 74
 const radioChange = () => {
@@ -52,13 +78,69 @@ const radioChange = () => {
52 78
       'copywriting': [],
53 79
       'postion': 'adcreative_elements'
54 80
     }
55
-    obj.api_value['floating_zone_switch'] = floating_zone_switch.value ? 1 : 0
56 81
     if(floating_zone_switch.value){
57
-    }else{
58
-      
82
+      if(floating_zone_struct.value.child?.name && (name.value == '' || !name.value)) {
83
+        obj['required'] = true;
84
+        obj['description'] = `请输入文案一,长度1-10`;
85
+      }else{
86
+        obj.api_value['floating_zone_struct'] = {}
87
+        obj.api_value['floating_zone_struct']['floating_desczone_switch'] = floating_zone_switch.value ? 1 : 0
88
+        obj.api_value['floating_zone_struct']['name'] = name.value
89
+        if(desc.value){
90
+          obj.api_value['floating_zone_struct']['desc'] = desc.value
91
+        }
92
+        if(type.value){
93
+          obj.api_value['floating_zone_struct']['type'] = type.value
94
+        }
95
+        if(selectValue.value) {
96
+          obj.api_value['floating_zone_struct']['button_text'] = selectValue.value
97
+        }
98
+      }
59 99
     }
60 100
     emit('backhaul', {'floating_zone_struct': obj})
61 101
   }
62 102
 }
63 103
 </script>
64
-<style lang="scss" scoped>@import "@/assets/style/batchDialogGdt.scss";</style>
104
+<style lang="scss" scoped>
105
+@import "@/assets/style/batchDialogGdt.scss";
106
+.upload-content{
107
+  position: relative;
108
+  display: inline-block;
109
+  margin-right: 20px;
110
+  .upload-area{
111
+    display: inline-flex;
112
+    align-items: center;
113
+    justify-content: center;
114
+    width: 124px;
115
+    height: 124px;
116
+    background-color: #fff;
117
+    border: 0.758865px solid #dadfe3;
118
+    border-radius: 4px;
119
+    .upload-empty{
120
+      display: flex;
121
+      align-items: center;
122
+      justify-content: center;
123
+      width: 108px;
124
+      height: 108px;
125
+      font-size: 14px;
126
+      color: #666;
127
+      cursor: pointer;
128
+      background-color: #f8f8f8;
129
+      border: 1px dashed #d6d6d6;
130
+      border-radius: 4px;
131
+    }
132
+    &:hover{
133
+      .upload-empty{
134
+        border-color: #3173FF;
135
+      }
136
+    }
137
+  }
138
+  .card-tips{
139
+    display: block;
140
+    padding-top: 4px;
141
+    font-size: 12px;
142
+    line-height: 1;
143
+    color: #999;
144
+  }
145
+}
146
+</style>