123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'referral/book/index',
- info_url: 'book/book/info',
- table: 'book',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'idx',
- search: false,
- showToggle:false,
- showColumns: false,
- showExport: false,
- commonSearch: false,
- columns: [
- [
- {field: 'id', title: __('Id')},
- {field: 'image', title: '封面', operate:false, formatter: Controller.api.formatter.image},
- {field: 'name', title: '名称', operate:false, formatter: Controller.api.formatter.name_text},
- {field: 'price', title: '单价(元)', operate:false, formatter: Controller.api.formatter.price},
- {field: 'sex', title:'频道',formatter: Controller.api.formatter.sex_text,searchList: {'1':'男频','2':'女频'},operate:false,},
- {field: 'book_category_id', title: '类别',formatter: Controller.api.formatter.category_text,searchList:$.getJSON('book/category/categorylist'),operate:false,},
- {field: 'is_finish', title:'完结状态',formatter:Controller.api.formatter.is_finish_text,searchList:{'1':'完结','0':'连载'},operate:false,},
- {field: 'state', title:'上架状态',visible:(Config.group<3),formatter:Controller.api.formatter.state_text,searchList:{'1':'上架','-1':'入库'},operate:false,},
- {field: 'idx', title: '派单指数',operate:'BETWEEN',searchList:{'91,100':'100-91','81,90':'90-81','61,80':'80-61','0,60':'60以下'},operate:false,},
- {field: 'keywords',title:'关键字搜索',operate:false,visible:false},
- {field: 'operate', title: '操作', formatter: Controller.api.formatter.tuiguang},
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 弹窗绑定
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).text(), {});
- return false;
- });
- $(document).on('click','.book_but',function () {
- Fast.api.open($(this).attr('href'), '推广连接', {});
- return false;
- });
- require(['vue','component','ELEMENT'], function (Vue, component, ELEMENT) {
- Vue.use(ELEMENT);
- Vue.use(component);
- var refreshTable = function (form) {
- var options = table.bootstrapTable('getOptions');
- options.pageNumber = 1;
- options.queryParams = function (params) {
- var submit = $.extend({
- sort: params.sort,
- order: params.order,
- offset: params.offset,
- limit: params.limit,
- name: name
- }, form);
- return submit;
- };
- table.bootstrapTable('refresh', {});
- }
- var Main = {
- el: '#book',
- data: function () {
- return {
- list_value: [
- {
- type: "input",
- data: {
- input: '',
- placeholder: '书籍ID/名称/主角名搜索',
- size: 'medium',
- field: 'name'
- }
- },
- {
- type: "pick",
- data: {
- label: '小说属性:',
- data: Config.filter.property,
- active: '',
- field: 'corner_mark',
- }
- },
- {
- type: "pick",
- data: {
- label: '读者性别:',
- data: Config.filter.sex,
- active: '',
- field: 'sex',
- }
- },
- {
- type: "pick",
- data: {
- label: '连载状态:',
- data: Config.filter.is_finish,
- active: '',
- field: 'is_finish',
- }
- },
- {
- type: "pick",
- data: {
- label: '字数筛选:',
- data: Config.filter.word_count,
- active: '',
- field: 'word_count',
- }
- },
- {
- type: "pick",
- data: {
- label: '上架状态:',
- data: Config.filter.state,
- active: '',
- field: 'state',
- }
- },
- {
- type: "pick",
- data: {
- label: '小说类型:',
- data: Config.filter.category_all,
- active: '',
- field: 'book_category_id',
- }
- },
- {
- type: "pick",
- data: {
- label: '派单指数:',
- data: Config.filter.idx,
- active: '',
- field: 'idx',
- }
- }
- ]
- }
- },
- methods: {
- commit: function (form) {
- if (form.sex) {
- if (form.sex == 2) {
- this.list_value[6].data.data = Config.filter.category_girl
- } else {
- this.list_value[6].data.data = Config.filter.category_boy
- }
- } else {
- this.list_value[6].data.data = Config.filter.category_all
- }
- refreshTable(form)
- }
- }
- };
- new Vue(Main)
- });
- },
- info: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'referral/book/info',
- }
- });
- var table = $("#table");
- var tableOptions = {
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- showColumns:false,
- showToggle:false,
- showExport:false,
- search:false,
- // commonSearch: false,
- columns: [
- [
- {field: 'id', title: __('Id')},
- {field: 'name', title: '章节',formatter: Controller.api.formatter.name},
- {field: 'operate', title: '操作', formatter: Controller.api.formatter.links},
- ]
- ],
- onLoadSuccess: function (data) {
- $("[data-toggle='tooltip']").tooltip();
- }
- };
- if (Config.show_all_select) {
- tableOptions.columns[0].push({field: 'uv', title: '阅读人数'})
- tableOptions.columns[0].push({field: 'uv_rate', title: '占比', formatter: function (value) {
- if (value !== undefined) {
- return value + '%'
- }
- }})
- }
- // 初始化表格
- table.bootstrapTable(tableOptions);
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 获取推广链接
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'获取推广链接', {});
- return false;
- });
- // 设置关注章节
- $(document).on('click','.set-guide-chapter-idx',function () {
- $this = $(this);
- Fast.api.ajax({
- 'url': $this.attr('href')
- }, function (data) { //success
- Config.guide_chapter_idx = data.guide_chapter_idx; //更新订购章节
- table.bootstrapTable('refresh');
- }, function (data) { //error
- });
- return false;
- });
- },
- chapter: function () {
- $(document).on('click', '.btn-close', function () {
- Fast.api.close();
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
-
- },
- formatter: {
- // name: function (value, row, index) {
- // return '<a href="/admin/book/book/info?id=' + row.id + '" style="cursor:pointer;">' + value + '</a>';
- // },
- image: function (value, row, index) {
- return '<div class="cover_img" style="width:auto !important; height:auto !important;">' +
- '<a href="/admin/referral/book/info?id=' + row.id + '" style="cursor:pointer;" class="btn btn-xs btn-editone book_but ">' +
- '<img class="img-sm img-center" style="width:100px !important; height:auto !important; display:block; border:0;" src="' + value + '" />' +
- '</a>' +
- '<span><img src="' + value + '" /></span></div>';
- },
- sex_text: function(value,row,index){return '<span style="white-space: nowrap;">' + row.sex_text + '</span>';},
- category_text: function(value,row,index){return '<span style="white-space: nowrap;">' + row.category_text + '</span>'},
- state_text: function(value,row,index){return '<span style="white-space: nowrap;">' + row.state_text + '</span>'},
- is_finish_text: function(value,row,index){return '<span style="white-space: nowrap;">' + row.is_finish_text + '</span>'},
- tuiguang: function (value, row, index) {
- return '<a href="/admin/referral/book/info?id=' + row.id + '" style="cursor:pointer;" class="btn btn-xs btn-success btn-editone book_but ">推广连接</a>';
- },
- //章节名称的格式化
- name: function (value, row, index) {
- bookinfo = Config.bookinfo;
- site = Config.site;
- mark = '';
- if(row.idx <= Config.free_chapter_num ) {
- if(bookinfo.article_chapter_order == row.idx || (( bookinfo.article_chapter_order == 0 ) && site.article_chapter_order ==row.idx )){
- mark = '<span style="background:red;color:#fff;padding:2px 5px;">推荐文案章节</span>';
- }
- if(bookinfo.attent_chapter_order == row.idx || ( (bookinfo.attent_chapter_order == 0) && site.attent_chapter_order == row.idx) ){
- mark = '<span style="background:green;color:#fff;padding:2px 5px;">推荐关注章节</span>';
- }
- return '<a href="/admin/book/book/chapter/book_id/' + Config.book_id + '/chapter_id/' + row.id + '" class="layer-open" data-title="章节正文">' + value + '</a>'+mark;
- }else{
- return value+' <i class="fa fa-jpy text-danger"></i>'+mark;
- }
- },
- price: function (value, row, index) {
- if (value > 0) {
- return value + '/' + (row.billing_type == 1 ? '章' : '本');
- } else {
- return Config.site.book_chapter_price + '/章';
- }
- },
- links: function (value, row, index) {
- html = [];
- if (Config.show_all_select == 1) {
- if(row.idx == 1 && Config.guide_switch){
- if(Config.not_ban != 1){
- html.push('<a href="/admin/referral/referral/add?book_id=' + Config.book_id + '&chapter_id=' + row.id + '&type=3' + '" class="layer-open" data-toggle="tooltip" title="生成落地页推广">生成落地页推广</a>');
- }
- }
- if(row.idx <= Config.bookinfo.referral_num){
- if(Config.not_ban != 1){
- html.push('<a href="/admin/referral.referral/essay/book_id/' + Config.book_id + '/chapter_idx/' + row.idx + '" target="_blank" data-toggle="tooltip" title="文章内容到当前章节,原文链接为下一章">生成推广文案</a>');
- html.push('<a href="/admin/referral.referral/essayimage/book_id/' + Config.book_id + '/chapter_idx/' + row.idx + '" target="_blank" data-toggle="tooltip" title="文章内容到当前章节,原文链接为下一章">生成推广图片</a>');
- html.push('<a href="/admin/referral.referral/background/book_id/' + Config.book_id + '/chapter_idx/' + row.idx + '" target="_blank" data-toggle="tooltip" title="文章内容到当前章节,原文链接为下一章">背景图模式</a>');
- }
- }
- }
- if(row.idx <= Config.free_chapter_num) {
- if(Config.not_ban != 1) {
- html.push('<a href="/admin/referral/referral/add?book_id=' + Config.book_id + '&chapter_id=' + row.id + '&chapter_idx=' + row.idx + '" class="layer-open" data-toggle="tooltip" title="原文链接为当前章节">获取推广链接</a>');
- }
- if (row.idx == Config.guide_chapter_idx) {
- html.push('<a href="javascript:;" class="text-green"><i class="fa fa-check-circle-o"></i> 当前关注章节</a>')
- } else {
- html.push('<a class="set-guide-chapter-idx" href="referral/book/setguidechapteridx?book_id=' + Config.book_id + '&chapter_idx=' + row.idx + '">设为关注章节</a>');
- }
- }
- return html.join(' ');
- },
- name_text: function(value,row,index){
- mark = '';
- if(row.corner_mark == 'hot'){
- mark = '<span class="rb_hot">'+row.corner_mark_text+'</span>';
- }else if(row.corner_mark == 'exclusive'){
- mark = '<span class="rb_exclusive">'+row.corner_mark_text+'</span>';
- }else if(row.corner_mark == 'new'){
- mark = '<span class="rb_new">'+row.corner_mark_text+'</span>';
- } else {
-
- }
- //endregion
- //region 是否完本
- is_finish = row.is_finish == '1' ? '已完结' : '连载中';
- is_finish = "【" + is_finish + "】";
- //endregion
- //章节数
- chapter_num = ' 共' + row.chapter_num + '章(共'+Math.floor(row.word_count / 10000)+'万字)';
- //推荐关注章节
- site = Config.site;
- if (row.attent_chapter_order == null || row.attent_chapter_order == 0) {
- attent_chapter_order = site.attent_chapter_order;
- } else {
- attent_chapter_order = row.attent_chapter_order;
- }
- str_attent_chapter_order = ' 第' + attent_chapter_order + '章开始关注';
- //region 最新章节
- last_chapter = ' 最新章节:' + row.last_chapter_name + (row.is_finish == '1' ? '(大结局)' : '') + ' ';
- str_last_chapter_utime = '<br/> ' + Moment.unix(row.last_chapter_utime).format('YYYY-MM-DD HH:mm:ss');
- last_chapter += str_last_chapter_utime;
- //endregion
- //主编推荐语
- editor_recommand = '';
- if(row.editor_recommand !== null && row.editor_recommand !== ''){
- var editor_text = row.editor_recommand;
- if (editor_text.length > 150) {
- editor_text = editor_text.substr(0, 150) + '...';
- }
- editor_recommand = '<br/><span title="' + row.editor_recommand + '"> 主编推荐语:' + editor_text + '</span>';
- }
- var free_text = '';
- var current_time = new Date().getTime() / 1000;
- if (current_time > row.free_stime && current_time < row.free_etime) {
- free_text = '<span class="free_time">限免:'+Moment.unix(row.free_stime).format('MM.DD') + '-' + Moment.unix(row.free_etime).format('MM.DD') + '</span><p>';
- }
- if(row.book_tags_text){
- return '<div style="text-align: left;"><p><span style="color#03f;font-size:16px;vertical-align: middle;">' +
- '<a href="/admin/referral/book/info?id=' + row.id + '" style="cursor:pointer;font-size:16px;">' +
- value + '</a>' + '</span><span style="font-size:16px;vertical-align: middle;">' + is_finish + '</span>' + row.book_tags_text + '</p>' +free_text+ chapter_num + '<br/>' + str_attent_chapter_order +
- '<br>' + last_chapter + '' + editor_recommand +'</div>';
- }else{
- return '<div style="text-align: left;"><p><span style="color#03f;font-size:16px;vertical-align: middle;">' +
- '<a href="/admin/referral/book/info?id=' + row.id + '" style="cursor:pointer;font-size:16px;">' +
- value + '</a>' + '</span><span style="font-size:16px;vertical-align: middle;">' + is_finish + '</span>' + mark + '</p>' +free_text+ chapter_num + '<br/>' + str_attent_chapter_order +
- '<br>' + last_chapter + '' + editor_recommand + '</div>';
- }
- }
- }
- }
- };
- return Controller;
- });
|