Browse Source

自定义菜单:页面逻辑,接口

zhengchengwu 5 years ago
parent
commit
7ad243a459

+ 1 - 3
config/index.js View File

17
     // can be overwritten by process.env.HOST
17
     // can be overwritten by process.env.HOST
18
     // if you want dev by ip, please set host: '0.0.0.0'
18
     // if you want dev by ip, please set host: '0.0.0.0'
19
 
19
 
20
-    // host: 'jk.kuyicloud.com',
21
-
22
-
20
+    host: 'test1.sgjyun.com',
23
     port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
21
     port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
24
     autoOpenBrowser: true,
22
     autoOpenBrowser: true,
25
     errorOverlay: true,
23
     errorOverlay: true,

+ 8 - 1
src/api/mpwechat/mpwechat.js View File

20
     method: 'get',
20
     method: 'get',
21
   })
21
   })
22
 }
22
 }
23
-  
23
+
24
+export function SaveMenus(data) {
25
+  return request({
26
+    url: '/api/mpwechat/savemenus',
27
+    method: 'put',
28
+    data:data,
29
+  })
30
+}

+ 1 - 1
src/scrm_pages/weixinmp/authorization.vue View File

110
         authorizer_qrcode_url: "",
110
         authorizer_qrcode_url: "",
111
         created_time: "",
111
         created_time: "",
112
         updated_time: "",
112
         updated_time: "",
113
-        authorizer_status: 1
113
+        authorizer_status: 0
114
       }
114
       }
115
     };
115
     };
116
   },
116
   },

+ 337 - 26
src/scrm_pages/weixinmp/menus.vue View File

2
   <div class="main-contain">
2
   <div class="main-contain">
3
     <div class="position">
3
     <div class="position">
4
       <bread-crumb :crumbs="crumbs"></bread-crumb>
4
       <bread-crumb :crumbs="crumbs"></bread-crumb>
5
-      <el-col :span="5" style="text-align: right;">
6
-        <el-button type="primary" size="small" icon="el-icon-upload">保存并发布</el-button>
7
-        <el-button  type="danger" size="small" icon="el-icon-delete" >停用菜单</el-button>
5
+      <el-col :span="5" style="text-align: right;" v-show="initButtons">
6
+        <el-button type="primary" size="small" :disabled="subload" icon="el-icon-upload" @click="submitSave">保存并发布</el-button>
7
+        <el-button  type="danger" size="small" :disabled="subload" icon="el-icon-delete" >停用菜单</el-button>
8
       </el-col>
8
       </el-col>
9
     </div>
9
     </div>
10
     <div class="app-container" id="winxin-menus-box">
10
     <div class="app-container" id="winxin-menus-box">
11
       <div class="menu_tips clearfix">
11
       <div class="menu_tips clearfix">
12
           <span class="ico_menu_tips fl"></span>  
12
           <span class="ico_menu_tips fl"></span>  
13
-          <div class="menu_tips_txt fl">
13
+          <div class="menu_tips_txt fl" v-show="initButtons">
14
               <p>菜单编辑中</p>
14
               <p>菜单编辑中</p>
15
               <p>菜单不会即时发布,请确定菜单编辑完成后点击“保存并发布”同步到手机,若停用菜单,点击“停用菜单”</p>
15
               <p>菜单不会即时发布,请确定菜单编辑完成后点击“保存并发布”同步到手机,若停用菜单,点击“停用菜单”</p>
16
           </div>
16
           </div>
17
+          <div class="menu_tips_txt fl" v-show="!initButtons">
18
+              <p>未认证的订阅号没有自定义菜单接口权限,无法编辑菜单。</p>
19
+          </div>
17
       </div>
20
       </div>
18
-      <div class="menu_setting_area clearfix">
21
+      <div class="menu_setting_area clearfix" v-loading='subload' element-loading-text="正在保存..." v-show="initButtons">
19
           <div class="menu_preview_area fl">
22
           <div class="menu_preview_area fl">
20
               <div class="mobile_menu_preview">
23
               <div class="mobile_menu_preview">
21
                   <div class="mobile_hd">{{authData.authorizer_nick_name}}</div>
24
                   <div class="mobile_hd">{{authData.authorizer_nick_name}}</div>
30
                                 </li> 
33
                                 </li> 
31
 
34
 
32
                                 <li class="jslevel2 jsAddSubMenu" v-show="childrenNode(menu.sub_button).length<5"> 
35
                                 <li class="jslevel2 jsAddSubMenu" v-show="childrenNode(menu.sub_button).length<5"> 
33
-                                  <a href="javascript:void(0);" class="jsSubView"> <span class="sub_pre_menu_inner "> <i class="icon14_menu_add">+</i> </span> </a> 
36
+                                  <a href="javascript:void(0);" class="jsSubView" @click="addItem(mi)"> <span class="sub_pre_menu_inner "> <i class="icon14_menu_add">+</i> </span> </a> 
34
                                 </li>
37
                                 </li>
35
                               </ul>
38
                               </ul>
36
                                 <i class="arrow arrow_out"></i> 
39
                                 <i class="arrow arrow_out"></i> 
39
                         </li>
42
                         </li>
40
 
43
 
41
                           <li class="jsAddMenu pre_menu_li" v-show="menus.button.length<3">
44
                           <li class="jsAddMenu pre_menu_li" v-show="menus.button.length<3">
42
-                              <a href="javascript:void(0);" class="pre_menu_link">
45
+                              <a href="javascript:void(0);" class="pre_menu_link" @click="addItem(-1)">
43
                                   <i class="icon_menu_dot "></i>
46
                                   <i class="icon_menu_dot "></i>
44
                                   <span class="js_l1Title_">
47
                                   <span class="js_l1Title_">
45
                                       <i class="icon14_menu_add">+</i>
48
                                       <i class="icon14_menu_add">+</i>
46
                                   </span>
49
                                   </span>
47
                               </a>
50
                               </a>
48
-                              <div class="sub_pre_menu_box">
51
+                              <!-- <div class="sub_pre_menu_box">
49
                                   <ul class="sub_pre_menu_list">
52
                                   <ul class="sub_pre_menu_list">
50
                                       <li class="jslevel2 jsAddSubMenu">
53
                                       <li class="jslevel2 jsAddSubMenu">
51
                                           <a href="javascript:void(0);" class="jsSubView">
54
                                           <a href="javascript:void(0);" class="jsSubView">
57
                                   </ul>
60
                                   </ul>
58
                                   <i class="arrow arrow_out"></i>
61
                                   <i class="arrow arrow_out"></i>
59
                                   <i class="arrow arrow_in"></i>
62
                                   <i class="arrow arrow_in"></i>
60
-                              </div>
63
+                              </div> -->
61
                           </li>
64
                           </li>
62
 
65
 
63
                       </ul>
66
                       </ul>
69
           <div class="menu_form_area fl" v-show="currentPatient>=0&&currentMenu">
72
           <div class="menu_form_area fl" v-show="currentPatient>=0&&currentMenu">
70
               <div class="menu_form_inner">
73
               <div class="menu_form_inner">
71
                   <h2 class="menu_form_tit clearfix">
74
                   <h2 class="menu_form_tit clearfix">
72
-                      <span class="delate fr delete_menu">{{deleteButtonName()}}</span>
75
+                      <span class="delate fr delete_menu" @click="deleteButtonItem">{{deleteButtonName()}}</span>
73
                       <span class="global_info">{{showMenuName()}}</span>
76
                       <span class="global_info">{{showMenuName()}}</span>
74
                   </h2>
77
                   </h2>
75
                   <div class="menu_form_item">
78
                   <div class="menu_form_item">
78
                       <span class="tips" id="tips" v-show="!menuNameError">{{menuNameTip()}}</span>
81
                       <span class="tips" id="tips" v-show="!menuNameError">{{menuNameTip()}}</span>
79
                       <span class="tips" id="errinfo" v-show="menuNameError" style="color: #f00;">{{menuNameTip()}}</span>
82
                       <span class="tips" id="errinfo" v-show="menuNameError" style="color: #f00;">{{menuNameTip()}}</span>
80
                   </div>
83
                   </div>
81
-                  <div class="menu_form_item menu_more_info" v-show="currentMenu&&!currentMenu.sub_button">
84
+                  <div class="menu_form_item menu_more_info" v-show="typeof(currentMenu.sub_button) == 'undefined' || !currentMenu.sub_button || currentMenu.sub_button.length==0">
82
                       <div class="menu_form__nav clearfix">
85
                       <div class="menu_form__nav clearfix">
83
                           <label for="" class="tit">菜单内容</label>
86
                           <label for="" class="tit">菜单内容</label>
84
-                          <el-radio-group v-model="menuType" class="radio_item">
87
+                          <el-radio-group v-model="menuType" class="radio_item" @change="changeMenuType">
85
                             <el-radio v-for="(menu, index) in menuTypeOptions" :key="index" :label="menu.id" :value="menu.id">{{menu.name}}</el-radio>
88
                             <el-radio v-for="(menu, index) in menuTypeOptions" :key="index" :label="menu.id" :value="menu.id">{{menu.name}}</el-radio>
86
                           </el-radio-group>
89
                           </el-radio-group>
87
                       </div>
90
                       </div>
97
                             <span class="tips" id="acterrinfo" v-if="!messageError" >&nbsp;&nbsp;{{menuMessageTip}}</span>
100
                             <span class="tips" id="acterrinfo" v-if="!messageError" >&nbsp;&nbsp;{{menuMessageTip}}</span>
98
                             <span class="tips" id="acterrinfo" v-if="messageError"  style="color: #f00;">&nbsp;&nbsp;{{menuMessageTip}}</span>
101
                             <span class="tips" id="acterrinfo" v-if="messageError"  style="color: #f00;">&nbsp;&nbsp;{{menuMessageTip}}</span>
99
                         </div>
102
                         </div>
100
-                        <div class="inner jump_page " v-show="menuType==2">
103
+                        <div class="inner  jump_page" v-show="menuType==2">
101
                             <span class="tips_size">订阅者点击该子菜单会跳到以下链接</span>
104
                             <span class="tips_size">订阅者点击该子菜单会跳到以下链接</span>
102
                             <div>
105
                             <div>
103
                               <label for="" class="address">页面地址:</label>
106
                               <label for="" class="address">页面地址:</label>
104
                               <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.url" :title="currentMenu.url"/>
107
                               <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.url" :title="currentMenu.url"/>
105
                               <el-button type="primary" size="small" icon="el-icon-menu">选择地址</el-button>
108
                               <el-button type="primary" size="small" icon="el-icon-menu">选择地址</el-button>
109
+                              <span class="mitips" v-if="urlError"  style="color: #f00;">请填写url</span>
106
                             </div>
110
                             </div>
107
                         </div>
111
                         </div>
108
                         
112
                         
110
                             <span class="tips_size">订阅者点击该子菜单会跳到以下小程序</span>
114
                             <span class="tips_size">订阅者点击该子菜单会跳到以下小程序</span>
111
                             <div class="miniprogram-item">
115
                             <div class="miniprogram-item">
112
                               <label for="" class="address">APPID:</label>
116
                               <label for="" class="address">APPID:</label>
113
-                              <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.appid" :title="currentMenu.appid"/>
114
-                              选择地址
117
+                              <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.appid" :title="currentMenu.appid" placeholder="请确保小程序与公众号关联,填写小程序"/>
118
+                              <a href="https://weixiao.qq.com/notice/view?mid=0&cid=2&id=274" target="_blank" rel="noopener noreferrer">如何获取</a>
119
+                              <span class="mitips" v-if="appidError"  style="color: #f00;">请填写appid</span>
115
                             </div>
120
                             </div>
116
                             <div class="miniprogram-item">
121
                             <div class="miniprogram-item">
117
                               <label for="" class="address">页面:</label>
122
                               <label for="" class="address">页面:</label>
118
-                              <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.pagepath" :title="currentMenu.pagepath"/>
119
-                              选择地址
123
+                              <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.pagepath" :title="currentMenu.pagepath" placeholder="请填写跳转页面的小程序访问路径"/>
124
+                              <a href="https://weixiao.qq.com/notice/view?mid=0&cid=2&id=275" target="_blank" rel="noopener noreferrer">填写指引</a>
125
+                              <span class="mitips" v-if="pagepathError" style="color: #f00;">请填写pagepath</span>
120
                             </div>
126
                             </div>
121
                             <div class="miniprogram-item">
127
                             <div class="miniprogram-item">
122
                               <label for="" class="address">备用页面:</label>
128
                               <label for="" class="address">备用页面:</label>
123
                               <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.url" :title="currentMenu.url"/>
129
                               <input type="text" id="view_menu_url" class="address_input " v-model="currentMenu.url" :title="currentMenu.url"/>
124
-                              <span style="display:block;left:84px;position:relative;margin-top:10px;">旧版微信客户端不支持小程序,用户点击菜单时会打开该网页</span>
130
+                              <span class="mitips" v-if="urlError"  style="color: #f00;">请填写url</span>
131
+                              <span class="mitips" >旧版微信客户端不支持小程序,用户点击菜单时会打开该网页</span>
125
                             </div>
132
                             </div>
126
                         </div>
133
                         </div>
127
                       </div>
134
                       </div>
135
 
142
 
136
 <script>
143
 <script>
137
 import BreadCrumb from "../components/bread-crumb";
144
 import BreadCrumb from "../components/bread-crumb";
138
-import {GetAuthorizationInfo,GetMenus} from "@/api/mpwechat/mpwechat";
145
+import {GetAuthorizationInfo,GetMenus,SaveMenus} from "@/api/mpwechat/mpwechat";
139
 export default {
146
 export default {
140
   name: "menus",
147
   name: "menus",
141
   components: {
148
   components: {
153
         {id:3, name:' 跳转小程序'},
160
         {id:3, name:' 跳转小程序'},
154
       ],
161
       ],
155
       initButtons:false,
162
       initButtons:false,
163
+      subload:false,
156
       menus:{button:[]},
164
       menus:{button:[]},
157
       currentMenu:{
165
       currentMenu:{
158
         type:'',
166
         type:'',
160
         url:'',
168
         url:'',
161
         appid:'',
169
         appid:'',
162
         pagepath:'',
170
         pagepath:'',
163
-        key:'',
171
+        key:'',//key规则:V_[number]_click;VC_[number]_click
164
         message:'',
172
         message:'',
165
         sub_button:[],
173
         sub_button:[],
166
         media_id:'',
174
         media_id:'',
170
       currentChild:-1,
178
       currentChild:-1,
171
       menuNameError:false,
179
       menuNameError:false,
172
       messageError:false,
180
       messageError:false,
181
+      urlError:false,
182
+      appidError:false,
183
+      pagepathError:false,
173
       menuMessageTip:'还可以输入 600 字',
184
       menuMessageTip:'还可以输入 600 字',
185
+      pclick:0,
186
+      cclick:0,
174
       authData: {
187
       authData: {
175
         id: 0,
188
         id: 0,
176
         user_org_id: 0,
189
         user_org_id: 0,
189
         authorizer_qrcode_url: "",
202
         authorizer_qrcode_url: "",
190
         created_time: "",
203
         created_time: "",
191
         updated_time: "",
204
         updated_time: "",
192
-        authorizer_status: 1
205
+        authorizer_status: 0
193
       }
206
       }
194
     };
207
     };
195
   },
208
   },
201
           if(res.data.authorization) {
214
           if(res.data.authorization) {
202
             this.authData = res.data.authorization;
215
             this.authData = res.data.authorization;
203
             if (this.authData.authorizer_status != 1) {
216
             if (this.authData.authorizer_status != 1) {
204
-              this.$message.error("公众号未授权给平台");
217
+              this.$message.error("公众号未授权");
205
               this.$router.push({path:"/weixinmp/authorization"})
218
               this.$router.push({path:"/weixinmp/authorization"})
206
               return false;
219
               return false;
207
-            }else {
220
+            }else if (this.authData.authorizer_verify_type_info>=0 || this.authData.authorizer_service_type_info==2) {
208
               this.initButtons = true;
221
               this.initButtons = true;
209
             }
222
             }
223
+          }else {
224
+              this.$message.error("公众号未授权");
225
+              this.$router.push({path:"/weixinmp/authorization"})
210
           }
226
           }
211
         }else {
227
         }else {
212
           this.$message.error(res.msg);
228
           this.$message.error(res.msg);
213
         }
229
         }
214
       }).catch(e=>{});
230
       }).catch(e=>{});
215
     },
231
     },
232
+    submitSave:function () {
233
+        this.subload = true;
234
+        var res = this.checkMenus();
235
+        if (!res) {
236
+          this.$message.error("保存失败");
237
+          this.subload = false;
238
+          return false;
239
+        }
240
+        SaveMenus(this.menus).then(response=>{
241
+          var res = response.data;
242
+          if (res.state===1) {
243
+            this.$message.success("保存成功")
244
+          }else {
245
+            this.$message.error(res.msg);
246
+          }
247
+          this.subload = false;
248
+        }).catch(e=>{
249
+          this.subload = false;
250
+        });
251
+
252
+    },
253
+    addItem:function(mi){
254
+       var menu={type:'click',name:'',url:'',appid:'',pagepath:'',key:'',message:'',sub_button:null,media_id:''};
255
+       if (mi>-1) {
256
+         this.cclick += 1;
257
+          menu.key = 'VC_' + this.cclick + "_click";
258
+          menu.name ='子菜单名称';
259
+          if(!this.menus.button[mi].sub_button) {
260
+            this.menus.button[mi].sub_button = [];
261
+          }
262
+          this.menus.button[mi].sub_button.push(menu);
263
+          var sblen = this.menus.button[mi].sub_button.length;
264
+          this.selectItem(mi, sblen-1, menu);
265
+       }else {
266
+         this.pclick += 1;
267
+          menu.key = 'V_' + this.pclick + "_click";
268
+          menu.name ='菜单名称';
269
+          if (!this.menus.button) {
270
+            this.menus.button = [];
271
+          }
272
+          this.menus.button.push(menu);
273
+          var len = this.menus.button.length;
274
+          this.selectItem(len-1, -1, menu);
275
+       }
276
+    },
277
+    deleteButtonItem:function(){
278
+      this.$confirm('删除后该菜单下设置的内容将被删除', '删除提示', {
279
+        dangerouslyUseHTMLString:true,
280
+        confirmButtonText: '确定',
281
+        cancelButtonText: '取消',
282
+        type: 'warning'
283
+      }).then(() => {
284
+        if (this.currentPatient>=0&&this.currentChild>=0) {
285
+          this.menus.button[this.currentPatient].sub_button.splice(this.currentChild, 1);
286
+          var sblen = this.menus.button[this.currentPatient].sub_button.length;
287
+          if(sblen>0) {
288
+            this.currentChild = sblen-1;
289
+            this.selectItem(this.currentPatient, this.currentChild,this.menus.button[this.currentPatient].sub_button[this.currentChild]);
290
+          }else {
291
+            this.menus.button[this.currentPatient].sub_button = null;
292
+            this.selectItem(this.currentPatient,-1,this.menus.button[this.currentPatient]);
293
+          }
294
+        }else if (this.currentPatient>=0) {
295
+          this.menus.button.splice(this.currentPatient, 1);
296
+          var blen = this.menus.buttonlength;
297
+          if(blen>0) {
298
+            this.currentPatient = blen-1;
299
+            this.selectItem(this.currentPatient, -1,this.menus.button[this.currentPatient]);
300
+          }else {
301
+            this.currentPatient = -1;
302
+            this.currentMenu={
303
+              type:'',
304
+              name:'',
305
+              url:'',
306
+              appid:'',
307
+              pagepath:'',
308
+              key:'',
309
+              message:'',
310
+              sub_button:[],
311
+              media_id:'',
312
+            };
313
+          }
314
+        }
315
+      }).catch(() => {
316
+      });
317
+    },
216
     GetMenus:function(){
318
     GetMenus:function(){
217
       GetMenus().then(response=>{
319
       GetMenus().then(response=>{
218
         var res = response.data;
320
         var res = response.data;
219
         if (res.state == 1) {
321
         if (res.state == 1) {
220
           if (res.data.menus){
322
           if (res.data.menus){
221
             this.menus = res.data.menus;
323
             this.menus = res.data.menus;
324
+            for (const index in this.menus.button) {
325
+              var button = this.menus.button[index];
326
+              if(typeof(button.key) !='undefined' && button.key) {
327
+                var keys = button.key.split("_")
328
+                if (typeof(keys[1]) !='undefined') {
329
+                  var num = parseInt(keys[1]);
330
+                  this.pclick = !isNaN(num) && num>this.pclick?num:this.pclick;
331
+                }
332
+              }
333
+              if(typeof(button.sub_button) !='undefined' && button.sub_button) {
334
+                for (const chilid in button.sub_button) {
335
+                  var cbutton = button.sub_button[chilid];
336
+                  if(typeof(cbutton.key) !='undefined' && cbutton.key) {
337
+                    var keys = cbutton.key.split("_")
338
+                    if (typeof(keys[1]) !='undefined') {
339
+                      var num = parseInt(keys[1]);
340
+                      this.cclick = !isNaN(num) && num>this.cclick?num:this.cclick;
341
+                    }
342
+                  }
343
+                }
344
+              }
345
+            }
222
           }
346
           }
223
         }else {
347
         }else {
224
           this.$message.error(res.msg);
348
           this.$message.error(res.msg);
243
           break;
367
           break;
244
       }
368
       }
245
     },
369
     },
370
+    changeMenuType:function(value){
371
+      switch (value) {
372
+        case 1:
373
+          this.currentMenu.type = 'click';
374
+          break;
375
+        case 2:
376
+          this.currentMenu.type = 'view';
377
+          break;
378
+        case 3:
379
+          this.currentMenu.type = 'miniprogram';
380
+          break;
381
+        default:
382
+          break;
383
+      }
384
+    },
246
     selectItem:function(mi, ni, node){
385
     selectItem:function(mi, ni, node){
247
       this.currentPatient = mi;
386
       this.currentPatient = mi;
248
       this.currentChild = ni;
387
       this.currentChild = ni;
388
+      this.currentMenu={
389
+        type:'',
390
+        name:'',
391
+        url:'',
392
+        appid:'',
393
+        pagepath:'',
394
+        key:'',
395
+        message:'',
396
+        sub_button:[],
397
+        media_id:'',
398
+      };
249
       for (const key in node) {
399
       for (const key in node) {
250
         this.currentMenu[key] = node[key]; 
400
         this.currentMenu[key] = node[key]; 
251
       }
401
       }
279
         return '';
429
         return '';
280
       }
430
       }
281
     },
431
     },
282
-    
283
     ChcekMenuNameError:function(){
432
     ChcekMenuNameError:function(){
284
       if (this.currentPatient>=0&&this.currentChild>=0) {
433
       if (this.currentPatient>=0&&this.currentChild>=0) {
285
         var res = /^[a-zA-Z0-9]{1,16}$/.test((this.currentMenu.name  + '').replace(/[\u4e00-\u9fa5]/g, 'aa'));
434
         var res = /^[a-zA-Z0-9]{1,16}$/.test((this.currentMenu.name  + '').replace(/[\u4e00-\u9fa5]/g, 'aa'));
290
       } else {
439
       } else {
291
         this.menuNameError = false;
440
         this.menuNameError = false;
292
       }
441
       }
293
-    }
442
+      return this.menuNameError;
443
+    },
444
+    CheckUrlError:function(){
445
+      if (this.currentMenu.url.length==0) {
446
+        this.urlError = true;
447
+      }else {
448
+        this.urlError = false;
449
+      }
450
+      return this.urlError;
451
+    },
452
+    CheckAppidError:function(){
453
+      if (this.currentMenu.appid.length==0) {
454
+        this.appidError = true;
455
+      }else {
456
+        this.appidError = false;
457
+      }
458
+      return this.appidError;
459
+    },
460
+    CheckPagePathError:function(){
461
+      if (this.currentMenu.pagepath.length==0) {
462
+        this.pagepathError = true;
463
+      }else {
464
+        this.pagepathError = false;
465
+      }
466
+      return this.pagepathError;
467
+    },
468
+    CheckMessageError:function(){
469
+      var len = $.trim(this.currentMenu.message+'').length; 
470
+      var mt = 600-len;
471
+      if ( mt < 0) {
472
+        this.messageError = true;
473
+      }else {
474
+        this.messageError = false;
475
+      }
476
+      return this.messageError;
477
+    },
478
+    checkMenus:function(){
479
+      let p = this.currentPatient;
480
+      let c = this.currentChild;
481
+      for (const parent in this.menus.button) {
482
+        if (this.menus.button[parent].sub_button && this.menus.button[parent].sub_button.length>0) {
483
+          let subs = this.menus.button[parent].sub_button;
484
+          for (const child in subs) {
485
+            this.selectItem(parent, child, subs[child]);
486
+            if (this.ChcekMenuNameError()) {
487
+              return false;
488
+            }
489
+            if (subs[child].type == 'click') {
490
+              if (this.CheckMessageError()) {
491
+                return false;
492
+              }
493
+            }
494
+            if (subs[child].type == 'view') {
495
+              if (this.CheckUrlError()) {
496
+                return false;
497
+              }
498
+            }
499
+            if (subs[child].type == 'miniprogram') {
500
+              if (this.CheckUrlError()) {
501
+                return false;
502
+              }
503
+              if (this.CheckAppidError()) {
504
+                return false;
505
+              }
506
+              if (this.CheckPagePathError()) {
507
+                return false;
508
+              }
509
+            }
510
+          }
511
+        }else {
512
+          this.selectItem(parent, -1, this.menus.button[parent]);
513
+          var res = this.ChcekMenuNameError();
514
+          if (res) {
515
+            return false;
516
+          }
517
+          if (this.menus.button[parent].type == 'click') {
518
+            if (this.CheckMessageError()) {
519
+              return false;
520
+            }
521
+          }
522
+          if (this.menus.button[parent].type == 'view') {
523
+            if (this.CheckUrlError()) {
524
+              return false;
525
+            }
526
+          }
527
+          if (this.menus.button[parent].type == 'miniprogram') {
528
+            if (this.CheckUrlError()) {
529
+              return false;
530
+            }
531
+            if (this.CheckAppidError()) {
532
+              return false;
533
+            }
534
+            if (this.CheckPagePathError()) {
535
+              return false;
536
+            }
537
+          }
538
+        }
539
+      }
540
+      if (p>-1&&c>-1) {
541
+        this.selectItem(p, c, this.menus.button[p].sub_button[c]);
542
+      }else if(p>-1) {
543
+        this.selectItem(p, -1, this.menus.button[p]);
544
+      }
545
+      return true;
546
+    },
294
   },
547
   },
295
   created() {
548
   created() {
296
     this.GetAuthorizationInfo();
549
     this.GetAuthorizationInfo();
304
       }
557
       }
305
     },
558
     },
306
     'currentMenu.name':function(){
559
     'currentMenu.name':function(){
307
-      this.ChcekMenuNameError();
560
+      var res = this.ChcekMenuNameError();
561
+      if (!res) { //如果当前的菜单名称没有错
562
+        if (this.currentPatient>=0&&this.currentChild>=0) {
563
+          this.menus.button[this.currentPatient].sub_button[this.currentChild].name = this.currentMenu.name;
564
+        } else if (this.currentPatient>=0){
565
+          this.menus.button[this.currentPatient].name = this.currentMenu.name;
566
+        }
567
+      }
568
+    },  
569
+    'currentMenu.type':function(){
570
+      if (this.currentPatient>=0&&this.currentChild>=0) {
571
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].type = this.currentMenu.type;
572
+        if (this.currentMenu.type == 'click' && this.currentMenu.key.length==0) {
573
+          this.cclick += 1;
574
+          var key = 'VC_' + this.cclick + "_click";
575
+          this.currentMenu.key = key;
576
+          this.menus.button[this.currentPatient].sub_button[this.currentChild]['key'] = key;
577
+        }
578
+      } else if (this.currentPatient>=0){
579
+        this.menus.button[this.currentPatient].type = this.currentMenu.type;
580
+        if (this.currentMenu.type == 'click' && this.currentMenu.key.length==0) {
581
+          this.pclick += 1;
582
+          var key = 'V_' + this.cclick + "_click";
583
+          this.currentMenu.key = key;
584
+          this.menus.button[this.currentPatient]['key'] = key;
585
+        }
586
+      }
587
+    },  
588
+    'currentMenu.url':function(){
589
+      if (this.currentPatient>=0&&this.currentChild>=0) {
590
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].url = this.currentMenu.url;
591
+      } else if (this.currentPatient>=0){
592
+        this.menus.button[this.currentPatient].url = this.currentMenu.url;
593
+      }
594
+      this.CheckUrlError();
595
+    },  
596
+    'currentMenu.appid':function(){
597
+      if (this.currentPatient>=0&&this.currentChild>=0) {
598
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].appid = this.currentMenu.appid;
599
+      } else if (this.currentPatient>=0){
600
+        this.menus.button[this.currentPatient].appid = this.currentMenu.appid;
601
+      }
602
+      this.CheckAppidError();
603
+    },  
604
+    'currentMenu.pagepath':function(){
605
+      if (this.currentPatient>=0&&this.currentChild>=0) {
606
+        this.menus.button[this.currentPatient].sub_button[this.currentChild].pagepath = this.currentMenu.pagepath;
607
+      } else if (this.currentPatient>=0){
608
+        this.menus.button[this.currentPatient].pagepath = this.currentMenu.pagepath;
609
+      }
610
+      this.CheckPagePathError();
308
     },  
611
     },  
309
     'currentMenu.message':function(){
612
     'currentMenu.message':function(){
310
       var len = $.trim(this.currentMenu.message+'').length; 
613
       var len = $.trim(this.currentMenu.message+'').length; 
316
       }else {
619
       }else {
317
         this.messageError = false;
620
         this.messageError = false;
318
         this.menuMessageTip = '还可以输入 ' + mt + ' 字';
621
         this.menuMessageTip = '还可以输入 ' + mt + ' 字';
622
+        if (this.currentPatient>=0&&this.currentChild>=0) {
623
+          this.menus.button[this.currentPatient].sub_button[this.currentChild].message = this.currentMenu.message;
624
+        } else if (this.currentPatient>=0){
625
+          this.menus.button[this.currentPatient].message = this.currentMenu.message;
626
+        }
319
       }
627
       }
320
     },  
628
     },  
321
   },
629
   },
673
     color: #485b6d;
981
     color: #485b6d;
674
     vertical-align: middle;
982
     vertical-align: middle;
675
 }
983
 }
984
+#winxin-menus-box .menu_form__con .mitips {
985
+  display:block;left:84px;position:relative;margin-top:10px;color: #c0c8d4;
986
+}
676
 /*.app-container .cell.clearfix .time ul li {*/
987
 /*.app-container .cell.clearfix .time ul li {*/
677
 /*float: left;*/
988
 /*float: left;*/
678
 /*list-style: none;*/
989
 /*list-style: none;*/

+ 8 - 8
src/xt_permission.js View File

10
 
10
 
11
 router.beforeEach((to, from, next) => {
11
 router.beforeEach((to, from, next) => {
12
   // 线上注释
12
   // 线上注释
13
-  if (store.getters.permission_routers === undefined) {
14
-    store.dispatch('xt_GenerateRoutes', []).then(() => {
15
-      next()
16
-    })
17
-  } else {
18
-    next()
19
-  }
20
-  return
13
+  // if (store.getters.permission_routers === undefined) {
14
+  //   store.dispatch('xt_GenerateRoutes', []).then(() => {
15
+  //     next()
16
+  //   })
17
+  // } else {
18
+  //   next()
19
+  // }
20
+  // return
21
   // 线上注释
21
   // 线上注释
22
 
22
 
23
   NProgress.start()
23
   NProgress.start()