截流自动化的商城平台
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <div class="layui-card-body">
  5. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  6. <div class="layui-colla-item">
  7. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  8. <div class="layui-colla-content layui-show">
  9. <p>*微信公众号回复管理,可以设置自动回复用户输入内容;</p>
  10. <p>*关注回复用于用户关注公众号时回复;</p>
  11. <p>*关键词回复用于用户输入内容时回复。关键词相同时,根据排序回复,排序值越小越前;</p>
  12. <p>*默认回复用于用户输入内容未匹配时回复;</p>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="layui-tab layui-tab-card" lay-filter="tab-all">
  18. <!-- 选项卡头部-->
  19. <ul class="layui-tab-title">
  20. {foreach $type_list as $type => $name}
  21. <li data-type={$type} {if 'subscribe' == $type } class="layui-this" {/if} >{$name}</li>
  22. {/foreach}
  23. </ul>
  24. <div class="layui-tab-item layui-show">
  25. <div class="layui-card">
  26. <div class="layui-card-body">
  27. <div style="padding-bottom: 10px;">
  28. <button class="layui-btn layui-btn-sm layuiadmin-btn-reply {$view_theme_color}" data-type="add">新增回复</button>
  29. </div>
  30. <table id="reply-lists" lay-filter="reply-lists"></table>
  31. <script type="text/html" id="status">
  32. <input type="checkbox" lay-filter="switch-status" data-id={{d.id}} data-field='status' lay-skin="switch"
  33. lay-text="显示|隐藏" {{# if(d.status){ }} checked {{# } }} />
  34. </script>
  35. <script type="text/html" id="reply-operation">
  36. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit"><i class="layui-icon"></i>编辑</a>
  37. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del" ><i class="layui-icon"></i>删除</a>
  38. </script>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <style>
  46. .layui-table-cell {
  47. height: auto;
  48. }
  49. </style>
  50. <script>
  51. // 初始回复类型
  52. var type = 'subscribe';
  53. layui.config({
  54. version:"{$front_version}",
  55. base: '/static/lib/' //静态资源所在路径
  56. }).use(['table', 'element'], function(){
  57. var $ = layui.$
  58. ,form = layui.form
  59. ,table = layui.table
  60. ,element = layui.element;
  61. // 初始获取列表数据
  62. getList()
  63. // 事件处理函数
  64. var active = {
  65. add: function(){
  66. var add = layer.open({
  67. type: 2
  68. ,title: '新增回复 '
  69. ,content: '{:url("wechat.reply/add")}?type='+type
  70. ,area: ['90%','90%']
  71. ,btn: ['确定', '取消']
  72. ,yes: function(index, layero){
  73. var iframeWindow = window['layui-layer-iframe'+ index]
  74. ,submitID = 'add-reply-submit'
  75. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  76. //监听提交
  77. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  78. var field = data.field;
  79. field['reply_type'] = type;
  80. like.ajax({
  81. url:'{:url("wechat.reply/add")}',
  82. data:field,
  83. type:"post",
  84. success:function(res)
  85. {
  86. if(res.code == 1)
  87. {
  88. layui.layer.msg(res.msg, {
  89. offset: '15px'
  90. , icon: 1
  91. , time: 1000
  92. });
  93. layer.close(index); //关闭弹层
  94. table.reload('reply-lists'); //数据刷新
  95. }
  96. },
  97. });
  98. });
  99. submit.trigger('click');
  100. }
  101. });
  102. }
  103. }
  104. // 监听文本框编辑
  105. table.on('edit(reply-lists)', function (obj) {
  106. var ids = [];
  107. var id = obj.data.id;
  108. var fields = obj.field;
  109. var field_value = obj.value;
  110. ids.push(id);
  111. if(isNaN(field_value)){
  112. var old_value=$(this).prev().text();
  113. layer.tips('请输入数字', $(this), {tips: [1, '#FF5722']});
  114. $(this).val(old_value);
  115. return false;
  116. }
  117. changeFields(ids,fields,field_value)
  118. });
  119. // 新增回复
  120. $('.layui-btn.layuiadmin-btn-reply').on('click', function(){
  121. var type = $(this).data('type');
  122. active[type] ? active[type].call(this) : '';
  123. });
  124. // 监听启用状态开关
  125. form.on('switch(switch-status)',function (obj) {
  126. var ids = [];
  127. var id = obj.elem.attributes['data-id'].nodeValue
  128. var fields = obj.elem.attributes['data-field'].nodeValue
  129. var field_value = 0;
  130. ids.push(id);
  131. if(this.checked){
  132. field_value = 1;
  133. }
  134. changeFields(ids,fields,field_value)
  135. })
  136. // 监听选项卡切换
  137. element.on('tab(tab-all)', function (data) {
  138. type = $(this).attr('data-type');
  139. getList();
  140. });
  141. // 加载列表数据
  142. function getList() {
  143. switch (type) {
  144. case "subscribe":
  145. var cols = [
  146. {field: 'name', title: '规则名称', align: 'center'}
  147. , {field: 'content_type', title: '回复类型', align: 'center'}
  148. , {field: 'content', title: '回复内容', align: 'center'}
  149. , {title:'启用状态', align: 'center', toolbar: '#status'}
  150. , {title: '操作', align: 'center', toolbar: '#reply-operation'}
  151. ];
  152. break;
  153. case "text":
  154. var cols = [
  155. {field: 'keyword', title: '关键词', align: 'center'}
  156. , {field: 'matching_type', title: '匹配方式', align: 'center'}
  157. , {field: 'content_type', title: '回复类型', align: 'center'}
  158. , {field: 'content', title: '回复内容', align: 'center'}
  159. , {title: 'status', title:'启用状态', align: 'center', toolbar: '#status'}
  160. , {field: 'sort', title: '排序', align: 'center',edit:'text'}
  161. , {title: '操作', align: 'center', toolbar: '#reply-operation'}
  162. ];
  163. break;
  164. case "default":
  165. var cols = [
  166. {field: 'name', title: '规则名称', align: 'center'}
  167. , {field: 'content_type', title: '回复类型', align: 'center'}
  168. , {field: 'content', title: '回复内容', align: 'center'}
  169. , {title: 'status', title:'启用状态', align: 'center', toolbar: '#status'}
  170. , {title: '操作', align: 'center', toolbar: '#reply-operation'}
  171. ];
  172. break;
  173. }
  174. //管理员管理
  175. table.render({
  176. elem: '#reply-lists'
  177. , url: '{:url("wechat.reply/lists")}?type='+type
  178. , cols: [
  179. cols
  180. ]
  181. , page: true
  182. , text: {none: '暂无数据!'}
  183. , response: {
  184. 'statusCode': 1
  185. }
  186. , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
  187. return {
  188. "code": res.code,
  189. "msg": res.msg,
  190. "count": res.data.count, //解析数据长度
  191. "data": res.data.list, //解析数据列表
  192. };
  193. }
  194. });
  195. }
  196. //监听工具条
  197. table.on('tool(reply-lists)', function(obj){
  198. if(obj.event === 'del'){
  199. var id = obj.data.id;
  200. var attr = obj.data.attr;
  201. var name = obj.data.name;
  202. layer.confirm('确认删除回复:'+'<span style="color: red">'+name+'</span>', function(index){
  203. like.ajax({
  204. url:'{:url("wechat.reply/del")}',
  205. data:{id:id},
  206. type:"post",
  207. success:function(res)
  208. {
  209. if(res.code == 1)
  210. {
  211. layui.layer.msg(res.msg, {
  212. offset: '15px'
  213. , icon: 1
  214. , time: 1000
  215. });
  216. layer.close(index); //关闭弹层
  217. table.reload('reply-lists'); //数据刷新
  218. }
  219. },
  220. });
  221. });
  222. }else if(obj.event === 'edit'){
  223. var id = obj.data.id;
  224. var edit = layer.open({
  225. type: 2
  226. ,title: '编辑回复'
  227. ,content: '{:url("wechat.reply/edit")}?id='+id
  228. ,area: ['90%','90%']
  229. ,btn: ['确定', '取消']
  230. ,yes: function(index, layero){
  231. var iframeWindow = window['layui-layer-iframe'+ index]
  232. ,submitID = 'edit-reply-submit'
  233. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  234. //监听提交
  235. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  236. var field = data.field;
  237. field['reply_type'] = type;
  238. like.ajax({
  239. url:'{:url("wechat.reply/edit")}',
  240. data:field,
  241. type:"post",
  242. success:function(res)
  243. {
  244. if(res.code == 1)
  245. {
  246. layui.layer.msg(res.msg, {
  247. offset: '15px'
  248. , icon: 1
  249. , time: 1000
  250. });
  251. layer.close(index); //关闭弹层
  252. table.reload('reply-lists'); //数据刷新
  253. }
  254. },
  255. });
  256. });
  257. submit.trigger('click');
  258. }
  259. })
  260. }
  261. });
  262. });
  263. function changeFields(ids,fields,value) {
  264. like.ajax({
  265. url:'{:url("wechat.reply/changeFields")}',
  266. data:{id:ids,field:fields,value:value,reply_type:type},
  267. type:'post',
  268. dataType:'json',
  269. success:function (res) {
  270. if(res.code == 1) {
  271. layui.layer.msg(res.msg, {
  272. offset: '15px'
  273. , icon: 1
  274. , time: 1000
  275. }, function(){
  276. location.href = location.href;
  277. });
  278. } else {
  279. layui.layer.msg(res.msg, {
  280. offset: '15px'
  281. , icon: 2
  282. , time: 1000
  283. }, function(){
  284. location.href = location.href;
  285. });
  286. }
  287. }
  288. })
  289. }
  290. </script>