diy.min.js 90 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332
  1. define(['jquery.ui'], function (ui) {
  2. var modal = {
  3. sysinfo: null,
  4. id: 0,
  5. type: 1,
  6. navs: {},
  7. initnav: [],
  8. data: {},
  9. selected: 'page',
  10. childid: null,
  11. keyworderr: false
  12. };
  13. jQuery.base64 = (function ($) {
  14. var _PADCHAR = "=", _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", _VERSION = "1.1";
  15. function _getbyte64(s, i) {
  16. var idx = _ALPHA.indexOf(s.charAt(i));
  17. if (idx === -1) {
  18. throw"Cannot decode base64"
  19. }
  20. return idx
  21. }
  22. function _decode_chars(y, x) {
  23. while (y.length > 0) {
  24. var ch = y[0];
  25. if (ch < 0x80) {
  26. y.shift();
  27. x.push(String.fromCharCode(ch))
  28. } else if ((ch & 0x80) == 0xc0) {
  29. if (y.length < 2)break;
  30. ch = y.shift();
  31. var ch1 = y.shift();
  32. x.push(String.fromCharCode(((ch & 0x1f) << 6) + (ch1 & 0x3f)))
  33. } else {
  34. if (y.length < 3)break;
  35. ch = y.shift();
  36. var ch1 = y.shift();
  37. var ch2 = y.shift();
  38. x.push(String.fromCharCode(((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f)))
  39. }
  40. }
  41. }
  42. function _decode(s) {
  43. var pads = 0, i, b10, imax = s.length, x = [], y = [];
  44. s = String(s);
  45. if (imax === 0) {
  46. return s
  47. }
  48. if (imax % 4 !== 0) {
  49. throw"Cannot decode base64"
  50. }
  51. if (s.charAt(imax - 1) === _PADCHAR) {
  52. pads = 1;
  53. if (s.charAt(imax - 2) === _PADCHAR) {
  54. pads = 2
  55. }
  56. imax -= 4
  57. }
  58. for (i = 0; i < imax; i += 4) {
  59. var ch1 = _getbyte64(s, i);
  60. var ch2 = _getbyte64(s, i + 1);
  61. var ch3 = _getbyte64(s, i + 2);
  62. var ch4 = _getbyte64(s, i + 3);
  63. b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6) | _getbyte64(s, i + 3);
  64. y.push(b10 >> 16);
  65. y.push((b10 >> 8) & 0xff);
  66. y.push(b10 & 0xff);
  67. _decode_chars(y, x)
  68. }
  69. switch (pads) {
  70. case 1:
  71. b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12) | (_getbyte64(s, i + 2) << 6);
  72. y.push(b10 >> 16);
  73. y.push((b10 >> 8) & 0xff);
  74. break;
  75. case 2:
  76. b10 = (_getbyte64(s, i) << 18) | (_getbyte64(s, i + 1) << 12);
  77. y.push(b10 >> 16);
  78. break
  79. }
  80. _decode_chars(y, x);
  81. if (y.length > 0)throw"Cannot decode base64";
  82. return x.join("")
  83. }
  84. function _get_chars(ch, y) {
  85. if (ch < 0x80)y.push(ch); else if (ch < 0x800) {
  86. y.push(0xc0 + ((ch >> 6) & 0x1f));
  87. y.push(0x80 + (ch & 0x3f))
  88. } else {
  89. y.push(0xe0 + ((ch >> 12) & 0xf));
  90. y.push(0x80 + ((ch >> 6) & 0x3f));
  91. y.push(0x80 + (ch & 0x3f))
  92. }
  93. }
  94. function _encode(s) {
  95. if (arguments.length !== 1) {
  96. throw"SyntaxError: exactly one argument required"
  97. }
  98. s = String(s);
  99. if (s.length === 0) {
  100. return s
  101. }
  102. var i, b10, y = [], x = [], len = s.length;
  103. i = 0;
  104. while (i < len) {
  105. _get_chars(s.charCodeAt(i), y);
  106. while (y.length >= 3) {
  107. var ch1 = y.shift();
  108. var ch2 = y.shift();
  109. var ch3 = y.shift();
  110. b10 = (ch1 << 16) | (ch2 << 8) | ch3;
  111. x.push(_ALPHA.charAt(b10 >> 18));
  112. x.push(_ALPHA.charAt((b10 >> 12) & 0x3F));
  113. x.push(_ALPHA.charAt((b10 >> 6) & 0x3f));
  114. x.push(_ALPHA.charAt(b10 & 0x3f))
  115. }
  116. i++
  117. }
  118. switch (y.length) {
  119. case 1:
  120. var ch = y.shift();
  121. b10 = ch << 16;
  122. x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 0x3F) + _PADCHAR + _PADCHAR);
  123. break;
  124. case 2:
  125. var ch1 = y.shift();
  126. var ch2 = y.shift();
  127. b10 = (ch1 << 16) | (ch2 << 8);
  128. x.push(_ALPHA.charAt(b10 >> 18) + _ALPHA.charAt((b10 >> 12) & 0x3F) + _ALPHA.charAt((b10 >> 6) & 0x3f) + _PADCHAR);
  129. break
  130. }
  131. return x.join("")
  132. }
  133. return {decode: _decode, encode: _encode, VERSION: _VERSION}
  134. }(jQuery));
  135. modal.init = function (params) {
  136. window.tpl = params.tpl;
  137. modal.attachurl = params.attachurl;
  138. modal.type = params.type;
  139. modal.data = params.data;
  140. modal.id = params.id;
  141. modal.diymenu = params.diymenu;
  142. modal.diyadvs = params.diyadvs;
  143. modal.levels = params.levels;
  144. modal.merch = params.merch;
  145. modal.plugins = params.plugins ? params.plugins : {};
  146. modal.shopset = params.shopset;
  147. if (modal.data) {
  148. modal.type = modal.data.page.type;
  149. modal.page = modal.data.page;
  150. modal.items = modal.data.items
  151. };
  152. modal.initTpl();
  153. modal.initPage();
  154. modal.initItems();
  155. modal.initNavs();
  156. modal.initSortable();
  157. modal.initGotop();
  158. $(".btn-save").unbind('click').click(function () {
  159. var status = $(this).data('status');
  160. var type = $(this).data('type');
  161. if (status) {
  162. tip.msgbox.err("正在保存,请稍候。。。");
  163. return
  164. }
  165. if (type == 'preview') {
  166. modal.save(true)
  167. } else if (type == 'save') {
  168. modal.save()
  169. } else if (type = 'savetemp') {
  170. modal.initTemp();
  171. return
  172. }
  173. });
  174. $("#page").unbind('click').click(function () {
  175. if (modal.selected == 'page') {
  176. return
  177. };
  178. modal.selected = 'page';
  179. modal.initPage()
  180. });
  181. var preview_id = util.cookie.get('preview_id');
  182. if (preview_id) {
  183. setTimeout(function () {
  184. var previewUrl = biz.url("diypage/page/preview") + "&id=" + preview_id;
  185. window.open(previewUrl)
  186. }, 1000);
  187. util.cookie.set('preview_id', '')
  188. }
  189. };
  190. modal.initNavs = function () {
  191. modal.getNavs();
  192. var navgroup = {
  193. 0: ['listmenu', 'richtext', 'title', 'line', 'blank', 'menu', 'menu2', 'picture', 'banner', 'picturew', 'pictures', 'icongroup', 'audio', 'coupon'],
  194. 1: ['search', 'fixedsearch', 'notice', 'goods', 'merchgroup', 'diymod', 'tabbar'],
  195. 2: ['search', 'fixedsearch', 'notice', 'goods', 'seckillgroup', 'tabbar'],
  196. 3: ['member', 'bindmobile', 'logout', 'wxcard', 'verify'],
  197. 4: ['memberc', 'blockgroup'],
  198. 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'],
  199. 6: ['goods', 'search', 'merchgroup'],
  200. 7: ['seckill_times', 'seckill_rooms', 'seckill_advs', 'seckill_list'],
  201. 8: ['exchange_banner', 'exchange_input', 'exchange_rule'],
  202. 99: ['tabbar']
  203. };
  204. var navpage = navgroup[modal.type];
  205. if (navpage) {
  206. navpage = $.merge(navpage, navgroup[0])
  207. } else {
  208. navpage = navgroup[0]
  209. }
  210. $.each(navpage, function (index, val) {
  211. var params = modal.navs[val];
  212. if (params) {
  213. params.id = val;
  214. if (val == 'merchgroup' && (!modal.plugins.merch || modal.merch)) {
  215. return true
  216. }
  217. if (val == 'seckillgroup' && (!modal.plugins.seckill || modal.seckill)) {
  218. return true
  219. }
  220. if (val == 'detail_seckill' && (!modal.plugins.seckill || modal.seckill)) {
  221. return true
  222. }
  223. modal.initnav.push(params)
  224. }
  225. });
  226. var html = tpl("tpl_navs", modal);
  227. $("#navs").html(html).show();
  228. $("#navs nav").unbind('click').click(function () {
  229. var id = $(this).data('id');
  230. if (id === 'page') {
  231. $("#page").trigger("click");
  232. return
  233. }
  234. if (id == 'merchgroup' && !modal.plugins.merch) {
  235. tip.msgbox.err("禁止添加此元素!");
  236. return
  237. }
  238. if ((id == 'seckillgroup' || id == 'detail_seckill') && !modal.plugins.seckill) {
  239. tip.msgbox.err("禁止添加此元素!");
  240. return
  241. }
  242. var inArray = $.inArray(id, navpage);
  243. if (inArray < 0) {
  244. tip.msgbox.err("此页面类型禁止添加此元素!");
  245. return
  246. }
  247. var item = $.extend(true, {}, modal.navs[id]);
  248. delete item.name;
  249. if (!item) {
  250. tip.msgbox.err("未找到此元素!");
  251. return
  252. }
  253. var itemTplShow = $("#tpl_show_" + id).length;
  254. var itemTplEdit = $("#tpl_edit_" + id).length;
  255. if (itemTplShow == 0 || itemTplEdit == 0) {
  256. tip.msgbox.err("添加失败!模板错误,请刷新页面重试");
  257. return
  258. }
  259. if (id === 'diymod') {
  260. modal.initMod(item);
  261. return
  262. }
  263. var itemid = modal.getId("M", 0);
  264. if (item.data) {
  265. var itemData = $.extend(true, {}, item.data);
  266. var newData = {};
  267. var index = 0;
  268. $.each(itemData, function (id, data) {
  269. var childid = modal.getId("C", index);
  270. newData[childid] = data;
  271. delete childid;
  272. index++
  273. });
  274. item.data = newData
  275. }
  276. if (item.max && item.max > 0) {
  277. var itemNum = modal.getItemNum(id);
  278. if (itemNum > 0 && itemNum >= item.max) {
  279. tip.msgbox.err("此元素最多允许添加 " + item.max + " 个");
  280. return
  281. }
  282. }
  283. var append = true;
  284. if (modal.selected && modal.selected != 'page') {
  285. var thisitem = modal.items[modal.selected];
  286. if (thisitem.id == 'detail_navbar' || thisitem.id == 'detail_pullup' || id == 'detail_navbar' || id == 'detail_pullup') {
  287. append = false
  288. }
  289. }
  290. if (item.istop) {
  291. var newItems = {};
  292. newItems[itemid] = item;
  293. $.each(modal.items, function (id, eachitem) {
  294. newItems[id] = eachitem
  295. });
  296. modal.items = newItems
  297. } else if (modal.selected && modal.selected != 'page' && append) {
  298. var newItems = {};
  299. $.each(modal.items, function (id, eachitem) {
  300. newItems[id] = eachitem;
  301. if (id == modal.selected) {
  302. newItems[itemid] = item
  303. }
  304. });
  305. modal.items = newItems
  306. } else {
  307. if (modal.page.type == 5 && modal.items && id != 'detail_navbar') {
  308. var navbar = null;
  309. var pullup = null;
  310. $.each(modal.items, function (newitemid, newitem) {
  311. if (newitem.id == 'detail_navbar') {
  312. navbar = {itemid: newitemid, item: newitem};
  313. delete modal.items[newitemid]
  314. } else if (newitem.id == 'detail_pullup') {
  315. pullup = {itemid: newitemid, item: newitem};
  316. delete modal.items[newitemid]
  317. }
  318. });
  319. modal.items[itemid] = item;
  320. if (pullup) {
  321. modal.items[pullup.itemid] = pullup.item
  322. }
  323. if (navbar) {
  324. modal.items[navbar.itemid] = navbar.item
  325. }
  326. } else {
  327. modal.items[itemid] = item
  328. }
  329. };
  330. modal.initItems();
  331. $(".drag[data-itemid='" + itemid + "']").trigger('mousedown').trigger('click');
  332. modal.selected = itemid
  333. })
  334. };
  335. modal.getId = function (S, N) {
  336. var date = +new Date();
  337. var id = S + (date + N);
  338. return id
  339. };
  340. modal.getNavs = function () {
  341. modal.navs = {
  342. notice: {
  343. name: '公告',
  344. params: {
  345. 'iconurl': '/static/diypage/images/default/hotdot.jpg',
  346. 'noticedata': '0',
  347. 'speed': '4',
  348. 'noticenum': '5'
  349. },
  350. style: {
  351. 'background': '#ffffff',
  352. 'iconcolor': '#fd5454',
  353. 'color': '#666666',
  354. 'bordercolor': '#e2e2e2'
  355. },
  356. data: {
  357. C0123456789101: {title: '这里是第一条自定义公告的标题', linkurl: '',},
  358. C0123456789102: {title: '这里是第二条自定义公告的标题', linkurl: '',}
  359. }
  360. },
  361. banner: {
  362. name: '图片轮播',
  363. params: {},
  364. style: {
  365. 'dotstyle': 'round',
  366. 'dotalign': 'left',
  367. 'background': '#ffffff',
  368. 'leftright': '5',
  369. 'bottom': '5',
  370. 'opacity': '0.8'
  371. },
  372. data: {
  373. C0123456789101: {
  374. imgurl: '/static/diypage/images/default/banner-1.jpg',
  375. linkurl: '',
  376. },
  377. C0123456789102: {
  378. imgurl: '/static/diypage/images/default/banner-2.jpg',
  379. linkurl: '',
  380. }
  381. }
  382. },
  383. richtext: {name: '富文本', params: {content: ''}, style: {'background': '#ffffff', 'padding': '0'}},
  384. title: {
  385. name: '标题栏',
  386. params: {'title': '', 'icon': ''},
  387. style: {
  388. 'background': '#ffffff',
  389. 'color': '#666666',
  390. 'textalign': 'left',
  391. 'fontsize': '12',
  392. 'paddingtop': '5',
  393. 'paddingleft': '5'
  394. }
  395. },
  396. search: {
  397. name: '搜索框',
  398. params: {'placeholder': '请输入关键字进行搜索'},
  399. style: {
  400. 'inputbackground': '#ffffff',
  401. 'background': '#f1f1f2',
  402. 'iconcolor': '#b4b4b4',
  403. 'color': '#999999',
  404. 'paddingtop': '10',
  405. 'paddingleft': '10',
  406. 'textalign': 'left',
  407. 'searchstyle': ''
  408. }
  409. },
  410. line: {
  411. name: '辅助线',
  412. params: {},
  413. style: {
  414. 'height': '2',
  415. 'background': '#ffffff',
  416. "border": "#000000",
  417. 'padding': '10',
  418. 'linestyle': 'solid'
  419. }
  420. },
  421. blank: {name: '辅助空白', params: {}, style: {height: '20', background: '#ffffff'}},
  422. menu: {
  423. name: '按钮组',
  424. params: {},
  425. style: {
  426. 'navstyle': '',
  427. 'background': '#ffffff',
  428. 'rownum': '4',
  429. 'showtype': '0',
  430. 'pagenum': '8',
  431. 'showdot': '1',
  432. },
  433. data: {
  434. C0123456789101: {
  435. imgurl: '/static/diypage/images/default/icon-1.png',
  436. linkurl: '',
  437. text: '按钮文字1',
  438. color: '#666666'
  439. },
  440. C0123456789102: {
  441. imgurl: '/static/diypage/images/default/icon-2.png',
  442. linkurl: '',
  443. text: '按钮文字2',
  444. color: '#666666'
  445. },
  446. C0123456789103: {
  447. imgurl: '/static/diypage/images/default/icon-3.png',
  448. linkurl: '',
  449. text: '按钮文字3',
  450. color: '#666666'
  451. },
  452. C0123456789104: {
  453. imgurl: '/static/diypage/images/default/icon-4.png',
  454. linkurl: '',
  455. text: '按钮文字4',
  456. color: '#666666'
  457. }
  458. }
  459. },
  460. menu2: {
  461. name: '按钮组2',
  462. params: {},
  463. style: {'margintop': '10', 'background': '#ffffff'},
  464. data: {
  465. C0123456789101: {
  466. text: '我的积分',
  467. iconclass: '',
  468. textcolor: '#666666',
  469. iconcolor: '#666666',
  470. linkurl: ''
  471. },
  472. C0123456789102: {
  473. text: '兑换记录',
  474. iconclass: '',
  475. textcolor: '#666666',
  476. iconcolor: '#666666',
  477. linkurl: ''
  478. }
  479. }
  480. },
  481. picture: {
  482. name: '单图组',
  483. params: {},
  484. style: {'paddingtop': '0', 'paddingleft': '0'},
  485. data: {
  486. C0123456789101: {
  487. imgurl: '/static/diypage/images/default/banner-1.jpg',
  488. linkurl: '',
  489. },
  490. C0123456789102: {
  491. imgurl: '/static/diypage/images/default/banner-2.jpg',
  492. linkurl: '',
  493. }
  494. }
  495. },
  496. picturew: {
  497. name: '图片橱窗',
  498. params: {row: '4', showtype: 0, pagenum: '2'},
  499. style: {paddingtop: '0', paddingleft: '0', showdot: 0, showbtn: 0},
  500. data: {
  501. C0123456789101: {
  502. imgurl: '/static/diypage/images/default/cube-1.jpg',
  503. linkurl: '',
  504. },
  505. C0123456789102: {
  506. imgurl: '/static/diypage/images/default/cube-2.jpg',
  507. linkurl: '',
  508. },
  509. C0123456789103: {
  510. imgurl: '/static/diypage/images/default/cube-3.jpg',
  511. linkurl: '',
  512. },
  513. C0123456789104: {
  514. imgurl: '/static/diypage/images/default/cube-4.jpg',
  515. linkurl: '',
  516. }
  517. }
  518. },
  519. /**
  520. pictures: {
  521. name: '图片展播',
  522. params: {hidetext: 0, showtype: 0, rownum: 3, showbtn: 0},
  523. style: {
  524. background: "#ffffff",
  525. paddingtop: "3",
  526. paddingleft: "5",
  527. titlealign: 'left',
  528. textalign: 'left',
  529. titlecolor: '#ffffff',
  530. textcolor: '#666666'
  531. },
  532. data: {
  533. C0123456789101: {
  534. imgurl: '/static/diypage/images/default/goods-1.jpg',
  535. linkurl: '',
  536. title: '这里是上标题',
  537. text: '这里是下标题'
  538. },
  539. C0123456789102: {
  540. imgurl: '/static/diypage/images/default/goods-2.jpg',
  541. linkurl: '',
  542. title: '这里是上标题',
  543. text: '这里是下标题'
  544. },
  545. C0123456789103: {
  546. imgurl: '/static/diypage/images/default/goods-4.jpg',
  547. linkurl: '',
  548. title: '这里是上标题',
  549. text: '这里是下标题'
  550. }
  551. }
  552. },
  553. **/
  554. goods: {
  555. name: '商品组',
  556. params: {
  557. 'goodstype': '0',
  558. 'showtitle': '1',
  559. 'showprice': '1',
  560. 'showtag': '0',
  561. 'goodsdata': '0',
  562. 'cateid': '',
  563. 'catename': '',
  564. 'groupid': '',
  565. 'groupname': '',
  566. 'goodssort': '0',
  567. 'goodsnum': '6',
  568. 'showicon': '1',
  569. 'iconposition': 'left top',
  570. 'productprice': '1',
  571. 'showproductprice': '0',
  572. 'showsales': '0',
  573. 'productpricetext': '原价',
  574. 'salestext': '销量',
  575. 'productpriceline': '0',
  576. 'saleout': '0'
  577. },
  578. style: {
  579. 'background': '#f3f3f3',
  580. 'liststyle': 'block',
  581. 'buystyle': 'buybtn-1',
  582. 'goodsicon': 'recommand',
  583. 'iconstyle': 'triangle',
  584. 'pricecolor': '#ff5555',
  585. 'productpricecolor': '#666666',
  586. 'iconpaddingtop': '0',
  587. 'iconpaddingleft': '0',
  588. 'buybtncolor': '#ff5555',
  589. 'iconzoom': '100',
  590. 'titlecolor': '#000000',
  591. 'tagbackground': '#fe5455',
  592. 'productpricecolor': '#999999',
  593. 'salescolor': '#999999',
  594. 'saleoutstyle': 1
  595. },
  596. data: {
  597. C0123456789101: {
  598. thumb: '/static/diypage/images/default/goods-1.jpg',
  599. price: '20.00',
  600. productprice: '99.00',
  601. title: '这里是商品标题',
  602. sales: '0',
  603. gid: '',
  604. bargain: 0,
  605. credit: 0,
  606. ctype: 1
  607. },
  608. C0123456789102: {
  609. thumb: '/static/diypage/images/default/goods-2.jpg',
  610. price: '20.00',
  611. productprice: '99.00',
  612. title: '这里是商品标题',
  613. sales: '0',
  614. gid: '',
  615. bargain: 0,
  616. credit: 0,
  617. ctype: 1
  618. },
  619. C0123456789103: {
  620. thumb: '/static/diypage/images/default/goods-3.jpg',
  621. price: '20.00',
  622. productprice: '99.00',
  623. sales: '0',
  624. title: '这里是商品标题',
  625. gid: '',
  626. bargain: 0,
  627. credit: 0,
  628. ctype: 0
  629. },
  630. C0123456789104: {
  631. thumb: '/static/diypage/images/default/goods-4.jpg',
  632. price: '20.00',
  633. productprice: '99.00',
  634. sales: '0',
  635. title: '这里是商品标题',
  636. gid: '',
  637. bargain: 0,
  638. credit: 0,
  639. ctype: 0
  640. }
  641. }
  642. },
  643. diymod: {name: '公用模块', params: {'modid': '', 'modname': ''}, style: {}},
  644. listmenu: {
  645. name: '列表导航',
  646. params: {},
  647. style: {
  648. 'margintop': '10',
  649. 'background': '#ffffff',
  650. 'iconcolor': '#999999',
  651. 'textcolor': '#000000',
  652. 'remarkcolor': '#888888'
  653. },
  654. data: {
  655. C0123456789101: {text: '文字1', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''},
  656. C0123456789102: {text: '文字2', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''},
  657. C0123456789103: {text: '文字3', linkurl: '', iconclass: 'icon-home', remark: '查看', dotnum: ''}
  658. }
  659. },
  660. wxcard: {
  661. name: '微信会员卡',
  662. max: 1,
  663. type: 3,
  664. params: {
  665. iconclass: 'icon-same'
  666. },
  667. style: {
  668. 'margintop': '10',
  669. 'background': '#ffffff',
  670. 'iconcolor': '#999999',
  671. 'textcolor': '#333333',
  672. 'remarkcolor': '#888888',
  673. }
  674. },
  675. verify: {
  676. name: '待使用商品',
  677. max: 1,
  678. type: 3,
  679. params: {
  680. title: '待使用商品',
  681. remark: '',
  682. iconclass: 'icon-list',
  683. style: ''
  684. },
  685. style: {
  686. titlecolor: '#333333',
  687. remarkcolor: '#888888',
  688. titlebg: '#ffffff',
  689. background: '#ffffff'
  690. }
  691. },
  692. member: {
  693. name: '会员信息',
  694. type: 3,
  695. params: {
  696. style: 'default1',
  697. levellink: '',
  698. seticon: 'icon-settings',
  699. setlink: '',
  700. leftnav: '充值',
  701. leftnavlink: '',
  702. rightnav: '兑换',
  703. rightnavlink: ''
  704. },
  705. style: {'background': '#ff5555', 'textcolor': '#ffffff', 'textlight': '#ffffff', 'headstyle': ''},
  706. info: {avatar: '', nickname: '', levelname: '', textmoney: '', textcredit: '', money: '', credit: ''}
  707. },
  708. /**
  709. icongroup: {
  710. name: '图标组',
  711. params: {rownum: '4', border: '1', bordertop: '1', borderbottom: '1',},
  712. style: {
  713. background: '#ffffff',
  714. bordercolor: '#ffffff',
  715. textcolor: '#000000',
  716. iconcolor: '#666666',
  717. dotcolor: '#ff0011'
  718. },
  719. data: {
  720. C0123456789101: {iconclass: 'icon-daifukuan', text: '待付款', linkurl: '', dotnum: 0},
  721. C0123456789102: {iconclass: 'icon-fahuo', text: '待发货', linkurl: '', dotnum: 0},
  722. C0123456789103: {iconclass: 'icon-daishouhuo', text: '待收货', linkurl: '', dotnum: 0},
  723. C0123456789104: {iconclass: 'icon-daituikuan', text: '退换货', linkurl: '', dotnum: 0}
  724. }
  725. },
  726. **/
  727. bindmobile: {
  728. name: '绑定手机',
  729. type: 3,
  730. params: {
  731. linkurl: '',
  732. title: '绑定手机号',
  733. text: '如果您用手机号注册过会员或您想通过微信外购物请绑定您的手机号码',
  734. iconclass: 'icon-mobile'
  735. },
  736. style: {
  737. margintop: '10',
  738. background: '#ffffff',
  739. titlecolor: '#ff5555',
  740. textcolor: '#999999',
  741. iconcolor: '#999999'
  742. }
  743. },
  744. logout: {
  745. name: '退出登录',
  746. type: 3,
  747. params: {bindurl: '', logouturl: ''},
  748. style: {subcolor: '#ffffff', maincolor: '#ff5555', margintop: '10'}
  749. },
  750. memberc: {
  751. name: '会员信息',
  752. type: 4,
  753. params: {
  754. style: 'default1',
  755. seticon: 'icon-settings',
  756. setlink: '',
  757. leftnav: '提现1',
  758. leftnavlink: '',
  759. rightnav: '提现2',
  760. rightnavlink: '',
  761. centernav: '提现',
  762. centernavlink: '',
  763. hideup: 0
  764. },
  765. style: {background: '#fe5455', textcolor: '#ffffff', textlight: '#ffffff'}
  766. },
  767. blockgroup: {
  768. name: '图标块',
  769. params: {rownum: 3},
  770. style: {background: '#ffffff', tipcolor: '#feb312'},
  771. data: {
  772. C0123456789101: {
  773. iconclass: 'icon-money',
  774. iconcolor: '#feb312',
  775. text: '分销佣金',
  776. textcolor: '#666666',
  777. linkurl: '',
  778. tipnum: '0.00',
  779. tiptext: '元'
  780. },
  781. C0123456789102: {
  782. iconclass: 'icon-list',
  783. iconcolor: '#50b6fe',
  784. text: '佣金明细',
  785. textcolor: '#666666',
  786. linkurl: '',
  787. tipnum: '50',
  788. tiptext: '笔'
  789. },
  790. C0123456789103: {
  791. iconclass: 'icon-manageorder',
  792. iconcolor: '#ff741d',
  793. text: '提现明细',
  794. textcolor: '#666666',
  795. linkurl: '',
  796. tipnum: '10',
  797. tiptext: '笔'
  798. },
  799. C0123456789104: {
  800. iconclass: 'icon-group',
  801. iconcolor: '#ff741d',
  802. text: '我的下线',
  803. textcolor: '#666666',
  804. linkurl: '',
  805. tipnum: '2',
  806. tiptext: '人'
  807. },
  808. C0123456789105: {
  809. iconclass: 'icon-qrcode',
  810. iconcolor: '#feb312',
  811. text: '推广二维码',
  812. textcolor: '#666666',
  813. linkurl: '',
  814. tipnum: '',
  815. tiptext: ''
  816. },
  817. C0123456789106: {
  818. iconclass: 'icon-shopfill',
  819. iconcolor: '#50b6fe',
  820. text: '小店设置',
  821. textcolor: '#666666',
  822. linkurl: '',
  823. tipnum: '',
  824. tiptext: ''
  825. },
  826. C0123456789107: {
  827. iconclass: 'icon-rank',
  828. iconcolor: '#ff741d',
  829. text: '佣金排名',
  830. textcolor: '#666666',
  831. linkurl: '',
  832. tipnum: '',
  833. tiptext: ''
  834. }
  835. }
  836. },
  837. detail_tab: {
  838. name: "选项卡",
  839. type: 5,
  840. max: 1,
  841. params: {goodstext: "商品", detailtext: "详情"},
  842. style: {background: "#f7f7f7", textcolor: "#666666", activecolor: "#ef4f4f"}
  843. },
  844. detail_swipe: {
  845. name: "商品图",
  846. type: 5,
  847. max: 1,
  848. params: {},
  849. style: {
  850. dotstyle: 'rectangle',
  851. dotalign: 'left',
  852. background: '#ffffff',
  853. leftright: '5',
  854. bottom: '5',
  855. opacity: '0.8'
  856. },
  857. },
  858. detail_info: {
  859. name: "商品信息",
  860. type: 5,
  861. max: 1,
  862. params: {hideshare: '0', share: "分享", share_link: "", share_icon: "icon-share",},
  863. style: {
  864. margintop: 0,
  865. marginbottom: 0,
  866. background: "#ffffff",
  867. titlecolor: "#000000",
  868. subtitlecolor: "#999999",
  869. pricecolor: "#ff5555",
  870. textcolor: "#cccccc",
  871. timecolor: "#ff5555",
  872. timetextcolor: "#000000",
  873. }
  874. },
  875. detail_sale: {
  876. name: "营销信息",
  877. type: 5,
  878. max: 1,
  879. params: {},
  880. style: {
  881. margintop: 0,
  882. marginbottom: 0,
  883. background: "#ffffff",
  884. textcolor: "#666666",
  885. textcolorhigh: "#ef4f4f"
  886. },
  887. data: {
  888. C0123456789100: {name: "商品预售", type: "yushou"},
  889. C0123456789101: {name: "二次购买", type: "erci"},
  890. C0123456789102: {name: "会员价", type: "huiyuan"},
  891. C0123456789103: {name: "优惠", type: "youhui"},
  892. C0123456789104: {name: "积分", type: "jifen"},
  893. C0123456789105: {name: "不配送区域", type: "bupeisong"},
  894. C0123456789106: {name: "商品标签", type: "biaoqian"},
  895. C0123456789107: {name: "可用优惠券", type: "coupon"},
  896. C0123456789108: {name: "赠品", type: "zengpin"},
  897. C0123456789108: {name: "全返", type: "fullback"}
  898. }
  899. },
  900. detail_spec: {
  901. name: "商品规格",
  902. type: 5,
  903. max: 1,
  904. params: {},
  905. style: {background: "#ffffff", textcolor: "#333333", margintop: 10, marginbottom: 0}
  906. },
  907. detail_shop: {
  908. name: "店铺信息",
  909. type: 5,
  910. max: 1,
  911. params: {
  912. shoplogo: "../addons/ewei_shopv2/static/images/designer.jpg",
  913. shopname: "",
  914. shopdesc: "",
  915. hidenum: 0,
  916. leftnavtext: "全部商品",
  917. leftnavlink: "",
  918. rightnavtext: "进店逛逛",
  919. rightnavlink: "",
  920. },
  921. style: {
  922. margintop: 10,
  923. marginbottom: 0,
  924. background: "#ffffff",
  925. goodsnumcolor: "#333333",
  926. goodstextcolor: "#7c7c7c",
  927. rightnavcolor: "#ff5555",
  928. shopnamecolor: "#333333",
  929. shopdesccolor: "#444444"
  930. }
  931. },
  932. detail_comment: {
  933. name: "商品评价",
  934. type: 5,
  935. max: 1,
  936. params: {},
  937. style: {
  938. margintop: 10,
  939. marginbottom: 10,
  940. background: "#ffffff",
  941. maincolor: "#fd5454",
  942. subcolor: "#000",
  943. textcolor: "#333333",
  944. }
  945. },
  946. detail_buyshow: {
  947. name: "购买可见",
  948. type: 5,
  949. max: 1,
  950. params: {},
  951. style: {background: "#ffffff", margintop: 10, marginbottom: 0}
  952. },
  953. detail_store: {
  954. name: "适用门店",
  955. type: 5,
  956. max: 1,
  957. params: {},
  958. style: {
  959. background: "#ffffff",
  960. margintop: 10,
  961. marginbottom: 0,
  962. titlecolor: "#333333",
  963. shopnamecolor: "#333333",
  964. shopinfocolor: "#666666",
  965. navtelcolor: "#008000",
  966. navlocationcolor: "#ff9900",
  967. }
  968. },
  969. detail_package: {
  970. name: "相关套餐",
  971. type: 5,
  972. max: 1,
  973. params: {},
  974. style: {background: "#ffffff", margintop: 10, marginbottom: 0, textcolor: "#000000"}
  975. },
  976. detail_pullup: {
  977. name: "上拉详情",
  978. type: 5,
  979. max: 1,
  980. params: {},
  981. style: {margintop: 10, background: "#ffffff", textcolor: "#333333"}
  982. },
  983. detail_navbar: {
  984. name: "底部导航",
  985. type: 5,
  986. max: 1,
  987. params: {
  988. hidelike: 0,
  989. hideshop: 0,
  990. hidecart: 0,
  991. hidecartbtn: 0,
  992. textbuy: "立刻购买",
  993. goodstext: "商品",
  994. liketext: "关注",
  995. likeiconclass: "icon-like",
  996. likelink: "icon-like",
  997. shoptext: "店铺",
  998. shopiconclass: "icon-shop",
  999. carttext: "购物车",
  1000. carticonclass: "icon-cart"
  1001. },
  1002. style: {
  1003. background: "#ffffff",
  1004. textcolor: "#999999",
  1005. iconcolor: "#999999",
  1006. cartcolor: "#fe9402",
  1007. buycolor: "#fd5555",
  1008. dotcolor: "#ff0011"
  1009. }
  1010. },
  1011. detail_seckill: {
  1012. name: "秒杀条",
  1013. type: 5,
  1014. max: 1,
  1015. params: {buybtntext: "原价购买"},
  1016. style: {
  1017. bgleft: "#ef4f4f",
  1018. bgright: "#ffef32",
  1019. pricecolor: '#ffffff',
  1020. marketpricecolor: '#ffffff',
  1021. tagcolor: '#ffffff',
  1022. statuscolor: '#ef4f4f',
  1023. processtextcolor: '#fffffff',
  1024. processcolor: '#ffef32',
  1025. bgleftwait: "#00b950",
  1026. bgrightwait: "#00b950",
  1027. timecolor: '#ffffff',
  1028. timebgcolor: '#582e19',
  1029. pricecolorwait: '#ffffff',
  1030. marketpricecolorwait: '#ffffff',
  1031. tagcolorwait: '#ffffff',
  1032. statuscolorwait: '#ffffff',
  1033. timecolorwait: '#ffffff',
  1034. timebgcolorwait: '#003718',
  1035. buybtntextwait: '#ffffff',
  1036. buybtnbgwait: '#00b950'
  1037. }
  1038. },
  1039. merchgroup: {
  1040. name: "商户组",
  1041. params: {
  1042. merchdata: '0',
  1043. merchnum: '6',
  1044. merchsort: '',
  1045. catename: '',
  1046. cateid: '',
  1047. groupname: '',
  1048. groupid: '',
  1049. openlocation: '0'
  1050. },
  1051. style: {
  1052. background: '#ffffff',
  1053. titlecolor: '#333333',
  1054. textcolor: '#666666',
  1055. rangecolor: '#ff5555',
  1056. locationcolor: '#ff5555',
  1057. margintop: '10'
  1058. },
  1059. data: {
  1060. C0123456789101: {name: "商户名称A", desc: "这里是商户A的介绍", thumb: "", merchid: ""},
  1061. C0123456789102: {name: "商户名称B", desc: "这里是商户B的介绍", thumb: "", merchid: ""},
  1062. C0123456789103: {name: "商户名称C", desc: "这里是商户C的介绍", thumb: "", merchid: ""}
  1063. }
  1064. },
  1065. /**
  1066. audio: {
  1067. name: "音频播放",
  1068. params: {
  1069. title: "未定义音频信息",
  1070. subtitle: "副标题",
  1071. playerstyle: 0,
  1072. autoplay: 0,
  1073. loopplay: 0,
  1074. pausestop: 0,
  1075. headalign: "left",
  1076. headtype: "",
  1077. headurl: ""
  1078. },
  1079. style: {
  1080. background: "#f1f1f1",
  1081. bordercolor: "#ededed",
  1082. textcolor: "#333333",
  1083. subtitlecolor: "#666666",
  1084. timecolor: "#666666",
  1085. paddingtop: "20",
  1086. paddingleft: "20",
  1087. width: "80"
  1088. }
  1089. },
  1090. **/
  1091. seckillgroup: {
  1092. max: 1,
  1093. name: "秒杀组",
  1094. params: {
  1095. iconurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/seckill.png',
  1096. hideborder: 0,
  1097. tag: ''
  1098. },
  1099. style: {
  1100. margintop: '10',
  1101. background: '#ffffff',
  1102. titlecolor: '#444444',
  1103. timecolor: '#444444',
  1104. timesigncolor: '#444444',
  1105. timebgcolor: '#ffffff',
  1106. timebordercolor: '#d9d9d9',
  1107. morecolor: '#888888',
  1108. marketpricecolor: '#ef4f4f',
  1109. productpricecolor: '#999999',
  1110. }
  1111. },
  1112. seckill_times: {
  1113. type: 7,
  1114. max: 1,
  1115. name: "秒杀时间段",
  1116. params: {},
  1117. style: {
  1118. margintop: '0',
  1119. background: '#ffffff',
  1120. color: '#333333',
  1121. bgcolor: '#ffffff',
  1122. selectedcolor: '#ff3300',
  1123. selectedbgcolor: '#ffffff'
  1124. }
  1125. },
  1126. seckill_rooms: {
  1127. type: 7,
  1128. name: "秒杀会场",
  1129. max: 1,
  1130. params: {},
  1131. style: {
  1132. margintop: '0',
  1133. background: '#ffffff',
  1134. color: '#333333',
  1135. bgcolor: '#ffffff',
  1136. selectedcolor: '#ef4f4f',
  1137. selectedbgcolor: '#ffffff'
  1138. }
  1139. },
  1140. seckill_advs: {
  1141. type: 7,
  1142. max: 1,
  1143. name: "秒杀广告",
  1144. params: {},
  1145. style: {margintop: '0', marginbottom: '0', background: '#ffffff'}
  1146. },
  1147. seckill_list: {
  1148. type: 7,
  1149. name: "秒杀商品",
  1150. max: 1,
  1151. params: {
  1152. titletext: '先下单先得哦~',
  1153. titleovertext: '还可以继续抢购哦~',
  1154. titlewaittext: '即将开始 先下单先得哦',
  1155. btntext: '抢购中',
  1156. btnovertext: '已抢完',
  1157. btnwaittext: '等待抢购'
  1158. },
  1159. style: {
  1160. margintop: '0',
  1161. marginbottom: '0',
  1162. background: '#ffffff',
  1163. topbgcolor: '#f0f2f5',
  1164. topcolor: '#333333',
  1165. timebgcolor: '#464553',
  1166. timecolor: '#ffffff',
  1167. titlecolor: '#333333',
  1168. pricecolor: '#ef4f4f',
  1169. marketpricecolor: '#949598',
  1170. btnbgcolor: '#ef4f4f',
  1171. btnoverbgcolor: '#f7f7f7',
  1172. btnwaitbgcolor: '#04be02',
  1173. btncolor: '#ffffff',
  1174. btnovercolor: '#333333',
  1175. btnwaitcolor: '#ffffff',
  1176. processtextcolor: '#d0d1d2',
  1177. processbgcolor: '#ff8f8f',
  1178. }
  1179. },
  1180. coupon: {
  1181. name: '优惠券组',
  1182. params: {couponstyle: '3'},
  1183. style: {background: '#ffffff', margintop: '10', marginleft: '5'},
  1184. data: {
  1185. C0123456789101: {
  1186. name: "优惠券名称",
  1187. desc: "满100元可用",
  1188. price: "89.90",
  1189. couponid: "",
  1190. background: '#fd5454',
  1191. bordercolor: '#fd5454',
  1192. textcolor: '#ffffff',
  1193. couponcolor: '#55b5ff'
  1194. },
  1195. C0123456789102: {
  1196. name: "优惠券名称",
  1197. desc: "满100元可用",
  1198. price: "89.90",
  1199. couponid: "",
  1200. background: '#ff9140',
  1201. bordercolor: '#ff9140',
  1202. textcolor: '#ffffff',
  1203. couponcolor: '#ff5555'
  1204. },
  1205. C0123456789103: {
  1206. name: "优惠券名称",
  1207. desc: "满100元可用",
  1208. price: "89.90",
  1209. couponid: "",
  1210. background: '#54b5fd',
  1211. bordercolor: '#54b5fd',
  1212. textcolor: '#ffffff',
  1213. couponcolor: '#ff913f'
  1214. }
  1215. }
  1216. },
  1217. fixedsearch: {
  1218. name: '固定搜索框',
  1219. istop: 1,
  1220. max: 1,
  1221. params: {
  1222. leftnav: '1',
  1223. rightnav: '1',
  1224. rightnavclick: '0',
  1225. leftnavicon: 'icon-shop',
  1226. rightnavicon: 'icon-cart',
  1227. searchstyle: 'round',
  1228. placeholder: '输入关键字进行搜索'
  1229. },
  1230. style: {
  1231. background: '#000000',
  1232. opacity: 0.8,
  1233. opacityinput: 0.8,
  1234. leftnavcolor: '#ffffff',
  1235. rightnavcolor: '#ffffff',
  1236. searchbackground: '#ffffff',
  1237. searchtextcolor: '#666666'
  1238. }
  1239. },
  1240. exchange_banner: {
  1241. name: '兑换轮播图',
  1242. max: 1,
  1243. type: 8,
  1244. params: {datatype: 0},
  1245. style: {
  1246. 'dotstyle': 'rectangle',
  1247. 'dotalign': 'left',
  1248. 'background': '#ffffff',
  1249. 'leftright': '5',
  1250. 'bottom': '5',
  1251. 'opacity': '0.8'
  1252. },
  1253. data: {
  1254. C0123456789101: {
  1255. imgurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/banner-1.jpg',
  1256. linkurl: '',
  1257. },
  1258. C0123456789102: {
  1259. imgurl: '../addons/ewei_shopv2/plugin/diypage/static/images/default/banner-2.jpg',
  1260. linkurl: '',
  1261. }
  1262. }
  1263. },
  1264. exchange_input: {
  1265. name: '兑换区域',
  1266. max: 1,
  1267. type: 8,
  1268. params: {
  1269. preview: '0',
  1270. title: '兑换码兑换',
  1271. placeholder: '请输入兑换码',
  1272. btntext: '立即兑换',
  1273. backbtn: '返回重新输入兑换码',
  1274. exbtntext: '兑换',
  1275. exbtn2text: '已兑换',
  1276. crediticon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_credit.png',
  1277. moneyicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_money.png',
  1278. couponicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_coupon.png',
  1279. redbagicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_redbag.png',
  1280. goodsicon: '../addons/ewei_shopv2/plugin/diypage/static/images/default/icon_goods.png'
  1281. },
  1282. style: {
  1283. titlecolor: '#444444',
  1284. btncolor: '#ffffff',
  1285. btnbackground: '#ed5565',
  1286. inputcolor: '#666666',
  1287. inputbackground: '#ffffff',
  1288. inputborder: '#efefef',
  1289. codecolor: '#444444',
  1290. numcolor: '#999999',
  1291. exbtncolor: '#ffffff',
  1292. exbtnbackground: '#ed5565',
  1293. exbtn2color: '#ffffff',
  1294. exbtn2background: '#cccccc',
  1295. backbtncolor: '#444444',
  1296. backbtnborder: '#e7eaec',
  1297. backbtnbackground: '#f7f7f7',
  1298. goodstitle: '#444444',
  1299. goodsprice: '#aaaaaa'
  1300. }
  1301. },
  1302. exchange_rule: {
  1303. name: '兑换规则',
  1304. max: 1,
  1305. type: 8,
  1306. params: {ruletitle: '兑换规则'},
  1307. style: {ruletitlecolor: '#555555'}
  1308. },
  1309. tabbar: {
  1310. name: '选项卡',
  1311. max: 2,
  1312. style: {
  1313. background: '#ffffff',
  1314. color: '#666666',
  1315. activebackground: '#ffffff',
  1316. activecolor: '#ef4f4f',
  1317. scrollnum: 3
  1318. },
  1319. data: {
  1320. C0123456789101: {
  1321. text: '选项卡文字',
  1322. linkurl: ''
  1323. },
  1324. C0123456789102: {
  1325. text: '选项卡文字',
  1326. linkurl: ''
  1327. }
  1328. }
  1329. }
  1330. }
  1331. };
  1332. modal.initItems = function (selected) {
  1333. var phone = $("#phone");
  1334. if (!modal.items) {
  1335. modal.items = {};
  1336. return
  1337. }
  1338. phone.empty();
  1339. $.each(modal.items, function (itemid, item) {
  1340. if (typeof(item.id) !== 'undefined') {
  1341. var newItem = $.extend(true, {}, item);
  1342. newItem.itemid = itemid;
  1343. if (item.id == 'audio') {
  1344. newItem.shoplogo = modal.shopset ? modal.shopset.logo : ''
  1345. }
  1346. var html = tpl("tpl_show_" + item.id, newItem);
  1347. $("#phone").append(html)
  1348. }
  1349. });
  1350. var btnhtml = $("#edit-del").html();
  1351. $("#phone .drag").append(btnhtml);
  1352. $("#phone .drag .btn-edit-del .btn-del").unbind('click').click(function (e) {
  1353. e.stopPropagation();
  1354. var drag = $(this).closest(".drag");
  1355. var itemid = drag.data('itemid');
  1356. var nodelete = $(this).closest(".drag").hasClass("nodelete");
  1357. if (nodelete) {
  1358. tip.alert("此元素禁止删除");
  1359. return
  1360. }
  1361. tip.confirm("确定删除吗", function () {
  1362. var nearid = modal.getNear(itemid);
  1363. delete modal.items[itemid];
  1364. modal.initItems();
  1365. if (nearid) {
  1366. $(document).find(".drag[data-itemid='" + nearid + "']").trigger('mousedown')
  1367. } else {
  1368. $("#page").trigger('click')
  1369. }
  1370. })
  1371. });
  1372. if (selected) {
  1373. modal.selectedItem(selected)
  1374. }
  1375. };
  1376. modal.selectedItem = function (itemid) {
  1377. if (!itemid) {
  1378. return
  1379. }
  1380. modal.selected = itemid;
  1381. if (itemid == 'page') {
  1382. $("#page").trigger('click')
  1383. } else {
  1384. $(".drag[data-itemid='" + itemid + "']").addClass('selected')
  1385. }
  1386. };
  1387. modal.initPage = function (initE) {
  1388. if (typeof(initE) === 'undefined') {
  1389. initE = true
  1390. }
  1391. if (!modal.page) {
  1392. modal.page = {
  1393. type: modal.type,
  1394. title: '请输入页面标题',
  1395. name: '未命名页面',
  1396. desc: '',
  1397. icon: '',
  1398. keyword: '',
  1399. background: '#f3f3f3',
  1400. diymenu: '-1',
  1401. diylayer: '0',
  1402. diygotop: '0',
  1403. followbar: '0',
  1404. visit: '0',
  1405. visitlevel: {member: null, commission: null},
  1406. novisit: {title: null, link: null}
  1407. };
  1408. if (modal.type == 5) {
  1409. modal.page.title = "商品详情"
  1410. }
  1411. else if (modal.type == 8) {
  1412. modal.page.title = "兑换中心"
  1413. }
  1414. else if (modal.type == 99) {
  1415. modal.page.type = 99;
  1416. modal.page.title = '公用模块';
  1417. modal.page.name = '未命名模块'
  1418. }
  1419. }
  1420. if(!modal.page.visitlevel){
  1421. modal.page.visitlevel = {member: null, commission: null};
  1422. }
  1423. if(!modal.page.novisit){
  1424. modal.page.novisit = {};
  1425. }
  1426. $("#page").text(modal.page.title);
  1427. $("#phone").css({'background-color': modal.page.background});
  1428. $("#phone").find(".drag").removeClass("selected");
  1429. if (initE) {
  1430. modal.initEditor()
  1431. }
  1432. };
  1433. modal.initSortable = function () {
  1434. $("#phone").sortable({
  1435. opacity: 0.8,
  1436. placeholder: "highlight",
  1437. items: '.drag:not(.fixed)',
  1438. revert: 100,
  1439. scroll: false,
  1440. start: function (event, ui) {
  1441. var height = ui.item.height();
  1442. $(".highlight").css({"height": height + "px"});
  1443. $(".highlight").html('<div><i class="fa fa-plus"></i> 放置此处</div>');
  1444. $(".highlight div").css({"line-height": height - 4 + "px"})
  1445. },
  1446. stop: function (event, ui) {
  1447. modal.initEditor()
  1448. },
  1449. update: function (event, ui) {
  1450. modal.sortItems()
  1451. }
  1452. });
  1453. $("#phone").disableSelection();
  1454. $(document).on('mousedown', "#phone .drag", function () {
  1455. if ($(this).hasClass("selected")) {
  1456. return
  1457. }
  1458. modal.selected = $(this).data('itemid');
  1459. $("#phone").find(".drag").removeClass("selected");
  1460. $(this).addClass("selected");
  1461. modal.selected = $(this).data('itemid');
  1462. modal.initEditor()
  1463. })
  1464. };
  1465. modal.sortItems = function () {
  1466. var newItems = {};
  1467. $("#phone .drag").each(function () {
  1468. var thisid = $(this).data('itemid');
  1469. newItems[thisid] = modal.items[thisid]
  1470. });
  1471. modal.items = newItems
  1472. };
  1473. modal.initEditor = function (scroll) {
  1474. if (typeof(scroll) === 'undefined') {
  1475. scroll = true
  1476. }
  1477. var itemid = modal.selected;
  1478. var top = 180;
  1479. if (modal.selected != 'page') {
  1480. var stop = $(".selected").position().top;
  1481. top = stop ? stop : 0
  1482. }
  1483. if (scroll) {
  1484. $("#diy-editor").unbind('animate').animate({"margin-top": top - 130 + "px"});
  1485. setTimeout(function () {
  1486. $("body").unbind('animate').animate({scrollTop: top - 130 + "px"}, 1000)
  1487. }, 1000)
  1488. }
  1489. if (modal.selected) {
  1490. if (modal.selected == 'page') {
  1491. if (modal.type == 99) {
  1492. var html = tpl("tpl_edit_page_mod", modal.page)
  1493. } else {
  1494. var html = tpl("tpl_edit_page", modal)
  1495. }
  1496. $("#diy-editor .inner").html(html)
  1497. } else {
  1498. var item = $.extend(true, {}, modal.items[modal.selected]);
  1499. item.itemid = modal.selected;
  1500. item.merch = modal.merch;
  1501. item.plugins = modal.plugins;
  1502. var html = tpl("tpl_edit_" + item.id, item);
  1503. $("#diy-editor .inner").html(html)
  1504. }
  1505. $("#diy-editor").attr("data-editid", modal.selected).show()
  1506. }
  1507. var sliderlength = $("#diy-editor .slider").length;
  1508. if (sliderlength > 0) {
  1509. $("#diy-editor .slider").each(function () {
  1510. var decimal = $(this).data('decimal');
  1511. var multiply = $(this).data('multiply');
  1512. var defaultValue = $(this).data("value");
  1513. if (decimal) {
  1514. defaultValue = defaultValue * decimal
  1515. }
  1516. $(this).slider({
  1517. slide: function (event, ui) {
  1518. var sliderValue = ui.value;
  1519. if (decimal) {
  1520. sliderValue = sliderValue / decimal
  1521. }
  1522. $(this).siblings(".input").val(sliderValue).trigger("propertychange");
  1523. $(this).siblings(".count").find("span").text(sliderValue)
  1524. }, value: defaultValue, min: $(this).data("min"), max: $(this).data("max")
  1525. })
  1526. })
  1527. }
  1528. var goodsSelector = $("#diy-editor .goods-selector").length;
  1529. if (goodsSelector > 0) {
  1530. var _this = $("#diy-editor .goods-selector");
  1531. var url = biz.url('goods/query', null, modal.merch);
  1532. if (_this.data('goodstype') == 1) {
  1533. url = biz.url('goods/query', null, modal.merch)+ "&is_normal=2";
  1534. }
  1535. _this.attr({'id': 'goods_selector', 'data-url': url, 'data-callback': 'callbackGoods'});
  1536. _this.unbind('click').click(function () {
  1537. biz.selector.select({name: 'goods'});
  1538. modal.childid = $(this).closest('.item').data('id')
  1539. })
  1540. } // + "&id=" + pageid;
  1541. var categorySelector = $("#diy-editor .category-selector").length;
  1542. if (categorySelector > 0) {
  1543. var _this = $("#diy-editor .category-selector");
  1544. var url = biz.url('goods/category/query', null, modal.merch);
  1545. if (_this.data('goodstype') == 1) {
  1546. url = biz.url('goods/category/query', null, modal.merch)+ "&is_normal=2";
  1547. }
  1548. _this.attr({'id': 'category_selector', 'data-url': url, 'data-callback': 'callbackCategory'});
  1549. _this.unbind('click').click(function () {
  1550. biz.selector.select({name: 'category'})
  1551. })
  1552. }
  1553. var groupSelector = $("#diy-editor .group-selector").length;
  1554. if (groupSelector > 0) {
  1555. var _this = $("#diy-editor .group-selector");
  1556. _this.attr({
  1557. 'id': 'group_selector',
  1558. 'data-url': biz.url('goods/group/query', null, modal.merch),
  1559. 'data-callback': 'callbackGroup'
  1560. });
  1561. _this.unbind('click').click(function () {
  1562. biz.selector.select({name: 'group'})
  1563. })
  1564. }
  1565. var merchSelector = $("#diy-editor .merch-selector").length;
  1566. if (merchSelector) {
  1567. var _this = $("#diy-editor .merch-selector");
  1568. var url = biz.url('merch/user/query', null, modal.merch);
  1569. _this.attr({'id': 'merch_selector', 'data-url': url, 'data-callback': 'callbackMerch'});
  1570. _this.unbind('click').click(function () {
  1571. biz.selector.select({name: 'merch'});
  1572. modal.childid = $(this).closest('.item').data('id')
  1573. })
  1574. }
  1575. var merchCategorySelector = $("#diy-editor .merch-category-selector").length;
  1576. if (merchCategorySelector) {
  1577. var _this = $("#diy-editor .merch-category-selector");
  1578. var url = biz.url('merch/category/query', null, modal.merch);
  1579. _this.attr({'id': 'category_selector', 'data-url': url, 'data-callback': 'callbackMerchCategory'});
  1580. _this.unbind('click').click(function () {
  1581. biz.selector.select({name: 'category'})
  1582. })
  1583. }
  1584. var merchGroupSelector = $("#diy-editor .merch-group-selector").length;
  1585. if (merchGroupSelector) {
  1586. var _this = $("#diy-editor .merch-group-selector");
  1587. _this.attr({
  1588. 'id': 'group_selector',
  1589. 'data-url': biz.url('merch/group/query', null, modal.merch),
  1590. 'data-callback': 'callbackMerchGroup'
  1591. });
  1592. _this.unbind('click').click(function () {
  1593. biz.selector.select({name: 'group'})
  1594. })
  1595. }
  1596. var couponSelector = $("#diy-editor .coupon-selector").length;
  1597. if (couponSelector) {
  1598. var _this = $("#diy-editor .coupon-selector");
  1599. _this.attr({
  1600. 'id': 'coupon_selector',
  1601. 'data-url': biz.url('marketing/querycoupon', {diy: 1}, modal.merch),
  1602. 'data-callback': 'callbackCoupon'
  1603. });
  1604. _this.unbind('click').click(function () {
  1605. biz.selector.select({name: 'coupon'});
  1606. modal.childid = $(this).closest('.item').data('id')
  1607. })
  1608. }
  1609. var audioPlayer = $("#diy-editor .audio-player").length;
  1610. if (audioPlayer) {
  1611. $("#diy-editor .audio-player").click(function () {
  1612. var _this = $(this);
  1613. var audio = _this.next('audio')[0];
  1614. var src = _this.next('audio').attr('src');
  1615. if (audio && src) {
  1616. if (audio.paused) {
  1617. audio.play();
  1618. _this.find('.fa').removeClass("fa-play").addClass("fa-stop");
  1619. var timer = setInterval(function () {
  1620. if (audio.currentTime >= audio.duration) {
  1621. audio.pause();
  1622. _this.find('.fa').removeClass("fa-stop").addClass("fa-play");
  1623. clearInterval(timer)
  1624. }
  1625. }, 1000)
  1626. } else {
  1627. audio.currentTime = 0;
  1628. audio.pause();
  1629. _this.find('.fa').removeClass("fa-stop").addClass("fa-play")
  1630. }
  1631. } else {
  1632. tip.msgbox.err("请先选择音频!")
  1633. }
  1634. })
  1635. }
  1636. var childitems = $("#diy-editor .form-items").length;
  1637. if (childitems > 0) {
  1638. modal.initSortableChild();
  1639. $("#addChild").unbind('click').click(function () {
  1640. var itemid = modal.selected;
  1641. var type = modal.items[itemid].id;
  1642. var temp = modal.navs[type].data;
  1643. var max = $(this).closest(".form-items").data('max');
  1644. if (max) {
  1645. var length = modal.length(modal.items[itemid].data);
  1646. if (length >= max) {
  1647. tip.msgbox.err("最大添加 " + max + " 个!");
  1648. return
  1649. }
  1650. }
  1651. var newChild = {};
  1652. var index = 0;
  1653. $.each(temp, function (i, t) {
  1654. if (index == 0) {
  1655. newChild = t;
  1656. index++
  1657. }
  1658. });
  1659. if (newChild) {
  1660. var childName = modal.getId("M", 0);
  1661. if (typeof(modal.items[itemid].data) === 'undefined') {
  1662. modal.items[itemid].data = {}
  1663. }
  1664. newChild = $.extend(true, {}, newChild);
  1665. modal.items[itemid].data[childName] = newChild
  1666. }
  1667. modal.initItems(itemid);
  1668. modal.initEditor(false)
  1669. });
  1670. $("#diy-editor .form-items .item .btn-del").unbind('click').click(function () {
  1671. var childid = $(this).closest(".item").data('id');
  1672. var itemid = modal.selected;
  1673. var min = $(this).closest(".form-items").data("min");
  1674. if (min) {
  1675. var length = modal.length(modal.items[itemid].data);
  1676. if (length <= min) {
  1677. tip.msgbox.err("至少保留 " + min + " 个!");
  1678. return
  1679. }
  1680. }
  1681. tip.confirm("确定删除吗", function () {
  1682. delete modal.items[itemid].data[childid];
  1683. modal.initItems(itemid);
  1684. modal.initEditor(false)
  1685. })
  1686. })
  1687. }
  1688. var richtext = $("#diy-editor .form-richtext").length;
  1689. if (richtext > 0) {
  1690. var ueditoroption = {
  1691. 'autoClearinitialContent': false,
  1692. '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']],
  1693. 'elementPathEnabled': false,
  1694. 'initialFrameHeight': 300,
  1695. 'focus': false,
  1696. 'maximumWords': 9999999999999
  1697. };
  1698. var opts = {
  1699. type: 'image',
  1700. direct: false,
  1701. multiple: true,
  1702. tabs: {'upload': 'active', 'browser': '', 'crawler': ''},
  1703. path: '',
  1704. dest_dir: '',
  1705. global: false,
  1706. thumb: false,
  1707. width: 0
  1708. };
  1709. UE.registerUI('myinsertimage', function (editor, uiName) {
  1710. editor.registerCommand(uiName, {
  1711. execCommand: function () {
  1712. require(['fileUploader'], function (uploader) {
  1713. uploader.show(function (imgs) {
  1714. if (imgs.length == 0) {
  1715. return
  1716. } else if (imgs.length == 1) {
  1717. editor.execCommand('insertimage', {
  1718. 'src': imgs[0]['url'],
  1719. '_src': imgs[0]['url'],
  1720. 'width': '100%',
  1721. 'alt': imgs[0].filename
  1722. })
  1723. } else {
  1724. var imglist = [];
  1725. for (i in imgs) {
  1726. imglist.push({
  1727. 'src': imgs[i]['url'],
  1728. '_src': imgs[i]['url'],
  1729. 'width': '100%',
  1730. 'alt': imgs[i].filename
  1731. })
  1732. }
  1733. editor.execCommand('insertimage', imglist)
  1734. }
  1735. }, opts)
  1736. })
  1737. }
  1738. });
  1739. var btn = new UE.ui.Button({
  1740. name: '插入图片',
  1741. title: '插入图片',
  1742. cssRules: 'background-position: -726px -77px',
  1743. onclick: function () {
  1744. editor.execCommand(uiName)
  1745. }
  1746. });
  1747. editor.addListener('selectionchange', function () {
  1748. var state = editor.queryCommandState(uiName);
  1749. if (state == -1) {
  1750. btn.setDisabled(true);
  1751. btn.setChecked(false)
  1752. } else {
  1753. btn.setDisabled(false);
  1754. btn.setChecked(state)
  1755. }
  1756. });
  1757. return btn
  1758. }, 48);
  1759. UE.registerUI('myinsertvideo', function (editor, uiName) {
  1760. editor.registerCommand(uiName, {
  1761. execCommand: function () {
  1762. require(['fileUploader'], function (uploader) {
  1763. uploader.show(function (video) {
  1764. if (!video) {
  1765. return
  1766. } else {
  1767. var videoType = video.isRemote ? 'iframe' : 'video';
  1768. editor.execCommand('insertvideo', {
  1769. 'url': video.url,
  1770. 'width': 300,
  1771. 'height': 200
  1772. }, videoType)
  1773. }
  1774. }, {fileSizeLimit: 5120000, type: 'video', allowUploadVideo: true})
  1775. })
  1776. }
  1777. });
  1778. var btn = new UE.ui.Button({
  1779. name: '插入视频',
  1780. title: '插入视频',
  1781. cssRules: 'background-position: -320px -20px',
  1782. onclick: function () {
  1783. editor.execCommand(uiName)
  1784. }
  1785. });
  1786. editor.addListener('selectionchange', function () {
  1787. var state = editor.queryCommandState(uiName);
  1788. if (state == -1) {
  1789. btn.setDisabled(true);
  1790. btn.setChecked(false)
  1791. } else {
  1792. btn.setDisabled(false);
  1793. btn.setChecked(state)
  1794. }
  1795. });
  1796. return btn
  1797. }, 20);
  1798. UE.registerUI('mylink', function (editor, uiName) {
  1799. var btn = new UE.ui.Button({
  1800. name: 'selectUrl',
  1801. title: '系统链接',
  1802. cssRules: 'background-position: -622px 80px;',
  1803. onclick: function () {
  1804. $("#" + this.id).attr({"data-toggle": "selectUrl", "data-callback": "selectUrlCallback"})
  1805. }
  1806. });
  1807. editor.addListener('selectionchange', function () {
  1808. var state = editor.queryCommandState(uiName);
  1809. if (state == -1) {
  1810. btn.setDisabled(true);
  1811. btn.setChecked(false)
  1812. } else {
  1813. btn.setDisabled(false);
  1814. btn.setChecked(state)
  1815. }
  1816. });
  1817. return btn
  1818. });
  1819. if (typeof(UE) != 'undefined') {
  1820. UE.delEditor('rich')
  1821. }
  1822. var ue = UE.getEditor('rich', ueditoroption);
  1823. ue.ready(function () {
  1824. var thisitem = modal.items[itemid];
  1825. var richContent = thisitem.params.content;
  1826. // richContent = $.base64.decode(richContent);
  1827. ue.setContent(richContent);
  1828. ue.addListener('contentChange', function () {
  1829. var newContent = ue.getContent();
  1830. //newContent = $.base64.encode(newContent);
  1831. $("#richtext").html(newContent).trigger('change')
  1832. })
  1833. })
  1834. }
  1835. $("#diy-editor").find(".diy-bind").bind('input propertychange change', function () {
  1836. var _this = $(this);
  1837. var bind = _this.data("bind");
  1838. var bindchild = _this.data('bind-child');
  1839. var bindparent = _this.data('bind-parent');
  1840. var initEditor = _this.data('bind-init');
  1841. var value = '';
  1842. var tag = this.tagName;
  1843. if (!itemid) {
  1844. modal.selectedItem('page ')
  1845. }
  1846. if (tag == 'INPUT') {
  1847. var type = _this.attr('type');
  1848. if (type == 'checkbox') {
  1849. value = [];
  1850. _this.closest('.form-group').find('input[type=checkbox]').each(function () {
  1851. var checked = this.checked;
  1852. var valname = $(this).val();
  1853. if (checked) {
  1854. value.push(valname)
  1855. }
  1856. })
  1857. } else {
  1858. var placeholder = _this.data('placeholder');
  1859. value = _this.val();
  1860. value = value == '' ? placeholder : value
  1861. }
  1862. } else if (tag == 'SELECT') {
  1863. value = _this.find('option:selected').val()
  1864. } else if (tag == 'TEXTAREA') {
  1865. value = _this.val()
  1866. }
  1867. value = $.trim(value);
  1868. if (itemid == 'page') {
  1869. if (bindchild) {
  1870. if (!modal.page[bindchild]) {
  1871. modal.page[bindchild] = {}
  1872. }
  1873. modal.page[bindchild][bind] = value
  1874. } else {
  1875. modal.page[bind] = value
  1876. }
  1877. modal.initPage(false);
  1878. if (bind == 'keyword') {
  1879. $.post(biz.url('diypage/page/keyword'), {id: modal.id, keyword: value}, function (r) {
  1880. if (r.status == 0) {
  1881. _this.closest('.form-group').addClass('has-error');
  1882. modal.keyworderr = true
  1883. } else {
  1884. _this.closest('.form-group').removeClass('has-error');
  1885. modal.keyworderr = false
  1886. }
  1887. }, 'json')
  1888. }
  1889. } else {
  1890. if (bindchild) {
  1891. if (bindparent) {
  1892. modal.items[itemid][bindparent][bindchild][bind] = value
  1893. } else {
  1894. modal.items[itemid][bindchild][bind] = value
  1895. }
  1896. } else {
  1897. modal.items[itemid][bind] = value
  1898. }
  1899. modal.initItems(itemid)
  1900. }
  1901. if (initEditor) {
  1902. modal.initEditor(false)
  1903. }
  1904. })
  1905. };
  1906. modal.initSortableChild = function () {
  1907. $("#diy-editor .inner").sortable({
  1908. opacity: 0.8,
  1909. placeholder: "highlight",
  1910. items: '.item',
  1911. revert: 100,
  1912. scroll: false,
  1913. cancel: '.goods-selector,input,select,.btn,btn-del',
  1914. start: function (event, ui) {
  1915. var height = ui.item.height();
  1916. $(".highlight").css({"height": height + 22 + "px"});
  1917. $(".highlight").html('<div><i class="fa fa-plus"></i> 放置此处</div>');
  1918. $(".highlight div").css({"line-height": height + 16 + "px"})
  1919. },
  1920. update: function (event, ui) {
  1921. modal.sortChildItems()
  1922. }
  1923. })
  1924. };
  1925. modal.initMod = function (item) {
  1926. $.ajax(biz.url('diypage/page/mod/query', null, modal.merch), {
  1927. type: "get",
  1928. dataType: "html",
  1929. cache: false
  1930. }).done(function (html) {
  1931. modModal = $('<div class="modal fade" id="modModal"></div>');
  1932. $(document.body).append(modal), modModal.modal('show');
  1933. modModal.append2(html, function () {
  1934. $(document).off("click", '#modModal nav').on("click", '#modModal nav', function () {
  1935. var modid = $(this).data('id');
  1936. var modname = $(this).data('name');
  1937. modModal.find(".close").click();
  1938. var itemid = modal.getId("M", 0);
  1939. item.params.modid = modid;
  1940. item.params.modname = modname;
  1941. if (modal.selected && modal.selected != 'page') {
  1942. var newItems = {};
  1943. $.each(modal.items, function (id, eachitem) {
  1944. newItems[id] = eachitem;
  1945. if (id == modal.selected) {
  1946. newItems[itemid] = item
  1947. }
  1948. });
  1949. modal.items = newItems
  1950. } else {
  1951. modal.items[itemid] = item
  1952. }
  1953. modal.initItems();
  1954. $(".drag[data-itemid='" + itemid + "']").trigger('mousedown').trigger('click');
  1955. modal.selected = itemid
  1956. })
  1957. })
  1958. })
  1959. };
  1960. modal.initTemp = function () {
  1961. var itemslength = 0;
  1962. $.each(modal.items, function (index) {
  1963. itemslength++;
  1964. return false
  1965. });
  1966. if (!itemslength) {
  1967. tip.msgbox.err("您还没有添加任何元素,不能保存为模板!");
  1968. return
  1969. }
  1970. if (modal.type == 99) {
  1971. tip.msgbox.err("页面类型为公用模块,不能保存为模板!");
  1972. return
  1973. }
  1974. $("#saveTempModal").modal();
  1975. $("#saveTemp", "#saveTempModal").unbind('click').click(function () {
  1976. var tempname = $.trim($("#saveTempModal").find("#saveTempName").val());
  1977. var tempcate = $.trim($("#saveTempModal").find("#saveTempCate option:selected").val());
  1978. var temppreview = $.trim($("#saveTempModal").find("#saveTempPreview").val());
  1979. var tempdata = {page: modal.page, items: modal.items};
  1980. if (!tempname) {
  1981. tip.msgbox.err("请填写模板名称!");
  1982. $("#saveTempModal").find("#saveTempName").focus();
  1983. return
  1984. }
  1985. $("#saveTempModal .close").trigger('click');
  1986. if (modal.type == 1) {
  1987. var posturl = biz.url("diypage/page/diy/savetemp", null, modal.merch)
  1988. } else if (modal.type > 1 && modal.type < 6 && modal.type != 4) {
  1989. var posturl = biz.url("diypage/page/sys/savetemp", null, modal.merch)
  1990. } else if (modal.type > 4 && modal.type < 99 && modal.type != 5) {
  1991. var posturl = biz.url("diypage/page/plu/savetemp", null, modal.merch)
  1992. }
  1993. $.post(posturl, {
  1994. type: modal.type,
  1995. cate: tempcate,
  1996. name: tempname,
  1997. preview: temppreview,
  1998. data: tempdata
  1999. }, function (ret) {
  2000. if (ret.status == 0) {
  2001. tip.msgbox.err(ret.result.message)
  2002. } else {
  2003. tip.msgbox.suc("另存为模板保存成功!")
  2004. }
  2005. }, 'json')
  2006. })
  2007. };
  2008. modal.initTpl = function () {
  2009. tpl.helper("imgsrc", function (src) {
  2010. if (typeof src != 'string') {
  2011. return ''
  2012. }
  2013. if (src.indexOf('http://') == 0 || src.indexOf('https://') == 0 || src.indexOf('/') == 0) {
  2014. return src
  2015. } else if (src.indexOf('images/') == 0 || src.indexOf('audios/') == 0) {
  2016. return modal.attachurl + src
  2017. }
  2018. });
  2019. tpl.helper("decode", function (content) {
  2020. return $.base64.decode(content)
  2021. });
  2022. tpl.helper("count", function (data) {
  2023. return modal.length(data)
  2024. });
  2025. tpl.helper("toArray", function (data) {
  2026. var oldArray = $.makeArray(data);
  2027. var newArray = [];
  2028. $.each(data, function (itemid, item) {
  2029. newArray.push(item)
  2030. });
  2031. return newArray
  2032. });
  2033. tpl.helper("strexists", function (str, tag) {
  2034. if (!str || !tag) {
  2035. return false
  2036. }
  2037. if (str.indexOf(tag) != -1) {
  2038. return true
  2039. }
  2040. return false
  2041. });
  2042. tpl.helper("inArray", function (str, tag) {
  2043. if (!str || !tag) {
  2044. return false
  2045. }
  2046. if(typeof(str)=='string'){
  2047. var arr = str.split(",");
  2048. if($.inArray(tag, arr)>-1){
  2049. return true;
  2050. }
  2051. }
  2052. return false
  2053. });
  2054. tpl.helper("define", function (str) {
  2055. var str
  2056. })
  2057. };
  2058. modal.initGotop = function () {
  2059. $(window).bind('scroll resize', function () {
  2060. var scrolltop = $(window).scrollTop();
  2061. if (scrolltop > 300) {
  2062. $("#gotop").show()
  2063. } else {
  2064. $("#gotop").hide()
  2065. }
  2066. $("#gotop").unbind('click').click(function () {
  2067. $('body').animate({scrollTop: "0px"}, 1000)
  2068. })
  2069. })
  2070. };
  2071. modal.getNear = function (itemid) {
  2072. var newarr = [];
  2073. var index = 0;
  2074. var prev = 0;
  2075. var next = 0;
  2076. $.each(modal.items, function (id, obj) {
  2077. newarr[index] = id;
  2078. if (id == itemid) {
  2079. prev = index - 1;
  2080. next = index + 1
  2081. }
  2082. index++
  2083. });
  2084. var pervid = newarr[prev];
  2085. var nextid = newarr[next];
  2086. if (nextid) {
  2087. return nextid
  2088. }
  2089. if (pervid) {
  2090. return pervid
  2091. }
  2092. return false
  2093. };
  2094. modal.getItemNum = function (id) {
  2095. if (!id || !modal.items) {
  2096. return -1
  2097. }
  2098. var itemNum = 0;
  2099. $.each(modal.items, function (itemid, eachitem) {
  2100. if (eachitem.id == id) {
  2101. itemNum++
  2102. }
  2103. });
  2104. return itemNum
  2105. };
  2106. modal.sortChildItems = function () {
  2107. var newChild = {};
  2108. var itemid = modal.selected;
  2109. $("#diy-editor .form-items .item").each(function () {
  2110. var thisid = $(this).data('id');
  2111. newChild[thisid] = modal.items[itemid].data[thisid]
  2112. });
  2113. modal.items[itemid].data = newChild;
  2114. modal.initItems(itemid)
  2115. };
  2116. modal.length = function (json) {
  2117. if (typeof(json) === 'undefined') {
  2118. return 0
  2119. }
  2120. var jsonlen = 0;
  2121. for (var item in json) {
  2122. jsonlen++
  2123. }
  2124. return jsonlen
  2125. };
  2126. modal.callbackGoods = function (data) {
  2127. if (!data) {
  2128. tip.msgbox.err("回调数据错误,请重试!");
  2129. return
  2130. }
  2131. var itemid = modal.selected;
  2132. var childid = modal.childid;
  2133. console.log(data);
  2134. modal.items[itemid].data[childid] = {
  2135. 'title': data.goodsname,
  2136. 'thumb': data.thumb,
  2137. 'price': data.price,
  2138. 'sales': data.sales,
  2139. 'gid': data.id,
  2140. 'bargain': data.bargain,
  2141. 'credit': data.credit
  2142. };
  2143. modal.initItems(itemid);
  2144. modal.initEditor(false);
  2145. modal.childid = null
  2146. };
  2147. modal.callbackCategory = function (data) {
  2148. if (!data) {
  2149. tip.msgbox.err("回调数据错误,请重试!");
  2150. return
  2151. }
  2152. var itemid = modal.selected;
  2153. modal.items[itemid].params.catename = data.name;
  2154. modal.items[itemid].params.cateid = data.id;
  2155. modal.items[itemid].params.groupname = '';
  2156. modal.items[itemid].params.groupid = '';
  2157. modal.initItems(itemid);
  2158. modal.initEditor(false)
  2159. };
  2160. modal.callbackGroup = function (data) {
  2161. if (!data) {
  2162. tip.msgbox.err("回调数据错误,请重试!");
  2163. return
  2164. }
  2165. var itemid = modal.selected;
  2166. modal.items[itemid].params.groupname = data.name;
  2167. modal.items[itemid].params.groupid = data.id;
  2168. modal.items[itemid].params.catename = '';
  2169. modal.items[itemid].params.cateid = '';
  2170. modal.initItems(itemid);
  2171. modal.initEditor()
  2172. };
  2173. modal.callbackMerch = function (data) {
  2174. if (!data) {
  2175. tip.msgbox.err("回调数据错误,请重试!");
  2176. return
  2177. }
  2178. var itemid = modal.selected;
  2179. var childid = modal.childid;
  2180. modal.items[itemid].data[childid] = {
  2181. 'name': data.merchname,
  2182. 'thumb': data.logo,
  2183. 'merchid': data.id,
  2184. 'desc': data.desc
  2185. };
  2186. modal.initItems(itemid);
  2187. modal.initEditor(false);
  2188. modal.childid = null
  2189. };
  2190. modal.callbackMerchCategory = function (data) {
  2191. if (!data) {
  2192. tip.msgbox.err("回调数据错误,请重试!");
  2193. return
  2194. }
  2195. var itemid = modal.selected;
  2196. modal.items[itemid].params.catename = data.catename;
  2197. modal.items[itemid].params.cateid = data.id;
  2198. modal.items[itemid].params.groupname = '';
  2199. modal.items[itemid].params.groupid = '';
  2200. modal.initItems(itemid);
  2201. modal.initEditor(false)
  2202. };
  2203. modal.callbackMerchGroup = function (data) {
  2204. if (!data) {
  2205. tip.msgbox.err("回调数据错误,请重试!");
  2206. return
  2207. }
  2208. var itemid = modal.selected;
  2209. modal.items[itemid].params.groupname = data.groupname;
  2210. modal.items[itemid].params.groupid = data.id;
  2211. modal.items[itemid].params.catename = '';
  2212. modal.items[itemid].params.cateid = '';
  2213. modal.initItems(itemid);
  2214. modal.initEditor()
  2215. };
  2216. modal.callbackCoupon = function (data) {
  2217. if (!data) {
  2218. tip.msgbox.err("回调数据错误,请重试!");
  2219. return
  2220. }
  2221. var itemid = modal.selected;
  2222. var childid = modal.childid;
  2223. modal.items[itemid].data[childid].price = data.credit;
  2224. modal.items[itemid].data[childid].desc = data.limit_money;
  2225. modal.items[itemid].data[childid].couponid = data.id;
  2226. modal.items[itemid].data[childid].name = data.voucher_title;
  2227. modal.initItems(itemid);
  2228. modal.initEditor(false);
  2229. modal.childid = null
  2230. };
  2231. modal.save = function (preview) {
  2232. if (typeof(preview) === 'undefined') {
  2233. preview = false
  2234. }
  2235. if (preview && modal.type == 5) {
  2236. tip.msgbox.err("商品详情页涉及商品数据问题,请至手机端预览");
  2237. return
  2238. }
  2239. if (modal.keyworderr) {
  2240. tip.msgbox.err("关键字已存在!");
  2241. $("#page").trigger('click');
  2242. $("#diy-editor input[data-bind='keyword']").closest('.form-group').addClass('has-error');
  2243. return
  2244. }
  2245. modal.data = {};
  2246. modal.data = {page: modal.page, items: modal.items};
  2247. if (!modal.page.title) {
  2248. tip.msgbox.err("页面标题是必填项");
  2249. $("#page").trigger("click");
  2250. return
  2251. }
  2252. $(".btn-save").data('status', 1).text("保存中...");
  2253. if (modal.type == 1) {
  2254. if (modal.id > 0) {
  2255. var posturl = biz.url("diypage/page/diy/edit", null, modal.merch)
  2256. } else {
  2257. var posturl = biz.url("diypage/page/diy/add", null, modal.merch)
  2258. }
  2259. } else if (modal.type == 2) {
  2260. var posturl = biz.url("config/layoutindex/index", null, modal.merch)
  2261. } else if (modal.type > 1 && modal.type < 6 && modal.type != 4) {
  2262. if (modal.id > 0) {
  2263. var posturl = biz.url("diypage/page/sys/edit", null, modal.merch)
  2264. } else {
  2265. var posturl = biz.url("diypage/page/sys/add", null, modal.merch)
  2266. }
  2267. } else if (modal.type > 4 && modal.type < 99 && modal.type != 5) {
  2268. if (modal.id > 0) {
  2269. var posturl = biz.url("diypage/page/plu/edit", null, modal.merch)
  2270. } else {
  2271. var posturl = biz.url("diypage/page/plu/add", null, modal.merch)
  2272. }
  2273. } else if (modal.type == 99) {
  2274. if (modal.id > 0) {
  2275. var posturl = biz.url("diypage/page/mod/edit", null, modal.merch)
  2276. } else {
  2277. var posturl = biz.url("diypage/page/mod/add", null, modal.merch)
  2278. }
  2279. }
  2280. $.post(posturl, {id: modal.id, data: modal.data}, function (ret) {
  2281. if (ret.status == 0) {
  2282. tip.msgbox.err(ret.result.message);
  2283. $(".btn-save[data-type='save']").text("保存页面").data("status", 0);
  2284. $(".btn-save[data-type='preview']").text("保存并预览").data("status", 0);
  2285. $(".btn-save[data-type='savetemp']").text("另存为模板").data("status", 0);
  2286. return
  2287. }
  2288. var pageid = ret.result.id;
  2289. if (pageid == modal.id) {
  2290. $(".btn-save[data-type='save']").text("保存页面").data("status", 0);
  2291. $(".btn-save[data-type='preview']").text("保存并预览").data("status", 0);
  2292. $(".btn-save[data-type='savetemp']").text("另存为模板").data("status", 0);
  2293. if (preview) {
  2294. tip.msgbox.suc("保存成功!正在生成预览...");
  2295. setTimeout(function () {
  2296. var previewUrl = biz.url("diypage/page/preview", null, modal.merch) + "&id=" + pageid;
  2297. window.open(previewUrl)
  2298. }, 1000)
  2299. } else {
  2300. tip.msgbox.suc("保存成功!")
  2301. }
  2302. } else {
  2303. if (preview) {
  2304. tip.msgbox.suc("保存成功!正在生成预览...");
  2305. util.cookie.set('preview_id', pageid)
  2306. } else {
  2307. tip.msgbox.suc("保存成功!")
  2308. }
  2309. location.href = ret.result.jump
  2310. }
  2311. }, 'json')
  2312. };
  2313. modal.length = function (json) {
  2314. if (typeof(json) === 'undefined') {
  2315. return 0
  2316. }
  2317. var jsonlen = 0;
  2318. for (var item in json) {
  2319. jsonlen++
  2320. }
  2321. return jsonlen
  2322. };
  2323. return modal
  2324. });