menu.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.wechat_menu}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. <a href="{:url('Wechat/pub_menu')}" class="btn btn-small" style="float: right">{$Think.lang.wechat_menu_update}</a>
  11. </div>
  12. </div>
  13. <div class="explanation" id="explanation">
  14. <div class="title" id="checkZoom">
  15. <h4 title="{$Think.lang.ds_explanation_tip}">{$Think.lang.ds_explanation}</h4>
  16. <span id="explanationZoom" title="{$Think.lang.ds_explanation_close}" class="arrow"></span>
  17. </div>
  18. <ul>
  19. <li>{$Think.lang.wechat_menu_help1}</li>
  20. <li>{$Think.lang.wechat_menu_help2}</li>
  21. <li>{$Think.lang.wechat_menu_help3}</li>
  22. <li>{$Think.lang.wechat_menu_help4}</li>
  23. <li>{$Think.lang.wechat_menu_help5}</li>
  24. </ul>
  25. </div>
  26. <div class='material-wrapper'>
  27. <div class='material-left'>
  28. <div class="material-mobile">
  29. <img class="material-mobile-head" src='{$Think.ADMIN_SITE_ROOT}/images/mobile_head.png' />
  30. <div class='material-mobile-content'>
  31. </div>
  32. <img class="material-mobile-head" style="border-top:1px solid #e1e1e1" src='{$Think.ADMIN_SITE_ROOT}/images/mobile_foot.png' />
  33. <div class="menu-wrapper">
  34. <div class="menu-block" {notpresent name='menu_list[0]'}style="display: none"{/notpresent}>
  35. <div class="menu-list">
  36. <div class="menu-item" {notpresent name='menu_list[0]["child"][0]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[0]["child"][0]['name']|default='子菜单名称'}</div>
  37. <div class="menu-item" {notpresent name='menu_list[0]["child"][1]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[0]["child"][1]['name']|default='子菜单名称'}</div>
  38. <div class="menu-item" {notpresent name='menu_list[0]["child"][2]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[0]["child"][2]['name']|default='子菜单名称'}</div>
  39. <div class="menu-item" {notpresent name='menu_list[0]["child"][3]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[0]["child"][3]['name']|default='子菜单名称'}</div>
  40. <div class="menu-item" {notpresent name='menu_list[0]["child"][4]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[0]["child"][4]['name']|default='子菜单名称'}</div>
  41. <div class="menu-btn" {if isset($menu_list[0]['child']) && count($menu_list[0]['child'])>=5}style="display: none"{/if} onclick="addMenu($(this))">+</div>
  42. </div>
  43. <div class="menu-item menu-foot" onclick="getMenu($(this))">{$menu_list[0]['name']|default='菜单名称'}</div>
  44. </div>
  45. <div class="menu-block" {notpresent name='menu_list[1]'}style="display: none"{/notpresent}>
  46. <div class="menu-list">
  47. <div class="menu-item" {notpresent name='menu_list[1]["child"][0]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[1]["child"][0]['name']|default='子菜单名称'}</div>
  48. <div class="menu-item" {notpresent name='menu_list[1]["child"][1]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[1]["child"][1]['name']|default='子菜单名称'}</div>
  49. <div class="menu-item" {notpresent name='menu_list[1]["child"][2]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[1]["child"][2]['name']|default='子菜单名称'}</div>
  50. <div class="menu-item" {notpresent name='menu_list[1]["child"][3]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[1]["child"][3]['name']|default='子菜单名称'}</div>
  51. <div class="menu-item" {notpresent name='menu_list[1]["child"][4]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[1]["child"][4]['name']|default='子菜单名称'}</div>
  52. <div class="menu-btn" {if isset($menu_list[1]['child']) && count($menu_list[1]['child'])>=5}style="display: none"{/if} onclick="addMenu($(this))">+</div>
  53. </div>
  54. <div class="menu-item menu-foot" onclick="getMenu($(this))">{$menu_list[1]['name']|default='菜单名称'}</div>
  55. </div>
  56. <div class="menu-block" {notpresent name='menu_list[2]'}style="display: none"{/notpresent}>
  57. <div class="menu-list">
  58. <div class="menu-item" {notpresent name='menu_list[2]["child"][0]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[2]["child"][0]['name']|default='子菜单名称'}</div>
  59. <div class="menu-item" {notpresent name='menu_list[2]["child"][1]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[2]["child"][1]['name']|default='子菜单名称'}</div>
  60. <div class="menu-item" {notpresent name='menu_list[2]["child"][2]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[2]["child"][2]['name']|default='子菜单名称'}</div>
  61. <div class="menu-item" {notpresent name='menu_list[2]["child"][3]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[2]["child"][3]['name']|default='子菜单名称'}</div>
  62. <div class="menu-item" {notpresent name='menu_list[2]["child"][4]'}style="display: none"{/notpresent} onclick="getMenu($(this))">{$menu_list[2]["child"][4]['name']|default='子菜单名称'}</div>
  63. <div class="menu-btn" {if isset($menu_list[2]['child']) && count($menu_list[2]['child'])>=5}style="display: none"{/if} onclick="addMenu($(this))">+</div>
  64. </div>
  65. <div class="menu-item menu-foot" onclick="getMenu($(this))">{$menu_list[2]['name']|default='菜单名称'}</div>
  66. </div>
  67. <div class="menu-block" {if isset($menu_list) && count($menu_list)>=3}style="display: none"{/if}>
  68. <div class="menu-btn menu-foot" onclick="addMenu($(this))">+</div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class='material-right'>
  74. <div class="material-right-content" {empty name='menu_list'}style="display: none"{/empty}>
  75. <div class="material-editor-head">
  76. <div class="material-editor-head-title menu-title">菜单(<span class='menu-number'>1</span>)</div>
  77. <div class="material-editor-head-title menu-sub-title" style="display: none">子菜单(<span class='menu-number'>1</span>-<span class='menu-sub-number'>1</span>)</div>
  78. <div class="material-editor-head-btn" onclick='delMenu()'>删除</div>
  79. </div>
  80. <div class="material-editor-content">
  81. <form method="post" enctype="multipart/form-data" id="form1" action="">
  82. <div class="ncap-form-default">
  83. <dl>
  84. <dt><label class="validation">菜单名称</label></dt>
  85. <dd>
  86. <input name="name" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text" onchange='setTitle($(this))'>
  87. </dd>
  88. </dl>
  89. <dl dstype="menu">
  90. <dt><label class="validation">菜单内容</label></dt>
  91. <dd>
  92. <label class="radio-label">
  93. <i class="radio-common {if !isset($editable_page) || !$editable_page['type']}selected{/if}">
  94. <input type="radio" value="article_id" name="type" {if !isset($editable_page) || !$editable_page['type']}checked="checked"{/if}>
  95. </i>
  96. <span>发送消息素材</span>
  97. </label>
  98. <label class="radio-label">
  99. <i class="radio-common {if isset($editable_page) && $editable_page['type']=='index/index'}selected{/if}">
  100. <input type="radio" value="click" name="type" {if isset($editable_page) && $editable_page['type']=='index/index'}checked="checked"{/if}>
  101. </i>
  102. <span>发送命令</span>
  103. </label>
  104. <label class="radio-label">
  105. <i class="radio-common {if isset($editable_page) && $editable_page['type']=='activity/detail'}selected{/if}">
  106. <input type="radio" value="view" name="type" {if isset($editable_page) && $editable_page['type']=='activity/detail'}checked="checked"{/if}>
  107. </i>
  108. <span>跳转到网页</span>
  109. </label>
  110. <label class="radio-label">
  111. <i class="radio-common {if isset($editable_page) && $editable_page['type']=='activity/detail'}selected{/if}">
  112. <input type="radio" value="miniprogram" name="type" {if isset($editable_page) && $editable_page['type']=='activity/detail'}checked="checked"{/if}>
  113. </i>
  114. <span>跳转小程序</span>
  115. </label>
  116. </dd>
  117. </dl>
  118. </div>
  119. <div class="ncap-form-default" dstype="menu">
  120. <div data-menu-type="article_id">
  121. <dl>
  122. <dt><label class="validation">消息素材</label></dt>
  123. <dd>
  124. <input type="hidden" name="article_id" value="{$material_info[0]["title"]|default=""}" />
  125. <div class="material-box" onclick="dsLayerOpen('{:url('Wechat/material_select')}','从素材库选择')">
  126. <div class="material-box-icon iconfont">&#xe74b;</div>
  127. <div class="material-box-text">从素材库选择</div>
  128. </div>
  129. <div class="material-item" style="display:none" onclick="dsLayerOpen('{:url('Wechat/material_select')}','从素材库选择')">
  130. <img class="material-image" src='' />
  131. <div class="material-title"></div>
  132. <div class="material-time"></div>
  133. </div>
  134. </dd>
  135. </dl>
  136. </div>
  137. <div data-menu-type="click" style="display: none">
  138. <dl>
  139. <dt><label class="validation">命令值</label></dt>
  140. <dd>
  141. <input name="key" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text">
  142. </dd>
  143. </dl>
  144. </div>
  145. <div data-menu-type="view" style="display: none">
  146. <dl>
  147. <dt><label class="validation">页面地址</label></dt>
  148. <dd>
  149. <input name="url1" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text">
  150. </dd>
  151. </dl>
  152. </div>
  153. <div data-menu-type="miniprogram" style="display: none">
  154. <dl>
  155. <dt><label class="validation">备用网页</label></dt>
  156. <dd>
  157. <input name="url2" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text">
  158. </dd>
  159. </dl>
  160. <dl>
  161. <dt><label class="validation">小程序APPID</label></dt>
  162. <dd>
  163. <input name="appid" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text">
  164. </dd>
  165. </dl>
  166. <dl>
  167. <dt><label class="validation">小程序页面路径</label></dt>
  168. <dd>
  169. <input name="pagepath" value="{$material_info[0]["title"]|default=""}" class="input-txt" type="text">
  170. </dd>
  171. </dl>
  172. </div>
  173. </div>
  174. </form>
  175. </div>
  176. </div>
  177. <div class="menu-notice" {notempty name='menu_list'}style="display:none"{/notempty}>点击左侧按钮 + 添加菜单</div>
  178. </div>
  179. </div>
  180. <div class="btn-wrapper">
  181. <a href="JavaScript:void(0);" class="btn" onclick="submit()">{$Think.lang.ds_confirm_submit}</a>
  182. </div>
  183. </div>
  184. <style>
  185. .material-wrapper{display: flex;margin-top:20px}
  186. .material-wrapper .material-left{margin-right:20px;}
  187. .material-wrapper .material-left .material-mobile{width:320px;border:1px solid #e1e1e1;font-size: 0;position:relative;}
  188. .material-wrapper .material-left .material-mobile .material-mobile-head{width:100%;}
  189. .material-wrapper .material-left .material-mobile .material-mobile-content{padding:20px;width:100%;box-sizing: border-box;height: 456px}
  190. .material-wrapper .material-right{flex:1;position:relative;border:1px solid #e1e1e1;background: #f4f5f9}
  191. .material-wrapper .material-right .material-right-content .material-editor-head{display: flex;align-items:center;border-bottom: 1px solid #e1e1e1;padding:10px 20px;}
  192. .material-wrapper .material-right .material-right-content .material-editor-head .material-editor-head-title{font-size:16px;flex:1;}
  193. .material-wrapper .material-right .material-right-content .material-editor-head .material-editor-head-btn{background: #fff;border:1px solid #e1e1e1;text-align: center;line-height: 40px;width:100px;font-size:14px;cursor: pointer}
  194. .material-wrapper .material-right .material-right-content .material-editor-content{margin:20px;}
  195. .menu-wrapper{position:absolute;right: -1px;bottom:0;width:277px;display: flex;}
  196. .menu-wrapper .menu-block{flex:1;position:relative;}
  197. .menu-wrapper .menu-block .menu-item{width:100%;height: 50px;text-align: center;line-height: 50px;white-space: nowrap;overflow: hidden;text-overflow:ellipsis;font-size:14px;box-sizing: border-box;background: #fafafa;cursor: pointer}
  198. .menu-wrapper .menu-block .menu-btn{width:100%;height: 50px;text-align: center;line-height: 50px;font-size:14px;box-sizing: border-box;background: #fafafa;cursor: pointer}
  199. .menu-wrapper .menu-block .menu-list{position:absolute;width:100%;bottom:60px;right:0;border:1px solid #e1e1e1;border-top:0;}
  200. .menu-wrapper .menu-block .menu-list .menu-item{border-top:1px solid #e1e1e1;}
  201. .menu-wrapper .menu-block .menu-list .menu-btn{border-top:1px solid #e1e1e1;}
  202. .menu-wrapper .menu-block .menu-foot{border-right:1px solid #e1e1e1;box-sizing: border-box}
  203. .menu-active{border: 1px solid #8b8b8b !important;}
  204. .menu-notice{font-size:14px;position:absolute;top:50%;left:50%;margin-left:-79px;}
  205. .btn-wrapper{text-align: center}
  206. .btn-wrapper .btn{margin:20px auto;}
  207. .material-box{border:1px solid #e1e1e1;border-radius: 5px;width:300px;height: 160px;text-align: center;cursor: pointer}
  208. .material-box .material-box-icon{font-size:50px;line-height:50px;font-weight: bold;padding-top:40px;}
  209. .material-box .material-box-text{font-size:16px;font-weight: bold;}
  210. .material-item{float:left;width:250px;height: 300px;margin-right:10px;margin-top:10px;border:1px solid #e1e1e1;position:relative;cursor: pointer}
  211. .material-item .material-add{text-align: center}
  212. .material-item .material-add .material-add-icon{font-size:50px;margin-top:100px;margin-bottom:10px;color:#333;}
  213. .material-item .material-add .material-add-text{font-size:24px;color:#333;}
  214. .material-item .material-image{width:100%;height: 200px;object-fit: cover}
  215. .material-item .material-title{font-size:16px;line-height: 17px;height: 34px;padding:0 10px;margin:10px 0;box-sizing: border-box;width:100%;overflow: hidden;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;}
  216. .material-item .material-time{font-size:14px;color:#999;padding:0 10px;}
  217. </style>
  218. <script>
  219. var menuIndex=-1
  220. var menuSubIndex=-1
  221. var menuList={:json_encode($menu_json)};
  222. if(menuList[0]){
  223. getMenu($('.menu-block').eq(0).find('.menu-item.menu-foot'),false)
  224. }
  225. $(function(){
  226. $('.radio-label').click(function(){
  227. $('[data-menu-type]').hide()
  228. $('[data-menu-type="'+$(this).find('input').val()+'"]').show()
  229. })
  230. })
  231. function addMenu(obj){
  232. if(menuSubIndex>-1){
  233. menuList[menuIndex][menuList[menuIndex].length-1]['child'][menuSubIndex]=$("#form1").serializeArray()
  234. }else if(menuIndex>-1){
  235. var temp=menuList[menuIndex][menuList[menuIndex].length-1]['child']
  236. menuList[menuIndex]=$("#form1").serializeArray()
  237. menuList[menuIndex].push({'child':temp})
  238. }
  239. $('.menu-active').removeClass('menu-active')
  240. if(obj.attr('class').indexOf("menu-foot") != -1 ){
  241. $('.menu-list').hide()
  242. menuSubIndex=-1
  243. menuList.push([{child:[]}])
  244. menuIndex=menuList.length-1
  245. $('.menu-block').eq(menuIndex).show()
  246. $('.menu-block').eq(menuIndex).find('.menu-list').show()
  247. $('.menu-block').eq(menuIndex).find('.menu-item.menu-foot').addClass('menu-active')
  248. $('.menu-number').text(menuIndex+1)
  249. $('.menu-title').show()
  250. $('.menu-sub-title').hide()
  251. }else{
  252. menuList[menuIndex][menuList[menuIndex].length-1]['child'].push([])
  253. menuSubIndex=menuList[menuIndex][menuList[menuIndex].length-1]['child'].length-1
  254. $('.menu-block').eq(menuIndex).find('.menu-list .menu-item').eq(menuSubIndex).addClass('menu-active').show()
  255. $('.menu-sub-number').text(menuSubIndex+1)
  256. $('.menu-title').hide()
  257. $('.menu-sub-title').show()
  258. }
  259. if(menuIndex>=2){
  260. $('.menu-btn.menu-foot').parents('.menu-block').hide()
  261. }
  262. if(menuSubIndex>=4){
  263. $('.menu-block').eq(menuIndex).find('.menu-btn').hide()
  264. }
  265. $('.material-right-content').show()
  266. $('.menu-notice').hide()
  267. $('#form1 input[type="text"]').val('')
  268. $('#form1 input[type="hidden"]').val('')
  269. $('.radio-common').removeClass('selected')
  270. $('input[name="type"]').removeAttr('checked')
  271. $('#form1 input[name="type"][value="article_id"]').attr('checked','checked')
  272. $('#form1 input[name="type"][value="article_id"]').parents('label').click()
  273. $('#form1 input[name="type"][value="article_id"]').parents('.radio-common').addClass('selected')
  274. $('.material-item').hide()
  275. $('.material-box').show()
  276. }
  277. function getMenu(obj,if_save=true){
  278. if(if_save){
  279. if(menuSubIndex>-1){
  280. menuList[menuIndex][menuList[menuIndex].length-1]['child'][menuSubIndex]=$("#form1").serializeArray()
  281. }else if(menuIndex>-1){
  282. var temp=menuList[menuIndex][menuList[menuIndex].length-1]['child']
  283. menuList[menuIndex]=$("#form1").serializeArray()
  284. menuList[menuIndex].push({'child':temp})
  285. }
  286. }
  287. $('.menu-active').removeClass('menu-active')
  288. var data
  289. if(obj.attr('class').indexOf("menu-foot") != -1 ){
  290. $('.menu-list').hide()
  291. menuIndex=obj.parents('.menu-block').index()
  292. menuSubIndex=-1
  293. $('.menu-block').eq(menuIndex).show()
  294. $('.menu-block').eq(menuIndex).find('.menu-list').show()
  295. $('.menu-block').eq(menuIndex).find('.menu-item.menu-foot').addClass('menu-active')
  296. $('.menu-number').text(menuIndex+1)
  297. $('.menu-title').show()
  298. $('.menu-sub-title').hide()
  299. data=menuList[menuIndex]
  300. if(data[data.length-1]['child'].length){
  301. $('[dstype="menu"]').hide()
  302. }else{
  303. $('[dstype="menu"]').show()
  304. }
  305. }else{
  306. $('[dstype="menu"]').show()
  307. menuSubIndex=obj.index()
  308. $('.menu-block').eq(menuIndex).find('.menu-list .menu-item').eq(menuSubIndex).addClass('menu-active').show()
  309. $('.menu-sub-number').text(menuSubIndex+1)
  310. $('.menu-title').hide()
  311. $('.menu-sub-title').show()
  312. data=menuList[menuIndex][menuList[menuIndex].length-1]['child'][menuSubIndex]
  313. }
  314. for(var i in data){
  315. if(data[i]['name']){
  316. if(data[i]['name']=='type'){
  317. $('.radio-common').removeClass('selected')
  318. $('input[name="type"]').removeAttr('checked')
  319. $('[name="'+data[i]['name']+'"][value="'+data[i]['value']+'"]').attr('checked','checked')
  320. $('[name="'+data[i]['name']+'"][value="'+data[i]['value']+'"]').parents('label').click()
  321. $('[name="'+data[i]['name']+'"][value="'+data[i]['value']+'"]').parents('.radio-common').addClass('selected')
  322. }else{
  323. $('[name="'+data[i]['name']+'"]').val(data[i]['value'])
  324. if(data[i]['name']=='article_id'){
  325. if(data[i]['value']!=''){
  326. selectMaterial(data[i]['value'])
  327. }else{
  328. $('.material-item').hide()
  329. $('.material-box').show()
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. function delMenu(){
  337. if(menuSubIndex==-1){
  338. $('.menu-btn.menu-foot').parents('.menu-block').show()
  339. menuList.splice(menuIndex,1)
  340. var obj=$('.menu-block').eq(menuIndex)
  341. obj.find('.menu-list .menu-item').text('子菜单名称')
  342. obj.find('.menu-item.menu-foot').text('菜单名称')
  343. obj.find('.menu-list .menu-item').hide()
  344. obj.find('.menu-list .menu-btn').show()
  345. obj.hide()
  346. obj.parent().find('.menu-btn.menu-foot').parents('.menu-block').before(obj)
  347. if((menuList.length-1)<menuIndex){
  348. menuIndex=menuList.length-1
  349. }
  350. if(menuIndex<=-1){
  351. $('.material-right-content').hide()
  352. $('.menu-notice').show()
  353. }else{
  354. menuSubIndex=-1
  355. getMenu($('.menu-block').eq(menuIndex).find('.menu-item.menu-foot'),false)
  356. }
  357. }else{
  358. $('.menu-block').eq(menuIndex).find('.menu-btn').show()
  359. menuList[menuIndex][menuList[menuIndex].length-1]['child'].splice(menuSubIndex,1)
  360. var obj=$('.menu-block').eq(menuIndex).find('.menu-list .menu-item').eq(menuSubIndex)
  361. obj.text('子菜单名称')
  362. obj.hide()
  363. obj.parent().find('.menu-btn').before(obj)
  364. if((menuList[menuIndex][menuList[menuIndex].length-1]['child'].length-1)<menuSubIndex){
  365. menuSubIndex=menuList[menuIndex][menuList[menuIndex].length-1]['child'].length-1
  366. }
  367. if(menuSubIndex>-1){
  368. getMenu($('.menu-block').eq(menuIndex).find('.menu-list .menu-item').eq(menuSubIndex),false)
  369. }else{
  370. getMenu($('.menu-block').eq(menuIndex).find('.menu-item.menu-foot'),false)
  371. }
  372. }
  373. }
  374. function selectMaterial(article_id){
  375. $.getJSON('{:url("Wechat/get_freepublish")}',{article_id:article_id},function(res){
  376. if(res.code){
  377. $('[name="article_id"]').val(article_id)
  378. $('.material-image').attr('src','{:url("admin/Wechat/get_material_image")}?media_id='+res.data.news_item[0]["thumb_media_id"])
  379. $('.material-title').text(res.data.news_item[0]["title"])
  380. var d = new Date(res.data.update_time*1000)
  381. $('.material-time').text('更新于'+d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate()+' '+d.getHours()+':'+d.getMinutes())
  382. $('.material-item').show()
  383. $('.material-box').hide()
  384. layer.closeAll('iframe')
  385. }else{
  386. layer.msg(res.msg)
  387. }
  388. })
  389. }
  390. function setTitle(obj){
  391. var title=obj.val()
  392. if(menuSubIndex>-1){
  393. if(title==''){
  394. title='子菜单名称'
  395. }
  396. $('.menu-block').eq(menuIndex).find('.menu-list .menu-item').eq(menuSubIndex).text(title)
  397. }else{
  398. if(title==''){
  399. title='菜单名称'
  400. }
  401. $('.menu-block').eq(menuIndex).find('.menu-item.menu-foot').text(title)
  402. }
  403. }
  404. function submit(){
  405. $('label.error').remove()
  406. if(menuSubIndex>-1){
  407. menuList[menuIndex][menuList[menuIndex].length-1]['child'][menuSubIndex]=$("#form1").serializeArray()
  408. }else if(menuIndex>-1){
  409. var temp=menuList[menuIndex][menuList[menuIndex].length-1]['child']
  410. menuList[menuIndex]=$("#form1").serializeArray()
  411. menuList[menuIndex].push({'child':temp})
  412. }
  413. $.ajax({
  414. type: "POST",
  415. url: '{:url("admin/Wechat/add_menu")}',
  416. dataType: 'json',
  417. data: {menus:menuList},
  418. success: function (res) {
  419. if (res.code == 10000) {
  420. layer.msg(res.message)
  421. }else{
  422. if(res.result){
  423. $('[name="'+res.result.name+'"]').parents('dd').append('<label class="error">不能为空</label>')
  424. if(res.result.index2>-1){
  425. getMenu($('.menu-block').eq(res.result.index1).find('.menu-list .menu-item').eq(res.result.index2),false)
  426. }else{
  427. getMenu($('.menu-block').eq(res.result.index1).find('.menu-item.menu-foot'),false)
  428. }
  429. }else{
  430. layer.msg(res.message)
  431. }
  432. }
  433. }
  434. })
  435. }
  436. </script>