index.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <link rel="stylesheet" type="text/css" href="{__ADMIN_PATH}css/main.css" />
  4. <link href="{__FRAME_PATH}css/plugins/iCheck/custom.css" rel="stylesheet">
  5. {/block}
  6. {block name="content"}
  7. <div id="app" class="row">
  8. <div class="col-sm-12">
  9. <div class="wechat-reply-wrapper wechat-menu">
  10. <div class="ibox-content clearfix">
  11. <div class="view-wrapper col-sm-4">
  12. <div class="mobile-header">公众号</div>
  13. <section class="view-body">
  14. <div class="time-wrapper"><span class="time">9:36</span></div>
  15. </section>
  16. <div class="menu-footer">
  17. <ul class="flex">
  18. <li v-for="(menu, index) in menus" :class="{active:menu === checkedMenu}">
  19. <span @click="activeMenu(menu,index,null)"><i class="icon-sub"></i>{{ menu.name || '一级菜单' }}</span>
  20. <div class="sub-menu">
  21. <ul>
  22. <li v-for="(child, cindex) in menu.sub_button" :class="{active:child === checkedMenu}">
  23. <span @click="activeMenu(child,cindex,index)">{{ child.name || '二级菜单' }}</span>
  24. </li>
  25. <li v-if="menu.sub_button.length < 5" @click="addChild(menu,index)"><i class="icon-add"></i></li>
  26. </ul>
  27. </div>
  28. </li>
  29. <li v-if="menus.length < 3" @click="addMenu()"><i class="icon-add"></i></li>
  30. </ul>
  31. </div>
  32. </div>
  33. <div class="control-wrapper menu-control col-sm-8" v-show="checkedMenuId !== null">
  34. <section>
  35. <div class="control-main">
  36. <h3 class="popover-title">菜单名称 <a class="fr" href="javascript:void(0);" @click="delMenu">删除</a></h3>
  37. <p class="tips-txt">已添加子菜单,仅可设置菜单名称。</p>
  38. <div class="menu-content control-body">
  39. <form action="">
  40. <div class="form-group clearfix">
  41. <label for="" class="col-sm-2">菜单名称</label>
  42. <div class="col-sm-9 group-item">
  43. <input type="text" placeholder="菜单名称" class="form-control" v-model="checkedMenu.name">
  44. <span>字数不超过13个汉字或40个字母</span>
  45. </div>
  46. </div>
  47. <div class="form-group clearfix">
  48. <label class="col-sm-2 control-label tips" for="">规则状态</label>
  49. <div class="group-item col-sm-9">
  50. <select class="form-control m-b" name="" id="" v-model="checkedMenu.type">
  51. <?php /* <option value="text">文字消息</option> */ ?>
  52. <option value="click">关键字</option>
  53. <option value="view">跳转网页</option>
  54. <?php /* <option value="feat">事件功能</option> */ ?>
  55. <option value="miniprogram">小程序</option>
  56. </select>
  57. </div>
  58. </div>
  59. <div class="menu-control-box">
  60. <!-- 文字消息 -->
  61. <?php /* <div class="text-box item" :class="{show:checkedMenu.type=='text'}">
  62. <p>回复内容</p>
  63. <textarea v-model="checkedMenu.content" cols="60" rows="10" placeholder="请输入回复内容"></textarea>
  64. </div> */ ?>
  65. <!-- 关键字 -->
  66. <div class="keywords item" :class="{show:checkedMenu.type=='click'}">
  67. <p>关键字</p>
  68. <input type="text" placeholder="请输入关键字" class="form-control" v-model="checkedMenu.key">
  69. </div>
  70. <!-- 跳转地址 -->
  71. <div class="url item" :class="{show:checkedMenu.type=='view'}">
  72. <p>跳转地址</p>
  73. <input type="text" v-model="checkedMenu.url" placeholder="请输入跳转地址" class="form-control">
  74. <p class="text-left"></p>
  75. <div class="well well-lg">
  76. <span class="help-block m-b-none">首页:{$Request.domain}</span>
  77. <span class="help-block m-b-none">个人中心:{$Request.domain}/user</span>
  78. </div>
  79. </div>
  80. <!-- 事件功能 -->
  81. <?php /* <div class="feat-select item" :class="{show:type=='feat'}">
  82. <div class="radio i-checks" style="display:block">
  83. <label class="" style="padding-left: 0;">
  84. <div class="iradio_square-green" style="position: relative;">
  85. <div class="iradio_square-green" style="position: relative;">
  86. <input checked="checked" type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  87. </div>
  88. <i></i>扫码推事件
  89. </label>
  90. </div>
  91. <div class="radio i-checks" style="display:block">
  92. <label class="" style="padding-left: 0;">
  93. <div class="iradio_square-green" style="position: relative;">
  94. <div class="iradio_square-green" style="position: relative;"><input type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  95. </div>
  96. <i></i>扫码推事件且弹出“消息接收中”提示框
  97. </label>
  98. </div>
  99. <div class="radio i-checks" style="display:block">
  100. <label class="" style="padding-left: 0;">
  101. <div class="iradio_square-green" style="position: relative;">
  102. <div class="iradio_square-green" style="position: relative;"><input type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  103. </div>
  104. <i></i>弹出系统拍照发图
  105. </label>
  106. </div>
  107. <div class="radio i-checks" style="display:block">
  108. <label class="" style="padding-left: 0;">
  109. <div class="iradio_square-green" style="position: relative;">
  110. <div class="iradio_square-green" style="position: relative;"><input type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  111. </div>
  112. <i></i>弹出拍照或者相册发图
  113. </label>
  114. </div>
  115. <div class="radio i-checks" style="display:block">
  116. <label class="" style="padding-left: 0;">
  117. <div class="iradio_square-green" style="position: relative;">
  118. <div class="iradio_square-green" style="position: relative;"><input type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  119. </div>
  120. <i></i>弹出微信相册发图器
  121. </label>
  122. </div>
  123. <div class="radio i-checks" style="display:block">
  124. <label class="" style="padding-left: 0;">
  125. <div class="iradio_square-green" style="position: relative;">
  126. <div class="iradio_square-green" style="position: relative;"><input type="radio" value="2" name="feat" style="position: absolute; opacity: 0;"></div>
  127. </div>
  128. <i></i>弹出地理位置选择器
  129. </label>
  130. </div>
  131. </div> */ ?>
  132. <!-- 小程序 -->
  133. <div class="wrchat-app item" :class="{show:checkedMenu.type=='miniprogram'}">
  134. <div class="list">
  135. <p>appid</p>
  136. <input class="form-control" v-model="checkedMenu.appid" type="text" />
  137. </div>
  138. <div class="list">
  139. <p>备用网页url</p>
  140. <input class="form-control" v-model="checkedMenu.url" type="text" />
  141. </div>
  142. <div class="list">
  143. <p>小程序路径</p>
  144. <input class="form-control" v-model="checkedMenu.pagepath" type="text" />
  145. </div>
  146. </div>
  147. <!-- 多客服 -->
  148. <div class="service item">
  149. <p>回复内容</p>
  150. <textarea cols="60" rows="10"></textarea>
  151. </div>
  152. </div>
  153. </form>
  154. </div>
  155. </div>
  156. </section>
  157. </div>
  158. </div>
  159. <div class="ibox-content submit">
  160. <button class="btn btn-w-m btn-primary" @click="submit">保存发布</button>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. {/block}
  166. {block name="script"}
  167. <script src="{__FRAME_PATH}js/plugins/iCheck/icheck.min.js"></script>
  168. <script src="{__FRAME_PATH}js/bootstrap.min.js"></script>
  169. <script src="{__FRAME_PATH}js/content.min.js"></script>
  170. <script src="{__PLUG_PATH}reg-verify.js"></script>
  171. <script type="text/javascript">
  172. $eb = parent._mpApi;
  173. $eb.mpFrame.start(function(Vue){
  174. var $http = $eb.axios;
  175. const vm = new Vue({
  176. data:{
  177. menus:<?=$menus?>,
  178. checkedMenu:{
  179. type:'click',
  180. name:''
  181. },
  182. checkedMenuId:null,
  183. parentMenuId:null
  184. },
  185. methods:{
  186. defaultMenusData:function(){
  187. return {
  188. type:'click',
  189. name:'',
  190. sub_button:[]
  191. };
  192. },
  193. defaultChildData:function(){
  194. return {
  195. type:'click',
  196. name:''
  197. };
  198. },
  199. addMenu:function(){
  200. if(!this.check()) return false;
  201. var data = this.defaultMenusData(),id = this.menus.length;
  202. this.menus.push(data);
  203. this.checkedMenu = data;
  204. this.checkedMenuId = id;
  205. this.parentMenuId = null;
  206. },
  207. addChild:function(menu,index){
  208. if(!this.check()) return false;
  209. var data = this.defaultChildData(),id = menu.sub_button.length;
  210. menu.sub_button.push(data);
  211. this.checkedMenu = data;
  212. this.checkedMenuId = id;
  213. this.parentMenuId = index;
  214. },
  215. delMenu:function(){
  216. console.log(this.parentMenuId);
  217. this.parentMenuId === null ?
  218. this.menus.splice(this.checkedMenuId,1) : this.menus[this.parentMenuId].sub_button.splice(this.checkedMenuId,1);
  219. this.parentMenuId = null;
  220. this.checkedMenu = {};
  221. this.checkedMenuId = null;
  222. },
  223. activeMenu:function(menu,index,pid){
  224. if(!this.check()) return false;
  225. pid === null ?
  226. (this.checkedMenu = menu) : (this.checkedMenu = this.menus[pid].sub_button[index],this.parentMenuId = pid);
  227. this.checkedMenuId=index
  228. },
  229. check:function(){
  230. if(this.checkedMenuId === null) return true;
  231. if(!this.checkedMenu.name){
  232. $eb.message('请输入按钮名称!');
  233. return false;
  234. }
  235. if(this.checkedMenu.type == 'click' && !this.checkedMenu.key){
  236. $eb.message('请输入关键字!');
  237. return false;
  238. }
  239. if(this.checkedMenu.type == 'view' && !$reg.isHref(this.checkedMenu.url)){
  240. $eb.message('请输入正确的跳转地址!');
  241. return false;
  242. }
  243. if(this.checkedMenu.type == 'miniprogram'
  244. && (!this.checkedMenu.appid
  245. || !this.checkedMenu.pagepath
  246. || !this.checkedMenu.url)){
  247. $eb.message('请填写完整小程序配置!');
  248. return false;
  249. }
  250. return true;
  251. },
  252. submit:function(){
  253. if(!this.menus.length){
  254. $eb.message('error','请添加菜单!');
  255. return false;
  256. }
  257. $http.post("{:url('wechat.menus/save',array('dis'=>1))}",{button:this.menus}).then(function (res) {
  258. if(res.status == 200 && res.data.code == 200)
  259. $eb.message('success','发布菜单成功!');
  260. else
  261. return Promise.reject(res.data.msg || '发布菜单失败!');
  262. }).catch(function(err){
  263. $eb.message('error',err);
  264. })
  265. }
  266. },
  267. mounted:function(){
  268. window.vm = this;
  269. }
  270. });
  271. vm.$mount(document.getElementById('app'));
  272. });
  273. $('.i-checks').iCheck({
  274. checkboxClass: 'icheckbox_square-green',
  275. radioClass: 'iradio_square-green',
  276. });
  277. </script>
  278. {/block}