diy.min-bak.js 92 KB

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