123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'qrcode'], function ($, undefined, Backend, Table, Form, Qrcode) {
- $(document).on('click', '.short_link_but', function () {
- var $this = $(this);
- $this.hide().siblings('.short_link').show();
- });
- $(document).on("click", '.qrcode', function () {
- var qrUrl = $(this).data("qrcode");
- Fast.api.open('referral/referral/show_tpl?url='+qrUrl, '图片二维码', {});
- });
- $(document).on('click','.btn-edit-row',function(){
- //btn-edit-row
- Fast.api.open($(this).data('href'), "编辑活动", {
- callback: function (data) {
- if(data.code){
- window.location.reload();
- }
- }
- });
- });
- var Controller = {
- showActivityField:function(table){
- var field = new Array();
- field.push({checkbox: true});
- field.push({field: 'id', title: __('Id')});
- field.push({field: 'name', title: __('活动名称'), operate: 'LIKE %...%'});
- field.push({field: 'copywriting', title: __('活动文案'), operate: 'LIKE %...%'});
- field.push({field: 'starttime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime});
- field.push({field: 'endtime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime});
- field.push({field:'status', title:'活动状态',formatter: Controller.api.formatter.activitstatus, operate:false});
- field.push({field:'money',title:'今日充值',formatter:Controller.api.formatter.money, operate:false});
- field.push({field:'allmoney',title:'累计充值',formatter:Controller.api.formatter.allmoney, operate:false});
- field.push({field: 'operate', title: __('Operate'), table: table, events: Controller.api.events.operate, buttons: [
- {
- name: 'operate',
- text: __('添加渠道账号'),
- title: __('添加渠道账号'),
- classname: 'btn btn-xs btn-primary btn-add-channels',
- icon: 'fa fa-list',
- },
- {
- name: 'operate',
- text: __('指定渠道分组'),
- title: __('指定渠道分组'),
- classname: 'btn btn-xs btn-success btn-add-group',
- icon: 'fa fa-pencil',
- }
- ],
- formatter: Table.api.formatter.buttons
- });
- field.push({field: 'chakan', title: __("查看"), operate: false,
- formatter: function (value, row, index) {
- var str = '';
- if (row.endtime > Config.time && row.starttime > Config.time) {
- //未开始的
- str += '<a data-href="/admin/activity/edit?type=1&ids='+row.id+'" href="javascript:;" class="btn btn-xs btn-success btn-edit-row" title="" data-table-id="table" data-field-index="12" data-row-index="0" data-button-index="1"><i class="fa fa-pencil"></i></a>';
- }
- return str +'<a style="float:left;margin-left: 10%" href="vipactivity/viewdata?ids=' + row.id + '" class="btn btn-xs btn-success book_but">查看</a>';
- },
- })
- return field;
- },
- showChannelActivityField:function(table){
- var field = new Array();
- field.push({checkbox: true});
- field.push({field: 'id', title: __('Id')});
- field.push({field: 'admin_id', title: __('渠道ID')});
- field.push({field: 'name', title: __('活动名称')});
- field.push({field: 'copywriting', title: __('活动文案')});
- field.push({field: 'starttime', title: __('开始时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime});
- field.push({field: 'endtime', title: __('结束时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime});
- field.push({field:'money',title:'今日充值',formatter:Controller.api.formatter.money});
- field.push({field:'allmoney',title:'累计充值',formatter:Controller.api.formatter.allmoney});
- field.push({field:'status', title:'活动状态',formatter: Controller.api.formatter.activitstatus});
- return field;
- },
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'vipactivity/index',
- add_url: 'activity/add?type='+Config.activity_type,
- table: 'activity',
- do_choose: 'vipactivity/doChoose',
- select_url: 'referral/vipreferral/selectchannel',
- disable_url: 'referral/referral/disable?isVip=1'
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [Controller.showActivityField(table)]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- viewdata: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'vipactivity/viewdata?ids='+ Config.id,
- add_url: 'referral/vipreferral/selectchannel',
- },
- showToggle: false,
- showColumns: false,
- visible: false,
- commonSearch: false,
- showExport: false,
- searchFormVisible: false,
- search: false
- });
- var table = $("#table");
- // 初始化表格
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [Controller.showChannelActivityField(table)]
- });
- //获取选中数据
- $(document).on('click', ".btn-open-choose", function () {
- var url = 'referral/vipreferral/selectchannel';
- Fast.api.open(url, __('Add'), {
- callback: function (data) {
- if (data.length > 0) {
- var qdsIds = '';
- var doUrl = 'vipactivity/doChoose/ids/'+Config.referral_id;
- for (var i in data) {
- qdsIds += data[i].qds_id + ',';
- }
- $.ajax({
- url: doUrl + '/qdsIds/' + qdsIds,
- type: 'get',
- success: function (res) {
- Toastr.success('操作成功');
- //刷新页面
- table.bootstrapTable('refresh');
- }
- });
- }
- }
- });
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- selectchannel: function() {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'referral/vipreferral/selectchannel'
- },
- searchFormVisible: true,
- search: false,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'vip_admin_bind.id',
- sortOrder: 'desc',
- columns: [
- [
- {checkbox: true},
- {field: 'bind_id', title: __('Id'), visible: false, operate: false},
- {field: 'wx_nickname', title: __('公众号名称')},
- {field: 'qds_id', title: __('账号ID'), operate: false},
- {field: 'qds_username', title: __('用户名')},
- {field: 'qds_nickname', title: __('用户昵称')},
- {field: 'operate', title: __('Operate'),
- events: {
- 'click .btn-chooseone': function (e, value, row, index) {
- Fast.api.close([row]);
- },
- }, formatter: function () {
- return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- //获取选中数据
- $(document).on('click', "#btn-chooseone", function () {
- var data = table.bootstrapTable('getSelections');
- if (data.length < 1) {
- Toastr.error('请选择公众号');
- } else {
- Fast.api.close(data);
- }
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- activitstatus: function (value, row, index) {
- if(row.starttime > Config.time){
- return '未开始';
- }else if (row.starttime<Config.time && row.endtime>Config.time){
- return '进行中';
- }else if (row.endtime < Config.time){
- return '已结束';
- }
- },
- money:function(value, row, index) {
- if (value){
- return value;
- }else{
- return '0.00';
- }
- },
- allmoney:function(value, row, index) {
- if (value){
- return value;
- }else{
- return '0.00';
- }
- },
- },
- source_url_1: function (value, row, index) {
- var html = [];
- html.push((row.wx_type == 1 ? '<b>认证公众号</b>' : '<b>未认证公众号</b>'));
- if (row.short_id > 0) {
- value = row.short_url;
- } else {
- if (Config.url_referral) {
- value = Config.url_referral + '/t/' + row.id;
- } else {
- value = row.url_referral;
- }
- }
- if (row.limited == 1) {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
- html.push('<div class="link_txt" style="padding:0 10px;background-color:red;color:#fff;font-weight:normal;display:inline-block;height:auto;">该链接对新用户已失效,无法进行推广</div></div>');
- } else {
- if (row.state == "1") {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + ' <i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + value + '"></i>');
- html.push('<a href="javascript:;" class="short_link_but">点击显示短链</a><div class="short_link"><strong>腾讯短链:</strong> ' + row.short_url_qq + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_qq + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_qq + '"></i>');
- html.push('<strong>微博短链:</strong> ' + row.short_url_weibo + ' <i class="fa fa-copy copy" data-clipboard-text="' + row.short_url_weibo + '"></i> <i class="fa fa-qrcode qrcode" data-qrcode="' + row.short_url_weibo + '"></i></div></div>');
- } else {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
- }
- }
- return html.join('<br>');
- },
- entry_page_1: function (value, row, index) {
- var html = [];
- if (row.type == 1) {
- html.push('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book_name + '</a>');
- html.push(row.chapter_name);
- if (row.guide_chapter_idx) {
- html.push('关注章节:' + row.guide_chapter_idx);
- } else {
- html.push('关注章节:默认');
- }
- } else if (row.type == 3) {
- html.push('落地页推广');
- html.push('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book_name + '</a>');
- html.push(row.chapter_name);
- if (row.guide_chapter_idx) {
- html.push('关注章节:' + row.guide_chapter_idx);
- } else {
- html.push('关注章节:默认');
- }
- } else {
- html.push('书城首页推广');
- }
- return html.join('<br>');
- },
- events: {
- operate: {
- 'click .btn-editone': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, {ids: ids});
- var url = options.extend.edit_url;
- Fast.api.open(Table.api.replaceurl(url, row, table), __('Edit'), $(this).data() || {});
- },
- 'click .btn-add-channels': function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, {ids: ids});
- var url = options.extend.select_url+'?not_in_qds='+row.channel_ids;
- Fast.api.open(Table.api.replaceurl(url, row, table), __('Add'), {
- callback: function (data) {
- if (data.length > 0) {
- var qdsIds = '';
- var doUrl = options.extend.do_choose;
- doUrl = Table.api.replaceurl(doUrl, row, table);
- for (var i in data) {
- qdsIds += data[i].qds_id + ',';
- }
- $.ajax({
- url: doUrl + '/qdsIds/' + qdsIds,
- type: 'get',
- success: function (res) {
- var data = JSON.parse(res);
- if (data.fail) {
- console.log(data.fail);
- Toastr.error(data.fail);
- } else {
- Toastr.success('操作成功');
- }
- //刷新页面
- table.bootstrapTable('refresh');
- }
- });
- }
- }
- });
- },
- 'click .btn-add-group':function (e, value, row, index) {
- e.stopPropagation();
- e.preventDefault();
- var table = $(this).closest('table');
- var options = table.bootstrapTable('getOptions');
- var ids = row[options.pk];
- row = $.extend({}, row ? row : {}, {ids: ids});
- var url = '/admin/vip/admin/group/select?not_in_ids=';
- Fast.api.open(Table.api.replaceurl(url, row, table), __('Add'), { callback: function (data) {
- if (data.length > 0) {
- var groupIds = '';
- for (var i in data) {
- groupIds += data[i].id + ',';
- }
- var doUrl = options.extend.do_choose;
- doUrl = Table.api.replaceurl(doUrl, row, table);
- $.ajax({
- url: doUrl + '/groupIds/' + groupIds,
- type: 'get',
- success: function (res) {
- var data = JSON.parse(res);
- if (data.fail) {
- console.log(data.fail);
- Toastr.error(data.fail);
- } else {
- Toastr.success('操作成功');
- }
- //刷新页面
- table.bootstrapTable('refresh');
- }
- });
- }
- }
- });
- }
- }
- },
- source_url: function (value, row, index) {
- var html = [];
- value = row.short_url;
- if (row.state == 0) {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">');
- } else {
- if(value.length < 10) {
- html.push('<div class="link_txt">请先选择渠道</div><div class="url_text">');
- } else {
- if (row.limited == 1) {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value);
- html.push('<div class="link_txt" style="padding:0 10px;background-color:red;color:#fff;font-weight:normal;display:inline-block;height:auto;">该链接对新用户已失效,无法进行推广</div></div>');
- } else {
- if (row.state == "1") {
- html.push('<div class="link_txt">公众号阅读原文必选</div><div class="url_text">' + value + ' <i class="fa fa-copy copy" data-clipboard-text="' + value + '"></i> <i style="margin:5px 0;" class="fa fa-qrcode qrcode" data-qrcode="'+value+'"></i>');
- } else {
- html.push('<div class="link_txt">当前链接已失效,请禁止使用</div><div class="url_text">' + value + '</div>');
- }
- }
- }
- }
- return html.join('<br>');
- },
- entry_page: function (value, row, index) {
- var html = [];
- if (row.type == 1) {
- html.push('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book_name + '</a>');
- html.push(row.chapter_name);
- if (row.guide_chapter_idx) {
- html.push('关注章节:' + row.guide_chapter_idx);
- } else {
- html.push('关注章节:默认');
- }
- } else if (row.type == 3) {
- html.push('落地页推广');
- html.push('<a href="/admin/referral/book/info?id=' + row.book_id + '">' + row.book_name + '</a>');
- html.push(row.chapter_name);
- if (row.guide_chapter_idx) {
- html.push('关注章节:' + row.guide_chapter_idx);
- } else {
- html.push('关注章节:默认');
- }
- } else {
- html.push('书城首页推广');
- }
- return html.join('<br>');
- },
- index_operate: function (value, row, index) {
- var row_id = row.id
- return
- }
- }
- };
- return Controller;
- });
|