define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'customqrcode/index', add_url: 'customqrcode/add', edit_url: 'customqrcode/edit', del_url: 'customqrcode/del', multi_url: 'customqrcode/multi', download_url: 'customqrcode/download', table: 'custom_qrcode', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id',title:"索引"}, {field: 'type', title: __('type'),searchList: {"0":__('Type0'),"1":__('Type1'),"2":__('Type2'),"3":"推广链接"},formatter: Controller.api.formatter.type_text}, {field: 'title', title: __('Title')}, {field: 'url', title: __('Url'),operate: false, formatter: Controller.api.formatter.formt_url_list}, {field: 'all_read_uv', title: '累计阅读人数(今日阅读人数)', operate:false,formatter:function(value,row,index){ return value+'('+row.day_read_uv+')'; }}, { field: 'all_pay_money', title: '累计充值金额(今日充值金额)', operate: false, formatter: function (value, row, index) { return value + "(" + row.day_pay_money + ")"; } }, {field: 'uv_per_day', title:"自定义二维码每日关注UV",operate: false}, {field: 'uv', title:"自定义二维码关注UV",operate: false}, {field: 'cost', title: '推广成本', operate: false}, { field: 'createtime', title: '创建时间', operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) { var that = $.extend({}, this); var table = $(that.table).clone(true); if (row.type == 2) $(table).data("operate-edit", null); that.table = table; return Table.api.formatter.operate.call(that, value, row, index); }} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); //选择推广链接 $(document).on('click', ".select-referral-id", function () { var obj_group = $(this).parent().parent().parent(); parent.Backend.api.open($(this).attr("href") , __('Select'), {callback: function(data){ obj_group.find('.c-referral_url').val(data[0].source_url); obj_group.find('.c-referral_id').val(data[0].id); }}); return false; }); //选择二维码主题 $(document).on('click','.thumbnail',function(){ $('#input_template_id').val($(this).data('template_id')); $('.thumbnail').css('border-color',''); $(this).css('border-color','#18bc9c'); var that = this; //生成二维码图片 if ($('#input_template_id').val() > 0 && typeof Config.ids != 'undefined') { $.ajax({ url: '/admin/customqrcode/createimage/ids/'+Config.ids+'/tpl_id/'+ $('#input_template_id').val(), type: 'post', success: function (res) { if (res.code == 1) { $(that).find('img').attr('src', res.data); Toastr.success(res.msg); } else { Toastr.error('生成二维码失败'); } } }); } }); //选择自定义二维码类型 $(document).on('click','input[type="radio"]',function(){ switch(parseInt($(this).val())){ case 0: $('.select-group').html(''); break; case 1: $('.select-group').html($('.resource_select').html()); break; case 3: $('.select-group').html($('.referral_select').html()); break; } }); //选择资源 $(document).on('click', ".select-resources", function () { var obj_group = $(this).parent().parent(); var key = obj_group.find("input[name='row[eventkey]']").val(); parent.Backend.api.open($(this).find('a').attr("href") + "?key=" + key, __('Select'), {callback: function(data){ obj_group.find("input[name='row[eventkey]']").val(data.eventkey).trigger("change"); var keytitle = data.title; var cont = obj_group.find(".clickbox .create-click:first"); $(".keytitle", cont).remove(); if (keytitle) { cont.append('