yuantianjiao 6 年之前
父節點
當前提交
f4a793907a

+ 21
- 13
src/components/material.vue 查看文件

@@ -6,12 +6,12 @@
6 6
     <Button type="error" @click="reflsh">同步素材库</Button>
7 7
     <div class="box" v-if="model === 'get'">
8 8
       <div v-if="type === 'img'">
9
-        <div  v-for="(item,index) in img" :key="index" @click="emit(item,index)" :class="{checked:item.checked}">
9
+        <div  v-for="(item,index) in img" :key="index" @click="emit(item,index)" @dblclick="dbemit(item,index)" :class="{checked:item.checked}">
10 10
           <img :src="item.url" alt="">
11 11
         </div>
12 12
       </div>
13 13
       <div v-if="type === 'view'">
14
-        <div v-for="(item,index) in view" :key="index" @click="emit(item,index)" :class="{checked:item.checked}">
14
+        <div v-for="(item,index) in view" :key="index" @click="emit(item,index)" @dblclick="dbemit(item,index)" :class="{checked:item.checked}">
15 15
           <img :src="item.url" alt="">
16 16
           <p>{{item.text}}</p>
17 17
         </div>
@@ -69,11 +69,6 @@ export default {
69 69
     }
70 70
   },
71 71
   created () {
72
-    // let meta = document.createElement('meta')
73
-    // meta.name = 'referrer'
74
-    // meta.content = 'never'
75
-    // this.meta = meta
76
-    // document.getElementsByTagName('head')[0].appendChild(meta)
77 72
     if (this.type === 'img') {
78 73
       this.getImg({ type: 'image' }).then(() => {
79 74
         if (this.model === 'set') {
@@ -112,6 +107,24 @@ export default {
112 107
       }
113 108
       this.$emit('emit', item)
114 109
     },
110
+    dbemit (item, index) {
111
+      if (this.type === 'img') {
112
+        this.img.forEach((curr, ind) => {
113
+          curr.checked = false
114
+          if (index === ind) {
115
+            curr.checked = true
116
+          }
117
+        })
118
+      } else {
119
+        this.view.forEach((curr, ind) => {
120
+          curr.checked = false
121
+          if (index === ind) {
122
+            curr.checked = true
123
+          }
124
+        })
125
+      }
126
+      this.$emit('dbemit', item)
127
+    },
115 128
     handleView (url) {
116 129
       this.imgName = url
117 130
       this.visible = true
@@ -177,12 +190,7 @@ export default {
177 190
         this.isLoading = false
178 191
       })
179 192
     }
180
-  },
181
-  // beforeDestroy () {
182
-  //   if (this.meta) {
183
-  //     document.getElementsByTagName('head')[0].removeChild(this.meta)
184
-  //   }
185
-  // }
193
+  }
186 194
 }
187 195
 </script>
188 196
 

+ 25
- 11
src/components/menuForm.vue 查看文件

@@ -2,8 +2,10 @@
2 2
   <div class="box">
3 3
     <div class="form-item" v-if="menuConfig">
4 4
       <label for="name">菜单名称</label>
5
-      <Input placeholder="字数不超过4个汉字或8个字母" size="large" v-model="menuTitle" clearable @input="toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')" name="name" style="width: 300px"/>
6
-      <span class="error">{{toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')}}</span>
5
+      <Input v-if="!isSub" placeholder="字数不超过4个汉字或8个字母" size="large" v-model="menuTitle" clearable @input="toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')" name="name" style="width: 300px"/>
6
+      <span v-if="!isSub" class="error">{{toolClass.CutStr(menuTitle, 8, '字数不超过4个汉字或8个字母')}}</span>
7
+      <Input v-if="isSub" placeholder="字数不超过8个汉字或16个字母" size="large" v-model="menuTitle" clearable @input="toolClass.CutStr(menuTitle, 8, '字数不超过8个汉字或16个字母')" name="name" style="width: 300px"/>
8
+      <span v-if="isSub" class="error">{{toolClass.CutStr(menuTitle, 16, '字数不超过8个汉字或16个字母')}}</span>
7 9
     </div>
8 10
     <div class="form-item" v-if="hasContent"  v-show="!noRadio">
9 11
       <label for="name">菜单内容</label>
@@ -69,7 +71,7 @@
69 71
             </Upload>
70 72
           </div>
71 73
           <Modal width='800' v-model="showMaterial" @on-ok="checkImg" @on-cancel="closeImg">
72
-            <material v-if="showMaterial" :type='materialType' :model='model' @emit='setImg'></material>
74
+            <material v-if="showMaterial" :type='materialType' :model='model' @emit='setImg' @dbemit='dbsetImg'></material>
73 75
           </Modal>
74 76
           <div class="img-view">
75 77
             <img v-if="img.url" :src="img.url">
@@ -113,7 +115,7 @@ import { createNamespacedHelpers } from 'vuex'
113 115
 const { mapActions: mapMaterialActions } = createNamespacedHelpers('material')
114 116
 const { mapActions: mapMenuConfigActions } = createNamespacedHelpers('menuConfig')
115 117
 export default {
116
-  props: ['data', 'menuConfig', 'hasContent', 'hasDelete', 'noRadio', 'hasCancel', 'needCheckDestroy'],
118
+  props: ['data', 'menuConfig', 'hasContent', 'hasDelete', 'noRadio', 'hasCancel', 'needCheckDestroy', 'isSub'],
117 119
   data () {
118 120
     return {
119 121
       active: '文字',
@@ -173,7 +175,6 @@ export default {
173 175
     ...mapMaterialActions(['addImg']),
174 176
     ...mapMenuConfigActions(['Changed']),
175 177
     checkLink () {
176
-      console.log(111)
177 178
       if (!this.linkText) {
178 179
         this.$Message.warning('链接名称必填')
179 180
         return false
@@ -214,6 +215,11 @@ export default {
214 215
       this.imghc = img
215 216
       this.imghc.url = this.imghc.Url
216 217
     },
218
+    dbsetImg (img) {
219
+      this.imghc = img
220
+      this.imghc.url = this.imghc.Url
221
+      this.checkImg()
222
+    },
217 223
     checkImg () {
218 224
       this.img = this.imghc
219 225
       this.closeImg()
@@ -255,6 +261,10 @@ export default {
255 261
     setView (view) {
256 262
       this.viewhc = view
257 263
     },
264
+    dbsetView (view) {
265
+      this.viewhc = view
266
+      this.checkView()
267
+    },
258 268
     checkView () {
259 269
       this.view = this.viewhc
260 270
       this.closeView()
@@ -274,9 +284,16 @@ export default {
274 284
         if (!this.menuTitle) {
275 285
           this.$Message.warning('菜单名称必填')
276 286
           return false
277
-        } else if (this.toolClass.CutStr(this.menuTitle, 8, '字数不超过4个汉字或8个字母')) {
278
-          this.$Message.warning('菜单名称超过4个汉字或8个字母')
279
-          return false
287
+        } else if (!this.isSub) {
288
+          if (this.toolClass.CutStr(this.menuTitle, 8, '字数不超过4个汉字或8个字母')) {
289
+            this.$Message.warning('一级菜单名称超过4个汉字或8个字母')
290
+            return false
291
+          }
292
+        } else if (this.isSub) {
293
+          if (this.toolClass.CutStr(this.menuTitle, 16, '字数不超过8个汉字或16个字母')) {
294
+            this.$Message.warning('二级菜单名称超过8个汉字或16个字母')
295
+            return false
296
+          }
280 297
         }
281 298
         this.emitData.name = this.menuTitle
282 299
       }
@@ -289,7 +306,6 @@ export default {
289 306
           this.emitData.type = 'text'
290 307
           this.emitData.value = this.text
291 308
         } else if (this.active === '图片') {
292
-          console.log(this.img)
293 309
           if (!this.img.media_id) {
294 310
             this.$Message.warning('请选择素材')
295 311
             return false
@@ -305,7 +321,6 @@ export default {
305 321
           this.emitData.media_id = this.view.media_id
306 322
         }
307 323
       } else if (this.type === '跳转网页') {
308
-        console.log(111)
309 324
         if (this.errors.first('link')) {
310 325
           this.$Message.warning('链接格式不正确')
311 326
           return false
@@ -336,7 +351,6 @@ export default {
336 351
   },
337 352
   beforeUpdate () {
338 353
     if (this.needCheckDestroy) {
339
-      console.log('check')
340 354
       if (this.data) {
341 355
         if (this.menuConfig) {
342 356
           if (this.menuTitle !== this.data.name) {

+ 5
- 4
src/components/subMenu.vue 查看文件

@@ -24,13 +24,14 @@ export default {
24 24
 
25 25
 <style lang="scss" scoped>
26 26
 .menu-item {
27
-  display: flex;
28
-  justify-content: center;
29
-  align-items: center;
30
-  padding: 8px 0;
27
+  padding: 8px 2px;
31 28
   border-top: 1px solid #ccc;
32 29
   border-left: 1px solid #ccc;
33 30
   border-right: 1px solid #ccc;
31
+  text-align: center;
32
+  overflow: hidden;
33
+  white-space: nowrap;
34
+  text-overflow: ellipsis;
34 35
   &:hover {
35 36
     cursor: pointer;
36 37
   }

+ 29
- 1
src/pages/main/menuConfig/menuConfig.vue 查看文件

@@ -1,5 +1,8 @@
1 1
 <template>
2 2
   <div>
3
+    <div class="loading" v-if="isLoading">
4
+      <img width='80px' :src="loading" alt="">
5
+    </div>
3 6
     <div class="content">
4 7
       <div class='phone'>
5 8
         <div class='phone-head'>
@@ -25,7 +28,7 @@
25 28
       <div class="content-item">
26 29
         <transition name="fade">
27 30
           <div v-if="formActive" class="boxshadow">
28
-            <menuForm :data='chooseItem' :menuConfig='true' :hasContent='hasContent' :hasDelete='hasDelete' :needCheckDestroy='true' @emit='checkForm' @delMenu='delMenu'></menuForm>
31
+            <menuForm :data='chooseItem' :menuConfig='true' :hasContent='hasContent' :hasDelete='hasDelete' :needCheckDestroy='true' :isSub='(chooseTag.type === 2 || chooseTag.type === 3) ? true : false' @emit='checkForm' @delMenu='delMenu'></menuForm>
29 32
           </div>
30 33
         </transition>
31 34
       </div>
@@ -37,6 +40,7 @@
37 40
 </template>
38 41
 
39 42
 <script>
43
+import loading from '@/assets/loading.gif'
40 44
 import defultImg from '@/assets/bottomMsg.png'
41 45
 import bottomMenu from '@/components/bottomMenu.vue'
42 46
 import menuForm from '@/components/menuForm.vue'
@@ -45,6 +49,8 @@ const { mapState: mapMenuConfigState, mapActions: mapMenuConfigActions } = creat
45 49
 export default {
46 50
   data () {
47 51
     return {
52
+      loading,
53
+      isLoading: false,
48 54
       defultImg,
49 55
       chooseItem: {},
50 56
       chooseTag: {
@@ -211,10 +217,15 @@ export default {
211 217
           title: '警告',
212 218
           content: `<p style='font-size:16px;'>当前编辑的菜单未保存,若确认发布,当前未保存菜单不会生效,是否确认发布?<p>`,
213 219
           onOk: () => {
220
+            this.isLoading = true
214 221
             this.setWechatMenu().then(() => {
215 222
               this.$Message.success('发布成功')
216 223
               this.formActive = false
217 224
               this.init()
225
+              this.Changed(false)
226
+              this.isLoading = false
227
+            }).catch(() => {
228
+              this.isLoading = false
218 229
             })
219 230
           },
220 231
           onCancel: () => {
@@ -222,10 +233,15 @@ export default {
222 233
           }
223 234
         })
224 235
       } else {
236
+        this.isLoading = true
225 237
         this.setWechatMenu().then(() => {
226 238
           this.$Message.success('发布成功')
227 239
           this.formActive = false
228 240
           this.init()
241
+          this.Changed(false)
242
+          this.isLoading = false
243
+        }).catch(() => {
244
+          this.isLoading = false
229 245
         })
230 246
       }
231 247
     }
@@ -238,6 +254,18 @@ export default {
238 254
 </script>
239 255
 
240 256
 <style lang='scss' scoped>
257
+.loading {
258
+  width: 100%;
259
+  height: 100%;
260
+  position: absolute;
261
+  top: 0;
262
+  left: 0;
263
+  display: flex;
264
+  justify-content: center;
265
+  align-items: center;
266
+  z-index: 2;
267
+  background: rgba(0, 0, 0, 0.2);
268
+}
241 269
 .content {
242 270
   display: flex;
243 271
   .content-item {

+ 27
- 0
src/router/index.js 查看文件

@@ -42,6 +42,33 @@ router.beforeEach((to, from, next) => {
42 42
   if (to.name !== 'login' && !store.state.main.isBind) {
43 43
     // Message.warning('请先通知管理员绑定项目,再进行微信配置')
44 44
   }
45
+  if (to.name === 'management') {
46
+    if (store.state.main.meta) {
47
+      document.getElementsByTagName('head')[0].children.referrer.content = 'default'
48
+      store.state.main.meta.content = 'default'
49
+    } else {
50
+      let meta = document.createElement('meta')
51
+      meta.name = 'referrer'
52
+      meta.content = 'default'
53
+      document.getElementsByTagName('head')[0].appendChild(meta)
54
+      store.state.main.meta = meta
55
+    }
56
+  } else {
57
+    if (store.state.main.meta) {
58
+      document.getElementsByTagName('head')[0].children.referrer.content = 'never'
59
+    } else {
60
+      let meta = document.createElement('meta')
61
+      meta.name = 'referrer'
62
+      meta.content = 'never'
63
+      document.getElementsByTagName('head')[0].appendChild(meta)
64
+      store.state.main.meta = meta
65
+    }
66
+
67
+    // let meta = document.createElement('meta')
68
+    // meta.name = 'referrer'
69
+    // meta.content = 'never'
70
+    // store.state.main.meta = meta
71
+  }
45 72
   next()
46 73
 })
47 74
 

+ 9
- 1
src/store/main.js 查看文件

@@ -6,7 +6,8 @@ export default {
6 6
   state: {
7 7
     menuData: [],
8 8
     userInfo: {},
9
-    isBind: false
9
+    isBind: false,
10
+    meta: null
10 11
   },
11 12
   mutations: {
12 13
     updateMenu (state, data) {
@@ -18,6 +19,9 @@ export default {
18 19
     updateIsBind (state, data) {
19 20
       state.isBind = data
20 21
     },
22
+    updateMeta (state, data) {
23
+      state.meta = data
24
+    }
21 25
   },
22 26
   actions: {
23 27
     login (context, data) {
@@ -92,5 +96,9 @@ export default {
92 96
         }).catch(reject)
93 97
       })
94 98
     },
99
+    setMeta (context, data) {
100
+      context.commit('updateMeta', data)
101
+
102
+    }
95 103
   }
96 104
 }

+ 5
- 2
src/store/material.js 查看文件

@@ -104,11 +104,14 @@ export default {
104 104
         }).catch(reject)
105 105
       })
106 106
     },
107
-    reflshImg (context) {
107
+    reflshImg (context, data) {
108 108
       console.log(context)
109 109
       return new Promise((resolve, reject) => {
110 110
         ajax({
111
-          ...api.material.reflshImg
111
+          ...api.material.reflshImg,
112
+          urlData: {
113
+            ...data
114
+          }
112 115
         }).then(() => {
113 116
           resolve()
114 117
         }).catch(reject)

+ 6
- 6
src/store/menuConfig.js 查看文件

@@ -1,7 +1,7 @@
1 1
 import ajax from '../util/ajax'
2 2
 import api from '../util/api'
3 3
 import Vue from 'vue'
4
-import { Message } from 'iview'
4
+// import { Message } from 'iview'
5 5
 
6 6
 const loop = (data, setTrue) => {
7 7
   let returnData = {}
@@ -202,11 +202,11 @@ export default {
202 202
     },
203 203
     setWechatMenu (context) {
204 204
       return new Promise((resolve, reject) => {
205
-        if (context.state.menuJson.button.length <= 0) {
206
-          Message.warning('您未添加任何菜单,请先添加菜单后再进行发布')
207
-          reject()
208
-          return false
209
-        }
205
+        // if (context.state.menuJson.button.length <= 0) {
206
+        //   Message.warning('您未添加任何菜单,请先添加菜单后再进行发布')
207
+        //   reject()
208
+        //   return false
209
+        // }
210 210
         let submitData = {
211 211
           menu: {}
212 212
         }