vipreply.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'wechat/vipreply/index',
  8. add_url: 'wechat/vipreply/add',
  9. del_url: 'wechat/vipreply/del',
  10. edit_url: 'wechat/vipreply/edit',
  11. }
  12. });
  13. var table = $("#table");
  14. // 初始化表格
  15. table.bootstrapTable({
  16. url: $.fn.bootstrapTable.defaults.extend.index_url,
  17. sortName: 'id',
  18. columns: [
  19. [
  20. {field: 'state', checkbox: true, operate: false},
  21. {field: 'id', title: __('Id'), operate: false},
  22. // {field: 'title', title: __('Title'),operate:false},
  23. {field: 'text', title: '触发关键字', operate: false},
  24. {field: 'uv', title: '阅读人数', operate: false},
  25. {field: 'subscribe', title: '关注人数', operate: false},
  26. {field: 'money', title: '充值金额', operate: false},
  27. // {field: 'eventkey', title: __('Event key'),operate:false},
  28. // {field: 'remark', title: __('Remark'),operate:false},
  29. {
  30. field: 'createtime',
  31. title: __('Create time'),
  32. formatter: Table.api.formatter.datetime,
  33. operate: false
  34. },
  35. // {field: 'updatetime', title: __('Update time'), formatter: Table.api.formatter.datetime,operate:false},
  36. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, operate: false},
  37. {
  38. field: 'operate',
  39. title: __('Operate'),
  40. table: table,
  41. events: Table.api.events.operate,
  42. formatter: function (value, row, index) {
  43. if (row.title == 'subscribe') {
  44. return '请到被关注回复中修改';
  45. } else if (row.title == '签到') {
  46. return '请到签到自动回复中修改';
  47. } else {
  48. return '<a href="/admin/wechat/autoreply/edit/ids/' + row.id + '" class="btn btn-xs btn-success btn-editone" title="" data-table-id="table" data-field-index="9" data-row-index="1" data-button-index="1"><i class="fa fa-pencil"></i></a> <a href="javascript:;" class="btn btn-xs btn-danger btn-delone" title="" data-table-id="table" data-field-index="9" data-row-index="1" data-button-index="2"><i class="fa fa-trash"></i></a>';
  49. }
  50. }
  51. },
  52. {
  53. field: 'event',
  54. title: '详情',
  55. table: table,
  56. events: Table.api.events.operate,
  57. formatter: function (value, row, index) {
  58. return '<a href="/admin/wechat/vipreply/detail/ids/' + row.id + '" class="btn btn-xs btn-success layer-open">查看详情</a>';
  59. }
  60. }
  61. ]
  62. ]
  63. });
  64. $(document).on('click', '.layer-open', function () {
  65. Fast.api.open($(this).attr('href'), $(this).data('title') ? $(this).data('title') : '详细信息', {});
  66. return false;
  67. });
  68. // 为表格绑定事件
  69. Table.api.bindevent(table);
  70. },
  71. add: function () {
  72. require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
  73. Vue.use(ELEMENT);
  74. Vue.use(component);
  75. Form.api.bindevent($("#edit-form"));
  76. var Main = {
  77. el: '#reply-form-vip',
  78. data: function () {
  79. return {
  80. news: [],
  81. text: [],
  82. resource_type: 2,
  83. deploy_type: 1,
  84. text_tip_input: {
  85. text_tip: '@$user_nickname,欢迎关注「$gzh_name」,点击下方继续阅读',
  86. text_split: '',
  87. },
  88. keywords: '',
  89. save: function (res) {
  90. if (res.code === 0) {
  91. Toastr.error(res.msg)
  92. } else {
  93. Fast.api.close();
  94. parent.$('.fa.fa-refresh').trigger('click')
  95. }
  96. }
  97. }
  98. }
  99. };
  100. $('.loading').hide();
  101. new Vue(Main)
  102. });
  103. },
  104. edit: function () {
  105. require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
  106. Vue.use(ELEMENT);
  107. Vue.use(component);
  108. Form.api.bindevent($("#edit-form"));
  109. var Main = {
  110. el: '#reply-form-vip',
  111. data: function () {
  112. return {
  113. news: Config.row.news_content,
  114. text: Config.row.text_content,
  115. deploy_type: parseInt(Config.row.deploy_type),
  116. resource_type: parseInt(Config.row.resource_type),
  117. text_tip_input: Config.row.text_tip_word,
  118. selected: Config.row.selected ? Config.row.selected:{},
  119. keywords: Config.row.keywords,
  120. id: Config.row.id,
  121. save: function (res) {
  122. if (res.code === 0) {
  123. Toastr.error(res.msg)
  124. } else {
  125. Fast.api.close();
  126. parent.$('.fa.fa-refresh').trigger('click')
  127. }
  128. }
  129. }
  130. }
  131. };
  132. $('.loading').hide();
  133. new Vue(Main)
  134. });
  135. },
  136. detail: function () {
  137. // 初始化表格参数配置
  138. Table.api.init({
  139. extend: {
  140. index_url: 'wechat/vipreply/detail',
  141. },
  142. search: false,
  143. });
  144. var table = $("#detail");
  145. // 初始化表格
  146. table.bootstrapTable({
  147. url: $.fn.bootstrapTable.defaults.extend.index_url + '?ids=' + Config.ids,
  148. sortName: 'id',
  149. columns: [
  150. [
  151. {field: 'id', title: __('Id'), operate: false},
  152. {field: 'nickname', title: '渠道昵称', operate: false},
  153. {field: 'a.nickname', title: '渠道昵称',visible:false, operate: 'LIKE'},
  154. {field: 'title', title: '触发关键字', operate: false},
  155. {field: 'uv', title: '阅读人数', operate: false},
  156. {field: 'subscribe', title: '关注人数', operate: false},
  157. {field: 'money', title: '充值金额', operate: false},
  158. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: false},
  159. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, operate: false}
  160. ]
  161. ]
  162. });
  163. // 为表格绑定事件
  164. Table.api.bindevent(table);
  165. },
  166. api: {
  167. bindevent: function () {
  168. Form.api.bindevent($("form[role=form]"));
  169. }
  170. }
  171. };
  172. return Controller;
  173. });