人人商城

display.html 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. <div class="panel we7-panel">
  2. <div class="panel-heading">
  3. {if $_GPC['a'] == 'qr'}二维码触发的关键字
  4. {elseif $_GPC['a'] == 'mass'}群发内容
  5. {else}
  6. {if $_GPC['c'] == 'mc' && $_GPC['a'] == 'chats'}发送聊天内容{else}触发后回复内容{/if}
  7. {if $_GPC['a'] == 'reply' && $_GPC['m'] == 'keyword'}<span class="pull-right color-gray">添加多条回复内容时, 随机回复其中一条</span>{/if}
  8. {/if}
  9. </div>
  10. <div class="panel-body we7-padding">
  11. <input type="hidden" name="reply[reply_basic]" value="">
  12. <input type="hidden" name="reply[reply_news]" value="">
  13. <input type="hidden" name="reply[reply_image]" value="">
  14. <input type="hidden" name="reply[reply_music]" value="">
  15. <input type="hidden" name="reply[reply_voice]" value="">
  16. <input type="hidden" name="reply[reply_video]" value="">
  17. <input type="hidden" name="reply[reply_wxcard]" value="">
  18. <input type="hidden" name="reply[reply_keyword]" value="">
  19. <input type="hidden" name="reply[reply_module]" value="">
  20. <ul class="keywords-list">
  21. </ul>
  22. <div class="we7-select-msg">
  23. <ul class="tab-navs">
  24. <li class="tab-nav tab-appmsg active {if $options['news']}hidden{/if}">
  25. <a href="javascript:void(0);"{if $_GPC['a'] == 'mass'} onclick="select_mediaid('news', 'wx')"{else} onclick="select_mediaid('news')"{/if}>&nbsp;<i class="wi wi-appmsg"></i><span class="msg-tab-title">图文</span></a>
  26. </li>
  27. <li class="tab-nav tab-text {if $options['basic']}hidden{/if}">
  28. <a href="javascript:void(0);" onclick="select_mediaid('basic');">&nbsp;<i class="wi wi-text"></i><span class="msg-tab-title">文字</span></a>
  29. </li>
  30. <li class="tab-nav tab-img {if $options['image']}hidden{/if}">
  31. <a href="javascript:void(0);" onclick="select_mediaid('image');">&nbsp;<i class="wi wi-img"></i><span class="msg-tab-title">{if in_array($_W['account']['type'], array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH))}熊掌号{else}微信{/if}图片</span></a>
  32. </li>
  33. <li class="tab-nav tab-audio {if $options['music']}hidden{/if}">
  34. <a href="javascript:void(0);" onclick="select_mediaid('music');">&nbsp;<i class="wi wi-notice"></i><span class="msg-tab-title">音乐</span></a>
  35. </li>
  36. <li class="tab-nav tab-audio {if $options['voice']}hidden{/if}">
  37. <a href="javascript:void(0);" onclick="select_mediaid('voice');">&nbsp;<i class="wi wi-radio"></i><span class="msg-tab-title">语音</span></a>
  38. </li>
  39. <li class="tab-nav tab-video {if $options['video']}hidden{/if}">
  40. <a href="javascript:void(0);" onclick="select_mediaid('video');">&nbsp;<i class="wi wi-video "></i><span class="msg-tab-title">视频</span></a>
  41. </li>
  42. <li class="tab-nav tab-cardmsg {if $options['wxcard']}hidden{/if}">
  43. <a href="javascript:void(0);" onclick="select_mediaid('wxcard');">&nbsp;<i class="wi wi-card"></i><span class="msg-tab-title">卡劵</span></a>
  44. </li>
  45. <li class="tab-nav tab-cardmsg {if $options['keyword']}hidden{/if}">
  46. <a href="javascript:void(0);" onclick="select_mediaid('keyword');">&nbsp;<i class="wi wi-keyword"></i><span class="msg-tab-title">{if $_GPC['m'] == 'welcome'}匹配{else}触发{/if}关键字</span></a>
  47. </li>
  48. <li class="tab-nav tab-cardmsg {if $options['module']}hidden{/if}">
  49. <a href="javascript:void(0);" onclick="select_mediaid('module');">&nbsp;<i class="wi wi-keyword"></i><span class="msg-tab-title">模块</span></a>
  50. </li>
  51. </ul>
  52. </div>
  53. </div>
  54. </div>
  55. <script>
  56. var action = "{php echo $_GPC['a']}";
  57. var m = "{php echo $_GPC['m']}";
  58. //删除已选素材
  59. var delmedia = function(type, ele) {
  60. var oldVal = $(':hidden[name="reply[reply_'+type+']"]').val();
  61. var newVal;
  62. var media = $(ele).attr('data-media');
  63. switch(type) {
  64. case 'basic':
  65. var middleVal = oldVal.split(',');
  66. newVal = angular.copy(middleVal);
  67. angular.forEach(middleVal, function(val, key) {
  68. middleVal[key] = htmlEncode(angular.toJson(val));
  69. });
  70. var index = _.indexOf(middleVal, htmlEncode(angular.toJson(media)));
  71. newVal = _.without(newVal, newVal[index]);
  72. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  73. break;
  74. case 'image':
  75. var middleVal = oldVal.split(',');
  76. newVal = angular.copy(middleVal);
  77. angular.forEach(middleVal, function(val, key) {
  78. if(val.match(media)) {
  79. newVal = _.without(newVal, middleVal[key]);
  80. }
  81. });
  82. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  83. break;
  84. case 'news':
  85. var middleVal = oldVal.slice(1, -1).split('},{');
  86. newVal = angular.copy(middleVal);
  87. angular.forEach(middleVal, function(val, key){
  88. if(val.match('"mediaid":"'+media)) {
  89. newVal = _.without(newVal, middleVal[key]);
  90. }
  91. });
  92. angular.forEach(newVal, function(val, key) {
  93. newVal[key] = '{'+val+'}';
  94. });
  95. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  96. break;
  97. case 'music':
  98. var middleVal = oldVal.slice(1, -1).split('},{');
  99. newVal = angular.copy(middleVal);
  100. angular.forEach(middleVal, function(val, key){
  101. if(val.match(media)) {
  102. newVal = _.without(newVal, middleVal[key]);
  103. }
  104. });
  105. angular.forEach(newVal, function(val, key) {
  106. newVal[key] = '{'+val+'}';
  107. });
  108. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  109. break;
  110. case 'voice':
  111. var middleVal = oldVal.split(',');
  112. newVal = angular.copy(middleVal);
  113. angular.forEach(middleVal, function(val, key) {
  114. if(val.match(media)) {
  115. newVal = _.without(newVal, middleVal[key]);
  116. }
  117. });
  118. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  119. break;
  120. case 'video':
  121. var middleVal = oldVal.slice(1, -1).split('},{');
  122. newVal = angular.copy(middleVal);
  123. angular.forEach(middleVal, function(val, key){
  124. if(val.match(media)) {
  125. newVal = _.without(newVal, middleVal[key]);
  126. }
  127. });
  128. angular.forEach(newVal, function(val, key) {
  129. newVal[key] = '{'+val+'}';
  130. });
  131. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  132. break;
  133. case 'wxcard':
  134. var middleVal = oldVal.slice(1, -1).split('},{');
  135. newVal = angular.copy(middleVal);
  136. angular.forEach(middleVal, function(val, key){
  137. if(val.match(media)) {
  138. newVal = _.without(newVal, middleVal[key]);
  139. }
  140. });
  141. angular.forEach(newVal, function(val, key) {
  142. newVal[key] = '{'+val+'}';
  143. });
  144. $(':hidden[name="reply[reply_'+type+']"]').val(newVal);
  145. break;
  146. case 'keyword':
  147. oldVal = oldVal.split(',');
  148. index = _.indexOf(oldVal, media);
  149. oldVal.splice(index, 1);
  150. $(':hidden[name="reply[reply_'+type+']"]').val(oldVal);
  151. break;
  152. case 'module':
  153. oldVal = oldVal.split(',');
  154. index = _.indexOf(oldVal, media);
  155. oldVal.splice(index, 1);
  156. $(':hidden[name="reply[reply_'+type+']"]').val(oldVal);
  157. break;
  158. }
  159. //显示隐藏-start
  160. if((action == 'qr' || action == 'mass' || m == 'special' || m == 'welcome' || m == 'default') && $(':hidden[name="reply[reply_'+type+']"]').val().length == 0) {
  161. $('.we7-select-msg').removeClass('hide');
  162. }
  163. //显示隐藏-end
  164. $(ele).parent().parent('.del-'+type+'-media').parent('li').remove();
  165. };
  166. window.select_mediaid = function(type, otherVal){
  167. var option = {
  168. type: type,
  169. isWechat : true, // 默认显示微信
  170. needType : 3, // 除了图文 其他只能微信
  171. otherVal : otherVal,//
  172. others: {
  173. image: {
  174. needType : 1
  175. },
  176. video : {
  177. needType : 1
  178. },
  179. voice : {
  180. needType : 3
  181. }
  182. }
  183. };
  184. if (type == 'module'){
  185. document.cookie = "special_reply_type={$_GPC['type']}";
  186. }
  187. util.material(function(material){
  188. var replyVal = [];
  189. $(':hidden[name="reply[reply_'+type+']"]').val() == '' ? '' : replyVal.push($(':hidden[name="reply[reply_'+type+']"]').val());
  190. if (type == 'basic') {
  191. if (angular.isDefined(otherVal)) {
  192. var editmedia = $(".del-basic-media");
  193. for (var i = 0; i < editmedia.length; i++) {
  194. if (htmlEncode($(editmedia.get(i)).find('.edit-gray').data('media')) == htmlEncode(angular.toJson(otherVal))) {
  195. var inputVal = $(':hidden[name="reply[reply_'+type+']"]').val();
  196. var inputValArr = inputVal.split(',');
  197. var middleVal = angular.copy(inputValArr);
  198. angular.forEach(inputValArr, function(val, key) {
  199. inputValArr[key] = htmlEncode(val);
  200. });
  201. var index = _.indexOf(inputValArr, htmlEncode(angular.toJson(otherVal)));
  202. material.content = material.content.replace(/,/g, ',');
  203. middleVal[index] = angular.toJson(material.content);
  204. replyVal = middleVal.join(',');
  205. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  206. $(editmedia.get(i)).html(
  207. ' <div class="desc">'+
  208. ' <div class="media-content">'+
  209. ' <span data-toggle="tooltip" data-placement="bottom" title="'+htmlEncode(material.content)+'">'+htmlEncode(cutStr(material.content,60))+
  210. ' </span>'+
  211. ' </div>'+
  212. ' </div>'+
  213. ' <div class="opr">'+
  214. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(material.content))+'" class="edit-gray" onclick="select_mediaid(\'basic\', '+htmlEncode(angular.toJson(material.content))+')">编辑</a>'+
  215. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(material.content))+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  216. ' </div>'
  217. );
  218. break;
  219. }
  220. }
  221. } else {
  222. if($.trim(material.content).length == 0) {
  223. return false;
  224. }
  225. material.content = material.content.replace(/,/g, ',');
  226. replyVal.push(angular.toJson(material.content));
  227. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  228. $('.keywords-list').append(
  229. '<li>'+
  230. '<div class="del-'+type+'-media">'+
  231. ' <div class="desc">'+
  232. ' <div class="media-content">'+
  233. ' <span data-toggle="tooltip" data-placement="bottom" title="'+htmlEncode(material.content)+'">'+htmlEncode(cutStr(material.content,60))+'</span>'+
  234. ' </div>'+
  235. ' </div>'+
  236. ' <div class="opr">'+
  237. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(material.content))+'" class="edit-gray" onclick="select_mediaid(\'basic\', '+htmlEncode(angular.toJson(material.content))+')">编辑</a>'+
  238. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(material.content))+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  239. ' </div>'+
  240. '</div>'+
  241. '</li>'
  242. );
  243. }
  244. } else if(type == 'keyword') {
  245. if($.trim(material.id).length == 0) {
  246. return false;
  247. }
  248. replyVal.push(angular.toJson(material.id));
  249. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  250. var keywords = [];
  251. for(var i = 0; i < material.length; i++) {
  252. keywords += '&nbsp;&nbsp;' + material.content;
  253. }
  254. $('.keywords-list').append(
  255. '<li>'+
  256. '<div class="del-'+type+'-media">'+
  257. ' <div class="desc">'+
  258. ' <div class="media-content">'+
  259. ' <a class="title-wrp" href="javascript:;">'+
  260. ' <span class="title">[关键字]'+material.content+'</span>'+
  261. ' </a>'+
  262. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+keywords+'</a></p>'+
  263. ' </div>'+
  264. ' </div>'+
  265. ' <div class="opr">'+
  266. '<a href="./index.php?c=platform&a=reply&do=post&m=keyword&rid=' + material.rid + '" target="_blank" class="del-gray">编辑</a> ' +
  267. ' <a href="javascript:;" data-media="'+material.content+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  268. ' </div>'+
  269. '</div>'+
  270. '</li>'
  271. );
  272. } else if(type == 'module') {
  273. if($.trim(material.name).length == 0) {
  274. return false;
  275. }
  276. replyVal.push(angular.toJson(material.name));
  277. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  278. $('.keywords-list').append(
  279. '<li>'+
  280. '<div class="del-'+type+'-media">'+
  281. ' <div class="desc">'+
  282. ' <div class="media-content">'+
  283. ' <div class="appmsgSendedItem">'+
  284. ' <a class="title-wrp" href="javascript:;">'+
  285. ' <span class="icon cover" style="background-image:url('+material.icon+');"></span>'+
  286. ' <span class="title">[模块]'+material.title+'</span>'+
  287. ' </a>'+
  288. ' </div>'+
  289. ' </div>'+
  290. ' </div>'+
  291. ' <div class="opr">'+
  292. ' <a href="javascript:;" data-media="'+material.name+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  293. ' </div>'+
  294. '</div>'+
  295. '</li>'
  296. );
  297. } else {
  298. if(type != 'music' && $.trim(material.media_id).length == 0 && !(type == 'news' && material.model == 'local')) {
  299. return false;
  300. };
  301. switch(type) {
  302. case 'image':
  303. replyVal.push(angular.toJson(material.media_id));
  304. $('.keywords-list').append(
  305. '<li>'+
  306. '<div class="del-'+type+'-media">'+
  307. ' <div class="desc">'+
  308. ' <div class="media-content">'+
  309. ' <div class="appmsgSendedItem">'+
  310. ' <a class="title-wrp" href="javascript:;">'+
  311. ' <span class="icon cover" style="background-image:url('+material.url+');"></span>'+
  312. ' <span class="title">[图片]</span>'+
  313. ' </a>'+
  314. ' </div>'+
  315. ' </div>'+
  316. ' </div>'+
  317. ' <div class="opr">'+
  318. ' <a href="javascript:;" data-media="'+material.media_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  319. ' </div>'+
  320. '</div>'+
  321. '</li>'
  322. );
  323. break;
  324. case 'news':
  325. angular.forEach(material.items, function(newsV, newsK){
  326. replyVal.push(angular.toJson({
  327. title: newsV.title,
  328. author: newsV.author,
  329. description: newsV.digest,
  330. thumb: newsV.thumb_url,
  331. url: newsV.content_source_url ? newsV.content_source_url : newsV.url,
  332. createtime: material.createtime,
  333. displayorder: newsV.displayorder ? newsV.displayorder : 0,
  334. mediaid: material.media_id,
  335. model: material.model,
  336. attach_id: newsV.attach_id
  337. }));
  338. });
  339. $('.keywords-list').append(
  340. '<li>'+
  341. '<div class="del-'+type+'-media">'+
  342. ' <div class="desc">'+
  343. ' <div class="media-content">'+
  344. ' <div class="appmsgSendedItem">'+
  345. ' <a class="title-wrp" href="javascript:;">'+
  346. ' <span class="icon cover" style="background-image:url('+material.items[0].thumb_url+');"></span>'+
  347. ' <span class="title">[图文消息]'+material.items[0].title+'<span class="color-red">(多条图文只显示一条,不影响实际回复效果)</span></span>'+
  348. ' </a>'+
  349. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+material.items[0].digest+'</a></p>'+
  350. ' </div>'+
  351. ' </div>'+
  352. ' </div>'+
  353. ' <div class="opr">'+
  354. ' <a href="./index.php?c=platform&a=material-post&type=reply&newsid='+material.id+'" target="_blank" class="del-gray">编辑</a>'+
  355. ' <a href="javascript:;" data-media="'+material.media_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  356. ' </div>'+
  357. '</div>'+
  358. '</li>'
  359. );
  360. break;
  361. case 'voice':
  362. replyVal.push(angular.toJson(material.media_id));
  363. $('.keywords-list').append(
  364. '<li>'+
  365. '<div class="del-'+type+'-media">'+
  366. ' <div class="desc">'+
  367. ' <div class="media-content">'+
  368. ' <div class="audio-msg">'+
  369. ' <div class="icon-audio-wrp">'+
  370. ' <span class="icon-audio-msg"></span>'+
  371. ' </div>'+
  372. ' <div class="audio-content">'+
  373. ' <div class="audio-title">[语音]'+material.filename+'</div>'+
  374. ' </div>'+
  375. ' </div>'+
  376. ' </div>'+
  377. ' </div>'+
  378. ' <div class="opr">'+
  379. ' <a href="javascript:;" data-media="'+material.media_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  380. ' </div>'+
  381. '</div>'+
  382. '</li>'
  383. );
  384. break;
  385. case 'video':
  386. replyVal.push(angular.toJson({
  387. mediaid: material.media_id,
  388. title: material.tag.title,
  389. description: material.tag.description
  390. }));
  391. $('.keywords-list').append(
  392. '<li>'+
  393. '<div class="del-'+type+'-media">'+
  394. ' <div class="desc">'+
  395. ' <div class="media-content">'+
  396. ' <div class="appmsgSendedItem">'+
  397. ' <a class="title-wrp" href="javascript:;">'+
  398. ' <span class="icon cover" data-contenturl="'+material.tag.down_url+'"></span>'+
  399. ' <span class="title">[视频]'+material.filename+'</span>'+
  400. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+(material.tag.description ? material.tag.description : '--')+'</a></p>'+
  401. ' </a>'+
  402. ' </div>'+
  403. ' </div>'+
  404. ' </div>'+
  405. ' <div class="opr">'+
  406. ' <a href="javascript:;" data-media="'+material.media_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  407. ' </div>'+
  408. '</div>'+
  409. '</li>'
  410. );
  411. break;
  412. case 'music':
  413. replyVal.push(angular.toJson({
  414. title: material.title,
  415. url: material.url,
  416. hqurl: material.HQUrl,
  417. description: material.description,
  418. }));
  419. $('.keywords-list').append(
  420. '<li>'+
  421. '<div class="del-'+type+'-media">'+
  422. ' <div class="desc">'+
  423. ' <div class="media-content">'+
  424. ' <div class="appmsgSendedItem">'+
  425. ' <a class="title-wrp" href="javascript:;">'+
  426. ' <span class="icon cover" style="background-image:'+material.url+';"></span>'+
  427. ' <span class="title">[音乐]'+material.title+'</span>'+
  428. ' </a>'+
  429. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+material.description+'</a></p>'+
  430. ' </div>'+
  431. ' </div>'+
  432. ' </div>'+
  433. ' <div class="opr">'+
  434. ' <a href="javascript:;" data-media="'+material.url+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  435. ' </div>'+
  436. '</div>'+
  437. '</li>'
  438. );
  439. break;
  440. case 'wxcard':
  441. replyVal.push(angular.toJson({
  442. mediaid: material.card_id,
  443. title: material.title,
  444. cid: material.id,
  445. brandname: material.brand_name,
  446. logo_url: material.logo_url,
  447. success: '成功',
  448. error: '失败'
  449. }));
  450. $('.keywords-list').append(
  451. '<li>'+
  452. '<div class="del-'+type+'-media">'+
  453. ' <div class="desc">'+
  454. ' <div class="media-content">'+
  455. ' <div class="appmsgSendedItem">'+
  456. ' <a class="title-wrp" href="javascript:;">'+
  457. ' <span class="icon cover" style="background-image:url('+material.logo_url+');"></span>'+
  458. ' <span class="title">[卡券]'+material.title+'</span>'+
  459. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+(material.brand_name ? material.brand_name : '--')+'</a></p>'+
  460. ' </a>'+
  461. ' </div>'+
  462. ' </div>'+
  463. ' </div>'+
  464. ' <div class="opr">'+
  465. ' <a href="javascript:;" data-media="'+material.card_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  466. ' </div>'+
  467. '</div>'+
  468. '</li>'
  469. );
  470. break;
  471. }
  472. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  473. }
  474. //显示隐藏-start
  475. if((action == 'qr' || action == 'mass' || m == 'special' || m == 'welcome' || m == 'default') && replyVal.length > 0) {
  476. $('.we7-select-msg').addClass('hide');
  477. }
  478. //显示隐藏-end
  479. }, option);
  480. };
  481. window.initReplyController = function($scope) {
  482. $scope.context = {};
  483. $scope.context.items = {php echo json_encode($replies)};
  484. var newsMediaIds = [];
  485. angular.forEach($scope.context.items, function(val, key){
  486. var replyVal = [];
  487. var type = key;
  488. switch(type) {
  489. case 'basic':
  490. angular.forEach(val, function(basicVal, basicKey) {
  491. replyVal.push(angular.toJson(basicVal.content));
  492. $('.keywords-list').append(
  493. '<li>'+
  494. '<div class="del-'+type+'-media">'+
  495. ' <div class="desc">'+
  496. ' <div class="media-content">'+
  497. ' <span data-toggle="tooltip" data-placement="bottom" title="'+htmlEncode(basicVal.content)+'">'+htmlEncode(cutStr(basicVal.content,60))+'</span>'+
  498. ' </div>'+
  499. ' </div>'+
  500. ' <div class="opr">'+
  501. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(basicVal.content))+'" class="edit-gray" onclick="select_mediaid(\'basic\', '+htmlEncode(angular.toJson(basicVal.content))+')">编辑</a>'+
  502. ' <a href="javascript:;" data-media="'+htmlEncode(angular.toJson(basicVal.content))+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  503. ' </div>'+
  504. '</div>'+
  505. '</li>'
  506. );
  507. });
  508. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  509. break;
  510. case 'news':
  511. angular.forEach(val, function(newsVal, newsKey) {
  512. var index = _.indexOf(newsMediaIds, newsVal.media_id);
  513. replyVal.push(angular.toJson({
  514. title: newsVal.title,
  515. author: newsVal.author,
  516. description: newsVal.description ? newsVal.description : newsVal.digest,
  517. thumb: newsVal.thumb ? newsVal.thumb : newsVal.thumb_url,
  518. url: newsVal.url,
  519. createtime: newsVal.createtime,
  520. displayorder: newsVal.displayorder ? newsVal.displayorder : 0,
  521. incontent: newsVal.incontent ? newsVal.incontent : 0,
  522. parent_id: newsVal.parent_id ? newsVal.parent_id : 0,
  523. mediaid: newsVal.media_id,
  524. attach_id: newsVal.attach_id,
  525. model: newsVal.model
  526. }));
  527. if (index == -1) {
  528. $('.keywords-list').append(
  529. '<li>'+
  530. '<div class="del-'+type+'-media">'+
  531. ' <div class="desc">'+
  532. ' <div class="media-content">'+
  533. ' <div class="appmsgSendedItem">'+
  534. ' <a class="title-wrp" href="javascript:;">'+
  535. ' <span class="icon cover" style="background-image:url('+(newsVal.thumb ? newsVal.thumb : newsVal.thumb_url)+');"></span>'+
  536. ' <span class="title">[图文消息]'+newsVal.title+(!newsVal.attach_id ? '<span class="color-red">(素材不存在或已被删除)</span>' : '')+
  537. ' </span>'+
  538. ' </a>'+
  539. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+(newsVal.description ? newsVal.description : '')+'</a></p>'+
  540. ' </div>'+
  541. ' </div>'+
  542. ' </div>'+
  543. ' <div class="opr">'+
  544. '<a href="./index.php?c=platform&a=material-post&type=reply&newsid='+(newsVal.attach_id ? newsVal.attach_id : '')+'&reply_news_id='+newsVal.id+'" target="_blank" class="del-gray">编辑</a>' +
  545. ' <a href="javascript:;" data-media="'+newsVal.media_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  546. ' </div>'+
  547. '</div>'+
  548. '</li>'
  549. );
  550. newsMediaIds.push(newsVal.media_id);
  551. }
  552. });
  553. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  554. break;
  555. case 'image':
  556. angular.forEach(val, function(imageVal, imageKey) {
  557. replyVal.push(angular.toJson(imageVal.mediaid));
  558. $('.keywords-list').append(
  559. '<li>'+
  560. '<div class="del-'+type+'-media">'+
  561. ' <div class="desc">'+
  562. ' <div class="media-content">'+
  563. ' <div class="appmsgSendedItem">'+
  564. ' <a class="title-wrp" href="javascript:;">'+
  565. ' <span class="icon cover" style="background-image:url('+imageVal.img_url+');"></span>'+
  566. ' <span class="title">[图片]</span>'+
  567. ' </a>'+
  568. ' </div>'+
  569. ' </div>'+
  570. ' </div>'+
  571. ' <div class="opr">'+
  572. ' <a href="javascript:;" data-media="'+imageVal.mediaid+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  573. ' </div>'+
  574. '</div>'+
  575. '</li>'
  576. );
  577. });
  578. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  579. break;
  580. case 'voice':
  581. angular.forEach(val, function(voiceVal, voiceKey) {
  582. replyVal.push(angular.toJson(voiceVal.mediaid));
  583. $('.keywords-list').append(
  584. '<li>'+
  585. '<div class="del-'+type+'-media">'+
  586. ' <div class="desc">'+
  587. ' <div class="media-content">'+
  588. ' <div class="audio-msg">'+
  589. ' <div class="icon-audio-wrp">'+
  590. ' <span class="icon-audio-msg"></span>'+
  591. ' </div>'+
  592. ' <div class="audio-content">'+
  593. ' <div class="audio-title">[语音]'+voiceVal.title+'</div>'+
  594. ' </div>'+
  595. ' </div>'+
  596. ' </div>'+
  597. ' </div>'+
  598. ' <div class="opr">'+
  599. ' <a href="javascript:;" data-media="'+voiceVal.mediaid+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  600. ' </div>'+
  601. '</div>'+
  602. '</li>'
  603. );
  604. });
  605. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  606. break;
  607. case 'video':
  608. angular.forEach(val, function(videoVal, videoKey) {
  609. replyVal.push(angular.toJson({
  610. mediaid: videoVal.mediaid,
  611. title: videoVal.title,
  612. description: videoVal.description
  613. }));
  614. $('.keywords-list').append(
  615. '<li>'+
  616. '<div class="del-'+type+'-media">'+
  617. ' <div class="desc">'+
  618. ' <div class="media-content">'+
  619. ' <div class="appmsgSendedItem">'+
  620. ' <a class="title-wrp" href="javascript:;">'+
  621. ' <span class="icon cover" data-contenturl="'+videoVal.down_url+'"></span>'+
  622. ' <span class="title">[视频]'+(videoVal.filename ? videoVal.filename : '--')+'</span>'+
  623. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+(videoVal.description ? videoVal.description : '--')+'</a></p>'+
  624. ' </a>'+
  625. ' </div>'+
  626. ' </div>'+
  627. ' </div>'+
  628. ' <div class="opr">'+
  629. ' <a href="javascript:;" data-media="'+videoVal.mediaid+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  630. ' </div>'+
  631. '</div>'+
  632. '</li>'
  633. );
  634. });
  635. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  636. break;
  637. case 'wxcard':
  638. angular.forEach(val, function(wxcardVal, wxcardKey) {
  639. replyVal.push(angular.toJson({
  640. mediaid: wxcardVal.card_id,
  641. title: wxcardVal.title,
  642. cid: wxcardVal.cid,
  643. brandname: wxcardVal.brand_name,
  644. logo_url: wxcardVal.logo_url,
  645. success: wxcardVal.success,
  646. error: wxcardVal.error
  647. }));
  648. $('.keywords-list').append(
  649. '<li>'+
  650. '<div class="del-'+type+'-media">'+
  651. ' <div class="desc">'+
  652. ' <div class="media-content">'+
  653. ' <div class="appmsgSendedItem">'+
  654. ' <a class="title-wrp" href="javascript:;">'+
  655. ' <span class="icon cover" style="background-image:url('+wxcardVal.logo_url+');"></span>'+
  656. ' <span class="title">[卡券]'+(wxcardVal.title ? wxcardVal.title : '--')+'</span>'+
  657. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+(wxcardVal.brand_name ? wxcardVal.brand_name : '--')+'</a></p>'+
  658. ' </a>'+
  659. ' </div>'+
  660. ' </div>'+
  661. ' </div>'+
  662. ' <div class="opr">'+
  663. ' <a href="javascript:;" data-media="'+wxcardVal.card_id+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  664. ' </div>'+
  665. '</div>'+
  666. '</li>'
  667. );
  668. });
  669. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  670. break;
  671. case 'keyword':
  672. angular.forEach(val, function(keywordVal, keywordKey) {
  673. replyVal.push(angular.toJson(keywordVal.id));
  674. var keywords = '&nbsp;&nbsp;' + keywordVal.content;
  675. $('.keywords-list').append(
  676. '<li>'+
  677. '<div class="del-'+type+'-media">'+
  678. ' <div class="desc">'+
  679. ' <div class="media-content">'+
  680. ' <a class="title-wrp" href="javascript:;">'+
  681. ' <span class="title">[关键字]'+keywordVal.name+'</span>'+
  682. ' </a>'+
  683. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+keywords+'</a></p>'+
  684. ' </div>'+
  685. ' </div>'+
  686. ' <div class="opr">'+
  687. '<a href="./index.php?c=platform&a=reply&do=post&m=keyword&rid=' + keywordVal.rid + '" target="_blank" class="del-gray">编辑</a> ' +
  688. '<a href="javascript:;" data-media="'+keywordVal.name+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  689. ' </div>'+
  690. '</div>'+
  691. '</li>'
  692. );
  693. });
  694. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal[0]);
  695. break;
  696. case 'module':
  697. angular.forEach(val, function(keywordVal, keywordKey) {
  698. replyVal.push(angular.toJson(keywordVal.rid));
  699. var keywords = '&nbsp;&nbsp;' + keywordVal.content;
  700. $('.keywords-list').append(
  701. '<li>'+
  702. '<div class="del-'+type+'-media">'+
  703. ' <div class="desc">'+
  704. ' <div class="media-content">'+
  705. ' <div class="appmsgSendedItem">'+
  706. ' <a class="title-wrp" href="javascript:;">'+
  707. ' <span class="icon cover" style="background-image:url('+keywordVal.icon+');"></span>'+
  708. ' <span class="title">[模块]'+keywordVal.title+'</span>'+
  709. ' </a>'+
  710. ' </div>'+
  711. ' </div>'+
  712. ' </div>'+
  713. ' <div class="opr">'+
  714. ' <a href="javascript:;" data-media="'+keywordVal.name+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  715. ' </div>'+
  716. '</div>'+
  717. '</li>'
  718. );
  719. });
  720. $(':hidden[name="reply[reply_'+type+']"]').val(val[0]['name']);
  721. break;
  722. case 'music':
  723. angular.forEach(val, function(musicVal, musicKey) {
  724. replyVal.push(angular.toJson({
  725. title: musicVal.title,
  726. url: musicVal.url,
  727. hqurl: musicVal.hqurl,
  728. description: musicVal.description,
  729. }));
  730. $('.keywords-list').append(
  731. '<li>'+
  732. '<div class="del-'+type+'-media">'+
  733. ' <div class="desc">'+
  734. ' <div class="media-content">'+
  735. ' <div class="appmsgSendedItem">'+
  736. ' <a class="title-wrp" href="javascript:;">'+
  737. ' <span class="icon cover" style="background-image:'+musicVal.url+';"></span>'+
  738. ' <span class="title">[音乐]'+musicVal.title+'</span>'+
  739. ' </a>'+
  740. ' <p class="desc"><a href="javascript:;" class="appmsg-desc">'+musicVal.description+'</a></p>'+
  741. ' </div>'+
  742. ' </div>'+
  743. ' </div>'+
  744. ' <div class="opr">'+
  745. ' <a href="javascript:;" data-media="'+musicVal.url+'" class="del-gray" onclick="delmedia(\''+type+'\', this)">删除</a>'+
  746. ' </div>'+
  747. '</div>'+
  748. '</li>'
  749. );
  750. });
  751. $(':hidden[name="reply[reply_'+type+']"]').val(replyVal);
  752. break;
  753. }
  754. //显示隐藏-start
  755. if((action == 'qr' || action == 'mass' || m == 'special' || m == 'welcome' || m == 'default') && replyVal.length > 0) {
  756. $('.we7-select-msg').addClass('hide');
  757. }
  758. //显示隐藏-end
  759. });
  760. };
  761. window.validateReplyForm = function(form, $, _, util, $scope) {
  762. var allEmpty = true;
  763. var modules = ['basic', 'news', 'image', 'music', 'voice', 'video', 'wxcard', 'keyword', 'module'];
  764. if($scope.reply.entry.module == 'reply') {
  765. angular.forEach(modules, function(val, key){
  766. if($(':hidden[name="reply[reply_'+val+']"]').val() != '') {
  767. allEmpty = false;
  768. };
  769. });
  770. }else {
  771. if($(':hidden[name="reply[reply_'+$scope.reply.entry.module+']"]').val() != ''){
  772. allEmpty = false;
  773. };
  774. }
  775. if(allEmpty) {
  776. util.message('请添加有效的回复内容。');
  777. return false;
  778. }
  779. return true;
  780. };
  781. function htmlEncode(str) {
  782. var s = "";
  783. if(str.length == 0) return "";
  784. s = str.replace(/&/g,"&amp;");
  785. s = s.replace(/</g,"&lt;");
  786. s = s.replace(/>/g,"&gt;");
  787. s = s.replace(/\'/g,"&#039;");
  788. s = s.replace(/\"/g,"&quot;");
  789. s = s.replace(/\n/g, "\\n");
  790. return s;
  791. }
  792. function htmlDecode(str) {
  793. var s = "";
  794. if(str.length == 0) return "";
  795. s = str.replace(/&amp;/g,"&");
  796. s = s.replace(/&lt;/g,"<");
  797. s = s.replace(/&gt;/g,">");
  798. s = s.replace(/&#039;/g,"'");
  799. s = s.replace(/&quot;/g,'"');
  800. s = s.replace(/\\n/g,'\n');
  801. return s;
  802. }
  803. function cutStr(str, len) {
  804. var str_length = 0;
  805. var str_len = 0;
  806. str_cut = new String();
  807. str_len = str.length;
  808. for (var i = 0; i < str_len; i++) {
  809. a = str.charAt(i);
  810. str_length++;
  811. if (escape(a).length > 4) {
  812. //中文字符的长度经编码之后大于4
  813. str_length++;
  814. }
  815. str_cut = str_cut.concat(a);
  816. if (str_length >= len) {
  817. str_cut = str_cut.concat("...");
  818. return str_cut;
  819. }
  820. }
  821. //如果给定字符串小于指定长度,则返回源字符串;
  822. if (str_length < len) {
  823. return str;
  824. }
  825. }
  826. $(document).on("mouseover","body",function(){
  827. $("[data-toggle='tooltip']").tooltip();
  828. });
  829. </script>