123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'clipboard','selectpage'], function ($, undefined, Backend, Table, Form, Clipboard,Selectpage) {
- var Controller = {
- index: function () {
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'配置公共信息', {});
- return false;
- });
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'toutiaolandingpage/index',
- add_url: 'toutiaolandingpage/add',
- edit_url: 'toutiaolandingpage/edit',
- multi_url: 'toutiaolandingpage/multi',
- editwx_url: 'toutiaolandingpage/editwx',
- table: 'toutiao_land_page',
- },
- search: false
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {field: 'id', title: __('Id'), operate:false},
- {field: 'title', title: __('Title'), operate:'LIKE'},
- {field: 'domain', title: '域名', operate:false},
- {field: 'image', title: '图片', operate:false, formatter: Table.api.formatter.image},
- {field: 'book_id', title: __('Book_id')},
- {field: 'book_name', title: '书籍名称', operate:false},
- {field: 'chapter_num', title: __('Chapter_num')},
- {field: 'new', title: '关注(今日/累计)', operate:false, formatter: function(value){return value + '';}},
- {field: 'payCount', title: '支付次数(今日/累计)', operate:false, formatter: function(value){return value + '';}},
- {field: 'payMoney', title: '支付金额(今日/累计)', operate:false, formatter: function(value){return value + '';}},
- {field: 'createtime', title: __('Createtime'), operate:false, formatter:Table.api.formatter.datetime},
- {
- field: 'operate',
- title: __('Operate'),
- formatter: function (value, row, index) {
- return '<span class="btn btn-xs btn-success copy-url" data-domain="'+row.domain+'" data-id="'+row.id+'">复制</span><a href="/uploads/static/toutiao/'+row.id+'.html" target="_blank" class="btn btn-xs btn-success" data-id="'+row.id+'">预览</a><a href="/admin/toutiaolandingpage/edit/ids/'+row.id+'" class="btn btn-xs btn-success btn-editone layer-open" data-title="编辑">编辑</a>';
- }
- }
- ]
- ]
- });
- var clipboard = new Clipboard(".copy-url", {
- text: function (trigger) {
- return Config.scheme + '://' + $(trigger).data('domain') + '/uploads/static/toutiao/' + $(trigger).data('id') + '.html';
- }
- });
- var clipboard1 = new Clipboard(".copy-pay", {
- text: function () {
- return Config.pay_url;
- }
- });
- clipboard1.on('success',function () {
- Toastr.success('复制成功');
- }).on('error',function () {
- Toastr.error('复制失败');
- });
- clipboard.on('success',function () {
- Toastr.success('复制成功');
- }).on('error',function () {
- Toastr.error('复制失败');
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#c-book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#c-book_id').val(d.id);
- },
- eClear : function(){
- $('#c-book_id').val('');
- }
- });
- Controller.api.bindevent();
- },
- edit: function () {
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- console.log(d);
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#c-book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- console.log(d);
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#c-book_id').val(d.id);
- },
- eClear : function(){
- $('#c-book_id').val('');
- }
- });
- if(Config.bnotin.length>0){
- if(Config.bnotin.indexOf(parseInt($('#c-book_id').val())) != -1){
- $('#c-book_id').val('');
- $('#c-book_book_name').val('');
- }
- }
- Controller.api.bindevent();
- },
- editwx: function () {
- $('input[type=radio]').each(function () {
- $(this).click(function () {
- if ($(this).val() == 2) {
- $('#div-c-mask').show();
- } else {
- $('#div-c-mask').hide();
- }
- });
- });
- Controller.api.bindevent();
- },
- callbacktime: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|