1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332 |
- define(['jquery.ui'], function (ui) {
- var modal = {
- sysinfo: null,
- id: 0,
- type: 1,
- navs: {},
- initnav: [],
- data: {},
- selected: 'page',
- childid: null,
- keyworderr: false
- };
- jQuery.base64 = (function ($) {
- var _PADCHAR = "=", _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", _VERSION = "1.1";
- function _getbyte64(s, i) {
- var idx = _ALPHA.indexOf(s.charAt(i));
- if (idx === -1) {
- throw"Cannot decode base64"
- }
- return idx
- }
- function _decode_chars(y, x) {
- while (y.length > 0) {
- var ch = y[0];
- if (ch < 0x80) {
- y.shift();
- x.push(String.fromCharCode(ch))
- } else if ((ch & 0x80) == 0xc0) {
- if (y.length < 2)break;
- ch = y.shift();
- var ch1 = y.shift();
- x.push(String.fromCharCode(((ch & 0x1f) << 6) + (ch1 & 0x3f)))
- } else {
- if (y.length < 3)break;
- ch = y.shift();
- var ch1 = y.shift();
- var ch2 = y.shift();
- x.push(String.fromCharCode(((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f)))
- }
- }
- }
- function _decode(s) {
- var pads = 0, i, b10, imax = s.length, x = [], y = [];
- s = String(s);
- if (imax === 0) {
- return s
- }
- if (imax % 4 !== 0) {
- throw"Cannot decode base64"
- }
- if (s.charAt(imax - 1) === _PADCHAR) {
- pads = 1;
- if (s.charAt(imax - 2) === _PADCHAR) {
- pads = 2
- }
- imax -= 4
- }
- for (i = 0; i < imax; i += 4) {
- var ch1 = _getbyte64(s, i);
- var ch2 = _getbyte64(s, i + 1);
- var ch3 = _getbyte64(s, i + 2);
- var ch4 = _getbyte64(s, i + 3);
- b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6) | _getbyte64(s, i + 3);
- y.push(b10 >> 16);
- y.push((b10 >> 8) & 0xff);
- y.push(b10 & 0xff);
- _decode_chars(y, x)
- }
- switch (pads) {
- case 1:
- b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6);
- y.push(b10 >> 16);
- y.push((b10 >> 8) & 0xff);
- break;
- case 2:
- b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12);
- y.push(b10 >> 16);
- break
- }
- _decode_chars(y, x);
- if (y.length > 0)throw"Cannot decode base64";
- return x.join("")
- }
- function _get_chars(ch, y) {
- if (ch < 0x80)y.push(ch); else if (ch < 0x800) {
- y.push(0xc0 + ((ch >> 6) & 0x1f));
- y.push(0x80 + (ch & 0x3f))
- } else {
- y.push(0xe0 + ((ch >> 12) & 0xf));
- y.push(0x80 + ((ch >> 6) & 0x3f));
- y.push(0x80 + (ch & 0x3f))
- }
- }
- function _encode(s) {
- if (arguments.length !== 1) {
- throw"SyntaxError: exactly one argument required"
- }
- s = String(s);
- if (s.length === 0) {
- return s
- }
- var i, b10, y = [], x = [], len = s.length;
- i = 0;
- while (i < len) {
- _get_chars(s.charCodeAt(i), y);
- while (y.length >= 3) {
- var ch1 = y.shift();
- var ch2 = y.shift();
- var ch3 = y.shift();
- b10 = (ch1 << 16) | (ch2 << 8) | ch3;
- x.push(_ALPHA.charAt(b10 >> 18));
- x.push(_ALPHA.charAt((b10 >> 12) & 0x3F));
- x.push(_ALPHA.charAt((b10 >> 6) & 0x3f));
- x.push(_ALPHA.charAt(b10 & 0x3f))
- }
- i++
- }
- switch (y.length) {
- case 1:
- var ch = y.shift();
- b10 = ch << 16;
- x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 0x3F) + _PADCHAR + _PADCHAR);
- break;
- case 2:
- var ch1 = y.shift();
- var ch2 = y.shift();
- b10 = (ch1 << 16) | (ch2 << 8);
- x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 0x3F) + _ALPHA.charAt((b10 >> 6) & 0x3f) + _PADCHAR);
- break
- }
- return x.join("")
- }
- return {decode: _decode, encode: _encode, VERSION: _VERSION}
- }(jQuery));
- modal.init = function (params) {
- window.tpl = params.tpl;
- modal.attachurl = params.attachurl;
- modal.type = params.type;
- modal.data = params.data;
- modal.id = params.id;
- modal.diymenu = params.diymenu;
- modal.diyadvs = params.diyadvs;
- modal.levels = params.levels;
- modal.merch = params.merch;
- modal.plugins = params.plugins ? params.plugins : {};
- modal.shopset = params.shopset;
- if (modal.data) {
- modal.type = modal.data.page.type;
- modal.page = modal.data.page;
- modal.items = modal.data.items
- };
- modal.initTpl();
- modal.initPage();
- modal.initItems();
- modal.initNavs();
- modal.initSortable();
- modal.initGotop();
- $(".btn-save").unbind('click').click(function () {
- var status = $(this).data('status');
- var type = $(this).data('type');
- if (status) {
- tip.msgbox.err("正在保存,请稍候。。。");
- return
- }
- if (type == 'preview') {
- modal.save(true)
- } else if (type == 'save') {
- modal.save()
- } else if (type = 'savetemp') {
- modal.initTemp();
- return
- }
- });
- $("#page").unbind('click').click(function () {
- if (modal.selected == 'page') {
- return
- };
- modal.selected = 'page';
- modal.initPage()
- });
- var preview_id = util.cookie.get('preview_id');
- if (preview_id) {
- setTimeout(function () {
- var previewUrl = biz.url("diypage/page/preview") + "&id=" + preview_id;
- window.open(previewUrl)
- }, 1000);
- util.cookie.set('preview_id', '')
- }
- };
- modal.initNavs = function () {
- modal.getNavs();
- var navgroup = {
- 0: ['listmenu', 'richtext', 'title', 'line', 'blank', 'menu', 'menu2', 'picture', 'banner', 'picturew', 'pictures', 'icongroup', 'audio', 'coupon'],
- 1: ['search', 'fixedsearch', 'notice', 'goods', 'merchgroup', 'diymod', 'tabbar'],
- 2: ['search', 'fixedsearch', 'notice', 'goods', 'seckillgroup', 'tabbar'],
- 3: ['member', 'bindmobile', 'logout', 'wxcard', 'verify'],
- 4: ['memberc', 'blockgroup'],
- 5: ['detail_tab', 'detail_swipe', 'detail_info', 'detail_sale', 'detail_spec', 'detail_package', 'detail_shop', 'detail_store', 'detail_buyshow', 'detail_comment', 'detail_pullup', 'detail_navbar', 'detail_seckill', 'goods'],
- 6: ['goods', 'search', 'merchgroup'],
- 7: ['seckill_times', 'seckill_rooms', 'seckill_advs', 'seckill_list'],
- 8: ['exchange_banner', 'exchange_input', 'exchange_rule'],
- 99: ['tabbar']
- };
- var navpage = navgroup[modal.type];
- if (navpage) {
- navpage = $.merge(navpage, navgroup[0])
- } else {
- navpage = navgroup[0]
- }
- $.each(navpage, function (index, val) {
- var params = modal.navs[val];
- if (params) {
- params.id = val;
- if (val == 'merchgroup' && (!modal.plugins.merch || modal.merch)) {
- return true
- }
- if (val == 'seckillgroup' && (!modal.plugins.seckill || modal.seckill)) {
- return true
- }
- if (val == 'detail_seckill' && (!modal.plugins.seckill || modal.seckill)) {
- return true
- }
- modal.initnav.push(params)
- }
- });
- var html = tpl("tpl_navs", modal);
- $("#navs").html(html).show();
- $("#navs nav").unbind('click').click(function () {
- var id = $(this).data('id');
- if (id === 'page') {
- $("#page").trigger("click");
- return
- }
- if (id == 'merchgroup' && !modal.plugins.merch) {
- tip.msgbox.err("禁止添加此元素!");
- return
- }
- if ((id == 'seckillgroup' || id == 'detail_seckill') && !modal.plugins.seckill) {
- tip.msgbox.err("禁止添加此元素!");
- return
- }
- var inArray = $.inArray(id, navpage);
- if (inArray < 0) {
- tip.msgbox.err("此页面类型禁止添加此元素!");
- return
- }
- var item = $.extend(true, {}, modal.navs[id]);
- delete item.name;
- if (!item) {
- tip.msgbox.err("未找到此元素!");
- return
- }
- var itemTplShow = $("#tpl_show_" + id).length;
- var itemTplEdit = $("#tpl_edit_" + id).length;
- if (itemTplShow == 0 || itemTplEdit == 0) {
- tip.msgbox.err("添加失败!模板错误,请刷新页面重试");
- return
- }
- if (id === 'diymod') {
- modal.initMod(item);
- return
- }
- var itemid = modal.getId("M", 0);
- if (item.data) {
- var itemData = $.extend(true, {}, item.data);
- var newData = {};
- var index = 0;
- $.each(itemData, function (id, data) {
- var childid = modal.getId("C", index);
- newData[childid] = data;
- delete childid;
- index++
- });
- item.data = newData
- }
- if (item.max && item.max > 0) {
- var itemNum = modal.getItemNum(id);
- if (itemNum > 0 && itemNum >= item.max) {
- tip.msgbox.err("此元素最多允许添加 " + item.max + " 个");
- return
- }
- }
- var append = true;
- if (modal.selected && modal.selected != 'page') {
- var thisitem = modal.items[modal.selected];
- if (thisitem.id == 'detail_navbar' || thisitem.id == 'detail_pullup' || id == 'detail_navbar' || id == 'detail_pullup') {
- append = false
- }
- }
- if (item.istop) {
- var newItems = {};
- newItems[itemid] = item;
- $.each(modal.items, function (id, eachitem) {
- newItems[id] = eachitem
- });
- modal.items = newItems
- } else if (modal.selected && modal.selected != 'page' && append) {
- var newItems = {};
- $.each(modal.items, function (id, eachitem) {
- newItems[id] = eachitem;
- if (id == modal.selected) {
- newItems[itemid] = item
- }
- });
- modal.items = newItems
- } else {
- if (modal.page.type == 5 && modal.items && id != 'detail_navbar') {
- var navbar = null;
- var pullup = null;
- $.each(modal.items, function (newitemid, newitem) {
- if (newitem.id == 'detail_navbar') {
- navbar = {itemid: newitemid, item: newitem};
- delete modal.items[newitemid]
- } else if (newitem.id == 'detail_pullup') {
- pullup = {itemid: newitemid, item: newitem};
- delete modal.items[newitemid]
- }
- });
- modal.items[itemid] = item;
- if (pullup) {
- modal.items[pullup.itemid] = pullup.item
- }
- if (navbar) {
- modal.items[navbar.itemid] = navbar.item
- }
- } else {
- modal.items[itemid] = item
- }
- };
- modal.initItems();
- $(".drag[data-itemid='" + itemid + "']").trigger('mousedown').trigger('click');
- modal.selected = itemid
- })
- };
- modal.getId = function (S, N) {
- var date = +new Date();
- var id = S + (date + N);
- return id
- };
- modal.getNavs = function () {
- modal.navs = {
- notice: {
- name: '公告',
- params: {
- 'iconurl': '/static/diypage/images/default/hotdot.jpg',
- 'noticedata': '0',
- 'speed': '4',
- 'noticenum': '5'
- },
- style: {
- 'background': '#ffffff',
- 'iconcolor': '#fd5454',
- 'color': '#666666',
- 'bordercolor': '#e2e2e2'
- },
- data: {
- C0123456789101: {title: '这里是第一条自定义公告的标题', linkurl: '',},
- C0123456789102: {title: '这里是第二条自定义公告的标题', linkurl: '',}
- }
- },
- banner: {
- name: '图片轮播',
- params: {},
- style: {
- 'dotstyle': 'round',
- 'dotalign': 'left',
- 'background': '#ffffff',
- 'leftright': '5',
- 'bottom': '5',
- 'opacity': '0.8'
- },
- data: {
- C0123456789101: {
- imgurl: '/static/diypage/images/default/banner-1.jpg',
- linkurl: '',
- },
- C0123456789102: {
- imgurl: '/static/diypage/images/default/banner-2.jpg',
- linkurl: '',
- }
- }
- },
- richtext: {name: '富文本', params: {content: ''}, style: {'background': '#ffffff', 'padding': '0'}},
- title: {
- name: '标题栏',
- params: {'title': '', 'icon': ''},
- style: {
- 'background': '#ffffff',
- 'color': '#666666',
- 'textalign': 'left',
- 'fontsize': '12',
- 'paddingtop': '5',
- 'paddingleft': '5'
- }
- },
- search: {
- name: '搜索框',
- params: {'placeholder': '请输入关键字进行搜索'},
- style: {
- 'inputbackground': '#ffffff',
- 'background': '#f1f1f2',
- 'iconcolor': '#b4b4b4',
- 'color': '#999999',
- 'paddingtop': '10',
- 'paddingleft': '10',
- 'textalign': 'left',
- 'searchstyle': ''
- }
- },
- line: {
- name: '辅助线',
- params: {},
- style: {
- 'height': '2',
- 'background': '#ffffff',
- "border": "#000000",
- 'padding': '10',
- 'linestyle': 'solid'
- }
- },
- blank: {name: '辅助空白', params: {}, style: {height: '20', background: '#ffffff'}},
- menu: {
- name: '按钮组',
- params: {},
- style: {
- 'navstyle': '',
- 'background': '#ffffff',
- 'rownum': '4',
- 'showtype': '0',
- 'pagenum': '8',
- 'showdot': '1',
- },
- data: {
- C0123456789101: {
- imgurl: '/static/diypage/images/default/icon-1.png',
- linkurl: '',
- text: '按钮文字1',
- color: '#666666'
- },
- C0123456789102: {
- imgurl: '/static/diypage/images/default/icon-2.png',
- linkurl: '',
- text: '按钮文字2',
- color: '#666666'
- },
- C0123456789103: {
- imgurl: '/static/diypage/images/default/icon-3.png',
- linkurl: '',
- text: '按钮文字3',
- color: '#666666'
- },
- C0123456789104: {
- imgurl: '/static/diypage/images/default/icon-4.png',
- linkurl: '',
- text: '按钮文字4',
- color: '#666666'
- }
- }
- },
- menu2: {
- name: '按钮组2',
- params: {},
- style: {'margintop': '10', 'background': '#ffffff'},
- data: {
- C0123456789101: {
- text: '我的积分',
- iconclass: '',
- textcolor: '#666666',
- iconcolor: '#666666',
- linkurl: ''
- },
- C0123456789102: {
- text: '兑换记录',
- iconclass: '',
- textcolor: '#666666',
- iconcolor: '#666666',
- linkurl: ''
- }
- }
- },
- picture: {
- name: '单图组',
- params: {},
- style: {'paddingtop': '0', 'paddingleft': '0'},
- data: {
- C0123456789101: {
- imgurl: '/static/diypage/images/default/banner-1.jpg',
- linkurl: '',
- },
- C0123456789102: {
- imgurl: '/static/diypage/images/default/banner-2.jpg',
- linkurl: '',
- }
- }
- },
- picturew: {
- name: '图片橱窗',
- params: {row: '4', showtype: 0, pagenum: '2'},
- style: {paddingtop: '0', paddingleft: '0', showdot: 0, showbtn: 0},
- data: {
- C0123456789101: {
- imgurl: '/static/diypage/images/default/cube-1.jpg',
- linkurl: '',
- },
- C0123456789102: {
- imgurl: '/static/diypage/images/default/cube-2.jpg',
- linkurl: '',
- },
- C0123456789103: {
- imgurl: '/static/diypage/images/default/cube-3.jpg',
- linkurl: '',
- },
- C0123456789104: {
- imgurl: '/static/diypage/images/default/cube-4.jpg',
- linkurl: '',
- }
- }
- },
- /**
- pictures: {
- name: '图片展播',
- params: {hidetext: 0, showtype: 0, rownum: 3, showbtn: 0},
- style: {
- background: "#ffffff",
- paddingtop: "3",
- paddingleft: "5",
- titlealign: 'left',
- textalign: 'left',
- titlecolor: '#ffffff',
- textcolor: '#666666'
- },
- data: {
- C0123456789101: {
- imgurl: '/static/diypage/images/default/goods-1.jpg',
- linkurl: '',
- title: '这里是上标题',
- text: '这里是下标题'
- },
- C0123456789102: {
- imgurl: '/static/diypage/images/default/goods-2.jpg',
- linkurl: '',
- title: '这里是上标题',
- text: '这里是下标题'
- },
- C0123456789103: {
- imgurl: '/static/diypage/images/default/goods-4.jpg',
- linkurl: '',
- title: '这里是上标题',
- text: '这里是下标题'
- }
- }
- },
- **/
- goods: {
- name: '商品组',
- params: {
- 'goodstype': '0',
- 'showtitle': '1',
- 'showprice': '1',
- 'showtag': '0',
- 'goodsdata': '0',
- 'cateid': '',
- 'catename': '',
- 'groupid': '',
- 'groupname': '',
- 'goodssort': '0',
- 'goodsnum': '6',
- 'showicon': '1',
- 'iconposition': 'left top',
- 'productprice': '1',
- 'showproductprice': '0',
- 'showsales': '0',
- 'productpricetext': '原价',
- 'salestext': '销量',
- 'productpriceline': '0',
- 'saleout': '0'
- },
- style: {
- 'background': '#f3f3f3',
- 'liststyle': 'block',
- 'buystyle': 'buybtn-1',
- 'goodsicon': 'recommand',
- 'iconstyle': 'triangle',
- 'pricecolor': '#ff5555',
- 'productpricecolor': '#666666',
- 'iconpaddingtop': '0',
- 'iconpaddingleft': '0',
- 'buybtncolor': '#ff5555',
- 'iconzoom': '100',
- 'titlecolor': '#000000',
- 'tagbackground': '#fe5455',
- 'productpricecolor': '#999999',
- 'salescolor': '#999999',
- 'saleoutstyle': 1
- },
- data: {
- C0123456789101: {
- thumb: '/static/diypage/images/default/goods-1.jpg',
- price: '20.00',
- productprice: '99.00',
- title: '这里是商品标题',
- sales: '0',
- gid: '',
- bargain: 0,
- credit: 0,
- ctype: 1
- },
- C0123456789102: {
- thumb: '/static/diypage/images/default/goods-2.jpg',
- price: '20.00',
- productprice: '99.00',
- title: '这里是商品标题',
- sales: '0',
- gid: '',
- bargain: 0,
- credit: 0,
- ctype: 1
- },
- C0123456789103: {
- thumb: '/static/diypage/images/default/goods-3.jpg',
- price: '20.00',
- productprice: '99.00',
- sales: '0',
- title: '这里是商品标题',
- gid: '',
- bargain: 0,
- credit: 0,
- ctype: 0
- },
- C0123456789104: {
- thumb: '/static/diypage/images/default/goods-4.jpg',
- price: '20.00',
- productprice: '99.00',
- sales: '0',
- title: '这里是商品标题',
- gid: '',
- bargain: 0,
- credit: 0,
- ctype: 0
- }
- }
- },
- diymod: {name: '公用模块', params: {'modid': '', 'modname': ''}, style: {}},
- listmenu: {
- name: '列表导航',
- params: {},
- style: {
- 'margintop': '10',
- 'background': '#ffffff',
- 'iconcolor': '#999999',
- 'textcolor': '#000000',
- 'remarkcolor': '#888888'
- },
- data: {
- C0123456789101: {text: '文字1', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''},
- C0123456789102: {text: '文字2', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''},
- C0123456789103: {text: '文字3', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''}
- }
- },
- wxcard: {
- name: '微信会员卡',
- max: 1,
- type: 3,
- params: {
- iconclass: 'icon-same'
- },
- style: {
- 'margintop': '10',
- 'background': '#ffffff',
- 'iconcolor': '#999999',
- 'textcolor': '#333333',
- 'remarkcolor': '#888888',
- }
- },
- verify: {
- name: '待使用商品',
- max: 1,
- type: 3,
- params: {
- title: '待使用商品',
- remark: '',
- iconclass: 'icon-list',
- style: ''
- },
- style: {
- titlecolor: '#333333',
- remarkcolor: '#888888',
- titlebg: '#ffffff',
- background: '#ffffff'
- }
- },
- member: {
- name: '会员信息',
- type: 3,
- params: {
- style: 'default1',
- levellink: '',
- seticon: 'icon-settings',
- setlink: '',
- leftnav: '充值',
- leftnavlink: '',
- rightnav: '兑换',
- rightnavlink: ''
- },
- style: {'background': '#ff5555', 'textcolor': '#ffffff', 'textlight': '#ffffff', 'headstyle': ''},
- info: {avatar: '', nickname: '', levelname: '', textmoney: '', textcredit: '', money: '', credit: ''}
- },
- /**
- icongroup: {
- name: '图标组',
- params: {rownum: '4', border: '1', bordertop: '1', borderbottom: '1',},
- style: {
- background: '#ffffff',
- bordercolor: '#ffffff',
- textcolor: '#000000',
- iconcolor: '#666666',
- dotcolor: '#ff0011'
- },
- data: {
- C0123456789101: {iconclass: 'icon-daifukuan', text: '待付款', linkurl: '', dotnum: 0},
- C0123456789102: {iconclass: 'icon-fahuo', text: '待发货', linkurl: '', dotnum: 0},
- C0123456789103: {iconclass: 'icon-daishouhuo', text: '待收货', linkurl: '', dotnum: 0},
- C0123456789104: {iconclass: 'icon-daituikuan', text: '退换货', linkurl: '', dotnum: 0}
- }
- },
- **/
- bindmobile: {
- name: '绑定手机',
- type: 3,
- params: {
- linkurl: '',
- title: '绑定手机号',
- text: '如果您用手机号注册过会员或您想通过微信外购物请绑定您的手机号码',
- iconclass: 'icon-mobile'
- },
- style: {
- margintop: '10',
- background: '#ffffff',
- titlecolor: '#ff5555',
- textcolor: '#999999',
- iconcolor: '#999999'
- }
- },
- logout: {
- name: '退出登录',
- type: 3,
- params: {bindurl: '', logouturl: ''},
- style: {subcolor: '#ffffff', maincolor: '#ff5555', margintop: '10'}
- },
- memberc: {
- name: '会员信息',
- type: 4,
- params: {
- style: 'default1',
- seticon: 'icon-settings',
- setlink: '',
- leftnav: '提现1',
- leftnavlink: '',
- rightnav: '提现2',
- rightnavlink: '',
- centernav: '提现',
- centernavlink: '',
- hideup: 0
- },
- style: {background: '#fe5455', textcolor: '#ffffff', textlight: '#ffffff'}
- },
- blockgroup: {
- name: '图标块',
- params: {rownum: 3},
- style: {background: '#ffffff', tipcolor: '#feb312'},
- data: {
- C0123456789101: {
- iconclass: 'icon-money',
- iconcolor: '#feb312',
- text: '分销佣金',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '0.00',
- tiptext: '元'
- },
- C0123456789102: {
- iconclass: 'icon-list',
- iconcolor: '#50b6fe',
- text: '佣金明细',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '50',
- tiptext: '笔'
- },
- C0123456789103: {
- iconclass: 'icon-manageorder',
- iconcolor: '#ff741d',
- text: '提现明细',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '10',
- tiptext: '笔'
- },
- C0123456789104: {
- iconclass: 'icon-group',
- iconcolor: '#ff741d',
- text: '我的下线',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '2',
- tiptext: '人'
- },
- C0123456789105: {
- iconclass: 'icon-qrcode',
- iconcolor: '#feb312',
- text: '推广二维码',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '',
- tiptext: ''
- },
- C0123456789106: {
- iconclass: 'icon-shopfill',
- iconcolor: '#50b6fe',
- text: '小店设置',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '',
- tiptext: ''
- },
- C0123456789107: {
- iconclass: 'icon-rank',
- iconcolor: '#ff741d',
- text: '佣金排名',
- textcolor: '#666666',
- linkurl: '',
- tipnum: '',
- tiptext: ''
- }
- }
- },
- detail_tab: {
- name: "选项卡",
- type: 5,
- max: 1,
- params: {goodstext: "商品", detailtext: "详情"},
- style: {background: "#f7f7f7", textcolor: "#666666", activecolor: "#ef4f4f"}
- },
- detail_swipe: {
- name: "商品图",
- type: 5,
- max: 1,
- params: {},
- style: {
- dotstyle: 'rectangle',
- dotalign: 'left',
- background: '#ffffff',
- leftright: '5',
- bottom: '5',
- opacity: '0.8'
- },
- },
- detail_info: {
- name: "商品信息",
- type: 5,
- max: 1,
- params: {hideshare: '0', share: "分享", share_link: "", share_icon: "icon-share",},
- style: {
- margintop: 0,
- marginbottom: 0,
- background: "#ffffff",
- titlecolor: "#000000",
- subtitlecolor: "#999999",
- pricecolor: "#ff5555",
- textcolor: "#cccccc",
- timecolor: "#ff5555",
- timetextcolor: "#000000",
- }
- },
- detail_sale: {
- name: "营销信息",
- type: 5,
- max: 1,
- params: {},
- style: {
- margintop: 0,
- marginbottom: 0,
- background: "#ffffff",
- textcolor: "#666666",
- textcolorhigh: "#ef4f4f"
- },
- data: {
- C0123456789100: {name: "商品预售", type: "yushou"},
- C0123456789101: {name: "二次购买", type: "erci"},
- C0123456789102: {name: "会员价", type: "huiyuan"},
- C0123456789103: {name: "优惠", type: "youhui"},
- C0123456789104: {name: "积分", type: "jifen"},
- C0123456789105: {name: "不配送区域", type: "bupeisong"},
- C0123456789106: {name: "商品标签", type: "biaoqian"},
- C0123456789107: {name: "可用优惠券", type: "coupon"},
- C0123456789108: {name: "赠品", type: "zengpin"},
- C0123456789108: {name: "全返", type: "fullback"}
- }
- },
- detail_spec: {
- name: "商品规格",
- type: 5,
- max: 1,
- params: {},
- style: {background: "#ffffff", textcolor: "#333333", margintop: 10, marginbottom: 0}
- },
- detail_shop: {
- name: "店铺信息",
- type: 5,
- max: 1,
- params: {
- shoplogo: "../addons/ewei_shopv2/static/images/designer.jpg",
- shopname: "",
- shopdesc: "",
- hidenum: 0,
- leftnavtext: "全部商品",
- leftnavlink: "",
- rightnavtext: "进店逛逛",
- rightnavlink: "",
- },
- style: {
- margintop: 10,
- marginbottom: 0,
- background: "#ffffff",
- goodsnumcolor: "#333333",
- goodstextcolor: "#7c7c7c",
- rightnavcolor: "#ff5555",
- shopnamecolor: "#333333",
- shopdesccolor: "#444444"
- }
- },
- detail_comment: {
- name: "商品评价",
- type: 5,
- max: 1,
- params: {},
- style: {
- margintop: 10,
- marginbottom: 10,
- background: "#ffffff",
- maincolor: "#fd5454",
- subcolor: "#000",
- textcolor: "#333333",
- }
- },
- detail_buyshow: {
- name: "购买可见",
- type: 5,
- max: 1,
- params: {},
- style: {background: "#ffffff", margintop: 10, marginbottom: 0}
- },
- detail_store: {
- name: "适用门店",
- type: 5,
- max: 1,
- params: {},
- style: {
- background: "#ffffff",
- margintop: 10,
- marginbottom: 0,
- titlecolor: "#333333",
- shopnamecolor: "#333333",
- shopinfocolor: "#666666",
- navtelcolor: "#008000",
- navlocationcolor: "#ff9900",
- }
- },
- detail_package: {
- name: "相关套餐",
- type: 5,
- max: 1,
- params: {},
- style: {background: "#ffffff", margintop: 10, marginbottom: 0, textcolor: "#000000"}
- },
- detail_pullup: {
- name: "上拉详情",
- type: 5,
- max: 1,
- params: {},
- style: {margintop: 10, background: "#ffffff", textcolor: "#333333"}
- },
- detail_navbar: {
- name: "底部导航",
- type: 5,
- max: 1,
- params: {
- hidelike: 0,
- hideshop: 0,
- hidecart: 0,
- hidecartbtn: 0,
- textbuy: "立刻购买",
- goodstext: "商品",
- liketext: "关注",
- likeiconclass: "icon-like",
- likelink: "icon-like",
- shoptext: "店铺",
- shopiconclass: "icon-shop",
- carttext: "购物车",
- carticonclass: "icon-cart"
- },
- style: {
- background: "#ffffff",
- textcolor: "#999999",
- iconcolor: "#999999",
- cartcolor: "#fe9402",
- buycolor: "#fd5555",
- dotcolor: "#ff0011"
- }
- },
- detail_seckill: {
- name: "秒杀条",
- type: 5,
- max: 1,
- params: {buybtntext: "原价购买"},
- style: {
- bgleft: "#ef4f4f",
- bgright: "#ffef32",
- pricecolor: '#ffffff',
- marketpricecolor: '#ffffff',
- tagcolor: '#ffffff',
- statuscolor: '#ef4f4f',
- processtextcolor: '#fffffff',
- processcolor: '#ffef32',
- bgleftwait: "#00b950",
- bgrightwait: "#00b950",
- timecolor: '#ffffff',
- timebgcolor: '#582e19',
- pricecolorwait: '#ffffff',
- marketpricecolorwait: '#ffffff',
- tagcolorwait: '#ffffff',
- statuscolorwait: '#ffffff',
- timecolorwait: '#ffffff',
- timebgcolorwait: '#003718',
- buybtntextwait: '#ffffff',
- buybtnbgwait: '#00b950'
- }
- },
- merchgroup: {
- name: "商户组",
- params: {
- merchdata: '0',
- merchnum: '6',
- merchsort: '',
- catename: '',
- cateid: '',
- groupname: '',
- groupid: '',
- openlocation: '0'
- },
- style: {
- background: '#ffffff',
- titlecolor: '#333333',
- textcolor: '#666666',
- rangecolor: '#ff5555',
- locationcolor: '#ff5555',
- margintop: '10'
- },
- data: {
- C0123456789101: {name: "商户名称A", desc: "这里是商户A的介绍", thumb: "", merchid: ""},
- C0123456789102: {name: "商户名称B", desc: "这里是商户B的介绍", thumb: "", merchid: ""},
- C0123456789103: {name: "商户名称C", desc: "这里是商户C的介绍", thumb: "", merchid: ""}
- }
- },
- /**
- audio: {
- name: "音频播放",
- params: {
- title: "未定义音频信息",
- subtitle: "副标题",
- playerstyle: 0,
- autoplay: 0,
- loopplay: 0,
- pausestop: 0,
- headalign: "left",
- headtype: "",
- headurl: ""
- },
- style: {
- background: "#f1f1f1",
- bordercolor: "#ededed",
- textcolor: "#333333",
- subtitlecolor: "#666666",
- timecolor: "#666666",
- paddingtop: "20",
- paddingleft: "20",
- width: "80"
- }
- },
- **/
- seckillgroup: {
- max: 1,
- name: "秒杀组",
- params: {
- iconurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/seckill.png',
- hideborder: 0,
- tag: ''
- },
- style: {
- margintop: '10',
- background: '#ffffff',
- titlecolor: '#444444',
- timecolor: '#444444',
- timesigncolor: '#444444',
- timebgcolor: '#ffffff',
- timebordercolor: '#d9d9d9',
- morecolor: '#888888',
- marketpricecolor: '#ef4f4f',
- productpricecolor: '#999999',
- }
- },
- seckill_times: {
- type: 7,
- max: 1,
- name: "秒杀时间段",
- params: {},
- style: {
- margintop: '0',
- background: '#ffffff',
- color: '#333333',
- bgcolor: '#ffffff',
- selectedcolor: '#ff3300',
- selectedbgcolor: '#ffffff'
- }
- },
- seckill_rooms: {
- type: 7,
- name: "秒杀会场",
- max: 1,
- params: {},
- style: {
- margintop: '0',
- background: '#ffffff',
- color: '#333333',
- bgcolor: '#ffffff',
- selectedcolor: '#ef4f4f',
- selectedbgcolor: '#ffffff'
- }
- },
- seckill_advs: {
- type: 7,
- max: 1,
- name: "秒杀广告",
- params: {},
- style: {margintop: '0', marginbottom: '0', background: '#ffffff'}
- },
- seckill_list: {
- type: 7,
- name: "秒杀商品",
- max: 1,
- params: {
- titletext: '先下单先得哦~',
- titleovertext: '还可以继续抢购哦~',
- titlewaittext: '即将开始 先下单先得哦',
- btntext: '抢购中',
- btnovertext: '已抢完',
- btnwaittext: '等待抢购'
- },
- style: {
- margintop: '0',
- marginbottom: '0',
- background: '#ffffff',
- topbgcolor: '#f0f2f5',
- topcolor: '#333333',
- timebgcolor: '#464553',
- timecolor: '#ffffff',
- titlecolor: '#333333',
- pricecolor: '#ef4f4f',
- marketpricecolor: '#949598',
- btnbgcolor: '#ef4f4f',
- btnoverbgcolor: '#f7f7f7',
- btnwaitbgcolor: '#04be02',
- btncolor: '#ffffff',
- btnovercolor: '#333333',
- btnwaitcolor: '#ffffff',
- processtextcolor: '#d0d1d2',
- processbgcolor: '#ff8f8f',
- }
- },
- coupon: {
- name: '优惠券组',
- params: {couponstyle: '3'},
- style: {background: '#ffffff', margintop: '10', marginleft: '5'},
- data: {
- C0123456789101: {
- name: "优惠券名称",
- desc: "满100元可用",
- price: "89.90",
- couponid: "",
- background: '#fd5454',
- bordercolor: '#fd5454',
- textcolor: '#ffffff',
- couponcolor: '#55b5ff'
- },
- C0123456789102: {
- name: "优惠券名称",
- desc: "满100元可用",
- price: "89.90",
- couponid: "",
- background: '#ff9140',
- bordercolor: '#ff9140',
- textcolor: '#ffffff',
- couponcolor: '#ff5555'
- },
- C0123456789103: {
- name: "优惠券名称",
- desc: "满100元可用",
- price: "89.90",
- couponid: "",
- background: '#54b5fd',
- bordercolor: '#54b5fd',
- textcolor: '#ffffff',
- couponcolor: '#ff913f'
- }
- }
- },
- fixedsearch: {
- name: '固定搜索框',
- istop: 1,
- max: 1,
- params: {
- leftnav: '1',
- rightnav: '1',
- rightnavclick: '0',
- leftnavicon: 'icon-shop',
- rightnavicon: 'icon-cart',
- searchstyle: 'round',
- placeholder: '输入关键字进行搜索'
- },
- style: {
- background: '#000000',
- opacity: 0.8,
- opacityinput: 0.8,
- leftnavcolor: '#ffffff',
- rightnavcolor: '#ffffff',
- searchbackground: '#ffffff',
- searchtextcolor: '#666666'
- }
- },
- exchange_banner: {
- name: '兑换轮播图',
- max: 1,
- type: 8,
- params: {datatype: 0},
- style: {
- 'dotstyle': 'rectangle',
- 'dotalign': 'left',
- 'background': '#ffffff',
- 'leftright': '5',
- 'bottom': '5',
- 'opacity': '0.8'
- },
- data: {
- C0123456789101: {
- imgurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/banner-1.jpg',
- linkurl: '',
- },
- C0123456789102: {
- imgurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/banner-2.jpg',
- linkurl: '',
- }
- }
- },
- exchange_input: {
- name: '兑换区域',
- max: 1,
- type: 8,
- params: {
- preview: '0',
- title: '兑换码兑换',
- placeholder: '请输入兑换码',
- btntext: '立即兑换',
- backbtn: '返回重新输入兑换码',
- exbtntext: '兑换',
- exbtn2text: '已兑换',
- crediticon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_credit.png',
- moneyicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_money.png',
- couponicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_coupon.png',
- redbagicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_redbag.png',
- goodsicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_goods.png'
- },
- style: {
- titlecolor: '#444444',
- btncolor: '#ffffff',
- btnbackground: '#ed5565',
- inputcolor: '#666666',
- inputbackground: '#ffffff',
- inputborder: '#efefef',
- codecolor: '#444444',
- numcolor: '#999999',
- exbtncolor: '#ffffff',
- exbtnbackground: '#ed5565',
- exbtn2color: '#ffffff',
- exbtn2background: '#cccccc',
- backbtncolor: '#444444',
- backbtnborder: '#e7eaec',
- backbtnbackground: '#f7f7f7',
- goodstitle: '#444444',
- goodsprice: '#aaaaaa'
- }
- },
- exchange_rule: {
- name: '兑换规则',
- max: 1,
- type: 8,
- params: {ruletitle: '兑换规则'},
- style: {ruletitlecolor: '#555555'}
- },
- tabbar: {
- name: '选项卡',
- max: 2,
- style: {
- background: '#ffffff',
- color: '#666666',
- activebackground: '#ffffff',
- activecolor: '#ef4f4f',
- scrollnum: 3
- },
- data: {
- C0123456789101: {
- text: '选项卡文字',
- linkurl: ''
- },
- C0123456789102: {
- text: '选项卡文字',
- linkurl: ''
- }
- }
- }
- }
- };
- modal.initItems = function (selected) {
- var phone = $("#phone");
- if (!modal.items) {
- modal.items = {};
- return
- }
- phone.empty();
- $.each(modal.items, function (itemid, item) {
- if (typeof(item.id) !== 'undefined') {
- var newItem = $.extend(true, {}, item);
- newItem.itemid = itemid;
- if (item.id == 'audio') {
- newItem.shoplogo = modal.shopset ? modal.shopset.logo : ''
- }
- var html = tpl("tpl_show_" + item.id, newItem);
- $("#phone").append(html)
- }
- });
- var btnhtml = $("#edit-del").html();
- $("#phone .drag").append(btnhtml);
- $("#phone .drag .btn-edit-del .btn-del").unbind('click').click(function (e) {
- e.stopPropagation();
- var drag = $(this).closest(".drag");
- var itemid = drag.data('itemid');
- var nodelete = $(this).closest(".drag").hasClass("nodelete");
- if (nodelete) {
- tip.alert("此元素禁止删除");
- return
- }
- tip.confirm("确定删除吗", function () {
- var nearid = modal.getNear(itemid);
- delete modal.items[itemid];
- modal.initItems();
- if (nearid) {
- $(document).find(".drag[data-itemid='" + nearid + "']").trigger('mousedown')
- } else {
- $("#page").trigger('click')
- }
- })
- });
- if (selected) {
- modal.selectedItem(selected)
- }
- };
- modal.selectedItem = function (itemid) {
- if (!itemid) {
- return
- }
- modal.selected = itemid;
- if (itemid == 'page') {
- $("#page").trigger('click')
- } else {
- $(".drag[data-itemid='" + itemid + "']").addClass('selected')
- }
- };
- modal.initPage = function (initE) {
- if (typeof(initE) === 'undefined') {
- initE = true
- }
- if (!modal.page) {
- modal.page = {
- type: modal.type,
- title: '请输入页面标题',
- name: '未命名页面',
- desc: '',
- icon: '',
- keyword: '',
- background: '#f3f3f3',
- diymenu: '-1',
- diylayer: '0',
- diygotop: '0',
- followbar: '0',
- visit: '0',
- visitlevel: {member: null, commission: null},
- novisit: {title: null, link: null}
- };
- if (modal.type == 5) {
- modal.page.title = "商品详情"
- }
- else if (modal.type == 8) {
- modal.page.title = "兑换中心"
- }
- else if (modal.type == 99) {
- modal.page.type = 99;
- modal.page.title = '公用模块';
- modal.page.name = '未命名模块'
- }
- }
- if(!modal.page.visitlevel){
- modal.page.visitlevel = {member: null, commission: null};
- }
- if(!modal.page.novisit){
- modal.page.novisit = {};
- }
- $("#page").text(modal.page.title);
- $("#phone").css({'background-color': modal.page.background});
- $("#phone").find(".drag").removeClass("selected");
- if (initE) {
- modal.initEditor()
- }
- };
- modal.initSortable = function () {
- $("#phone").sortable({
- opacity: 0.8,
- placeholder: "highlight",
- items: '.drag:not(.fixed)',
- revert: 100,
- scroll: false,
- start: function (event, ui) {
- var height = ui.item.height();
- $(".highlight").css({"height": height + "px"});
- $(".highlight").html('<div><i class="fa fa-plus"></i> 放置此处</div>');
- $(".highlight div").css({"line-height": height - 4 + "px"})
- },
- stop: function (event, ui) {
- modal.initEditor()
- },
- update: function (event, ui) {
- modal.sortItems()
- }
- });
- $("#phone").disableSelection();
- $(document).on('mousedown', "#phone .drag", function () {
- if ($(this).hasClass("selected")) {
- return
- }
- modal.selected = $(this).data('itemid');
- $("#phone").find(".drag").removeClass("selected");
- $(this).addClass("selected");
- modal.selected = $(this).data('itemid');
- modal.initEditor()
- })
- };
- modal.sortItems = function () {
- var newItems = {};
- $("#phone .drag").each(function () {
- var thisid = $(this).data('itemid');
- newItems[thisid] = modal.items[thisid]
- });
- modal.items = newItems
- };
- modal.initEditor = function (scroll) {
- if (typeof(scroll) === 'undefined') {
- scroll = true
- }
- var itemid = modal.selected;
- var top = 180;
- if (modal.selected != 'page') {
- var stop = $(".selected").position().top;
- top = stop ? stop : 0
- }
- if (scroll) {
- $("#diy-editor").unbind('animate').animate({"margin-top": top - 130 + "px"});
- setTimeout(function () {
- $("body").unbind('animate').animate({scrollTop: top - 130 + "px"}, 1000)
- }, 1000)
- }
- if (modal.selected) {
- if (modal.selected == 'page') {
- if (modal.type == 99) {
- var html = tpl("tpl_edit_page_mod", modal.page)
- } else {
- var html = tpl("tpl_edit_page", modal)
- }
- $("#diy-editor .inner").html(html)
- } else {
- var item = $.extend(true, {}, modal.items[modal.selected]);
- item.itemid = modal.selected;
- item.merch = modal.merch;
- item.plugins = modal.plugins;
- var html = tpl("tpl_edit_" + item.id, item);
- $("#diy-editor .inner").html(html)
- }
- $("#diy-editor").attr("data-editid", modal.selected).show()
- }
- var sliderlength = $("#diy-editor .slider").length;
- if (sliderlength > 0) {
- $("#diy-editor .slider").each(function () {
- var decimal = $(this).data('decimal');
- var multiply = $(this).data('multiply');
- var defaultValue = $(this).data("value");
- if (decimal) {
- defaultValue = defaultValue * decimal
- }
- $(this).slider({
- slide: function (event, ui) {
- var sliderValue = ui.value;
- if (decimal) {
- sliderValue = sliderValue / decimal
- }
- $(this).siblings(".input").val(sliderValue).trigger("propertychange");
- $(this).siblings(".count").find("span").text(sliderValue)
- }, value: defaultValue, min: $(this).data("min"), max: $(this).data("max")
- })
- })
- }
- var goodsSelector = $("#diy-editor .goods-selector").length;
- if (goodsSelector > 0) {
- var _this = $("#diy-editor .goods-selector");
- var url = biz.url('goods/query', null, modal.merch);
- if (_this.data('goodstype') == 1) {
- url = biz.url('goods/query', null, modal.merch)+ "&is_normal=2";
- }
- _this.attr({'id': 'goods_selector', 'data-url': url, 'data-callback': 'callbackGoods'});
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'goods'});
- modal.childid = $(this).closest('.item').data('id')
- })
- } // + "&id=" + pageid;
- var categorySelector = $("#diy-editor .category-selector").length;
- if (categorySelector > 0) {
- var _this = $("#diy-editor .category-selector");
- var url = biz.url('goods/category/query', null, modal.merch);
- if (_this.data('goodstype') == 1) {
- url = biz.url('goods/category/query', null, modal.merch)+ "&is_normal=2";
- }
- _this.attr({'id': 'category_selector', 'data-url': url, 'data-callback': 'callbackCategory'});
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'category'})
- })
- }
- var groupSelector = $("#diy-editor .group-selector").length;
- if (groupSelector > 0) {
- var _this = $("#diy-editor .group-selector");
- _this.attr({
- 'id': 'group_selector',
- 'data-url': biz.url('goods/group/query', null, modal.merch),
- 'data-callback': 'callbackGroup'
- });
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'group'})
- })
- }
- var merchSelector = $("#diy-editor .merch-selector").length;
- if (merchSelector) {
- var _this = $("#diy-editor .merch-selector");
- var url = biz.url('merch/user/query', null, modal.merch);
- _this.attr({'id': 'merch_selector', 'data-url': url, 'data-callback': 'callbackMerch'});
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'merch'});
- modal.childid = $(this).closest('.item').data('id')
- })
- }
- var merchCategorySelector = $("#diy-editor .merch-category-selector").length;
- if (merchCategorySelector) {
- var _this = $("#diy-editor .merch-category-selector");
- var url = biz.url('merch/category/query', null, modal.merch);
- _this.attr({'id': 'category_selector', 'data-url': url, 'data-callback': 'callbackMerchCategory'});
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'category'})
- })
- }
- var merchGroupSelector = $("#diy-editor .merch-group-selector").length;
- if (merchGroupSelector) {
- var _this = $("#diy-editor .merch-group-selector");
- _this.attr({
- 'id': 'group_selector',
- 'data-url': biz.url('merch/group/query', null, modal.merch),
- 'data-callback': 'callbackMerchGroup'
- });
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'group'})
- })
- }
- var couponSelector = $("#diy-editor .coupon-selector").length;
- if (couponSelector) {
- var _this = $("#diy-editor .coupon-selector");
- _this.attr({
- 'id': 'coupon_selector',
- 'data-url': biz.url('marketing/querycoupon', {diy: 1}, modal.merch),
- 'data-callback': 'callbackCoupon'
- });
- _this.unbind('click').click(function () {
- biz.selector.select({name: 'coupon'});
- modal.childid = $(this).closest('.item').data('id')
- })
- }
- var audioPlayer = $("#diy-editor .audio-player").length;
- if (audioPlayer) {
- $("#diy-editor .audio-player").click(function () {
- var _this = $(this);
- var audio = _this.next('audio')[0];
- var src = _this.next('audio').attr('src');
- if (audio && src) {
- if (audio.paused) {
- audio.play();
- _this.find('.fa').removeClass("fa-play").addClass("fa-stop");
- var timer = setInterval(function () {
- if (audio.currentTime >= audio.duration) {
- audio.pause();
- _this.find('.fa').removeClass("fa-stop").addClass("fa-play");
- clearInterval(timer)
- }
- }, 1000)
- } else {
- audio.currentTime = 0;
- audio.pause();
- _this.find('.fa').removeClass("fa-stop").addClass("fa-play")
- }
- } else {
- tip.msgbox.err("请先选择音频!")
- }
- })
- }
- var childitems = $("#diy-editor .form-items").length;
- if (childitems > 0) {
- modal.initSortableChild();
- $("#addChild").unbind('click').click(function () {
- var itemid = modal.selected;
- var type = modal.items[itemid].id;
- var temp = modal.navs[type].data;
- var max = $(this).closest(".form-items").data('max');
- if (max) {
- var length = modal.length(modal.items[itemid].data);
- if (length >= max) {
- tip.msgbox.err("最大添加 " + max + " 个!");
- return
- }
- }
- var newChild = {};
- var index = 0;
- $.each(temp, function (i, t) {
- if (index == 0) {
- newChild = t;
- index++
- }
- });
- if (newChild) {
- var childName = modal.getId("M", 0);
- if (typeof(modal.items[itemid].data) === 'undefined') {
- modal.items[itemid].data = {}
- }
- newChild = $.extend(true, {}, newChild);
- modal.items[itemid].data[childName] = newChild
- }
- modal.initItems(itemid);
- modal.initEditor(false)
- });
- $("#diy-editor .form-items .item .btn-del").unbind('click').click(function () {
- var childid = $(this).closest(".item").data('id');
- var itemid = modal.selected;
- var min = $(this).closest(".form-items").data("min");
- if (min) {
- var length = modal.length(modal.items[itemid].data);
- if (length <= min) {
- tip.msgbox.err("至少保留 " + min + " 个!");
- return
- }
- }
- tip.confirm("确定删除吗", function () {
- delete modal.items[itemid].data[childid];
- modal.initItems(itemid);
- modal.initEditor(false)
- })
- })
- }
- var richtext = $("#diy-editor .form-richtext").length;
- if (richtext > 0) {
- var ueditoroption = {
- 'autoClearinitialContent': false,
- 'toolbars': [['fullscreen', 'source', 'preview', '|', 'bold', 'italic', 'underline', 'strikethrough', 'forecolor', 'backcolor', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'insertorderedlist', 'insertunorderedlist', 'blockquote', 'emotion', 'removeformat', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', 'indent', 'paragraph', 'fontsize', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|', 'anchor', 'map', 'print', 'drafts', '|', 'link']],
- 'elementPathEnabled': false,
- 'initialFrameHeight': 300,
- 'focus': false,
- 'maximumWords': 9999999999999
- };
- var opts = {
- type: 'image',
- direct: false,
- multiple: true,
- tabs: {'upload': 'active', 'browser': '', 'crawler': ''},
- path: '',
- dest_dir: '',
- global: false,
- thumb: false,
- width: 0
- };
- UE.registerUI('myinsertimage', function (editor, uiName) {
- editor.registerCommand(uiName, {
- execCommand: function () {
- require(['fileUploader'], function (uploader) {
- uploader.show(function (imgs) {
- if (imgs.length == 0) {
- return
- } else if (imgs.length == 1) {
- editor.execCommand('insertimage', {
- 'src': imgs[0]['url'],
- '_src': imgs[0]['url'],
- 'width': '100%',
- 'alt': imgs[0].filename
- })
- } else {
- var imglist = [];
- for (i in imgs) {
- imglist.push({
- 'src': imgs[i]['url'],
- '_src': imgs[i]['url'],
- 'width': '100%',
- 'alt': imgs[i].filename
- })
- }
- editor.execCommand('insertimage', imglist)
- }
- }, opts)
- })
- }
- });
- var btn = new UE.ui.Button({
- name: '插入图片',
- title: '插入图片',
- cssRules: 'background-position: -726px -77px',
- onclick: function () {
- editor.execCommand(uiName)
- }
- });
- editor.addListener('selectionchange', function () {
- var state = editor.queryCommandState(uiName);
- if (state == -1) {
- btn.setDisabled(true);
- btn.setChecked(false)
- } else {
- btn.setDisabled(false);
- btn.setChecked(state)
- }
- });
- return btn
- }, 48);
- UE.registerUI('myinsertvideo', function (editor, uiName) {
- editor.registerCommand(uiName, {
- execCommand: function () {
- require(['fileUploader'], function (uploader) {
- uploader.show(function (video) {
- if (!video) {
- return
- } else {
- var videoType = video.isRemote ? 'iframe' : 'video';
- editor.execCommand('insertvideo', {
- 'url': video.url,
- 'width': 300,
- 'height': 200
- }, videoType)
- }
- }, {fileSizeLimit: 5120000, type: 'video', allowUploadVideo: true})
- })
- }
- });
- var btn = new UE.ui.Button({
- name: '插入视频',
- title: '插入视频',
- cssRules: 'background-position: -320px -20px',
- onclick: function () {
- editor.execCommand(uiName)
- }
- });
- editor.addListener('selectionchange', function () {
- var state = editor.queryCommandState(uiName);
- if (state == -1) {
- btn.setDisabled(true);
- btn.setChecked(false)
- } else {
- btn.setDisabled(false);
- btn.setChecked(state)
- }
- });
- return btn
- }, 20);
- UE.registerUI('mylink', function (editor, uiName) {
- var btn = new UE.ui.Button({
- name: 'selectUrl',
- title: '系统链接',
- cssRules: 'background-position: -622px 80px;',
- onclick: function () {
- $("#" + this.id).attr({"data-toggle": "selectUrl", "data-callback": "selectUrlCallback"})
- }
- });
- editor.addListener('selectionchange', function () {
- var state = editor.queryCommandState(uiName);
- if (state == -1) {
- btn.setDisabled(true);
- btn.setChecked(false)
- } else {
- btn.setDisabled(false);
- btn.setChecked(state)
- }
- });
- return btn
- });
- if (typeof(UE) != 'undefined') {
- UE.delEditor('rich')
- }
- var ue = UE.getEditor('rich', ueditoroption);
- ue.ready(function () {
- var thisitem = modal.items[itemid];
- var richContent = thisitem.params.content;
- // richContent = $.base64.decode(richContent);
- ue.setContent(richContent);
- ue.addListener('contentChange', function () {
- var newContent = ue.getContent();
- //newContent = $.base64.encode(newContent);
- $("#richtext").html(newContent).trigger('change')
- })
- })
- }
- $("#diy-editor").find(".diy-bind").bind('input propertychange change', function () {
- var _this = $(this);
- var bind = _this.data("bind");
- var bindchild = _this.data('bind-child');
- var bindparent = _this.data('bind-parent');
- var initEditor = _this.data('bind-init');
- var value = '';
- var tag = this.tagName;
- if (!itemid) {
- modal.selectedItem('page ')
- }
- if (tag == 'INPUT') {
- var type = _this.attr('type');
- if (type == 'checkbox') {
- value = [];
- _this.closest('.form-group').find('input[type=checkbox]').each(function () {
- var checked = this.checked;
- var valname = $(this).val();
- if (checked) {
- value.push(valname)
- }
- })
- } else {
- var placeholder = _this.data('placeholder');
- value = _this.val();
- value = value == '' ? placeholder : value
- }
- } else if (tag == 'SELECT') {
- value = _this.find('option:selected').val()
- } else if (tag == 'TEXTAREA') {
- value = _this.val()
- }
- value = $.trim(value);
- if (itemid == 'page') {
- if (bindchild) {
- if (!modal.page[bindchild]) {
- modal.page[bindchild] = {}
- }
- modal.page[bindchild][bind] = value
- } else {
- modal.page[bind] = value
- }
- modal.initPage(false);
- if (bind == 'keyword') {
- $.post(biz.url('diypage/page/keyword'), {id: modal.id, keyword: value}, function (r) {
- if (r.status == 0) {
- _this.closest('.form-group').addClass('has-error');
- modal.keyworderr = true
- } else {
- _this.closest('.form-group').removeClass('has-error');
- modal.keyworderr = false
- }
- }, 'json')
- }
- } else {
- if (bindchild) {
- if (bindparent) {
- modal.items[itemid][bindparent][bindchild][bind] = value
- } else {
- modal.items[itemid][bindchild][bind] = value
- }
- } else {
- modal.items[itemid][bind] = value
- }
- modal.initItems(itemid)
- }
- if (initEditor) {
- modal.initEditor(false)
- }
- })
- };
- modal.initSortableChild = function () {
- $("#diy-editor .inner").sortable({
- opacity: 0.8,
- placeholder: "highlight",
- items: '.item',
- revert: 100,
- scroll: false,
- cancel: '.goods-selector,input,select,.btn,btn-del',
- start: function (event, ui) {
- var height = ui.item.height();
- $(".highlight").css({"height": height + 22 + "px"});
- $(".highlight").html('<div><i class="fa fa-plus"></i> 放置此处</div>');
- $(".highlight div").css({"line-height": height + 16 + "px"})
- },
- update: function (event, ui) {
- modal.sortChildItems()
- }
- })
- };
- modal.initMod = function (item) {
- $.ajax(biz.url('diypage/page/mod/query', null, modal.merch), {
- type: "get",
- dataType: "html",
- cache: false
- }).done(function (html) {
- modModal = $('<div class="modal fade" id="modModal"></div>');
- $(document.body).append(modal), modModal.modal('show');
- modModal.append2(html, function () {
- $(document).off("click", '#modModal nav').on("click", '#modModal nav', function () {
- var modid = $(this).data('id');
- var modname = $(this).data('name');
- modModal.find(".close").click();
- var itemid = modal.getId("M", 0);
- item.params.modid = modid;
- item.params.modname = modname;
- if (modal.selected && modal.selected != 'page') {
- var newItems = {};
- $.each(modal.items, function (id, eachitem) {
- newItems[id] = eachitem;
- if (id == modal.selected) {
- newItems[itemid] = item
- }
- });
- modal.items = newItems
- } else {
- modal.items[itemid] = item
- }
- modal.initItems();
- $(".drag[data-itemid='" + itemid + "']").trigger('mousedown').trigger('click');
- modal.selected = itemid
- })
- })
- })
- };
- modal.initTemp = function () {
- var itemslength = 0;
- $.each(modal.items, function (index) {
- itemslength++;
- return false
- });
- if (!itemslength) {
- tip.msgbox.err("您还没有添加任何元素,不能保存为模板!");
- return
- }
- if (modal.type == 99) {
- tip.msgbox.err("页面类型为公用模块,不能保存为模板!");
- return
- }
- $("#saveTempModal").modal();
- $("#saveTemp", "#saveTempModal").unbind('click').click(function () {
- var tempname = $.trim($("#saveTempModal").find("#saveTempName").val());
- var tempcate = $.trim($("#saveTempModal").find("#saveTempCate option:selected").val());
- var temppreview = $.trim($("#saveTempModal").find("#saveTempPreview").val());
- var tempdata = {page: modal.page, items: modal.items};
- if (!tempname) {
- tip.msgbox.err("请填写模板名称!");
- $("#saveTempModal").find("#saveTempName").focus();
- return
- }
- $("#saveTempModal .close").trigger('click');
- if (modal.type == 1) {
- var posturl = biz.url("diypage/page/diy/savetemp", null, modal.merch)
- } else if (modal.type > 1 && modal.type < 6 && modal.type != 4) {
- var posturl = biz.url("diypage/page/sys/savetemp", null, modal.merch)
- } else if (modal.type > 4 && modal.type < 99 && modal.type != 5) {
- var posturl = biz.url("diypage/page/plu/savetemp", null, modal.merch)
- }
- $.post(posturl, {
- type: modal.type,
- cate: tempcate,
- name: tempname,
- preview: temppreview,
- data: tempdata
- }, function (ret) {
- if (ret.status == 0) {
- tip.msgbox.err(ret.result.message)
- } else {
- tip.msgbox.suc("另存为模板保存成功!")
- }
- }, 'json')
- })
- };
- modal.initTpl = function () {
- tpl.helper("imgsrc", function (src) {
- if (typeof src != 'string') {
- return ''
- }
- if (src.indexOf('http://') == 0 || src.indexOf('https://') == 0 || src.indexOf('/') == 0) {
- return src
- } else if (src.indexOf('images/') == 0 || src.indexOf('audios/') == 0) {
- return modal.attachurl + src
- }
- });
- tpl.helper("decode", function (content) {
- return $.base64.decode(content)
- });
- tpl.helper("count", function (data) {
- return modal.length(data)
- });
- tpl.helper("toArray", function (data) {
- var oldArray = $.makeArray(data);
- var newArray = [];
- $.each(data, function (itemid, item) {
- newArray.push(item)
- });
- return newArray
- });
- tpl.helper("strexists", function (str, tag) {
- if (!str || !tag) {
- return false
- }
- if (str.indexOf(tag) != -1) {
- return true
- }
- return false
- });
- tpl.helper("inArray", function (str, tag) {
- if (!str || !tag) {
- return false
- }
- if(typeof(str)=='string'){
- var arr = str.split(",");
- if($.inArray(tag, arr)>-1){
- return true;
- }
- }
- return false
- });
- tpl.helper("define", function (str) {
- var str
- })
- };
- modal.initGotop = function () {
- $(window).bind('scroll resize', function () {
- var scrolltop = $(window).scrollTop();
- if (scrolltop > 300) {
- $("#gotop").show()
- } else {
- $("#gotop").hide()
- }
- $("#gotop").unbind('click').click(function () {
- $('body').animate({scrollTop: "0px"}, 1000)
- })
- })
- };
- modal.getNear = function (itemid) {
- var newarr = [];
- var index = 0;
- var prev = 0;
- var next = 0;
- $.each(modal.items, function (id, obj) {
- newarr[index] = id;
- if (id == itemid) {
- prev = index - 1;
- next = index + 1
- }
- index++
- });
- var pervid = newarr[prev];
- var nextid = newarr[next];
- if (nextid) {
- return nextid
- }
- if (pervid) {
- return pervid
- }
- return false
- };
- modal.getItemNum = function (id) {
- if (!id || !modal.items) {
- return -1
- }
- var itemNum = 0;
- $.each(modal.items, function (itemid, eachitem) {
- if (eachitem.id == id) {
- itemNum++
- }
- });
- return itemNum
- };
- modal.sortChildItems = function () {
- var newChild = {};
- var itemid = modal.selected;
- $("#diy-editor .form-items .item").each(function () {
- var thisid = $(this).data('id');
- newChild[thisid] = modal.items[itemid].data[thisid]
- });
- modal.items[itemid].data = newChild;
- modal.initItems(itemid)
- };
- modal.length = function (json) {
- if (typeof(json) === 'undefined') {
- return 0
- }
- var jsonlen = 0;
- for (var item in json) {
- jsonlen++
- }
- return jsonlen
- };
- modal.callbackGoods = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- var childid = modal.childid;
- console.log(data);
- modal.items[itemid].data[childid] = {
- 'title': data.goodsname,
- 'thumb': data.thumb,
- 'price': data.price,
- 'sales': data.sales,
- 'gid': data.id,
- 'bargain': data.bargain,
- 'credit': data.credit
- };
- modal.initItems(itemid);
- modal.initEditor(false);
- modal.childid = null
- };
- modal.callbackCategory = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- modal.items[itemid].params.catename = data.name;
- modal.items[itemid].params.cateid = data.id;
- modal.items[itemid].params.groupname = '';
- modal.items[itemid].params.groupid = '';
- modal.initItems(itemid);
- modal.initEditor(false)
- };
- modal.callbackGroup = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- modal.items[itemid].params.groupname = data.name;
- modal.items[itemid].params.groupid = data.id;
- modal.items[itemid].params.catename = '';
- modal.items[itemid].params.cateid = '';
- modal.initItems(itemid);
- modal.initEditor()
- };
- modal.callbackMerch = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- var childid = modal.childid;
- modal.items[itemid].data[childid] = {
- 'name': data.merchname,
- 'thumb': data.logo,
- 'merchid': data.id,
- 'desc': data.desc
- };
- modal.initItems(itemid);
- modal.initEditor(false);
- modal.childid = null
- };
- modal.callbackMerchCategory = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- modal.items[itemid].params.catename = data.catename;
- modal.items[itemid].params.cateid = data.id;
- modal.items[itemid].params.groupname = '';
- modal.items[itemid].params.groupid = '';
- modal.initItems(itemid);
- modal.initEditor(false)
- };
- modal.callbackMerchGroup = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- modal.items[itemid].params.groupname = data.groupname;
- modal.items[itemid].params.groupid = data.id;
- modal.items[itemid].params.catename = '';
- modal.items[itemid].params.cateid = '';
- modal.initItems(itemid);
- modal.initEditor()
- };
- modal.callbackCoupon = function (data) {
- if (!data) {
- tip.msgbox.err("回调数据错误,请重试!");
- return
- }
- var itemid = modal.selected;
- var childid = modal.childid;
- modal.items[itemid].data[childid].price = data.credit;
- modal.items[itemid].data[childid].desc = data.limit_money;
- modal.items[itemid].data[childid].couponid = data.id;
- modal.items[itemid].data[childid].name = data.voucher_title;
- modal.initItems(itemid);
- modal.initEditor(false);
- modal.childid = null
- };
- modal.save = function (preview) {
- if (typeof(preview) === 'undefined') {
- preview = false
- }
- if (preview && modal.type == 5) {
- tip.msgbox.err("商品详情页涉及商品数据问题,请至手机端预览");
- return
- }
- if (modal.keyworderr) {
- tip.msgbox.err("关键字已存在!");
- $("#page").trigger('click');
- $("#diy-editor input[data-bind='keyword']").closest('.form-group').addClass('has-error');
- return
- }
- modal.data = {};
- modal.data = {page: modal.page, items: modal.items};
- if (!modal.page.title) {
- tip.msgbox.err("页面标题是必填项");
- $("#page").trigger("click");
- return
- }
- $(".btn-save").data('status', 1).text("保存中...");
- if (modal.type == 1) {
- if (modal.id > 0) {
- var posturl = biz.url("diypage/page/diy/edit", null, modal.merch)
- } else {
- var posturl = biz.url("diypage/page/diy/add", null, modal.merch)
- }
- } else if (modal.type == 2) {
- var posturl = biz.url("config/layoutindex/index", null, modal.merch)
- } else if (modal.type > 1 && modal.type < 6 && modal.type != 4) {
- if (modal.id > 0) {
- var posturl = biz.url("diypage/page/sys/edit", null, modal.merch)
- } else {
- var posturl = biz.url("diypage/page/sys/add", null, modal.merch)
- }
- } else if (modal.type > 4 && modal.type < 99 && modal.type != 5) {
- if (modal.id > 0) {
- var posturl = biz.url("diypage/page/plu/edit", null, modal.merch)
- } else {
- var posturl = biz.url("diypage/page/plu/add", null, modal.merch)
- }
- } else if (modal.type == 99) {
- if (modal.id > 0) {
- var posturl = biz.url("diypage/page/mod/edit", null, modal.merch)
- } else {
- var posturl = biz.url("diypage/page/mod/add", null, modal.merch)
- }
- }
- $.post(posturl, {id: modal.id, data: modal.data}, function (ret) {
- if (ret.status == 0) {
- tip.msgbox.err(ret.result.message);
- $(".btn-save[data-type='save']").text("保存页面").data("status", 0);
- $(".btn-save[data-type='preview']").text("保存并预览").data("status", 0);
- $(".btn-save[data-type='savetemp']").text("另存为模板").data("status", 0);
- return
- }
- var pageid = ret.result.id;
- if (pageid == modal.id) {
- $(".btn-save[data-type='save']").text("保存页面").data("status", 0);
- $(".btn-save[data-type='preview']").text("保存并预览").data("status", 0);
- $(".btn-save[data-type='savetemp']").text("另存为模板").data("status", 0);
- if (preview) {
- tip.msgbox.suc("保存成功!正在生成预览...");
- setTimeout(function () {
- var previewUrl = biz.url("diypage/page/preview", null, modal.merch) + "&id=" + pageid;
- window.open(previewUrl)
- }, 1000)
- } else {
- tip.msgbox.suc("保存成功!")
- }
- } else {
- if (preview) {
- tip.msgbox.suc("保存成功!正在生成预览...");
- util.cookie.set('preview_id', pageid)
- } else {
- tip.msgbox.suc("保存成功!")
- }
- location.href = ret.result.jump
- }
- }, 'json')
- };
- modal.length = function (json) {
- if (typeof(json) === 'undefined') {
- return 0
- }
- var jsonlen = 0;
- for (var item in json) {
- jsonlen++
- }
- return jsonlen
- };
- return modal
- });
|