12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','selectpage', 'custommain'], function ($, undefined, Backend, Table, Form,Selectpage, Custommain) {
- //去掉特殊字符和转义字符
- function excludeSpecial(s) {
- s = s.replace(/[\\\/\b\f\n\r\t\'\[\]\@\#\$\%\^\&\*\{\}\:\"\L\<\>\?]/g,'');
- return s;
- };
- $(document).on('keyup','#description, #description-book, #description-activity, #description-recent, #description-url',function () {
- var descrp = $(this).val();
- $(this).val(excludeSpecial(descrp));
- });
- //编辑按钮
- $(document).on('click','.btn-editone',function(){
- var url = $(this).data('tourl');
- var sendtime = Number($(this).data('sendtime'));
- if((sendtime - Date.parse(new Date())/1000)<300){
- $(this).hide();
- return false;
- }else{
- Fast.api.open(url, __('Edit'), $(this).data() || {});
- }
- });
- $(document).on('click', '.btn-editold', function () {
- var ids = $(this).data('field-index');
- Fast.api.open("/admin/custom/editold/ids/"+ids, __('Edit'), $(this).data() || {});
- });
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'custom/index',
- add_url: 'custom/add',
- edit_url: 'custom/edit',
- del_url: 'custom/del',
- multi_url: 'custom/multi',
- table: 'custom',
- },
- search:false,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- // {field: 'id', title: __('Id')},
- {field: 'title', title: __('标题'), operate: 'LIKE %...%'},
- {
- field: 'sendtime',
- title: __('Sendtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime
- },
- {field: 'statue', title: __('Statue'), visible: false, operate: false},
- {field: 'statue_text', title: __('Statue'), operate: false},
- {field: 'send_num', title: '发送人数', operate: false},
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- formatter: Table.api.formatter.datetime
- },
- // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Controller.api.formatter.total_benefit_channel
- }
- //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- $('.s_time_box span:eq(1)').click();
- //文字消息字数限制
- $('#textarea_txt_box').on('input change',function(){
- var $this = $(this);
- var sval = $this.val();
- if(sval.length > 600){
- sval = sval.substring(0,600);
- $this.val(sval);
- }
- $('.textarea_txt_error span').text(sval.length + '/600');
- });
- //文字消息添加内容
- function setTextareaVal(str){
- var obj = $('#textarea_txt_box');
- }
- //修改菜单链接
- $(document).on('click', '.t_t_menuurl_but', function () {
- var $this = $(this);
- Fast.api.open('link/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- var otextareaval = $this.parents('.new-template-wrap').find('textarea');
- var stextareaval = otextareaval.val();
- otextareaval.val(stextareaval + data.menu_url);
- }
- });
- });
- //修改最近阅读链接
- $(document).on('click', '.t_t_goonurl_but', function () {
- var $this = $(this);
- $.ajax({
- type: 'get',
- url: '/admin/book/book/getrecenturl',
- cache: false,
- async: false,
- success:function(data){
- var otextareaval = $this.parents('.new-template-wrap').find('textarea');
- var stextareaval = otextareaval.val();
- otextareaval.val(stextareaval + data.url);
- },
- error:function(err){
- ofansopen = true;
- $('.s_tag_footer').removeClass('s_tag_fans_show');
- }
- });
- });
- //修改活动
- $(document).on('click', '.t_t_activityurl_but', function () {
- var $this = $(this);
- Fast.api.open('activity/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- var otextareaval = $this.parents('.new-template-wrap').find('textarea');
- var stextareaval = otextareaval.val();
- otextareaval.val(stextareaval + data.activity_url);
- }
- });
- });
- //修改url
- $(document).on('click','.t_t_pushurl_but',function(){
- var $this=$(this);
- Fast.api.open('referral/referral/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- // console.log('展示title回调', data);
- var otextareaval = $this.parents('.new-template-wrap').find('textarea');
- var stextareaval = otextareaval.val();
- otextareaval.val(stextareaval + data.source_url);
- }
- });
- });
- //修改book
- $(document).on('click','.t_t_book_but',function(){
- var $this=$(this);
- Fast.api.open('book.book/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- var otextareaval = $this.parents('.new-template-wrap').find('textarea');
- var stextareaval = otextareaval.val();
- //otextareaval.val(stextareaval + data.current_book_url);
- insertText(data.current_book_url);
- }
- });
- });
- function insertText(str) {
- var obj = document.getElementById('textarea_txt_box');
- obj.focus();
- if (document.selection) {
- var sel = document.selection.createRange();
- sel.text = str;
- } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
- var startPos = obj.selectionStart,
- endPos = obj.selectionEnd,
- cursorPos = startPos,
- tmpStr = obj.value;
- obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
- cursorPos += str.length;
- obj.selectionStart = obj.selectionEnd = cursorPos;
- } else {
- obj.value += str;
- }
- var sval = obj.value;
- if(sval.length > 600){
- sval = sval.substring(0,600);
- obj.value = sval;
- }
- $('.textarea_txt_error span').text(sval.length + '/600');
- }
- function moveEnd(len){
- var obj = document.getElementById('textarea_txt_box');
- obj.focus();
- if (document.selection) {
- var sel = obj.createTextRange();
- sel.moveStart('character',len);
- sel.collapse();
- sel.select();
- } else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
- obj.selectionStart = obj.selectionEnd = len;
- }
- }
- require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
- Vue.use(ELEMENT);
- Vue.use(component);
- var Main = {
- el: '#title-select',
- methods: {
- select: function (value) {
- $('.anticon_edit_input_tit').find('input').val(value);
- }
- }
- };
- new Vue(Main)
- });
- },
- edit: function () {
- Controller.api.isEidt = true;
- Controller.api.bindevent();
- require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
- Vue.use(ELEMENT);
- Vue.use(component);
- var Main = {
- el: '#title-select',
- methods: {
- select: function (value) {
- $('.anticon_edit_input_tit').find('input').val(value)
- }
- }
- };
- new Vue(Main)
- });
- },
- editold: function () {
- Controller.api.oldbindevet();
- },
- addimagetext: function () {
- Controller.api.bindevent();
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(d.list.length==0){
- $('#c-book_book_name').val('');
- $('#select_book_id').val('');
- $("#description-book").val('');
- }else {
- if (selectdata && JSON.stringify(selectdata) != JSON.stringify(d)) {
- $('#select_book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- }
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#select_book_id').val(d.id);
- $('#select_book_id').attr('data-sex_text', d.sex_text);
- $("#description-book").val(d.description);
- Custommain.get_channel_book_name();
- },
- eClear : function(){
- $('#select_book_id').val('');
- }
- });
- require(['upload'], function (Upload) {
- var data = {};
- data.width=1080;
- data.height = 864;
- Upload.api.plupload(".mini_plupload", function (data, ret) {
- $('.mini-card').find('.img_card img').attr('src',data.url);
- $('.mini-image').val(data.url);
- $('.mini-card').find('.inner').hide();
- $('.mini-card').find('.img_card').show();
- });
- });
- $(document).on('click','#c-mini_type',function () {
- $(this).change(function(){
- var value = $(this).find('input:checked').val();
- console.log(value);
- switch (value) {
- case "3":
- $('.mini-type3').show()
- break;
- case "4":
- $('.mini-type3').hide()
- break;
- }
- })
- })
- Controller.api.eventTitle()
- },
- editimagetext:function(){
- Controller.api.bindevent();
- var spage = $('#c-book_book_name').val();
- var sbl = true;
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(d.list.length==0){
- $('#c-book_book_name').val('');
- $('#select_book_id').val('');
- $("#description-book").val('');
- }else{
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#select_book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- }
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#select_book_id').val(d.id);
- $('#select_book_id').attr('data-sex_text', d.sex_text);
- $("#description-book").val(d.description);
- Custommain.get_channel_book_name('图文客服消息');
- },
- eClear : function(){
- $('#select_book_id').val('');
- }
- });
- if(Config.bnotin.length>0){
- $.each(Config.bnotin,function (index,value) {
- if($('#select_book_id').val().indexOf(value)!=-1){
- $('#select_book_id').val('');
- $('#c-book_book_name').val('');
- $('#c-book_book_name_text').val('');
- return false;
- }
- });
- }
- $(document).on('click','#c-mini_type',function () {
- $(this).change(function(){
- var value = $(this).find('input:checked').val();
- console.log(value);
- switch (value) {
- case "3":
- $('.mini-type3').show()
- break;
- case "4":
- $('.mini-type3').hide()
- break;
- }
- })
- })
- require(['upload'], function (Upload) {
- var data = {};
- data.width=1080;
- data.height = 864;
- Upload.api.plupload(".mini_plupload", function (data, ret) {
- $('.mini-card').find('.img_card img').attr('src',data.url);
- $('.mini-image').val(data.url);
- $('.mini-card').find('.inner').hide();
- $('.mini-card').find('.img_card').show();
- });
- });
- Controller.api.eventTitle()
- },
- addlinktext:function(){
- Controller.api.bindevent();
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#select_book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#select_book_id').val(d.id);
- $('#select_book_id').attr('data-sex_text', d.sex_text);
- $("#description-book").val(d.description);
- Custommain.get_channel_book_name('文字客服消息');
- },
- eClear : function(){
- $('#select_book_id').val('');
- }
- });
- Controller.api.eventTitle()
- },
- editlinktext:function(){
- Controller.api.bindevent();
- var spage = $('#c-book_book_name').val();
- var sbl = true;
- var selectdata = '';
- $('#c-book_book_name').selectPage({
- eAjaxSuccess : function(d){
- if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
- $('#select_book_id').val('');
- }
- selectdata = d;
- return d ? d : '';
- },
- eSelect : function(d){
- selectdata = '';
- $('#c-book_book_name').val(d.name);
- $('#select_book_id').val(d.id);
- $('#select_book_id').attr('data-sex_text', d.sex_text);
- $("#description-book").val(d.description);
- Custommain.get_channel_book_name('文字客服消息');
- },
- eClear : function(){
- $('#select_book_id').val('');
- }
- });
- if(Config.bnotin.length>0){
- $.each(Config.bnotin,function (index,value) {
- if($('#select_book_id').val().indexOf(value)!=-1){
- $('#select_book_id').val('');
- $('#c-book_book_name').val('');
- $('#c-book_book_name_text').val('');
- return false;
- }
- });
- }
- Controller.api.eventTitle()
- },
- api: {
- eventTitle: function () {
- require(['vue', 'component', 'ELEMENT'], function (Vue, component, ELEMENT) {
- Vue.use(ELEMENT);
- Vue.use(component);
- var Main = {
- el: '#title-select',
- methods: {
- select: function (value) {
- $('.group-type:visible').find('input').first().val(value)
- }
- }
- };
- new Vue(Main)
- });
- },
- isEidt:false,
- getStatue: function (value, row, index) {
- if (value == 'normal') {
- if (row.sendtime < Date.parse(new Date()) / 1000) {
- return '<span style="color:red">发送失败</span>';
- } else {
- return '未发送';
- }
- } else {
- return '<span style="color:green">已发送</span>';
- }
- }, formatter: {
- total_benefit_channel: function (value, row, index) {
- if (row.createtime < 1556539200) {
- if (row.sendtime - Config.nowtime < 600) {
- return '<a href="javascript:;" class="btn btn-xs btn-success btn-editold" title="预览" data-table-id="table" data-field-index="'+row.id+'" data-row-index="0" data-button-index="1"><i class="fa fa-eye"></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="0" data-button-index="2"><i class="fa fa-trash"></i></a>';
- } else {
- return '<a href="javascript:;" class="btn btn-xs btn-success btn-editold" title="编辑" data-table-id="table" data-field-index="'+row.id+'" data-row-index="0" 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="0" data-button-index="2"><i class="fa fa-trash"></i></a>';
- }
- } else {
- if (row.sendtime - Config.nowtime < 600) {
- return '<a href="/admin/custom/edit/ids/' + row.id + '" class="btn btn-xs btn-success btn-editone" title="预览" data-table-id="table" data-field-index="9" data-row-index="0" data-button-index="1"><i class="fa fa-eye"></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="0" data-button-index="2"><i class="fa fa-trash"></i></a>';
- } else {
- return '<a href="/admin/custom/edit/ids/' + row.id + '" class="btn btn-xs btn-success btn-editone" title="编辑" data-table-id="table" data-field-index="9" data-row-index="0" 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="0" data-button-index="2"><i class="fa fa-trash"></i></a>';
- }
- }
- }
- },
- editCustom: function (value, row, index) {
- if (row.statue == 'normal' && (Number(row.sendtime) - Date.parse(new Date()) / 1000) > 300) {
- //5分钟外的
- return '<a href="javascript:;" class="btn btn-xs btn-success btn-editone" data-sendtime="' + row.sendtime + '" data-tourl="/admin/custom/edit/ids/' + row.id + '" data-table-id="table" data-field-index="8" data-row-index="2" data-button-index="1"><i class="fa fa-pencil"></i></a>';
- }
- },
- /*bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- if (canedit) {
- //资源管理
- var ore = {
- arrma: [
- {
- 'title': '',
- 'image': '',
- 'url': 'http://'
- }
- ],
- imglis: [],
- titlist: [],
- sli: '<div class="img_txt_li img_txt_main">\
- <div class="img_txt_li_img img_txt_edit_img"><img src="sli_img" /></div>\
- <div class="img_txt_li_txt">\
- <div class="img_txt_li_h3"><input type="text" value="sli_value" /></div>\
- <div class="img_txt_li_url"><input type="text" value="click_url" /></div>\
- </div>\
- <div class="fa img_txt_remvoe"></div>\
- </div>'
- };
- } else {
- //资源管理
- var ore = {
- arrma: [
- {
- 'title': '',
- 'image': '',
- 'url': 'http://'
- }
- ],
- imglis: [],
- titlist: [],
- sli: '<div class="img_txt_li img_txt_main">\
- <div class="img_txt_li_img img_txt_edit_img"><img src="sli_img" /></div>\
- <div class="img_txt_li_txt">\
- <i class="fa fa-pencil img_txt_edit_tit"></i>\
- <div class="img_txt_li_h3"><input type="text" value="sli_value" /></div>\
- <i class="fa fa-chain img_txt_edit_url"></i>\
- <i class="fa fa-book img_txt_edit_book"></i>\
- <div class="img_txt_li_url"><input type="text" value="click_url" /></div>\
- </div>\
- <div class="fa img_txt_remvoe"></div>\
- </div>'
- };*/
- bindevent: function () {
- $('#c-menu_menu_id,#c-activity_activity_id').change(function(){
- Custommain.get_channel_other_name();
- });
- //推广链接类型id
- var simgtexttype = $('input[name="row[imgtxt_type]"]:checked').val();
- //资源管理
- var ore={
- arrma:[
- {
- 'title':'',
- 'image':'',
- 'url':'http://'
- }
- ],
- imglis:[],
- titlist:[],
- sli:'<div class="img_txt_li img_txt_main">\
- <div class="img_txt_li_img img_txt_edit_img"><img src="sli_img" /></div>\
- <div class="img_txt_li_txt">\
- <i class="fa fa-pencil img_txt_edit_tit"></i>\
- <div class="img_txt_li_h3"><input type="text" value="sli_value" /></div>\
- <i class="fa fa-chain img_txt_edit_url" title="推广链接"></i>\
- <i class="fa fa-book img_txt_edit_book" title="小说链接"></i>\
- <i class="fa fa-address-card-o img_txt_edit_card_o" title="活动链接"></i>\
- <i class="fa fa-bookmark-o img_txt_edit_bookmark_o" title="继续阅读链接"></i>\
- <i class="fa fa-bars img_txt_edit_bars" title="菜单链接"></i>\
- <div class="img_txt_li_url"><input type="text" value="click_url" /></div>\
- </div>\
- <div class="fa img_txt_remvoe"></div>\
- </div>',
- pli:'<li>\
- <a class="article-item">\
- <div class="novel-img article-item-cover" style="background-image: url(sli_img);"></div>\
- <p class="article-item-title">sli_value</p>\
- </a>\
- <div class="article-actions">\
- <div>\
- <span class="action-item">\
- <i class="anticon anticon-title-edit" style="font-size: 17px;" data-toggle="tooltip" data-original-title="修改标题"></i>\
- </span>\
- <span class="action-item">\
- <i class="anticon anticon-cover-edit" data-toggle="tooltip" data-original-title="修改封面"></i>\
- </span>\
- <span class="action-item">\
- <i class="anticon anticon-novel-edit" style="font-size: 13px;" data-toggle="tooltip" data-original-title="编辑链接"></i>\
- </span>\
- <span class="action-item action-item-up">\
- <i class="anticon anticon-arrow-up" data-toggle="tooltip" data-original-title="上移"></i>\
- </span>\
- <span class="action-item action-item-down">\
- <i class="anticon anticon-arrow-down" data-toggle="tooltip" data-original-title="下移"></i>\
- </span>\
- <span class="action-item">\
- <i class="anticon anticon-delete" data-toggle="tooltip" data-original-title="删除"></i>\
- </span>\
- </div>\
- </div>\
- </li>',
- ptxtli:'<li>\
- <p scolor>sli_value</p>\
- <div class="img_txt_tip_box">\
- <i class="anticon anticon-novel-edit" style="font-size: 13px;" data-toggle="tooltip" data-original-title="编辑链接"></i>\
- <i class="anticon anticon-delete" data-toggle="tooltip" data-original-title="删除"></i>\
- </div>\
- </li>'
- };
- //图文切换为文字链
- $(document).on('click', '.switch_txt_but', function () {
- layer.open({
- type: 1,
- title: '温馨提示',
- maxmin: false,
- area: ['300px', '200px'],
- btn: ['确认', '取消'],
- shadeClose: true,
- resize: false,
- // skin: 'layui-layer-rim',
- content: '<div class="layui_txt">切换为文字链模式后将无法恢复为图文模式,确定切换吗?</div>',
- yes: function (index, layero) {
- var imgsval = $('.img_txt_hidden_input').val();
- $('.msg_type').val('1');
- $('#group-type-news').remove();
- $('#group-type-news_txt').show();
- $('.textarea_txt_hidden_input').val(imgsval);
- try {
- imgsval = JSON.parse(imgsval);
- txttext(imgsval);
- } catch (e) {
- }
- Toastr.success('切换成功');
- layer.close(index);
- },
- btn2: function (index, node) {
- layer.close(index)
- }
- });
- })
- //添加图文
- $(document).on('click', '.img_txt_add_but', function () {
- var $this = $(this);
- Fast.api.open('custom/addimagetext', '添加图文', {
- callback: function (data) {
- console.log(data);
- strImgtext = $('.img_txt_hidden_input').val();
- var imgtext_data = [];
- if (strImgtext.length > 0) {
- imgtext_data = JSON.parse(strImgtext);
- }
- imgtext_data.push(data);
- $('.img_txt_hidden_input').val(JSON.stringify(imgtext_data));
- $('.textarea_txt_hidden_input').val(JSON.stringify(imgtext_data));
- console.log(data);
- imagetext(imgtext_data);
- txttext(imgtext_data);
- $this.hide();
- }
- })
- });
- //编辑图文文字链单条列表
- if (Controller.api.isEidt) {
- try {
- var inpimgjson = $('.img_txt_hidden_input').val();
- inpimgjson ? inpimgjson = JSON.parse(inpimgjson) : '';
- if (inpimgjson && inpimgjson.length) {
- imagetext(inpimgjson);
- $('.img_txt_add_but').hide();
- }
- var inptestjson = $('.textarea_txt_hidden_input').val();
- inptestjson ? inptestjson = JSON.parse(inptestjson) : '';
- if (inptestjson && inptestjson.length) {
- txttext(inptestjson);
- }
- } catch (e) {
- console.log(e);
- }
- }
- //渲染图文列表
- function imagetext(data) {
- var lihtmls = '';
- var sli = '';
- for (var i = 0; i < data.length; i++) {
- sli = ore.pli.replace('sli_img', data[i]['image']);
- sli = sli.replace('sli_value', data[i]['title']);
- lihtmls += sli;
- }
- lihtmls = '<div class="wxb-card-item"><div class="wxb-card-item-inner"><ul class="article-list">' + lihtmls + '</ul></div></div>';
- $('.wxb-card-list-scroll').html(lihtmls);
- //图文列表tip
- $('.wxb-card-list-scroll .action-item i').tooltip();
- }
- //渲染文字列表
- function txttext(data) {
- var lihtmls = '';
- var sli = '';
- for (var i = 0; i < data.length; i++) {
- var scol = '';
- sli = ore.ptxtli.replace('sli_value', data[i]['title']);
- if (data[i]['type'] == 4) scol = 'style="color:#333"'
- sli = sli.replace('scolor', scol);
- lihtmls += sli;
- }
- lihtmls = '<div class="img_txt_url"><ul>' + lihtmls + '</ul></div>';
- $('#group-type-news_txt .img_txt_list').html(lihtmls);
- //图文列表tip
- $('.img_txt_url i').tooltip();
- }
- //获取数组
- function getimagetxtarr(val) {
- strImgtext = val;
- var imgtext_data = [];
- if (strImgtext.length > 0) {
- try {
- return JSON.parse(strImgtext);
- } catch (err) {
- return '';
- }
- }
- return '';
- }
- //数组上移下移
- Array.prototype.swapItems = function (startindex, endindex) {
- this[startindex] = this.splice(endindex, 1, this[startindex])[0];
- return this;
- }
- //数组删除指定项
- Array.prototype.removeItems = function (index) {
- this.splice(index, 1);
- return this;
- }
- //图文上移 下移
- $('.wxb-card-list-scroll').on('click', '.anticon-arrow-up,.anticon-arrow-down', function () {
- var $this = $(this);
- var nindex = $this.parents('li').index();
- var arrimgtxt = getimagetxtarr($('.img_txt_hidden_input').val());
- if (!arrimgtxt) return false;
- if ($this.hasClass('anticon-arrow-up')) {
- if (nindex == 0) return false;
- arrimgtxt.swapItems(nindex, nindex - 1);
- } else {
- if (nindex == arrimgtxt.length - 1) return false;
- arrimgtxt.swapItems(nindex, nindex + 1);
- }
- $('.img_txt_hidden_input').val(JSON.stringify(arrimgtxt));
- $('.textarea_txt_hidden_input').val(JSON.stringify(arrimgtxt));
- imagetext(arrimgtxt);
- });
- //删除图文
- $('.wxb-card-list-scroll').on('click', '.anticon-delete', function () {
- var $this = $(this);
- layer.open({
- type: 1,
- title: '温馨提示',
- maxmin: false,
- area: ['260px', '160px'],
- btn: ['确认', '取消'],
- shadeClose: true,
- resize: false,
- // skin: 'layui-layer-rim',
- content: '<div style="height:100%; width:100%; text-align: center; line-height: 65px;">您确定删除此条信息?</div>',
- yes: function (index, layero) {
- var nindex = $this.parents('li').index();
- var arrimgtxt = getimagetxtarr($('.img_txt_hidden_input').val());
- if (!arrimgtxt) return false;
- arrimgtxt.removeItems(nindex);
- $('.img_txt_hidden_input').val(JSON.stringify(arrimgtxt));
- $('.textarea_txt_hidden_input').val(JSON.stringify(arrimgtxt));
- if (arrimgtxt.length == 0) {
- $('.wxb-card-list-scroll').html('');
- $('.img_txt_add_but').show();
- } else {
- imagetext(arrimgtxt);
- }
- Toastr.success('删除成功');
- layer.close(index);
- },
- btn2: function (index, node) {
- layer.close(index)
- }
- });
- });
- //修改title
- $(document).on('click', '.anticon-title-edit', function () {
- var $this = $(this);
- var nIndex = $this.parents('li').index();
- var stitle = $this.parents('li').find('p').text();
- layer.open({
- type: 1,
- title: false,
- maxmin: false,
- zIndex:1800,
- area: ['auto', 'auto'],
- btn: ['确认', '取消'],
- shadeClose: true,
- resize: false,
- skin: 'layui-layer-rim',
- content: '<div class="anticon_edit_box">\
- <div class="anticon_edit_select_tit_box">\
- <strong>当前标题:</strong>\
- <p>' + stitle + '</p>\
- <a href="javascript:;" class="anticon_edit_select_tit_box_in"><i class="fa fa-pencil"></i></a>\
- </div>\
- <div class="anticon_edit_input_tit_box">\
- <strong>修改为:</strong>\
- <div class="anticon_edit_input_tit"><input type="text" value="' + stitle + '" /></div>\
- </div>\
- </div>',
- yes: function (index, layero) {
- var stit = $(layero.selector + ' p').text();
- var sinputtit = $(layero.selector + ' input').val();
- if (sinputtit) {
- stit = sinputtit;
- }
- editimglist('title', nIndex, stit);
- layer.close(index);
- },
- btn2: function (index, node) {
- layer.close(index)
- }
- });
- });
- //修改列表内容
- function editimglist(name, item, val) {
- var strImgtext = JSON.parse($('.img_txt_hidden_input').val());
- strImgtext[item][name] = val;
- $('.img_txt_hidden_input').val(JSON.stringify(strImgtext));
- $('.textarea_txt_hidden_input').val(JSON.stringify(strImgtext));
- imagetext(strImgtext);
- }
- //修改封面
- $(document).on('click', '.anticon-cover-edit', function () {
- var $this = $(this);
- var nIndex = $this.parents('li').index();
- Fast.api.open('manage/cover/select', '选择', {
- callback: function (data) {
- // console.log('展示image回调', data);
- editimglist('image', nIndex, data.image);
- }
- });
- });
- //修改图文内容
- $(document).on('click', '#group-type-news .anticon-novel-edit', function () {
- var $this = $(this);
- var nIndex = $this.parents('li').index();
- var sjson = JSON.parse($('.img_txt_hidden_input').val());
- Fast.api.open('custom/editimagetext?json=' + encodeURIComponent(JSON.stringify(sjson[nIndex])), '修改内容', {
- callback: function (data) {
- var data = data;
- var strImgtext = JSON.parse($('.img_txt_hidden_input').val());
- strImgtext[nIndex] = data;
- $('.img_txt_hidden_input').val(JSON.stringify(strImgtext));
- $('.textarea_txt_hidden_input').val(JSON.stringify(strImgtext));
- imagetext(strImgtext);
- }
- });
- });
- //修改文字内容
- $(document).on('click', '#group-type-news_txt .anticon-novel-edit', function () {
- var $this = $(this);
- var nIndex = $this.parents('li').index();
- var sjson = JSON.parse($('.textarea_txt_hidden_input').val());
- Fast.api.open('custom/editlinktext?json=' + encodeURIComponent(JSON.stringify(sjson[nIndex])), '修改文字链接', {
- callback: function (data) {
- var data = data;
- console.log('展示title回调', data);
- var strImgtext = JSON.parse($('.textarea_txt_hidden_input').val());
- strImgtext[nIndex] = data;
- $('.textarea_txt_hidden_input').val(JSON.stringify(strImgtext));
- txttext(strImgtext);
- }
- });
- });
- //删除文字列表
- $('#group-type-news_txt').on('click', '.anticon-delete', function () {
- var $this = $(this);
- layer.open({
- type: 1,
- title: '温馨提示',
- maxmin: false,
- area: ['260px', '160px'],
- btn: ['确认', '取消'],
- shadeClose: true,
- resize: false,
- // skin: 'layui-layer-rim',
- content: '<div style="height:100%; width:100%; text-align: center; line-height: 65px;">您确定删除此条信息?</div>',
- yes: function (index, layero) {
- var nindex = $this.parents('li').index();
- var arrimgtxt = getimagetxtarr($('.textarea_txt_hidden_input').val());
- if (!arrimgtxt) return false;
- arrimgtxt.removeItems(nindex);
- $('.textarea_txt_hidden_input').val(JSON.stringify(arrimgtxt));
- if (arrimgtxt.length == 0) {
- $('.img_txt_list').html('');
- } else {
- txttext(arrimgtxt);
- }
- Toastr.success('删除成功');
- layer.close(index);
- },
- btn2: function (index, node) {
- layer.close(index)
- }
- });
- });
- Custommain.bind_form_validation();
- /**
- * form表单验证
- */
- //$("form[role=form]").data("validator-options", {
- $("#add-form").data("validator-options", {
- ignore: ':hidden',
- beforeSubmit: function (form) {
- var user_json = $.parseJSON($('.img_txt_hidde_input_no').val())
- if (user_json.all==0 && !user_json.subscribe_time) {
- var sub_from = (new Moment($('input[name="row[sub_from]"]').val())).valueOf() / 1000
- var sub_to = (new Moment($('input[name="row[sub_to]"]').val())).valueOf() / 1000
- if(!sub_from && !sub_to){
- Toastr.error("起止时间不能为空");
- return false;
- }else{
- user_json.subscribe_range = sub_from +'-'+ sub_to;
- }
- }
- $('.img_txt_hidde_input_no').val(JSON.stringify(user_json));
- var $imgTxtMain = $('.img_txt_main');
- var reg = /^(http[s]?|ftp):\/\/[^\/\.]+?\..+\w/;
- var sList = '';
- ore.arrma = [];
- //标题
- if ($.trim($('#title').val()).length == 0) {
- Toastr.error("标题不能为空");
- return false;
- }
- if ($('.msg_type').val() == '1') {
- var scdata = $(".textarea_txt_hidden_input").val();
- } else {
- var scdata = $(".img_txt_hidden_input").val();
- }
- try {
- if (!scdata || JSON.parse(scdata).length == 0) {
- Toastr.error("请编辑消息内容");
- flag = 0;
- return false;
- }
- } catch (e) {
- Toastr.error("请编辑消息内容");
- flag = 0;
- return false;
- }
- for (var i = 0; i < $imgTxtMain.length; i++) {
- ore.arrma.push({});
- //标题
- if ($('.img_txt_main:eq(' + i + ') input:eq(0)').val().length > 0) {
- ore.arrma[i].title = $('.img_txt_main:eq(' + i + ') input:eq(0)').val();
- } else {
- Toastr.error("图文标题不能为空");
- return false;
- }
- //链接
- if (reg.test($('.img_txt_main:eq(' + i + ') input:eq(1)').val())) {
- ore.arrma[i].url = $('.img_txt_main:eq(' + i + ') input:eq(1)').val();
- } else {
- Toastr.error("请填写图文正确的跳转链接");
- return false;
- }
- //图片
- if ($('.img_txt_main:eq(' + i + ') img').attr('src').length > 0) {
- ore.arrma[i].image = $('.img_txt_main:eq(' + i + ') img').attr('src');
- } else {
- Toastr.error("请填写图文正确的跳转链接");
- return false;
- }
- ore.arrma[i].description = excludeSpecial($('#description').val());
- }
- //发送时间必须大于当前时间
- var sdatatime = $('#c-sendtime').val() + '';
- sdatatime = sdatatime.replace(/-/g, '/');
- sdatatime = new Date(sdatatime).getTime();
- if (sdatatime <= new Date().getTime()) {
- Toastr.error("发送时间必须大于当前时间");
- return false;
- }
- sList = JSON.stringify(ore.arrma);
- $('.img_txt_hidde_input').val(sList);
- }
- });
- Form.api.bindevent($("form[role=form]"),
- function (data) {
- if (data.jump) {
- window.parent.location.href = data.jump;
- } else {
- Fast.api.close(data);
- }
- },
- function (data) {
- console.log('error', data);
- }
- );
- /**
- * 资源类型管理
- */
- $(document).on('click', "input[name='row[type]']", function () {
- if (canedit) {
- return false;
- }
- var type = $(this).val();
- if (type == 'all') {
- var tagObj = {
- all: "1"
- }
- } else {
- var tagObj = {
- sex: -1,
- mobile_system: 0,
- tag: -1,
- consume: -1,
- kandian: -1,
- subscribe_time: -1,
- all: "0"
- }
- }
- var ucon = JSON.stringify(tagObj);
- $('#usercondition').val(ucon);
- $('.group-tag-type').addClass('hide');
- $('.group-tag-type input').attr('disabled');
- $('#group-tag-type-' + type).removeClass('hide');
- $('#group-tag-type-' + type + ' input').removeAttr('disabled');
- });
- //切换推广链接类型
- $(document).on('click', "input[name='row[imgtxt_type]']", function () {
- var type = $(this).val();
- $('.group-type').addClass('hide');
- $('.group-type input').attr('disabled');
- $('#group-type-' + type).removeClass('hide');
- $('#group-type-' + type + ' input').removeAttr('disabled');
- var oshowfrombox = $('#group-type-' + type + ' input[type="hidden"]');
- simgtexttype = type;
- if (type == 0) {
- Custommain.get_channel_book_name();
- } else {
- Custommain.get_channel_other_name();
- }
- });
- $(document).on('click', "input[name='book[push]']", function () {
- var type = $(this).val();
- $('.group-push').addClass('hide');
- $('.group-push input').attr('disabled');
- $('#group-push-' + type).removeClass('hide');
- $('#group-push-' + type + ' input').removeAttr('disabled');
- Custommain.get_channel_book_name();
- });
- /**
- * 插入链接
- */
- $(document).on('click', ".btn-insertlink", function () {
- if (canedit) {
- return false;
- }
- var textarea = $("textarea[name='row[content]']");
- var cursorPos = textarea.prop('selectionStart');
- var v = textarea.val();
- var textBefore = v.substring(0, cursorPos);
- var textAfter = v.substring(cursorPos, v.length);
- Layer.prompt({title: '请输入显示的文字', formType: 3}, function (text, index) {
- Layer.close(index);
- Layer.prompt({title: '请输入跳转的链接URL(包含http/https)', formType: 3}, function (link, index) {
- text = text == '' ? link : text;
- textarea.val(textBefore + '<a href="' + link + '">' + text + '</a>' + textAfter);
- Layer.close(index);
- });
- });
- });
- if ($('#usercondition').val() && $('#usercondition').val().length > 0) {
- $tagval = JSON.parse($('#usercondition').val());
- if ($tagval.all == 1) { //选择所有用户
- $('#type-all').attr('checked', true);
- var type = 'all';
- $('.group-tag-type').addClass('hide');
- $('.group-tag-type input').attr('disabled');
- $('#group-tag-type-' + type).removeClass('hide');
- $('#group-tag-type-' + type + ' input').removeAttr('disabled');
- }
- }
- $.ajax({
- type: 'get',
- url: '/admin/custom/ajaxcategory',
- cache: false,
- async: false,
- success: function (res) {
- data = res.data;
- var htmlstr = '';
- for (var i = 0; i < data.length; i++) {
- htmlstr += '<span data-cid="' + data[i].id + '" >' + data[i].name + '</span>';
- }
- $('#ctag').append(htmlstr);
- $('#mustbe').html('约' + res.ids + '人');
- if ($('#usercondition').val() && $('#usercondition').val().length > 0) {
- $tagval = JSON.parse($('#usercondition').val());
- $("#sex span[data-sex='" + $tagval.sex + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- $("#mobile_system span[data-mobile_system='" + $tagval.mobile_system + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- $("#ctag span[data-cid='" + $tagval.tag + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- $("#consume span[data-fee='" + $tagval.consume + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- $("#kandian span[data-kandian='" + $tagval.kandian + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- if ($tagval.subscribe_time) {
- $("#subscribe_time1 span[data-fee='" + $tagval.subscribe_time + "']").addClass('s_s_tag').siblings().removeClass('s_s_tag');
- $('#subscribe_time2').hide();
- } else {
- $("#subscribe_time1 span").last().addClass('s_s_tag').siblings().removeClass('s_s_tag');
- }
- } else {
- var tagObj1 = {
- sex: -1,
- mobile_system:0,
- tag: -1,
- consume: -1,
- kandian: -1,
- subscribe_time: -1,
- all: "0"
- };
- var ucon1 = JSON.stringify(tagObj1);
- $('#usercondition').val(ucon1);
- }
- },
- error: function (err) {
- }
- });
- var flag = 0;
- //测试发送
- $('.test_fans_but').click(function () {
- Custommain.fans_send_message();
- });
- //发送消息时间
- $(document).on('click', '.s_time_box span', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- var nval = parseInt($this.attr('stime'));
- var ntime = Date.parse(new Date());
- var nt = ntime + nval;
- $('#c-sendtime').val(GetRTime(nt));
- });
- $(document).on('click', '.s_tag_li_list span', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- $this.addClass('s_s_tag').siblings('span').removeClass('s_s_tag');
- var tagObj = {
- sex: $('#sex span.s_s_tag').data('sex'),
- mobile_system: $('#mobile_system span.s_s_tag').data('mobile_system'),
- tag: $('#ctag span.s_s_tag').data('cid'),
- consume: $('#consume span.s_s_tag').data('fee'),
- kandian: $('#kandian span.s_s_tag').data('kandian'),
- subscribe_time: $('#subscribe_time1 span.s_s_tag').data('fee'),
- all: "0"
- }
- if ($(this).parent().attr('id') == 'subscribe_time1') {
- if ($(this).data('fee')) {
- $('#cdstarttime').val('');
- $('#cdendtime').val('');
- $('#subscribe_time2').hide();
- } else {
- $('#subscribe_time2').show();
- }
- }
- var uconditon = JSON.stringify(tagObj);
- $('#usercondition').val(uconditon);
- });
- var ofansopen = true;
- //tag切换
- $(document).on('click', '.s_tag_fans_num', function () {
- var $this = $(this);
- //防止重复点击
- if (!ofansopen) {
- return false;
- }
- ofansopen = false;
- $('.s_tag_footer').addClass('s_tag_fans_show');
- var tagObj = {
- sex: $('#sex span.s_s_tag').data('sex'),
- mobile_system: $('#mobile_system span.s_s_tag').data('mobile_system'),
- tag: $('#ctag span.s_s_tag').data('cid'),
- consume: $('#consume span.s_s_tag').data('fee'),
- kandian: $('#kandian span.s_s_tag').data('kandian'),
- subscribe_time: $('#subscribe_time1 span.s_s_tag').data('fee'),
- all: "0"
- }
- var uconditon = JSON.stringify(tagObj);
- $('#usercondition').val(uconditon);
- //console.log(tagObj);
- $.ajax({
- type: 'post',
- data: tagObj,
- //dataType:'json',
- url: '/admin/custom/ajaxcustom',
- success: function (data) {
- //console.log(data);
- $('#mustbe').html('约' + data.ids + '人');
- ofansopen = true;
- $('.s_tag_footer').removeClass('s_tag_fans_show');
- },
- error: function (err) {
- ofansopen = true;
- $('.s_tag_footer').removeClass('s_tag_fans_show');
- }
- });
- });
- /*$(document).on('click', '.img_txt_add_but', function () {
- if (canedit) {
- return false;
- }
- var $List = $('.img_txt_main');
- var oNowData = {
- image: ore.imglis[parseInt(Math.random() * ore.imglis.length)]['image'],
- title: ore.titlist[parseInt(Math.random() * ore.titlist.length)]['title'],
- url: 'http://'
- };
- var sLiImg = ore.sli.replace(/sli_img/g, oNowData['image']);
- sLiImg = sLiImg.replace(/sli_value/g, oNowData['title']);
- sLiImg = sLiImg.replace(/click_url/g, 'http://');
- if ($List.length < 8) {
- $('.img_txt_list').append(sLiImg);
- ore.arrma.push(oNowData);
- } else {
- Toastr.error("不能超过8篇");
- }
- });*/
- $(document).on('click', '.img_txt_remvoe', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- $this.parent().remove();
- });
- //修改title
- // $(document).on('click', '.img_txt_edit_tit', function () {
- // var $this = $(this);
- // Fast.api.open('manage/title/select', '选择', {
- // callback: function (data) {
- // $this.parent().parent().find('input').eq(0).val(data.title);
- // $this.parent().parent().find('input').eq(0)
- // .next().empty().css('display', 'none').closest('.form-group').removeClass('has-error').addClass('has-success');
- // }
- // });
- // });
- //修改菜单链接
- $(document).on('click', '.img_txt_edit_bars', function () {
- var $this = $(this);
- Fast.api.open('link/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- $this.parent().find('input').eq(1).val(data.menu_url);
- }
- });
- });
- //添加文字链
- $(document).on('click', '.textarea_txt_add_but', function () {
- Fast.api.open('custom/addlinktext', '添加消息', {
- callback: function (data) {
- strLinktext = $('.textarea_txt_hidden_input').val()
- var linktext_data = [];
- if (strLinktext.length > 0) {
- linktext_data = JSON.parse(strLinktext);
- }
- linktext_data.push(data);
- $('.textarea_txt_hidden_input').val(JSON.stringify(linktext_data));
- txttext(linktext_data);
- }
- })
- });
- $(document).on('click', '.btn_save_media_but button', function () {
- var saveval = $(this).data('save-val');
- if (typeof saveval != 'undefined') {
- $('.js_is_save_media').val(saveval);
- } else {
- Fast.api.close();
- }
- });
- $(document).on('click', '.js_save_media', function () {
- $('.js_is_save_media').val(1);
- });
- //修改最近阅读链接
- $(document).on('click', '.img_txt_edit_bookmark_o', function () {
- var $this = $(this);
- $.ajax({
- type: 'get',
- url: '/admin/book/book/getrecenturl',
- cache: false,
- async: false,
- success: function (data) {
- $this.parent().find('input').eq(1).val(data.url);
- },
- error: function (err) {
- ofansopen = true;
- $('.s_tag_footer').removeClass('s_tag_fans_show');
- }
- });
- });
- //修改活动
- $(document).on('click', '.img_txt_edit_card_o', function () {
- var $this = $(this);
- Fast.api.open('activity/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- $this.parent().find('input').eq(1).val(data.activity_url);
- }
- });
- });
- //修改url
- $(document).on('click', '.img_txt_edit_url', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- Fast.api.open('referral/referral/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- $('#description').val(excludeSpecial(data['book']['description']));
- // console.log('展示title回调', data);
- $this.parent().find('input').eq(1).val(data.source_url);
- }
- });
- });
- //修改book
- $(document).on('click', '.img_txt_edit_book', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- Fast.api.open('book.book/select?one=1', '选择', {
- callback: function (data) {
- var data = data[0];
- $this.parent().find('input').eq(1).val(data.current_book_url);
- $('#description').val(excludeSpecial(data.description));
- }
- });
- });
- //修改图片
- $(document).on('click', '.img_txt_edit_img', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- Fast.api.open('manage/cover/select', '选择', {
- callback: function (data) {
- $this.find('img').attr('src', data.image);
- }
- });
- });
- //修改图片
- $(document).on('click', '.add_img_txt_edit_img', function () {
- var $this = $(this);
- Fast.api.open('manage/cover/select', '选择', {
- callback: function (data) {
- $this.parent().find('img').attr('src', data.image);
- $this.parent().find('input').eq(0).val(data.image);
- }
- });
- });
- //修改跳转链接
- $(document).on('click', '.img_txt_main a', function () {
- if (canedit) {
- return false;
- }
- var $this = $(this);
- var nIndex = $this.parents('.img_txt_main').index();
- layer.prompt({
- formType: 2,
- value: ore.arrma[nIndex].url,
- title: '请输入跳转链接地址(http://)',
- area: ['300px', '100px'] //自定义文本域宽高
- }, function (value, index, elem) {
- var reg = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
- if (reg.test(value)) {
- layer.close(index);
- ore.arrma[nIndex].url = value;
- $this.html(value);
- } else {
- Toastr.error("请输入正确的跳转地址。");
- }
- });
- });
- function GetRTime(time) {
- var stime;
- time = new Date(time);
- var year = time.getYear() + 1900;
- var month = time.getMonth() + 1;
- var day = time.getDate();
- var hours = time.getHours();
- var minutes = time.getMinutes();
- var seconds = time.getSeconds();
- stime = year + '-' +
- (month < 10 ? '0' + month : month) + '-' +
- (day < 10 ? '0' + day : day) + ' ' +
- (hours < 10 ? '0' + hours : hours) + ':' +
- (minutes < 10 ? '0' + minutes : minutes) + ':' +
- (seconds < 10 ? '0' + seconds : seconds);
- return stime;
- }
- },
- oldbindevet: function () {
- //资源管理
- var ore = {
- arrma: [
- {
- 'title': '',
- 'image': '',
- 'url': 'http://'
- }
- ],
- imglis: [],
- titlist: [],
- sli: '<div class="img_txt_li img_txt_main">\
- <div class="img_txt_li_img img_txt_edit_img"><img src="sli_img" /></div>\
- <div class="img_txt_li_txt">\
- <i class="fa fa-pencil img_txt_edit_tit"></i>\
- <div class="img_txt_li_h3"><input type="text" value="sli_value" /></div>\
- <i class="fa fa-chain img_txt_edit_url"></i>\
- <i class="fa fa-book img_txt_edit_book"></i>\
- <div class="img_txt_li_url"><input type="text" value="click_url" /></div>\
- </div>\
- <div class="fa img_txt_remvoe"></div>\
- </div>'
- };
- $.ajax({
- type:'get',
- url:'/admin/manage/cover/ajax?sort=id&order=desc&offset=0&limit=10&filter={"status":"normal"}',
- cache:false,
- async:false,
- success:function(data){
- // console.log(data)
- ore.imglis = data.rows;
- },
- error:function(err){
- }
- });
- $.ajax({
- type:'get',
- url:'/admin/manage/title/ajax?sort=id&order=desc&offset=0&limit=10&filter={"status":"normal"}',
- cache:false,
- async:false,
- success:function(data){
- // console.log(data)
- ore.titlist = data.rows;
- ore.arrma[0]['image'] = ore.imglis[parseInt(Math.random()*ore.imglis.length)]['image'];
- ore.arrma[0]['title'] = ore.titlist[parseInt(Math.random()*ore.titlist.length)]['title'];
- if($('.img_txt_hidde_input').val().length > 0){
- ore.arrma = JSON.parse($('.img_txt_hidde_input').val());
- //console.log(ore.arrma);
- for(var i=0; i<1; i++){
- if(i==0){
- if(canedit){
- $('.img_txt_list').html('<div class="img_txt_one img_txt_main">\
- <div class="img_txt_one_tit">\
- <div class="img_txt_one_h3"><input type="text" readonly value="' + ore.arrma[0]['title'] + '" /></div>\
- <div class="img_txt_one_url"><input type="text" readonly value="' + ore.arrma[0]['url'] + '" /></div>\
- </div>\
- <div class="img_txt_one_img img_txt_edit_img"><img src="' + ore.arrma[0]['image'] + '" /></div>\
- </div>');
- $('#description').val(excludeSpecial(ore.arrma[0]['description']));
- }else{
- $('.img_txt_list').html('<div class="img_txt_one img_txt_main">\
- <div class="img_txt_one_tit">\
- <i class="fa fa-pencil img_txt_edit_tit"></i>\
- <div class="img_txt_one_h3"><input type="text" value="' + ore.arrma[0]['title'] + '" /></div>\
- <i class="fa fa-chain img_txt_edit_url"></i>\
- <i class="fa fa-book img_txt_edit_book"></i>\
- <div class="img_txt_one_url"><input type="text" value="' + ore.arrma[0]['url'] + '" /></div>\
- </div>\
- <div class="img_txt_one_img img_txt_edit_img"><img src="' + ore.arrma[0]['image'] + '" /></div>\
- </div>');
- $('#description').val(excludeSpecial(ore.arrma[0]['description']));
- }
- }else{
- var sLiImg=ore.sli.replace(/sli_img/g,ore.arrma[i]['image']);
- sLiImg=sLiImg.replace(/sli_value/g,ore.arrma[i]['title']);
- sLiImg=sLiImg.replace(/click_url/g,ore.arrma[i]['url']);
- $('.img_txt_list').append(sLiImg);
- }
- }
- }else{
- if(!canedit){
- $('.img_txt_list').html('<div class="img_txt_one img_txt_main">\
- <div class="img_txt_one_tit">\
- <i class="fa fa-pencil img_txt_edit_tit"></i>\
- <div class="img_txt_one_h3"><input type="text" value="' + ore.arrma[0]['title'] + '" /></div>\
- <i class="fa fa-chain img_txt_edit_url"></i>\
- <i class="fa fa-book img_txt_edit_book"></i>\
- <div class="img_txt_one_url"><input type="text" value="' + ore.arrma[0]['url'] + '" /></div>\
- </div>\
- <div class="img_txt_one_img img_txt_edit_img"><img src="' + ore.arrma[0]['image'] + '" /></div>\
- </div>');
- $('#description').val(excludeSpecial(ore.arrma[0]['description']));
- }else{
- $('.img_txt_list').html('<div class="img_txt_one img_txt_main">\
- <div class="img_txt_one_tit">\
- <div class="img_txt_one_h3"><input type="text" value="' + ore.arrma[0]['title'] + '" /></div>\
- <div class="img_txt_one_url"><input type="text" value="' + ore.arrma[0]['url'] + '" /></div>\
- </div>\
- <div class="img_txt_one_img img_txt_edit_img"><img src="' + ore.arrma[0]['image'] + '" /></div>\
- </div>');
- $('#description').val(excludeSpecial(ore.arrma[0]['description']));
- }
- }
- },
- error:function(err){
- }
- });
- }
- }
- }
- return Controller;
- });
|