define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'wechat/autoreply/index', add_url: 'wechat/autoreply/add', del_url: 'wechat/autoreply/del', edit_url: 'wechat/autoreply/edit', multi_url: 'wechat/autoreply/multi', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, sortName: 'id', columns: [ [ {field: 'state', checkbox: true, }, {field: 'id', title: __('Id')}, // {field: 'title', title: __('Title')}, {field: 'text', title: '触发关键字'}, { field: 'books', title: '书籍', halign: 'center', align: 'left', formatter: function (value, row, index) { if (row.book_names) { return row.book_names.join('
') } } }, {field: 'uv', title: '阅读人数'}, {field: 'subscribe', title: '关注人数'}, {field: 'money', title: '充值金额'}, // {field: 'eventkey', title: __('Event key')}, // {field: 'remark', title: __('Remark')}, {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime}, // {field: 'updatetime', title: __('Update time'), formatter: Table.api.formatter.datetime}, {field: 'status', title: __('Status'), formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function(value, row, index){ if (row.title == 'subscribe') { return '请到被关注回复中修改'; } else if (row.title == '签到') { return '请到签到自动回复中修改'; } else { return ' '; } } }, { field: 'tongji', title: __("统计"), operate: false, formatter: function (value, row, index) { return '订单详情'; } }, ] ] }); $(document).on('click', '.tongji', function () { Fast.api.open($(this).attr('href'), '订单详情', {}); return false; }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) { Vue.use(ELEMENT); Vue.use(component); Form.api.bindevent($("#edit-form")); var Main = { el: '#reply-form', data: function () { return { news: [], text: [], resource_type: 2, text_tip_input: { text_tip:'@$user_nickname,欢迎关注「$gzh_name」,点击下方继续阅读', text_split:'', }, keywords: '', kandian:Config.kandian, save: function (res) { if (res.code === 0) { Toastr.error(res.msg) }else{ Fast.api.close(); parent.$('.fa.fa-refresh').trigger('click') } } } } }; $('.loading').hide(); new Vue(Main) }); }, edit: function () { require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) { Vue.use(ELEMENT); Vue.use(component); Form.api.bindevent($("#edit-form")); var Main = { el: '#reply-form', data: function () { return { news: Config.row.news_content, text: Config.row.text_content, resource_type: Config.row.type == 'text' ? 2 : 3, text_tip_input: Config.row.text_tip_word, keywords: Config.row.text, kandian:Config.kandian, id:Config.row.id, save: function (res) { if (res.code === 0) { Toastr.error(res.msg) }else{ Fast.api.close(); parent.$('.fa.fa-refresh').trigger('click') } } } } }; $('.loading').hide(); new Vue(Main) }); }, signreply: function () { require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) { Vue.use(component); Vue.use(ELEMENT); var Main = { el: '#sign', data() { return { type: Config.type, text: eval(Config.text), text_split: Config.text_split } } }; new Vue(Main) }); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); var refreshkey = function (data) { $("input[name='row[eventkey]']").val(data.eventkey).trigger("change"); Layer.closeAll(); var keytitle = data.title; var cont = $(".clickbox .create-click:first"); $(".keytitle", cont).remove(); if (keytitle) { cont.append('
' + __('Event key') + ':' + keytitle + '
'); } }; $(document).on('click', "#select-resources", function () { var va = $("input[name='row[text]']").val(); var key = $("input[name='row[eventkey]']").val(); var filter = op = '' if (va != 'subscribe') { filter = encodeURIComponent('{"is_subscribe":"0"}'); op = encodeURIComponent('{"is_subscribe":"="}'); } parent.Backend.api.open($(this).attr("data") + "?key=" + key + "&filter1=" + filter + "&op1=" + op, __('Select'), {callback: refreshkey}); return false; }); $(document).on('click', "#add-resources", function () { var va = $("input[name='row[text]']").val(); var filter = op = '' if (va != 'subscribe') { filter = encodeURIComponent('{"is_subscribe":"0"}'); op = encodeURIComponent('{"is_subscribe":"="}'); } parent.Backend.api.open($(this).attr("data") + "?key=" + "&filter1=" + filter + "&op1=" + op, __('Add'), {callback: refreshkey}); return false; }); } } }; return Controller; });