123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- 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('<br>')
- }
- }
- },
- {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 '<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>';
- }
- }
- },
- {
- field: 'tongji',
- title: __("统计"),
- operate: false,
- formatter: function (value, row, index) {
- return '<a style="text-align:center" href="/admin/orders/index?mark=1022&push_id=' + row.id + '" class="btn btn-xs btn-success btn-editone tongji">订单详情</a>';
- }
- },
- ]
- ]
- });
- $(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('<div class="keytitle">' + __('Event key') + ':' + keytitle + '</div>');
- }
- };
- $(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;
- });
|