vipimagetextmedia.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'selectpage', 'gridify', 'custommain'], function ($, undefined, Backend, Table, Form, Template, Selectpage, Gridify, Custommain) {
  2. function excludeSpecial(s) {
  3. s = s.replace(/[\\\/\b\f\n\r\t\'\[\]\@\#\$\%\^\&\*\{\}\:\"\L\<\>\?]/g,'');
  4. return s;
  5. };
  6. $(document).on('keyup','#description, #description-book, #description-activity, #description-recent',function () {
  7. var descrp = $(this).val();
  8. $(this).val(excludeSpecial(descrp));
  9. });
  10. var Controller = {
  11. index: function () {
  12. // 初始化表格参数配置
  13. Table.api.init({
  14. extend: {
  15. index_url: 'vipcustom/vipimagetextmedia/index?table=' + Config.table + '&table_status=' + Config.table_status,
  16. },
  17. searchFormVisible: true,
  18. search: false
  19. });
  20. var table = $("#table");
  21. // 初始化表格
  22. table.bootstrapTable({
  23. url: $.fn.bootstrapTable.defaults.extend.index_url,
  24. pk: 'id',
  25. sortName: 'id',
  26. clickToSelect: false,
  27. pageSize: 12, //每页的记录行数(*)
  28. pageList: [12, 36, 72, 120], //可供选择的每页的行数(*)
  29. columns: [Controller.api.showFilterColumns(table)],
  30. onLoadSuccess: function () { //加载成功时执行
  31. },
  32. onPostBody: function () {
  33. $('#table td').attr('rowspan', '1000');
  34. var ooptions = {
  35. srcNode: 'tr', // grid items (class, node)
  36. margin: '0', // margin in pixel, default: 0px
  37. width: '296px', // grid item width in pixel, default: 220px
  38. max_width: '', // dynamic gird item width if specified, (pixel)
  39. resizable: true, // re-layout if window resize
  40. transition: 'all 0.5s ease' // support transition for CSS3, default: all 0.5s ease
  41. }
  42. $('#table').gridify(ooptions);
  43. }
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. //tooltip
  48. $(document).on('mouseover', '#table td', function () {
  49. $('.wxb-card-list-scroll .anticon').tooltip();
  50. $('[rel="popover"]').popover({
  51. trigger: 'manual',
  52. placement: 'top',
  53. html: true,
  54. content: function () {
  55. var ids = $(this).data('rowid');
  56. /*jshint multistr: true*/
  57. return '<div class="msg_popover_but_box">\
  58. <a href="javascript:;" class="btn-multi-ajax" data-href="/admin/vipcustom/vipimagetextmedia/multisendmessage?table=media&ids=' + ids + '&official_type=0">群发服务号</a>\
  59. <a href="javascript:;" class="btn-multi-ajax" data-href="/admin/vipcustom/vipimagetextmedia/multisendmessage?table=media&ids=' + ids + '&official_type=1">群发订阅号</a>\
  60. </div>';
  61. }
  62. }).on("mouseenter", function () {
  63. var _this = this;
  64. $(this).popover("show");
  65. $(this).siblings(".popover").on("mouseleave", function () {
  66. $(_this).popover('hide');
  67. });
  68. }).on("mouseleave", function () {
  69. var _this = this;
  70. setTimeout(function () {
  71. if (!$(".popover:hover").length) {
  72. $(_this).popover("hide");
  73. }
  74. }, 100);
  75. });
  76. });
  77. //群发消息
  78. $(document).on('click', '.btn-multi-ajax', function () {
  79. var stxt = $(this).text();
  80. var multi_url = $(this).attr('data-href');
  81. Fast.api.open(multi_url, stxt, {
  82. callback: function (data) {
  83. if(!data) return false;
  84. var data = data[0];
  85. console.log(data);
  86. }
  87. });
  88. });
  89. //删除
  90. $(document).on('click', '.btn-del-ajax', function () {
  91. var del_url = $(this).attr('data-href');
  92. layer.confirm("确定删除此项?", {
  93. icon: 3,
  94. title: "温馨提示",
  95. shadeClose: true
  96. }, function (index) {
  97. layer.close(index);
  98. $.get(del_url, {}, function (data) {
  99. if (data.code) {
  100. var msg = data.msg != '' ? data.msg : '操作成功';
  101. Toastr.success(msg);
  102. table.bootstrapTable('refresh');
  103. } else {
  104. var msg = data.msg != '' ? data.msg : '操作失败';
  105. Toastr.error(msg);
  106. }
  107. });
  108. }, function () {
  109. layer.close();
  110. });
  111. });
  112. // 打开详情页面
  113. $(document).on('click', '.btn-view-ajax', function () {
  114. Fast.api.open($(this).attr('data-href'), '查看详情', {});
  115. });
  116. //消息图文素材库列表tit
  117. $(document).on('click', '.anticon-title-edit', function () {
  118. var $this = $(this);
  119. var sid = $this.data('id');
  120. var nindex = $this.parents('li').index();
  121. var stit = $this.parents('li').find('.article-item-title').text();
  122. layer.open({
  123. type: 1,
  124. title: false,
  125. maxmin: false,
  126. zIndex:1800,
  127. area: ['auto', 'auto'],
  128. btn: ['确认', '取消'],
  129. shadeClose: true,
  130. resize: false,
  131. skin: 'layui-layer-rim',
  132. content: '<div class="anticon_edit_box">\
  133. <div class="anticon_edit_select_tit_box">\
  134. <strong>当前标题:</strong>\
  135. <p>' + stit + '</p>\
  136. <a href="javascript:;" class="anticon_edit_select_tit_box_a"><i class="fa fa-pencil"></i></a>\
  137. </div>\
  138. <div class="anticon_edit_input_tit_box">\
  139. <strong>修改为:</strong>\
  140. <div class="anticon_edit_input_tit"><input type="text" value="' + stit + '" /></div>\
  141. </div>\
  142. </div>',
  143. yes: function (index, layero) {
  144. var stit = $(layero.selector + ' p').text();
  145. var sinputtit = $(layero.selector + ' input').val();
  146. if (sinputtit) {
  147. stit = sinputtit;
  148. }
  149. //sid 列表id stit 修改的标题内容
  150. // 修改Title
  151. $.ajax({
  152. type: 'get',
  153. url: './vipcustom/vipimagetextmedia/edittitle?ids=' + sid + '&title=' + stit + '&index=' + nindex,
  154. success: function (data) {
  155. console.log(data);
  156. $this.parents('li').find('.article-item-title').text(data.data);
  157. }
  158. })
  159. layer.close(index);
  160. },
  161. btn2: function (index, node) {
  162. layer.close(index)
  163. }
  164. });
  165. });
  166. //修改封面
  167. $(document).on('click', '.anticon-cover-edit', function () {
  168. var $this = $(this);
  169. var sid = $this.data('id');
  170. var nindex = $this.parents('li').index();
  171. var stit = $this.parents('li').find('.article-item-cover');
  172. Fast.api.open('manage/cover/select', '选择', {
  173. callback: function (data) {
  174. // console.log('展示image回调', data);
  175. //sid 列表id image 修改封面image
  176. $.ajax({
  177. type: 'get',
  178. url: './vipcustom/vipimagetextmedia/editcover?ids=' + sid + '&cover=' + data.image + '&index=' + nindex,
  179. success: function (data) {
  180. $this.parents('li').find('.article-item-cover').css('background-image', 'url(' + data.data + ')');
  181. }
  182. })
  183. }
  184. });
  185. });
  186. //修改图文内容
  187. $(document).on('click', '.anticon-novel-edit', function () {
  188. var $this = $(this);
  189. var nIndex = $this.parents('li').index();
  190. var sid = $this.data('id');
  191. $.ajax({
  192. type: 'get',
  193. url: 'vipcustom/vipimagetextmedia/getMediaMessage?ids=' + sid + '&index=' + nIndex,
  194. success: function (data) {
  195. if (!data.code) {
  196. Fast.api.open('vipcustom/vipimagetextmedia/editimagetext?ids=' + sid + '&index=' + nIndex + '&json=' + encodeURIComponent(data.data), '修改内容', {
  197. callback: function (data) {
  198. var data = data;
  199. $.ajax({
  200. type: 'get',
  201. url: 'vipcustom/vipimagetextmedia/editLink?ids=' + sid + '&index=' + nIndex + '&message_json=' + encodeURIComponent(JSON.stringify(data)),
  202. success: function (data) {
  203. if (data.code == 0) {
  204. Toastr.success('成功');
  205. } else {
  206. Toastr.error('失败');
  207. }
  208. }
  209. })
  210. }
  211. });
  212. }
  213. }
  214. })
  215. });
  216. require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
  217. Vue.use(ELEMENT);
  218. Vue.use(component);
  219. var Main = {
  220. el: '#title-select',
  221. methods: {
  222. select: function (value) {
  223. $('.anticon_edit_input_tit').find('input').val(value);
  224. }
  225. }
  226. };
  227. new Vue(Main)
  228. });
  229. },
  230. //编辑图文消息
  231. editimagetext: function () {
  232. Controller.api.bindevent();
  233. var spage = $('#c-book_book_name').val();
  234. var sbl = true;
  235. var selectdata = '';
  236. $('#c-book_book_name').selectPage({
  237. eAjaxSuccess: function (d) {
  238. if (selectdata && JSON.stringify(selectdata) != JSON.stringify(d)) {
  239. $('#select_book_id').val('');
  240. }
  241. selectdata = d;
  242. return d ? d : '';
  243. },
  244. eSelect: function (d) {
  245. selectdata = '';
  246. $('#c-book_book_name').val(d.name);
  247. $('#select_book_id').val(d.id);
  248. $('#select_book_id').attr('data-sex_text', d.sex_text);
  249. $("#description-book").val(d.description);
  250. Custommain.get_channel_book_name();
  251. },
  252. eClear: function () {
  253. $('#select_book_id').val('');
  254. }
  255. });
  256. if(Config.bnotin.length>0){
  257. $.each(Config.bnotin,function (index,value) {
  258. if($('#select_book_id').val().indexOf(value)!=-1){
  259. $('#select_book_id').val('');
  260. $('#c-book_book_name').val('');
  261. $('#c-book_book_name_text').val('');
  262. $('#description-book').val('');
  263. return false;
  264. }
  265. });
  266. }
  267. $(document).on('click','#c-mini_type',function () {
  268. $(this).change(function(){
  269. var value = $(this).find('input:checked').val();
  270. console.log(value);
  271. switch (value) {
  272. case "3":
  273. $('.mini-type3').show()
  274. break;
  275. case "4":
  276. $('.mini-type3').hide()
  277. break;
  278. }
  279. })
  280. })
  281. require(['upload'], function (Upload) {
  282. var data = {};
  283. data.width=1080;
  284. data.height = 864;
  285. Upload.api.plupload(".mini_plupload", function (data, ret) {
  286. $('.mini-card').find('.img_card img').attr('src',data.url);
  287. $('.mini-image').val(data.url);
  288. $('.mini-card').find('.inner').hide();
  289. $('.mini-card').find('.img_card').show();
  290. });
  291. });
  292. },
  293. //图文客服消息 群发 订阅号 服务号
  294. multisendmessage: function () {
  295. //发送 订阅号/服务号 验证
  296. $("#add-form").data("validator-options", {
  297. ignore: ':hidden',
  298. beforeSubmit: function (form) {
  299. var user_json = $.parseJSON($('.img_txt_hidde_input_no').val())
  300. if (user_json.all==0 && !user_json.subscribe_time) {
  301. var sub_from = (new Moment($('input[name="row[sub_from]"]').val())).valueOf() / 1000
  302. var sub_to = (new Moment($('input[name="row[sub_to]"]').val())).valueOf() / 1000
  303. if(!sub_from && !sub_to){
  304. Toastr.error("起止时间不能为空");
  305. return false;
  306. }else{
  307. user_json.subscribe_range = sub_from +'-'+ sub_to;
  308. }
  309. }
  310. $('.img_txt_hidde_input_no').val(JSON.stringify(user_json));
  311. var senddyhradioval = $('#dyhradio input').val();
  312. if ($(":checkbox[name^='row[sub_id]']", $("#add-form")).length) {
  313. if (!$('#c-name').val()) {
  314. Toastr.error("请选择需要发送的服务号");
  315. return false;
  316. }
  317. var other_tips = $(":checked[name^='row[sub_id]']", $("#add-form"));
  318. if (other_tips.length <= 0) {
  319. Toastr.error("请选择需要发送的订阅号");
  320. return false;
  321. }
  322. if (senddyhradioval < other_tips.length) {
  323. Toastr.error("最多可选择发送" + senddyhradioval + '个订阅号');
  324. return false;
  325. }
  326. }
  327. if (!$('.js_selected_group_id').val()) {
  328. if ($(":checkbox[name^='row[service_id]']", $("#add-form")).length) {
  329. var other_tips = $(":checked[name^='row[service_id]']", $("#add-form"));
  330. if (other_tips.length <= 0) {
  331. Toastr.error("请选择需要发送的服务号");
  332. return false;
  333. }
  334. if (senddyhradioval < other_tips.length) {
  335. Toastr.error("最多可选择发送" + senddyhradioval + '个服务号');
  336. return false;
  337. }
  338. }
  339. }
  340. //发送时间必须大于当前时间
  341. var sdatatime=$('#c-sendtime').val()+'';
  342. sdatatime = sdatatime.replace(/-/g,'/');
  343. sdatatime =new Date(sdatatime).getTime();
  344. if(sdatatime <= new Date().getTime()){
  345. Toastr.error("发送时间必须大于当前时间");
  346. return false;
  347. }
  348. }
  349. });
  350. Controller.api.bindevent();
  351. },
  352. //查看详情
  353. viewdetail: function () {
  354. // 初始化表格参数配置
  355. Table.api.init({
  356. extend: {
  357. getimage_url: window.location.href,
  358. },
  359. search: false,
  360. showToggle: false,
  361. showColumns: false,
  362. showExport: false,
  363. commonSearch: false
  364. });
  365. var table = $("#table");
  366. //当表格数据加载完成时
  367. table.on('load-success.bs.table', function (e, data) {
  368. //这里可以获取从服务端获取的JSON数据
  369. //console.log(data);
  370. //这里我们手动设置底部的值
  371. //$("#money").text(data.extend.money);
  372. //$("#price").text(data.extend.price);
  373. });
  374. // 初始化表格
  375. table.bootstrapTable({
  376. url: $.fn.bootstrapTable.defaults.extend.getimage_url,
  377. pk: 'id',
  378. sortName: 'id',
  379. columns: [Controller.api.getimagelist(table)]
  380. });
  381. // 为表格绑定事件
  382. Table.api.bindevent(table);
  383. },
  384. api: {
  385. showFilterColumns: function (table) {
  386. var cols = new Array();
  387. cols.push({
  388. field: 'id',
  389. title: "素材ID",
  390. visible: false
  391. });
  392. cols.push({
  393. field: 'message_json$[*].book_name',
  394. title: "书籍名称",
  395. visible: false,
  396. operate: 'LIKE %...%'
  397. });
  398. cols.push({
  399. field: 'id',
  400. operate: false,
  401. formatter: Controller.api.formatter.showStyle
  402. });
  403. return cols;
  404. },
  405. getimagelist: function (table) {
  406. var cols = new Array();
  407. cols.push({
  408. field: 'title',
  409. title: "标题",
  410. operate: false
  411. });
  412. cols.push({
  413. field: 'image',
  414. title: "图片",
  415. operate: false,
  416. formatter: Controller.api.formatter.showImage
  417. });
  418. /* cols.push({
  419. field: 'push',
  420. title: "推广类型",
  421. operate: false,
  422. formatter: Controller.api.formatter.showPushType
  423. });*/
  424. cols.push({
  425. field: 'type',
  426. title: "链接类型",
  427. operate: false,
  428. formatter: Controller.api.formatter.showType
  429. });
  430. cols.push({
  431. field: 'book_id',
  432. title: "书籍ID",
  433. operate: false
  434. });
  435. cols.push({
  436. field: 'book_name',
  437. title: "书籍名称/活动名称/菜单名称",
  438. operate: false
  439. });
  440. /* cols.push({
  441. field: '',
  442. title: "推广位置",
  443. operate: false,
  444. formatter: Controller.api.formatter.showPosition
  445. });*/
  446. //cols.push({field: 'book_id', title:"阅读原文连接"});
  447. return cols;
  448. },
  449. bindevent: function () {
  450. $('#c-menu_menu_id,#c-activity_activity_id').change(function(){
  451. Custommain.get_channel_other_name();
  452. });
  453. $(document).on('click', "input[name='book[push]']", function () {
  454. var type = $(this).val();
  455. $('.group-push').addClass('hide');
  456. $('.group-push input').attr('disabled');
  457. $('#group-push-' + type).removeClass('hide');
  458. $('#group-push-' + type + ' input').removeAttr('disabled');
  459. Custommain.get_channel_book_name();
  460. });
  461. Custommain.checkbox_relation('#dyhradio', '#dyhcheck');
  462. //推广链接类型id
  463. var simgtexttype = $('input[name="row[imgtxt_type]"]:checked').val();
  464. var oshowfrombox = $('#group-type-0 input[type="hidden"]');
  465. Custommain.bind_form_validation();
  466. Form.api.bindevent($("form[role=form]"),
  467. function (data) {
  468. if (data.jump) {
  469. window.location.href = data.jump;
  470. } else {
  471. Fast.api.close(data);
  472. }
  473. },
  474. function (data) {
  475. console.log('TODO:这里需要处理。。。');
  476. console.log('error', data);
  477. }
  478. );
  479. if ($('#usercondition').val() && $('#usercondition').val().length > 0) {
  480. $tagval = JSON.parse($('#usercondition').val());
  481. if ($tagval.all == 1) { //选择所有用户
  482. $('#type-all').attr('checked', true);
  483. var type = 'all';
  484. $('.group-tag-type').addClass('hide');
  485. $('.group-tag-type input').attr('disabled');
  486. $('#group-tag-type-' + type).removeClass('hide');
  487. $('#group-tag-type-' + type + ' input').removeAttr('disabled');
  488. }
  489. }
  490. $.ajax({
  491. type: 'get',
  492. url: '/admin/custom/ajaxcategory',
  493. cache: false,
  494. async: false,
  495. success: function (res) {
  496. data = res.data;
  497. var htmlstr = '';
  498. for (var i = 0; i < data.length; i++) {
  499. htmlstr += '<span data-cid="' + data[i].id + '" >' + data[i].name + '</span>';
  500. }
  501. $('#ctag').append(htmlstr);
  502. $('#mustbe').html('约' + res.ids + '人');
  503. if ($('#usercondition').val() && $('#usercondition').val().length > 0) {
  504. $tagval = JSON.parse($('#usercondition').val());
  505. $("#sex span[data-sex='" + $tagval.sex + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  506. $("#ctag span[data-cid='" + $tagval.tag + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  507. $("#consume span[data-fee='" + $tagval.consume + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  508. $("#kandian span[data-kandian='" + $tagval.kandian + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  509. // $("#subTime span[data-week='" + $tagval.subscribe_time + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  510. // if ($tagval.subscribe_range) {
  511. // var t_l = $tagval.subscribe_range.split('-');
  512. // $('input[name="row[sub_from]"]').val(Moment(parseInt(t_l[0]) * 1000).format("YYYY-MM-DD HH:mm:ss"));
  513. // $('input[name="row[sub_to]"]').val(Moment(parseInt(t_l[1]) * 1000).format("YYYY-MM-DD HH:mm:ss"));
  514. // }
  515. $('#subscribe_time2').hide();
  516. if ($tagval.subscribe_time) {
  517. $("#subscribe_time1 span[data-fee='" + $tagval.subscribe_time + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
  518. $('#subscribe_time2').hide();
  519. } else {
  520. $("#subscribe_time1 span").last().addClass('s_s_tag').siblings().removeClass('s_s_tag');
  521. }
  522. } else {
  523. var tagObj1 = {
  524. sex: -1,
  525. mobile_system: 0,
  526. tag: -1,
  527. consume: -1,
  528. kandian: -1,
  529. subscribe_time: -1,
  530. subscribe_range:-1,
  531. all: "0"
  532. };
  533. var ucon1 = JSON.stringify(tagObj1);
  534. $('#usercondition').val(ucon1);
  535. }
  536. },
  537. error: function (err) {
  538. }
  539. });
  540. $(document).on('click', '.s_tag_li_list span', function () {
  541. var $this = $(this);
  542. $this.addClass('s_s_tag').siblings('span').removeClass('s_s_tag');
  543. var tagObj = {
  544. sex: $('#sex span.s_s_tag').data('sex'),
  545. mobile_system: $('#mobile_system span.s_s_tag').data('mobile_system'),
  546. tag: $('#ctag span.s_s_tag').data('cid'),
  547. consume: $('#consume span.s_s_tag').data('fee'),
  548. kandian: $('#kandian span.s_s_tag').data('kandian'),
  549. subscribe_time: $('#subscribe_time1 span.s_s_tag').data('fee'),
  550. all: "0"
  551. }
  552. if ($(this).parent().attr('id') == 'subscribe_time1') {
  553. if ($(this).data('fee')) {
  554. $('#cdstarttime').val('');
  555. $('#cdendtime').val('');
  556. $('#subscribe_time2').hide();
  557. } else {
  558. $('#subscribe_time2').show();
  559. }
  560. }
  561. var uconditon = JSON.stringify(tagObj);
  562. $('#usercondition').val(uconditon);
  563. });
  564. //测试发送
  565. $('.test_fans_but').click(function(){
  566. Custommain.fans_send_message();
  567. });
  568. /**
  569. * 资源类型管理
  570. */
  571. $(document).on('click', "input[name='row[type]']", function () {
  572. var type = $(this).val();
  573. if (type=='all'){
  574. var tagObj = {
  575. all:"1"
  576. }
  577. }else{
  578. var tagObj ={
  579. sex:-1,
  580. mobile_system: 0,
  581. tag:-1,
  582. consume:-1,
  583. kandian: -1,
  584. subscribe_time:-1,
  585. all:"0"
  586. }
  587. }
  588. var ucon = JSON.stringify(tagObj);
  589. $('#usercondition').val(ucon);
  590. $('.group-tag-type').addClass('hide');
  591. $('.group-tag-type input').attr('disabled');
  592. $('#group-tag-type-' + type).removeClass('hide');
  593. $('#group-tag-type-' + type+' input').removeAttr('disabled');
  594. });
  595. //切换推广链接类型
  596. $(document).on('click', "input[name='row[imgtxt_type]']", function () {
  597. var type = $(this).val();
  598. $('.group-type').addClass('hide');
  599. $('.group-type input').attr('disabled');
  600. $('#group-type-' + type).removeClass('hide');
  601. $('#group-type-' + type + ' input').removeAttr('disabled');
  602. oshowfrombox = $('#group-type-' + type + ' input[type="hidden"]');
  603. simgtexttype = type;
  604. if(type == 0){
  605. Custommain.get_channel_book_name();
  606. }else{
  607. Custommain.get_channel_other_name();
  608. }
  609. });
  610. //修改发送消息时间
  611. $(document).on('click', '.s_time_box span', function () {
  612. var $this = $(this);
  613. var nval = parseInt($this.attr('stime'));
  614. var ntime = Date.parse(new Date());
  615. var nt = ntime + nval;
  616. $('#c-sendtime').val(GetRTime(nt));
  617. });
  618. function GetRTime(time) {
  619. var stime;
  620. time = new Date(time);
  621. var year = time.getYear() + 1900;
  622. var month = time.getMonth() + 1;
  623. var day = time.getDate();
  624. var hours = time.getHours();
  625. var minutes = time.getMinutes();
  626. var seconds = time.getSeconds();
  627. stime = year + '-' +
  628. (month < 10 ? '0' + month : month) + '-' +
  629. (day < 10 ? '0' + day : day) + ' ' +
  630. (hours < 10 ? '0' + hours : hours) + ':' +
  631. (minutes < 10 ? '0' + minutes : minutes) + ':' +
  632. (seconds < 10 ? '0' + seconds : seconds);
  633. return stime;
  634. }
  635. $(document).on('click', '.btn-close', function () {
  636. Fast.api.close();
  637. });
  638. },
  639. formatter: {
  640. showImage: function (value, row, index) {
  641. return '<img style="height:100px;" src="' + value + '"/>';
  642. },
  643. showType: function (value, row, index) {
  644. var type_arr = ['书籍', '活动', '继续阅读', '菜单'];
  645. return type_arr[value];
  646. },
  647. showPosition: function (value, row, index) {
  648. return index + 1;
  649. },
  650. showPushType: function (value, row, index) {
  651. var push_arr = ['外推', '内推'];
  652. return push_arr[value];
  653. },
  654. showStyle: function (value, row, index) {
  655. var message_data = JSON.parse(row.message_json).shift();
  656. /*jshint multistr: true */
  657. var html = '<div class="wxb-card-list-scroll"><div class="wxb-card-item"><div class="wxb-card-item-inner"><div class="item-header"><div>';
  658. html += '<div class="tweets-card-title"><p>素材id:' + row.id + '</p></div>';
  659. html += '<div class="tweets-card-title"><p>创建时间:' + Table.api.formatter.datetime(row.createtime, row, index) + '</p></div>';
  660. html += '<div class="tweets-card-title"><p>修改时间:' + Table.api.formatter.datetime(row.updatetime, row, index) + '</p></div>';
  661. var offical_type = parseInt(row.official_account_type) == 1 ? '订阅号' : '服务号';
  662. /*var send_color = '';
  663. var send_text = '';
  664. switch (parseInt(row.status)) {
  665. case 0:
  666. send_color = 'red';
  667. send_text = '待发送';
  668. break;
  669. case 1:
  670. send_color = '#FF9900';
  671. send_text = '群发中';
  672. break;
  673. case 2:
  674. send_color = '#88d743';
  675. send_text = '已群发';
  676. break;
  677. }
  678. html += '<div class="tweets-card-title"><p style="color:' + send_color + '">发送时间:' + Table.api.formatter.datetime(row.sendtime, row, index) + ' ' + send_text + '</p></div>';
  679. html += '<div class="tweets-card-title"><p>群发类型:' + offical_type + '</p></div>';
  680. */
  681. html += '</div></div><ul class="article-list"><li> <a class="article-item">';
  682. html += '<div class="novel-img article-item-cover" style="background-image: url(' + message_data.image + ');"></div>';
  683. html += '<p class="article-item-title">' + message_data.title + '</p>';
  684. html += '</a><div class="article-actions">';
  685. html += '<div> <span class="action-item"> <i class="anticon anticon-title-edit" style="font-size: 17px;" data-id="' + row.id + '" data-toggle="tooltip" data-original-title="修改标题"></i> </span> <span class="action-item"> <i class="anticon anticon-cover-edit" data-toggle="tooltip" data-original-title="修改封面" data-id="' + row.id + '"></i> </span> <span class="action-item"> <i class="anticon anticon-novel-edit" style="font-size: 13px;" data-toggle="tooltip" data-original-title="编辑链接" data-id="' + row.id + '"></i> </span> <span class="action-item action-item-up"> <i class="anticon anticon-arrow-up" data-toggle="tooltip" data-original-title="上移"></i> </span> <span class="action-item action-item-down"> <i class="anticon anticon-arrow-down" data-toggle="tooltip" data-original-title="下移"></i> </span></div>';
  686. html += '</ul><ul class="footer-btns">';
  687. html += '<li><a class="btn-del-ajax" href="javascript:void(0);" data-href="/admin/vipcustom/vipimagetextmedia/del?table=media&ids=' + row.id + '">删除</a></li>';
  688. html += '<li><a class="btn-view-ajax" href="javascript:void(0);" data-href="/admin/vipcustom/vipimagetextmedia/viewdetail?ids=' + row.id + '">查看详情</a></li>';
  689. //html += '<li><a rel="popover" data-rowid="' + row.id + '">群发</a></li>';
  690. html += '<li><a class="btn-multi-ajax" data-href="/admin/vipcustom/vipimagetextmedia/multisendmessage?table=media&ids=' + row.id + '&official_type=0" data-rowid="' + row.id + '">群发</a></li>';
  691. html += '</ul></div></div></div>';
  692. return html;
  693. }
  694. }
  695. }
  696. };
  697. return Controller;
  698. });