cms_index.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. var object_module_edit;
  2. var article_save_function;
  3. var limit_count;
  4. var image_count = 1;
  5. $(document).ready(function(){
  6. var function_list = {};
  7. //标题修改
  8. $("[nctype='btn_module_title_edit']").click(function(){
  9. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  10. var title = object_module_edit.html();
  11. $('#dialog_module_title_edit').nc_show_dialog({width: 640, title: '编辑标题'});
  12. $("#input_module_title").val(title);
  13. });
  14. //标题保存
  15. $("#btn_module_title_save").click(function(){
  16. object_module_edit.html($("#input_module_title").val());
  17. $('#dialog_module_title_edit').hide();
  18. });
  19. //标签修改
  20. $(".article-tag-selected-list").sortable();
  21. $("#btn_module_tag_edit").click(function(){
  22. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  23. var tag_list = object_module_edit.clone();
  24. tag_list.find("li").append('<i nctype="btn_module_tag_select_drop" class="cms-index-tag-select-drop" class="删除所选"></i>');
  25. $('#dialog_module_tag_edit').nc_show_dialog({width: 640, title: '编辑标签'});
  26. $("#article_tag_selected_list").html(tag_list.html());
  27. });
  28. //标签选择
  29. $(".article-tag-list [nctype='btn_tag_select']").live('click', function(){
  30. var tag_id = $(this).attr("data-tag-id");
  31. $("#article_tag_selected_list li").each(function(){
  32. if($(this).attr("data-tag-id") == tag_id) {
  33. tag_id = 0;
  34. }
  35. });
  36. if(tag_id > 0) {
  37. $("#article_tag_selected_list").append($(this).clone());
  38. }
  39. return false;
  40. });
  41. $(".article-tag-selected-list [nctype='btn_tag_select']").live('click', function(){
  42. $(this).remove();
  43. return false;
  44. });
  45. //标签保存
  46. $("#btn_module_tag_save").click(function(){
  47. var tag_list = $("#article_tag_selected_list").clone();
  48. tag_list.find("[nctype='btn_module_tag_select_drop']").remove();
  49. object_module_edit.html(tag_list.html());
  50. $('#dialog_module_tag_edit').hide();
  51. });
  52. //图片修改
  53. $("[nctype='btn_module_image_edit']").click(function(){
  54. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  55. if(parseInt($(this).attr("image_count"), 10) !== 1) {
  56. $("#btn_image_upload").attr("multiple", "1");
  57. image_count = 2;
  58. }
  59. var image_list = object_module_edit.clone();
  60. if(image_list.find("li.picture").length > 0) {
  61. image_list.find("li").each(function(){
  62. var image_item = $(this).find("img");
  63. var link = image_item.parent().attr("href");
  64. var image_name = image_item.attr("image_name");
  65. $(this).append('<a nctype="btn_module_drop_image" image_name="'+image_name+'" class="handle-del" title="删除该图片"><i></i>&nbsp;</a>');
  66. $(this).append('<div class="pic-url">相关网址:<input type="text" class="w200" value="'+link+'"> 网址应包含http://</div>');
  67. });
  68. }
  69. $("#module_image_edit_explain").html("<i></i>" + $(this).attr("data-title"));
  70. $('#dialog_module_image_edit').nc_show_dialog({width: 640, title: '编辑图片'});
  71. if(image_list.find("li.picture").length > 0) {
  72. $("#image_selected_list").html(image_list.html());
  73. } else {
  74. $("#image_selected_list").html("");
  75. }
  76. });
  77. //图片上传
  78. $("#btn_image_upload").fileupload({
  79. dataType: 'json',
  80. url: "index.php?act=cms_index&op=image_upload",
  81. add: function(e,data) {
  82. data.submit();
  83. },
  84. done: function (e,data) {
  85. result = data.result;
  86. if(result.status == "success") {
  87. var image_content = '<li class="picture">';
  88. image_content += '<div class="cms-thumb"><a href="" target="_blank"><img data-image-name="'+result.file_name+'" src="'+result.file_url+'" alt="" class="t-img" /></a></div>';
  89. image_content += '<a nctype="btn_module_drop_image" image_name="'+result.file_name+'" class="handle-del" title="删除该图片"><i></i>&nbsp;</a>';
  90. image_content += '<div class="pic-url">';
  91. image_content += '相关网址:';
  92. image_content += '<input type="text" value="" class="w200"/>';
  93. image_content += ' 网址应包含http://</div></li>';
  94. if(image_count === 1) {
  95. $("#image_selected_list li").each(function(){
  96. $("#add_form").append('<input name="module_drop_image[]" type="hidden" value="'+$(this).find("img").attr("data-image-name")+'" />');
  97. });
  98. $("#image_selected_list").html("");
  99. }
  100. $("#image_selected_list").append(image_content);
  101. } else {
  102. showError(result.error);
  103. }
  104. }
  105. });
  106. //图片删除
  107. $("[nctype='btn_module_drop_image']").live("click", function(){
  108. $("#add_form").append('<input name="module_drop_image[]" type="hidden" value="'+$(this).attr("image_name")+'" />');
  109. $(this).parents("li.picture").remove();
  110. });
  111. //图片保存
  112. $("#btn_module_image_save").click(function(){
  113. var image_list = $("#image_selected_list").clone();
  114. image_list.find("li").each(function(){
  115. $(this).find("img").parent().attr("href", $(this).find("input").val());
  116. });
  117. image_list.find(".handle-del").remove();
  118. image_list.find(".pic-url").remove();
  119. object_module_edit.html(image_list.html());
  120. $('#dialog_module_image_edit').hide();
  121. });
  122. //文章拖动改变顺序
  123. $("#article_selected_list").sortable();
  124. //文章修改
  125. $("[nctype='btn_module_article_edit']").click(function(){
  126. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  127. var article_list = object_module_edit.clone();
  128. article_save_function = $(this).attr("save_function");
  129. limit_count = parseInt($(this).attr("limit_count"), 10);
  130. if(!limit_count) {
  131. limit_count = 0;
  132. }
  133. article_list.find('[nctype="article_view"]').remove();
  134. article_list.find("li").each(function(){
  135. var title = $(this).find("span.title");
  136. var article = $(this).find("span.title a");
  137. $(this).prepend('<span class="article-image" nctype="cms_index_not_display"><p><img src="'+article.attr("article_image")+'"></p></span>');
  138. title.prepend('<em class="class-name" nctype="cms_index_not_display">['+article.attr("class_name")+']</em>');
  139. title.append('<em class="publish-time" nctype="cms_index_not_display">('+article.attr("article_publish_time")+')</em>');
  140. $(this).append('<span title="'+article.attr("article_abstract")+'" class="article-abstract" nctype="cms_index_not_display">文章摘要:'+article.attr("article_abstract")+'</span>');
  141. $(this).append('<a nctype="btn_article_select" href="JavaScript:void(0);" class="delete" title="选择删除"></a>');
  142. });
  143. $('#dialog_module_article_edit').nc_show_dialog({width: 640, title: '编辑文章'});
  144. $("#article_selected_list").html(article_list.html());
  145. $("#article_search_list").html("");
  146. });
  147. //文章搜索
  148. $("#btn_article_search").click(function(){
  149. var search_type = $("[name='article_search_type']:checked").val();
  150. var search_keyword = $("#input_article_search_keyword").val();
  151. if(search_keyword !== "") {
  152. $("#div_article_select_list").load("index.php?act=cms_base&op=get_article_list&" + $.param({search_type: search_type,search_keyword: search_keyword}));
  153. }
  154. });
  155. //文章选择翻页
  156. $("#div_article_select_list .demo").live('click',function(e){
  157. $("#div_article_select_list").load($(this).attr('href'));
  158. return false;
  159. });
  160. //文章选择
  161. $("#article_search_list [nctype='btn_article_select']").live("click", function(){
  162. var current_count = $("#article_selected_list li").length;
  163. if(current_count < limit_count || limit_count === 0) {
  164. var temp = $(this).parent().clone();
  165. temp.find("[nctype='btn_article_select']").attr("title","删除");
  166. $("#article_selected_list").append($("<div />").append(temp).html());
  167. }
  168. });
  169. //文章删除
  170. $("#article_selected_list [nctype='btn_article_select']").live("click", function(){
  171. $(this).parent().remove();
  172. });
  173. //文章列表保存
  174. $("#btn_module_article_save").click(function(){
  175. $("#article_selected_list").find("[nctype='btn_article_select']").remove();
  176. $("#article_selected_list").find("[nctype='cms_index_not_display']").remove();
  177. object_module_edit.html("");
  178. function_list[article_save_function]();
  179. $('#dialog_module_article_edit').hide();
  180. });
  181. //文章列表保存(文字链接)
  182. function_list['article_type_0_save'] = function() {
  183. var count = 1;
  184. $("#article_selected_list li").each(function(){
  185. if(count > 1) {
  186. $(this).attr("class", "cms-index-article-normal");
  187. } else {
  188. $(this).attr("class", "cms-index-article-focus");
  189. }
  190. object_module_edit.append($(this));
  191. count++;
  192. });
  193. };
  194. //文章列表1-1保存
  195. function_list['article_type_1_save'] = function() {
  196. var count = 1;
  197. $("#article_selected_list li").each(function(){
  198. $(this).prepend('<span nctype="article_view" class="cms-index-count_'+count+'">'+count+'</span>');
  199. $(this).append('<span nctype="article_view" class="cms-index-click-count">'+$(this).find('[nctype="article_item"]').attr("article_click")+'人关注</span>');
  200. object_module_edit.append($(this));
  201. count++;
  202. });
  203. };
  204. //文章列表1-2保存
  205. function_list['article_type_2_save'] = function() {
  206. var count = 1;
  207. $("#article_selected_list li").each(function(){
  208. var article = $(this).find('[nctype="article_item"]');
  209. if(count > 1) {
  210. $(this).attr("class", "cms-index-article-normal");
  211. $(this).prepend('<span nctype="article_view" class="cms-index-article-class">'+article.attr("class_name")+'</span>');
  212. $(this).append('<span nctype="article_view" class="cms-index-article-date">'+article.attr("article_publish_time").substring(8)+'日</span>');
  213. } else {
  214. $(this).attr("class", "cms-index-article-focus");
  215. }
  216. object_module_edit.append($(this));
  217. count++;
  218. });
  219. };
  220. //文章列表保存(图文)
  221. function_list['article_type_3_save'] = function() {
  222. $("#article_selected_list li").each(function(){
  223. var article = $(this).find('[nctype="article_item"]');
  224. $(this).prepend('<div class="cms-thumb" nctype="article_view"><a nctype="article_view" href="'+article.attr("href")+'"><img class="t-img" src="'+article.attr("article_image")+'" /></a></div');
  225. object_module_edit.append($(this));
  226. });
  227. };
  228. //文章列表1-1保存
  229. function_list['article_type_4_save'] = function() {
  230. var count = 1;
  231. $("#article_selected_list li").each(function(){
  232. $(this).append('<span nctype="article_view" class="cms-index-article-abstract">'+$(this).find('[nctype="article_item"]').attr("article_abstract")+'</span>');
  233. object_module_edit.append($(this));
  234. count++;
  235. });
  236. };
  237. //文章列表2-3保存
  238. function_list['article_type_5_save'] = function() {
  239. $("#article_selected_list li").each(function(){
  240. var article = $(this).find('[nctype="article_item"]');
  241. $(this).attr("class", "cms-index-article-normal");
  242. $(this).prepend('<span nctype="article_view" class="cms-index-article-class">'+article.attr("class_name")+'</span>');
  243. $(this).append('<span nctype="article_view" class="cms-index-article-date">'+article.attr("article_publish_time").substring(8)+'日</span>');
  244. object_module_edit.append($(this));
  245. });
  246. };
  247. //文章列表保存(文字链接)
  248. function_list['article_type_6_save'] = function() {
  249. $("#article_selected_list li").each(function(){
  250. $(this).attr("class", "cms-index-article-normal");
  251. object_module_edit.append($(this));
  252. });
  253. };
  254. //商品拖动改变顺序
  255. $("#goods_selected_list").sortable();
  256. //商品修改
  257. $("[nctype='btn_module_goods_edit']").click(function(){
  258. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  259. var goods_list = object_module_edit.clone();
  260. goods_list.find("dl").append('<dd class="taobao-item-delete" nctype="btn_goods_delete" title="删除添加的商品">&nbsp;</dd>');
  261. limit_count = parseInt($(this).attr("limit_count"), 10);
  262. if(!limit_count) {
  263. limit_count = 0;
  264. }
  265. $('#dialog_module_goods_edit').nc_show_dialog({width: 640, title: '编辑商品'});
  266. $("#goods_selected_list").html(goods_list.html());
  267. });
  268. //选择商品
  269. $("#btn_goods_search").live('click', function(){
  270. var goods_list = $("#goods_selected_list");
  271. var link_item = $("#input_goods_link");
  272. var link = link_item.val();
  273. link_item.val('');
  274. if($("#goods_selected_list li").length < limit_count || limit_count === 0) {
  275. if(link != '') {
  276. var url = encodeURIComponent(link);
  277. $.getJSON('index.php?act=cms_base&op=goods_info_by_url', { url: url}, function(data){
  278. if(data.result == "true") {
  279. var temp = '<li nctype="btn_goods_select"><dl>';
  280. temp += '<dt class="name"><a href="'+data.url+'" target="_blank">'+data.title+'</a></dt>';
  281. temp += '<dd class="cms-thumb" title="'+data.title+'"><a href="'+data.url+'" target="_blank"><img src="'+data.image+'" class="t-img"/></a></dd>';
  282. temp += '<dd class="price"><em>'+data.price+'</em></dd>';
  283. temp += '<dd class="taobao-item-delete" nctype="btn_goods_delete" title="删除添加的商品">&nbsp;</dd>';
  284. temp += '</dl></li>';
  285. $(goods_list).append(temp);
  286. } else {
  287. alert(data.message);
  288. }
  289. });
  290. }
  291. }
  292. });
  293. //删除商品
  294. $("[nctype='btn_goods_delete']").live('click', function(){
  295. $(this).parent().parent().remove();
  296. });
  297. //保存商品列表
  298. $("#btn_module_goods_save").live('click', function() {
  299. var goods_list = $("#goods_selected_list").clone();
  300. goods_list.find("[nctype='btn_goods_delete']").remove();
  301. object_module_edit.html(goods_list.html());
  302. $('#dialog_module_goods_edit').hide();
  303. });
  304. //品牌拖动改变顺序
  305. $("#brand_selected_list").sortable();
  306. //品牌修改
  307. $("[nctype='btn_module_brand_edit']").click(function(){
  308. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  309. var brand_list = object_module_edit.clone();
  310. brand_list.find("li").append('<div nctype="btn_brand_select" class="add-brand"><i></i></div>');
  311. limit_count = parseInt($(this).attr("limit_count"), 10);
  312. if(!limit_count) {
  313. limit_count = 0;
  314. }
  315. //读取品牌列表
  316. if($("#div_brand_select_list").html() === '') {
  317. $("#div_brand_select_list").load("index.php?act=cms_base&op=get_brand_list");
  318. }
  319. $('#dialog_module_brand_edit').nc_show_dialog({width: 640, title: '编辑品牌'});
  320. $("#brand_selected_list").html(brand_list.html());
  321. });
  322. //品牌选择翻页
  323. $("#div_brand_select_list .demo").live('click',function(e){
  324. $("#div_brand_select_list").load($(this).attr('href'));
  325. return false;
  326. });
  327. //品牌选择
  328. $("#brand_search_list [nctype='btn_brand_select']").live("click", function(){
  329. var current_count = $("#brand_selected_list li").length;
  330. if(current_count < limit_count || limit_count === 0) {
  331. var temp = $(this).parent().clone();
  332. $("#brand_selected_list").append($("<div />").append(temp).html());
  333. }
  334. });
  335. //品牌删除
  336. $("#brand_selected_list [nctype='btn_brand_select']").live("click", function(){
  337. $(this).parent().remove();
  338. });
  339. //品牌列表保存
  340. $("#btn_module_brand_save").click(function(){
  341. var brand_list = $("#brand_selected_list").clone();
  342. brand_list.find("[nctype='btn_brand_select']").remove();
  343. object_module_edit.html(brand_list.html());
  344. $('#dialog_module_brand_edit').hide();
  345. });
  346. //品牌拖动改变顺序
  347. $("#goods_class_selected_list").sortable();
  348. //商品分类修改
  349. $("[nctype='btn_module_goods_class_edit']").click(function(){
  350. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  351. var goods_class_list = object_module_edit.clone();
  352. goods_class_list.find("dt").prepend("<i>删除</i>");
  353. goods_class_list.find("dd").prepend("<i>删除</i>");
  354. //读取品牌列表
  355. if($("#select_goods_class_list option").length < 1) {
  356. $("#select_goods_class_list").html("");
  357. $("#select_goods_class_list").append('<option value="0">请选择</option>');
  358. $.getJSON("index.php?act=cms_base&op=get_goods_class_list_json", { }, function(result){
  359. var count = result.length;
  360. for(var i = 0; i < count; i++) {
  361. $("#select_goods_class_list").append('<option value="'+result[i]['gc_id']+'">'+result[i]['gc_name']+'</option>');
  362. }
  363. });
  364. }
  365. $('#dialog_module_goods_class_edit').nc_show_dialog({width: 640, title: '编辑分类'});
  366. if(goods_class_list.find("dl").length > 0) {
  367. $("#goods_class_selected_list").html(goods_class_list.html());
  368. }
  369. });
  370. //商品分类选择
  371. $("#select_goods_class_list").change(function(){
  372. $.get("index.php?act=cms_base&op=get_goods_class_detail", {class_id: $(this).val() }, function(result){
  373. $("#goods_class_selected_list").append(result);
  374. });
  375. });
  376. //商品分类删除
  377. $("#goods_class_selected_list dt i").live('click', function(){
  378. $(this).parents("dl").remove();
  379. });
  380. $("#goods_class_selected_list dd i").live('click', function(){
  381. $(this).parents("dd").remove();
  382. });
  383. //商品分类列表保存
  384. $("#btn_module_goods_class_save").click(function(){
  385. var goods_class_list = $("#goods_class_selected_list").clone();
  386. goods_class_list.find("i").remove();
  387. object_module_edit.html(goods_class_list.html());
  388. $('#dialog_module_goods_class_edit').hide();
  389. });
  390. //微商城更新
  391. $("#btn_module_micro_edit").live('click', function(){
  392. var micro_url = MICROSHOP_SITE_URL;
  393. var api_url = "";
  394. var micro_html = "";
  395. var micro_name = "";
  396. var micro_personal_class = "";
  397. var micro_personal_commend = "";
  398. var micro_store_commend = "";
  399. var count = 0;
  400. api_url = micro_url+'/index.php?act=api&op=get_micro_name&callback=?';
  401. $.getJSON(api_url, {data_type: 'html'}, function(result){
  402. micro_name = result;
  403. write_html();
  404. });
  405. api_url = micro_url+'/index.php?act=api&op=get_personal_class&callback=?';
  406. $.getJSON(api_url, {data_type: 'html'}, function(result){
  407. micro_personal_class = result;
  408. write_html();
  409. });
  410. api_url = micro_url+'/index.php?act=api&op=get_personal_commend&callback=?';
  411. $.getJSON(api_url, {data_type: 'html', data_count: 8}, function(result){
  412. micro_personal_commend = result;
  413. write_html();
  414. });
  415. api_url = micro_url+'/index.php?act=api&op=get_store_commend&callback=?';
  416. $.getJSON(api_url, {data_type: 'html', data_count: 10}, function(result){
  417. micro_store_commend = result;
  418. write_html();
  419. });
  420. function write_html() {
  421. count++;
  422. if(count > 3) {
  423. micro_html += '<div class="cms-module-micro-left">';
  424. micro_html += '<div class="title-bar">';
  425. micro_html += '<div class="micro-api-title">'+micro_name+'</div>';
  426. micro_html += '<div class="micro-api-personal-class">'+micro_personal_class+'</div>';
  427. micro_html += '<div class="title-more"><a href=' + micro_url + ' class="more" target="_blank">更多</a></div>';
  428. micro_html += '</div>';
  429. micro_html += '<div class="micro-api-personal-list">'+micro_personal_commend+'</div>';
  430. micro_html += '</div>';
  431. micro_html += '<div class="micro-api-store-list">'+micro_store_commend+'</div>';
  432. micro_html += '<div class="clear"></div>';
  433. $("#micro_content").html(micro_html);
  434. }
  435. }
  436. });
  437. //圈子更新
  438. $("#btn_module_circle_edit").live('click', function(){
  439. var module_item = $(this).parent().parent().find("[nctype='object_module_edit']");
  440. var circle_url = CIRCLE_SITE_URL;
  441. var api_url = "";
  442. var circle_theme_list = "";
  443. var circle_reply_themelist = "";
  444. var circle_more_membertheme = "";
  445. var count = 0;
  446. api_url = circle_url+'/index.php?act=api&op=get_theme_list&callback=?';
  447. $.getJSON(api_url, {data_type: 'html'}, function(result){
  448. circle_theme_list = result;
  449. write_html();
  450. });
  451. api_url = circle_url+'/index.php?act=api&op=get_reply_themelist&callback=?';
  452. $.getJSON(api_url, {data_type: 'html'}, function(result){
  453. circle_reply_themelist = result;
  454. write_html();
  455. });
  456. api_url = circle_url+'/index.php?act=api&op=get_more_membertheme&callback=?';
  457. $.getJSON(api_url, {data_type: 'html', data_count: 4}, function(result){
  458. circle_more_membertheme = result;
  459. write_html();
  460. });
  461. function write_html() {
  462. count++;
  463. if(count > 2) {
  464. module_item.html(circle_theme_list + circle_reply_themelist + circle_more_membertheme);
  465. }
  466. }
  467. });
  468. //店铺拖动改变顺序
  469. $("#store_selected_list").sortable();
  470. //店铺修改
  471. $("[nctype='btn_module_store_edit']").click(function(){
  472. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  473. var store_list = object_module_edit.clone();
  474. store_list.find("li").each(function(){
  475. $(this).find('dl').append('<dd nctype="btn_store_select" class="handle-button" title="删除"></dd>');
  476. });
  477. $('#dialog_module_store_edit').nc_show_dialog({width: 640, title: '编辑店铺'});
  478. $("#store_selected_list").html(store_list.html());
  479. $("#store_search_list").html("");
  480. });
  481. //店铺搜索
  482. $("#btn_store_search").click(function(){
  483. var search_keyword = $("#input_store_search_keyword").val();
  484. if(search_keyword !== "") {
  485. $("#div_store_select_list").load("index.php?act=cms_base&op=get_store_list&" + $.param({search_keyword: search_keyword}));
  486. }
  487. });
  488. //店铺选择翻页
  489. $('#div_store_select_list').on('click', '.demo' ,function(){
  490. $("#div_store_select_list").load($(this).attr('href'));
  491. return false;
  492. });
  493. //店铺选择
  494. $('#div_store_select_list').on('click', '[nctype="btn_store_select"]', function(){
  495. var current_count = $("#article_selected_list li").length;
  496. var temp = $(this).parents('li').clone();
  497. temp.find("[nctype='btn_store_select']").attr("title","删除");
  498. $("#store_selected_list").append($("<div />").append(temp).html());
  499. });
  500. //店铺删除
  501. $('#store_selected_list').on('click', '[nctype="btn_store_select"]', function(){
  502. $(this).parents('li').remove();
  503. });
  504. //店铺列表保存
  505. $("#btn_module_store_save").click(function(){
  506. $("#store_selected_list").find("[nctype='btn_store_select']").remove();
  507. object_module_edit.html("");
  508. object_module_edit.html($('#store_selected_list').html());
  509. $('#dialog_module_store_edit').hide();
  510. });
  511. //用户拖动改变顺序
  512. $("#member_selected_list").sortable();
  513. //用户修改
  514. $("[nctype='btn_module_member_edit']").click(function(){
  515. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  516. var member_list = object_module_edit.clone();
  517. member_list.find("li").each(function(){
  518. $(this).find('dl').append('<dd nctype="btn_member_select" class="handle-button" title="删除"></dd>');
  519. });
  520. $('#dialog_module_member_edit').nc_show_dialog({width: 640, title: '编辑会员'});
  521. $("#member_selected_list").html(member_list.html());
  522. $("#member_search_list").html("");
  523. });
  524. //用户搜索
  525. $("#btn_member_search").click(function(){
  526. var search_keyword = $("#input_member_search_keyword").val();
  527. if(search_keyword !== "") {
  528. $("#div_member_select_list").load("index.php?act=cms_base&op=get_member_list&" + $.param({search_keyword: search_keyword}));
  529. }
  530. });
  531. //用户选择翻页
  532. $('#div_member_select_list').on('click', '.demo' ,function(){
  533. $("#div_member_select_list").load($(this).attr('href'));
  534. return false;
  535. });
  536. //用户选择
  537. $('#div_member_select_list').on('click', '[nctype="btn_member_select"]', function(){
  538. var current_count = $("#article_selected_list li").length;
  539. var temp = $(this).parents('li').clone();
  540. temp.find("[nctype='btn_member_select']").attr("title","删除");
  541. $("#member_selected_list").append($("<div />").append(temp).html());
  542. });
  543. //用户删除
  544. $('#member_selected_list').on('click', '[nctype="btn_member_select"]', function(){
  545. $(this).parent('li').remove();
  546. });
  547. //文章列表保存
  548. $("#btn_module_member_save").click(function(){
  549. $("#member_selected_list").find("[nctype='btn_member_select']").remove();
  550. object_module_edit.html("");
  551. object_module_edit.html($('#member_selected_list').html());
  552. $('#dialog_module_member_edit').hide();
  553. });
  554. //FLASH修改
  555. $("[nctype='btn_module_flash_edit']").click(function(){
  556. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  557. $('#dialog_module_flash_edit').nc_show_dialog({width: 640, title: '编辑FLASH'});
  558. });
  559. //FLASH保存
  560. $("#btn_module_flash_save").click(function(){
  561. var data = {};
  562. data.address = $('#input_flash_address').val();
  563. data.width = $('#input_flash_width').val();
  564. data.height = $('#input_flash_height').val();
  565. object_module_edit.html(template.render('module_assembly_flash_template', data));
  566. $('#dialog_module_flash_edit').hide();
  567. });
  568. //自定义块修改
  569. $("[nctype='btn_module_html_edit']").click(function(){
  570. object_module_edit = $(this).parent().parent().find("[nctype='object_module_edit']");
  571. $('#dialog_module_html_edit').nc_show_dialog({width: 680, title: '编辑自定义块'});
  572. var KE = KindEditor.create("#textarea_module_html", {
  573. items : ['source', '|', 'fullscreen', 'undo', 'redo', 'cut', 'copy', 'paste', '|','fontname', 'fontsize', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline','removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist', '|', 'emoticons', 'image', 'link', '|', 'about'],
  574. allowImageUpload: false,
  575. allowFlashUpload: false,
  576. allowMediaUpload: false,
  577. allowFileManager: false,
  578. filterMode: false,
  579. syncType: "form",
  580. afterCreate: function() {
  581. this.sync();
  582. },
  583. afterChange: function() {
  584. this.sync();
  585. },
  586. afterBlur: function() {
  587. this.sync();
  588. }
  589. });
  590. KE.html(object_module_edit.html());
  591. });
  592. //自定义块保存
  593. $("#btn_module_html_save").click(function(){
  594. object_module_edit.html($('#textarea_module_html').val());
  595. KindEditor.remove("#textarea_module_html");
  596. $('#dialog_module_html_edit').hide();
  597. });
  598. //保存
  599. $("#btn_module_save").click(function(){
  600. $("[nctype='object_module_edit']").each(function(){
  601. $("#add_form").append('<input name="'+$(this).attr("id")+'" type="hidden" value="" />');
  602. //去掉无用内容
  603. $(this).find("[nctype='cms_index_not_save']").remove();
  604. $("#add_form input").last().val($(this).html());
  605. });
  606. $("#add_form").submit();
  607. });
  608. //提示信息最靠近边界时无法自适应,暂时注释
  609. //提示文字信息居右形式
  610. // $('.tip-r').poshytip({
  611. //className: 'tip-yellowsimple',
  612. //showTimeout: 1,
  613. //alignTo: 'target',
  614. //alignX: 'right',
  615. //alignY: 'center',
  616. //offsetX: 2,
  617. //allowTipHover: false
  618. // });
  619. //提示文字信息居左形式
  620. // $('.tip-l').poshytip({
  621. //className: 'tip-yellowsimple',
  622. //showTimeout: 1,
  623. //alignTo: 'target',
  624. //alignX: 'left',
  625. //alignY: 'center',
  626. //offsetX: 2,
  627. //allowTipHover: false
  628. // });
  629. });
  630. $(window).load(function () {
  631. //比例局中裁切显示图片
  632. $(".micro-api-personal-list .t-img").VMiddleImg({"width":170,"height":220});
  633. $(".cms-index-module-article1-1 .t-img").VMiddleImg({"width":380,"height":210});
  634. $(".cms-index-module-article1-3 .t-img").VMiddleImg({"width":78,"height":78});
  635. $(".cms-index-module-article2-1 .t-img").VMiddleImg({"width":160,"height":120});
  636. $(".cms-index-module-article2-2 .t-img").VMiddleImg({"width":160,"height":120});
  637. $(".cms-index-module-article2-3 .t-img").VMiddleImg({"width":78,"height":38});
  638. $(".cms-module-assembly-article-image .t-img").VMiddleImg({"width":160,"height":120});
  639. $(".cms-module-assembly-brand .t-img").VMiddleImg({"width":80,"height":40});
  640. $("#block1_goods_content .t-img").VMiddleImg({"width":148,"height":148});
  641. $("#block2_goods_content .t-img").VMiddleImg({"width":148,"height":148});
  642. $("#block3_goods_content .t-img").VMiddleImg({"width":148,"height":148});
  643. $("#block4_article_content .t-img").VMiddleImg({"width":148,"height":148});
  644. });