Showing
3 changed files
with
220 additions
and
4 deletions
| @@ -213,6 +213,24 @@ class Wechat extends Common{ | @@ -213,6 +213,24 @@ class Wechat extends Common{ | ||
| 213 | } | 213 | } |
| 214 | return - 1; | 214 | return - 1; |
| 215 | } | 215 | } |
| 216 | + public function updateweixinmenuappid() | ||
| 217 | + { | ||
| 218 | + $data = input('post.'); | ||
| 219 | + if (! empty($data['appid'])) { | ||
| 220 | + $retval = db('wx_menu')->update($data); | ||
| 221 | + return $retval; | ||
| 222 | + } | ||
| 223 | + return - 1; | ||
| 224 | + } | ||
| 225 | + public function updateweixinmenuliteurl() | ||
| 226 | + { | ||
| 227 | + $data = input('post.'); | ||
| 228 | + if (! empty($data['menu_event_url'])) { | ||
| 229 | + $retval = db('wx_menu')->update($data); | ||
| 230 | + return $retval; | ||
| 231 | + } | ||
| 232 | + return - 1; | ||
| 233 | + } | ||
| 216 | public function updateweixinmenuSort() | 234 | public function updateweixinmenuSort() |
| 217 | { | 235 | { |
| 218 | $menu_id_arr = input('menu_id_arr'); | 236 | $menu_id_arr = input('menu_id_arr'); |
| @@ -559,12 +577,32 @@ class Wechat extends Common{ | @@ -559,12 +577,32 @@ class Wechat extends Common{ | ||
| 559 | } | 577 | } |
| 560 | } | 578 | } |
| 561 | } else { | 579 | } else { |
| 562 | - if ($v['menu_event_type'] == 1) { | 580 | + |
| 581 | + /*if ($v['menu_event_type'] == 1) { | ||
| 563 | $menu_item['type'] = 'view'; | 582 | $menu_item['type'] = 'view'; |
| 564 | $menu_item['url'] = $v['menu_event_url']; | 583 | $menu_item['url'] = $v['menu_event_url']; |
| 565 | } else { | 584 | } else { |
| 566 | $menu_item['type'] = 'click'; | 585 | $menu_item['type'] = 'click'; |
| 567 | $menu_item['key'] = $v['menu_id']; | 586 | $menu_item['key'] = $v['menu_id']; |
| 587 | + }*/ | ||
| 588 | + switch ($v['menu_event_type']) { | ||
| 589 | + case '1': | ||
| 590 | + $menu_item['type'] = 'view'; | ||
| 591 | + $menu_item['url'] = $v['menu_event_url']; | ||
| 592 | + break; | ||
| 593 | + case '2': | ||
| 594 | + $menu_item['type'] = 'click'; | ||
| 595 | + $menu_item['key'] = $v['menu_id']; | ||
| 596 | + break; | ||
| 597 | + case '3': | ||
| 598 | + $menu_item['type'] = 'miniprogram'; | ||
| 599 | + $menu_item['appid'] = $v['appid']; | ||
| 600 | + $menu_item['url'] = "http://mp.weixin.qq.com"; | ||
| 601 | + $menu_item['pagepath'] = $v['menu_event_url']; | ||
| 602 | + break; | ||
| 603 | + default: | ||
| 604 | + # code... | ||
| 605 | + break; | ||
| 568 | } | 606 | } |
| 569 | } | 607 | } |
| 570 | $menu[] = $menu_item; | 608 | $menu[] = $menu_item; |
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | var AWM = "{:url('addweixinmenu')}" | 21 | var AWM = "{:url('addweixinmenu')}" |
| 22 | var UWMN = "{:url('updateweixinmenuname')}" | 22 | var UWMN = "{:url('updateweixinmenuname')}" |
| 23 | var UWMU = "{:url('updateweixinmenuurl')}" | 23 | var UWMU = "{:url('updateweixinmenuurl')}" |
| 24 | + var UWMUAPPID = "{:url('updateweixinmenuappid')}" | ||
| 24 | var DWM = "{:url('deleteweixinmenu')}" | 25 | var DWM = "{:url('deleteweixinmenu')}" |
| 25 | var UWMM = "{:url('updateweixinmenumessage')}" | 26 | var UWMM = "{:url('updateweixinmenumessage')}" |
| 26 | var GWMD = "{:url('getweixinmediadetail')}" | 27 | var GWMD = "{:url('getweixinmediadetail')}" |
| @@ -143,17 +144,20 @@ | @@ -143,17 +144,20 @@ | ||
| 143 | <div class="frm_control_group js_setGraphic" style="{if condition='$default_menu_info.child_count>0' }display:none;{/if}" > | 144 | <div class="frm_control_group js_setGraphic" style="{if condition='$default_menu_info.child_count>0' }display:none;{/if}" > |
| 144 | <label for="" class="frm_label"> <strong class="title js_menuContent">菜单内容</strong></label> | 145 | <label for="" class="frm_label"> <strong class="title js_menuContent">菜单内容</strong></label> |
| 145 | <div class="frm_controls frm_vertical_pt"> | 146 | <div class="frm_controls frm_vertical_pt"> |
| 146 | - <label class="frm_radio_label js_radio_sendMsg {if condition='$default_menu_info.menu_event_type == 2|| $default_menu_info.menu_event_type == 3'}selected{/if}"> | 147 | + <label class="frm_radio_label js_radio_sendMsg {if condition='$default_menu_info.menu_event_type == 2'}selected{/if}"> |
| 147 | <i class="icon_radio"></i> <span class="lbl_content">发送消息</span> | 148 | <i class="icon_radio"></i> <span class="lbl_content">发送消息</span> |
| 148 | </label> | 149 | </label> |
| 149 | <label class="frm_radio_label js_radio_url {if condition='$default_menu_info.menu_event_type == 1'}selected{/if}"> | 150 | <label class="frm_radio_label js_radio_url {if condition='$default_menu_info.menu_event_type == 1'}selected{/if}"> |
| 150 | <i class="icon_radio"></i> <span class="lbl_content">跳转网页</span> | 151 | <i class="icon_radio"></i> <span class="lbl_content">跳转网页</span> |
| 151 | </label> | 152 | </label> |
| 153 | + <label class="frm_radio_label js_radio_lite {if condition='$default_menu_info.menu_event_type == 3'}selected{/if}"> | ||
| 154 | + <i class="icon_radio"></i> <span class="lbl_content">跳转小程序</span> | ||
| 155 | + </label> | ||
| 152 | </div> | 156 | </div> |
| 153 | </div> | 157 | </div> |
| 154 | <div class="menu_content_container js_setGraphic" style="{if condition='$default_menu_info.child_count>0' }display:none;{/if}"> | 158 | <div class="menu_content_container js_setGraphic" style="{if condition='$default_menu_info.child_count>0' }display:none;{/if}"> |
| 155 | <!-- 发送消息 --> | 159 | <!-- 发送消息 --> |
| 156 | - <div class="menu_content send jsMain" id="edit" style="{if condition='$default_menu_info.menu_event_type == 2|| $default_menu_info.menu_event_type == 3' }display: block;{else/}display:none;{/if}"> | 160 | + <div class="menu_content send jsMain" id="edit" style="{if condition='$default_menu_info.menu_event_type == 2' }display: block;{else/}display:none;{/if}"> |
| 157 | <div class="msg_sender" id="editDiv"> | 161 | <div class="msg_sender" id="editDiv"> |
| 158 | <div class="msg_tab"> | 162 | <div class="msg_tab"> |
| 159 | <div class="tab_navs_panel"> | 163 | <div class="tab_navs_panel"> |
| @@ -244,6 +248,29 @@ | @@ -244,6 +248,29 @@ | ||
| 244 | </div> | 248 | </div> |
| 245 | </div> | 249 | </div> |
| 246 | </div> | 250 | </div> |
| 251 | + <!-- 跳转网页 --> | ||
| 252 | + <!-- 跳转小程序 --> | ||
| 253 | + <div class="menu_content lite jsMain" id="pagepath" style="{if condition='$default_menu_info.menu_event_type == 3' } display: block;{else/}display:none;{/if}"> | ||
| 254 | + <p class="menu_content_tips tips_global">订阅者点击该子菜单会跳到指定小程序</p> | ||
| 255 | + <div class="frm_control_group"> | ||
| 256 | + <label for="urltext" class="frm_label"><strong class="title">APPID</strong></label> | ||
| 257 | + <div class="frm_controls"> | ||
| 258 | + <span class="frm_input_box"> | ||
| 259 | + <input type="text" class="frm_input" id="urlappid" data-switch="url" value="{$default_menu_info.appid}" name="urlText" style="border: 0; box-shadow: none; padding: 0;"> | ||
| 260 | + </span> | ||
| 261 | + <p class="profile_link_msg_global menu_url mini_tips warn dn js_warn">请勿添加其他公众号的主页链接</p> | ||
| 262 | + </div> | ||
| 263 | + <br> | ||
| 264 | + <label for="urltext" class="frm_label"><strong class="title">小程序地址</strong></label> | ||
| 265 | + <div class="frm_controls"> | ||
| 266 | + <span class="frm_input_box"> | ||
| 267 | + <input type="text" class="frm_input" id="urlpath" data-switch="url" value="{$default_menu_info.menu_event_url}" name="urlText" style="border: 0; box-shadow: none; padding: 0;"> | ||
| 268 | + </span> | ||
| 269 | + <p class="profile_link_msg_global menu_url mini_tips warn dn js_warn">请勿添加其他公众号的主页链接</p> | ||
| 270 | + </div> | ||
| 271 | + </div> | ||
| 272 | + </div> | ||
| 273 | + <!-- 跳转小程序 --> | ||
| 247 | <div id="js_errTips" style="display: none;" class="msg_sender_msg mini_tips warn"></div> | 274 | <div id="js_errTips" style="display: none;" class="msg_sender_msg mini_tips warn"></div> |
| 248 | </div> | 275 | </div> |
| 249 | </div> | 276 | </div> |
| @@ -240,6 +240,36 @@ $(function() { | @@ -240,6 +240,36 @@ $(function() { | ||
| 240 | } | 240 | } |
| 241 | } | 241 | } |
| 242 | }); | 242 | }); |
| 243 | + | ||
| 244 | + // 修改小程序地址 | ||
| 245 | + $("#urlpath").blur(function(){ | ||
| 246 | + if(parseInt($(this).attr("data-flag")) == 1 &&$("#urlpath").val().length > 0){ | ||
| 247 | + var obj = getCurrentMenu(); | ||
| 248 | + var isUpdate = true;//是否更新 | ||
| 249 | + //没有变化,则做不修改操作 | ||
| 250 | + if(obj.attr("data-menu-eventurl") == $(this).val()){ | ||
| 251 | + isUpdate = false; | ||
| 252 | + } | ||
| 253 | + if(isUpdate){ | ||
| 254 | + updateWeixinMenuUrlLite(obj.attr("data-menuid"),$(this).val()); | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | + }); | ||
| 258 | + | ||
| 259 | + // 修改小程序地址 | ||
| 260 | + $("#urlappid").blur(function(){ | ||
| 261 | + if(parseInt($(this).attr("data-flag")) == 1 &&$("#urlappid").val().length > 0){ | ||
| 262 | + var obj = getCurrentMenu(); | ||
| 263 | + var isUpdate = true;//是否更新 | ||
| 264 | + //没有变化,则做不修改操作 | ||
| 265 | + if(obj.attr("data-menu-eventurl") == $(this).val()){ | ||
| 266 | + isUpdate = false; | ||
| 267 | + } | ||
| 268 | + if(isUpdate){ | ||
| 269 | + updateWeixinMenuAPPID(obj.attr("data-menuid"),$(this).val()); | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + }); | ||
| 243 | 273 | ||
| 244 | /** | 274 | /** |
| 245 | * 点击一级菜单弹出二级菜单 | 275 | * 点击一级菜单弹出二级菜单 |
| @@ -416,8 +446,10 @@ $(function() { | @@ -416,8 +446,10 @@ $(function() { | ||
| 416 | $(".js_radio_sendMsg").click(function(){ | 446 | $(".js_radio_sendMsg").click(function(){ |
| 417 | $(this).addClass("selected"); | 447 | $(this).addClass("selected"); |
| 418 | $(".js_radio_url").removeClass("selected"); | 448 | $(".js_radio_url").removeClass("selected"); |
| 449 | + $(".js_radio_lite").removeClass("selected"); | ||
| 419 | $("#edit").show(); | 450 | $("#edit").show(); |
| 420 | $("#url").hide(); | 451 | $("#url").hide(); |
| 452 | + $("#pagepath").hide(); | ||
| 421 | updateMenuType(2);//图文消息和链接如果都存在,则判断当前选中更新类型 | 453 | updateMenuType(2);//图文消息和链接如果都存在,则判断当前选中更新类型 |
| 422 | }); | 454 | }); |
| 423 | 455 | ||
| @@ -427,10 +459,25 @@ $(function() { | @@ -427,10 +459,25 @@ $(function() { | ||
| 427 | $(".js_radio_url").click(function(){ | 459 | $(".js_radio_url").click(function(){ |
| 428 | $(this).addClass("selected"); | 460 | $(this).addClass("selected"); |
| 429 | $(".js_radio_sendMsg").removeClass("selected"); | 461 | $(".js_radio_sendMsg").removeClass("selected"); |
| 462 | + $(".js_radio_lite").removeClass("selected"); | ||
| 430 | $("#edit").hide(); | 463 | $("#edit").hide(); |
| 464 | + $("#pagepath").hide(); | ||
| 431 | $("#url").show(); | 465 | $("#url").show(); |
| 432 | updateMenuType(1);//图文消息和链接如果都存在,则判断当前选中更新类型 | 466 | updateMenuType(1);//图文消息和链接如果都存在,则判断当前选中更新类型 |
| 433 | }); | 467 | }); |
| 468 | + | ||
| 469 | + /** | ||
| 470 | + * 右侧编辑["跳转小程序"]单选按钮 | ||
| 471 | + */ | ||
| 472 | + $(".js_radio_lite").click(function(){ | ||
| 473 | + $(this).addClass("selected"); | ||
| 474 | + $(".js_radio_url").removeClass("selected"); | ||
| 475 | + $(".js_radio_sendMsg").removeClass("selected"); | ||
| 476 | + $("#pagepath").show(); | ||
| 477 | + $("#edit").hide(); | ||
| 478 | + $("#url").hide(); | ||
| 479 | + updateMenuType(3);//图文消息和链接如果都存在,则判断当前选中更新类型 | ||
| 480 | + }); | ||
| 434 | 481 | ||
| 435 | /** | 482 | /** |
| 436 | * 右侧编辑["发送消息"]选择类型 目前只有一个类型:图文消息 | 483 | * 右侧编辑["发送消息"]选择类型 目前只有一个类型:图文消息 |
| @@ -518,7 +565,50 @@ $(function() { | @@ -518,7 +565,50 @@ $(function() { | ||
| 518 | $(this).attr("data-flag","1"); | 565 | $(this).attr("data-flag","1"); |
| 519 | } | 566 | } |
| 520 | }); | 567 | }); |
| 521 | - | 568 | + |
| 569 | + /** | ||
| 570 | + * 小程序网址验证,非空 | ||
| 571 | + */ | ||
| 572 | + $("#urlpath").keyup(function(){ | ||
| 573 | + | ||
| 574 | + if($(this).val().length>0){ | ||
| 575 | + if(!validateAppid($(this).val())){ | ||
| 576 | + $(this).parent().next().removeClass("dn"); | ||
| 577 | + $(this).parent().next().text("网址不正确"); | ||
| 578 | + $(this).attr("data-flag","-1"); | ||
| 579 | + IS_OK = false; | ||
| 580 | + }else{ | ||
| 581 | + $(this).parent().next().addClass("dn"); | ||
| 582 | + $(this).attr("data-flag","1"); | ||
| 583 | + IS_OK = true; | ||
| 584 | + } | ||
| 585 | + }else{ | ||
| 586 | + $(this).parent().next().addClass("dn"); | ||
| 587 | + $(this).attr("data-flag","1"); | ||
| 588 | + } | ||
| 589 | + }); | ||
| 590 | + | ||
| 591 | + /** | ||
| 592 | + * 小程序appid验证 非空 | ||
| 593 | + */ | ||
| 594 | + $("#urlappid").keyup(function(){ | ||
| 595 | + | ||
| 596 | + if($(this).val().length>0){ | ||
| 597 | + if(!validateAppid($(this).val())){ | ||
| 598 | + $(this).parent().next().removeClass("dn"); | ||
| 599 | + $(this).parent().next().text("APPID不正确"); | ||
| 600 | + $(this).attr("data-flag","-1"); | ||
| 601 | + IS_OK = false; | ||
| 602 | + }else{ | ||
| 603 | + $(this).parent().next().addClass("dn"); | ||
| 604 | + $(this).attr("data-flag","1"); | ||
| 605 | + IS_OK = true; | ||
| 606 | + } | ||
| 607 | + }else{ | ||
| 608 | + $(this).parent().next().addClass("dn"); | ||
| 609 | + $(this).attr("data-flag","1"); | ||
| 610 | + } | ||
| 611 | + }); | ||
| 522 | 612 | ||
| 523 | /** | 613 | /** |
| 524 | * 删除图文消息 | 614 | * 删除图文消息 |
| @@ -864,6 +954,52 @@ function updateWeixinMenuUrl(menu_id,menu_event_url){ | @@ -864,6 +954,52 @@ function updateWeixinMenuUrl(menu_id,menu_event_url){ | ||
| 864 | } | 954 | } |
| 865 | 955 | ||
| 866 | /** | 956 | /** |
| 957 | + * 修改小程序跳转地址及appid | ||
| 958 | + * @param menu_id | ||
| 959 | + * @param menu_event_url | ||
| 960 | + */ | ||
| 961 | +function updateWeixinMenuUrlLite(menu_id,menu_event_url){ | ||
| 962 | + $.ajax({ | ||
| 963 | + url : UWMU, | ||
| 964 | + type : "post", | ||
| 965 | + async : false, | ||
| 966 | + data : { "menu_id" : menu_id, "menu_event_url" : menu_event_url}, | ||
| 967 | + success : function(res){; | ||
| 968 | + if(res>0){ | ||
| 969 | + var obj = getCurrentMenu(); | ||
| 970 | + obj.attr("data-menu-eventurl",menu_event_url); | ||
| 971 | + showDialog("修改成功", 1); | ||
| 972 | + }else{ | ||
| 973 | + showDialog("修改失败", 0); | ||
| 974 | + } | ||
| 975 | + } | ||
| 976 | + }) | ||
| 977 | +} | ||
| 978 | + | ||
| 979 | +/** | ||
| 980 | + * 修改小程序跳转地址及appid | ||
| 981 | + * @param menu_id | ||
| 982 | + * @param menu_event_url | ||
| 983 | + */ | ||
| 984 | +function updateWeixinMenuAPPID(menu_id,menu_event_url){ | ||
| 985 | + $.ajax({ | ||
| 986 | + url : UWMUAPPID, | ||
| 987 | + type : "post", | ||
| 988 | + async : false, | ||
| 989 | + data : { "menu_id" : menu_id, "appid" : menu_event_url}, | ||
| 990 | + success : function(res){; | ||
| 991 | + if(res>0){ | ||
| 992 | + var obj = getCurrentMenu(); | ||
| 993 | + obj.attr("data-menu-eventurl",menu_event_url); | ||
| 994 | + showDialog("修改成功", 1); | ||
| 995 | + }else{ | ||
| 996 | + showDialog("修改失败", 0); | ||
| 997 | + } | ||
| 998 | + } | ||
| 999 | + }) | ||
| 1000 | +} | ||
| 1001 | + | ||
| 1002 | +/** | ||
| 867 | * 删除微信自定义菜单 | 1003 | * 删除微信自定义菜单 |
| 868 | * @param menuid 菜单id | 1004 | * @param menuid 菜单id |
| 869 | */ | 1005 | */ |
| @@ -1180,4 +1316,19 @@ function validateDomainName(str){ | @@ -1180,4 +1316,19 @@ function validateDomainName(str){ | ||
| 1180 | return true; | 1316 | return true; |
| 1181 | } | 1317 | } |
| 1182 | return false; | 1318 | return false; |
| 1319 | +} | ||
| 1320 | + | ||
| 1321 | +/** | ||
| 1322 | + * 非空验证 | ||
| 1323 | + * 创建时间:2017年7月31日 19:47:09 | ||
| 1324 | + * 更新时间:2019年12月26日 20:49:55 | ||
| 1325 | + * @param str | ||
| 1326 | + * @returns boolean | ||
| 1327 | + */ | ||
| 1328 | +function validateAppid(str){ | ||
| 1329 | + var appid = str.replace(/^([ ]+)/,"").replace(/([ ]+)$/,""); | ||
| 1330 | + if(appid!=''){ | ||
| 1331 | + return true; | ||
| 1332 | + } | ||
| 1333 | + return false; | ||
| 1183 | } | 1334 | } |
-
Please register or login to post a comment