mb_special_item_edit.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <extend name="Public:base" />
  2. <block name="content">
  3. <link rel="stylesheet" href="__PUBLIC__/css/special.css" />
  4. <div class="page-header">
  5. <h1>
  6. {$breadcrumb2}
  7. <small>
  8. <i class="icon-double-angle-right"></i>
  9. {$crumbs}
  10. </small>
  11. </h1>
  12. </div>
  13. <link rel="stylesheet" href="__CSS__/dialog.css" />
  14. <div class="ks-ext-mask" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 999; display:none"></div>
  15. <div id="dialog" class="dialog" style="z-index: 9999; display:none;top:110px;">
  16. <div class="ks-contentbox">
  17. <div class="title"><span id="ks-contentbox-title">新增分类</span><a class="ks-ext-close" href="javascript:void(0)">X</a></div>
  18. <input type="hidden" name="action" value="" />
  19. <div class="s-tips margintop" style="margin:10px;"><i></i>请按提示尺寸制作上传图片,已达到手机客户端及Wap手机商城最佳显示效果。</div>
  20. <div class="upload-thumb"> <img style="display:none;" id="dialog_item_image" src="" alt=""></div>
  21. <input id="dialog_item_image_name" type="hidden">
  22. <input id="dialog_type" type="hidden">
  23. <dl>
  24. <dt>
  25. <span title="" data-toggle="tooltip" data-original-title="">选择要上传的图片</span>
  26. </dt>
  27. <dd id="thumb">
  28. <a href="#" data-toggle="image" class="img-thumbnail">
  29. <img osctype="image" data-placeholder="__ROOT__/Common/image/no_image_100x100.jpg" src="__ROOT__/Common/image/no_image_100x100.jpg" />
  30. </a>
  31. <input osctype="image_input" type="hidden" name="image" value="" id="input-image" />
  32. <span class="help-inline ">
  33. <span class="middle red" id="dialog_image_desc"></span>
  34. </span>
  35. </dd>
  36. <dt>操作类型</dt>
  37. <dd>
  38. <div>
  39. <select id="dialog_item_image_type" name="" class="vatop">
  40. <option value="">-请选择-</option>
  41. <option value="goods">商品编号</option>
  42. <option value="url">链接</option>
  43. </select>
  44. <input id="dialog_item_image_data" type="text" class="txt w200 marginright marginbot vatop"><br />
  45. <span id="dialog_item_image_desc" class="dialog-image-desc"></span>
  46. </div>
  47. </dd>
  48. </dl>
  49. <div class="J_DefaultMessage"></div>
  50. <div class="bottom">
  51. <a id="btn_save_item" class="J_SubmitPL ncsc-btn ncsc-btn-green" href="javascript:;"><span>保存</span></a>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="row">
  56. <div class="page">
  57. <!-- 页面导航 -->
  58. <div class="fixed-empty"></div>
  59. <form id="form_item" action="{:U('Special/special_item_save')}" method="post">
  60. <input type="hidden" name="special_id" value="{$item_info.special_id}">
  61. <input type="hidden" name="item_id" value="{$item_info.item_id}">
  62. <table class="table tb-type2 nohover">
  63. <include file="Widget:pin_toast" />
  64. <tbody>
  65. <?php $item_data = $item_info['item_data'];?>
  66. <?php $item_edit_flag = true;?>
  67. <tr class="noborder">
  68. <td style="height: auto; padding: 0;">
  69. <div id="item_edit_content" class="mb-item-edit-content">
  70. <?php
  71. if($item_info['item_type'] == 'adv_list'){
  72. ?>
  73. <include file="Special:mb_special_item.module_adv_list" />
  74. <?php
  75. }else if($item_info['item_type'] == 'home1'){
  76. ?>
  77. <include file="Special:mb_special_item.module_home1" />
  78. <?php
  79. } else if($item_info['item_type'] == 'home2'){
  80. ?>
  81. <include file="Special:mb_special_item.module_home2" />
  82. <?php
  83. } else if($item_info['item_type'] == 'home3'){
  84. ?>
  85. <include file="Special:mb_special_item.module_home3" />
  86. <?php
  87. } else if($item_info['item_type'] == 'home4'){
  88. ?>
  89. <include file="Special:mb_special_item.module_home4" />
  90. <?php
  91. }else if($item_info['item_type'] == 'goods'){
  92. ?>
  93. <include file="Special:mb_special_item.module_goods" />
  94. <?php
  95. }
  96. ?>
  97. </div>
  98. </td>
  99. </tr>
  100. </tbody>
  101. <tfoot>
  102. <tr class="tfoot"> <input type="hidden" name="special_id" value="{$item_info.special_id}">
  103. <td colspan="2"><a id="btn_save" class="btn" href="javascript:;"><span>保存编辑</span></a>
  104. <a id="btn_back" href="{:U('Special/addGoods', array('special_id' => $item_info['special_id']))}" class="btn"><span>返回上一级</span></a>
  105. </td>
  106. </tr>
  107. </tfoot>
  108. </table>
  109. </form>
  110. </div>
  111. </div>
  112. </block>
  113. <block name="javascript">
  114. <script id="item_image_template" type="text/html">
  115. <div nctype="item_image" class="item">
  116. <img nctype="image" src="<%=image%>" alt="">
  117. <input nctype="image_name" name="item_data[item][<%=image_name%>][image]" type="hidden" value="<%=image_name%>">
  118. <input nctype="image_type" name="item_data[item][<%=image_name%>][type]" type="hidden" value="<%=image_type%>">
  119. <input nctype="image_data" name="item_data[item][<%=image_name%>][data]" type="hidden" value="<%=image_data%>">
  120. <a nctype="btn_del_item_image" href="javascript:;">删除</a>
  121. </div>
  122. </script>
  123. <script type="text/javascript" src="__PUBLIC__/js/jquery.ui.js"></script>
  124. <script src="__PUBLIC__/fileupload/jquery.ui.widget.js"></script>
  125. <script src="__PUBLIC__/fileupload/jquery.fileupload.js"></script>
  126. <script type="text/javascript" src="__PUBLIC__/js/template.min.js" charset="utf-8"></script>
  127. <script type="text/javascript">
  128. $(document).ready(function(){
  129. var $current_content = null;
  130. var $current_image = null;
  131. var $current_image_name = null;
  132. var $current_image_type = null;
  133. var $current_image_data = null;
  134. var old_image = '';
  135. var $dialog_item_image = $('#dialog_item_image');
  136. var $dialog_item_image_name = $('#dialog_item_image_name');
  137. var special_id = {$item_info.special_id};
  138. //关闭弹出层
  139. $('#dialog').on('click','.ks-ext-close',function(){
  140. $("#dialog").css('display','none');
  141. $('.ks-ext-mask').css('display','none');
  142. return false;
  143. });
  144. //关闭弹出层
  145. $('#dialog').on('click','.J_Cancel',function(){
  146. $("#dialog").css('display','none');
  147. $('.ks-ext-mask').css('display','none');
  148. return false;
  149. });
  150. //保存
  151. $('#btn_save').on('click', function() {
  152. $('#form_item').submit();
  153. });
  154. //编辑图片
  155. $('[nctype="btn_edit_item_image"]').on('click', function() {
  156. //初始化当前图片对象
  157. $item_image = $(this).parents('[nctype="item_image"]');
  158. $current_image = $item_image.find('[nctype="image"]');
  159. $current_image_name = $item_image.find('[nctype="image_name"]');
  160. $current_image_type = $item_image.find('[nctype="image_type"]');
  161. $current_image_data = $item_image.find('[nctype="image_data"]');
  162. $('#dialog_item_image').attr('src', $current_image.attr('src'));
  163. $('#dialog_item_image_name').val($current_image_name.val());
  164. $('#dialog_item_image_type').val($current_image_type.val());
  165. $('#dialog_item_image_data').val($current_image_data.val());
  166. $('#dialog_image_desc').text('推荐图片尺寸' + $(this).attr('data-desc'));
  167. $('#dialog_type').val('edit');
  168. change_image_type_desc($('#dialog_item_image_type').val());
  169. $("#dialog").css({'position' : 'fixed','display' : 'block', 'z-index' : '9999'});
  170. $('#ks-contentbox-title').html('编辑');
  171. });
  172. //添加图片
  173. $('[nctype="btn_add_item_image"]').on('click', function() {
  174. $dialog_item_image.hide();
  175. $dialog_item_image_name.val('');
  176. $current_content = $(this).parent().find('[nctype="item_content"]');
  177. $('#dialog_image_desc').text('推荐图片尺寸' + $(this).attr('data-desc'));
  178. $('#dialog_type').val('add');
  179. change_image_type_desc($('#dialog_item_image_type').val());
  180. $("#dialog").css({'position' : 'fixed','display' : 'block', 'z-index' : '9999'});
  181. $('#ks-contentbox-title').html('添加');
  182. });
  183. //删除图片
  184. $('#item_edit_content').on('click', '[nctype="btn_del_item_image"]', function() {
  185. $(this).parents('[nctype="item_image"]').remove();
  186. });
  187. $('#btn_save_item').on('click', function() {
  188. var type = $('#dialog_type').val();
  189. if(type == 'edit') {
  190. edit_item_image_save();
  191. } else {
  192. if($dialog_item_image_name.val() == '') {
  193. alert('请上传图片');
  194. return false;
  195. }
  196. add_item_image_save();
  197. }
  198. $('#dialog_item_edit_image').hide();
  199. });
  200. function edit_item_image_save() {
  201. $current_image.attr('src', $('#dialog_item_image').attr('src'));
  202. $current_image_name.val($('#dialog_item_image_name').val());
  203. $current_image_type.val($('#dialog_item_image_type').val());
  204. $current_image_data.val($('#dialog_item_image_data').val());
  205. $("#dialog").css('display','none');
  206. $('.ks-ext-mask').css('display','none');
  207. }
  208. function add_item_image_save() {
  209. var $html_item_image = $('#html_item_image');
  210. var item = {};
  211. item.image = $('#dialog_item_image').attr('src');
  212. item.image_name = $('#dialog_item_image_name').val();
  213. item.image_type = $('#dialog_item_image_type').val();
  214. item.image_data = $('#dialog_item_image_data').val();
  215. var item = {};
  216. item.image = $('#dialog_item_image').attr('src');
  217. item.image_name = $('#dialog_item_image_name').val();
  218. item.image_type = $('#dialog_item_image_type').val();
  219. item.image_data = $('#dialog_item_image_data').val();
  220. $current_content.append(template.render('item_image_template', item));
  221. $("#dialog").css('display','none');
  222. $('.ks-ext-mask').css('display','none');
  223. }
  224. $('#btn_mb_special_goods_search').on('click', function() {
  225. var url = '{:U("Special/goods_list")}';
  226. var keyword = $('#txt_goods_name').val();
  227. if(keyword) {
  228. $('#mb_special_goods_list').load(url, {keyword: keyword});
  229. }
  230. });
  231. $('#mb_special_goods_list').on('click', '[nctype="btn_add_goods"]', function() {
  232. var item = {};
  233. item.goods_id = $(this).attr('data-goods-id');
  234. item.goods_name = $(this).attr('data-goods-name');
  235. item.goods_price = $(this).attr('data-goods-price');
  236. item.goods_image = $(this).attr('data-goods-image');
  237. // var html = template.render('item_goods_template', item);
  238. $('[nctype="item_content"]').append(html);
  239. });
  240. $('#dialog_item_image_type').on('change', function() {
  241. change_image_type_desc($(this).val());
  242. });
  243. function change_image_type_desc(type) {
  244. var desc_array = {};
  245. var desc = '操作类型一共四种,对应点击以后的操作。';
  246. if(type != '') {
  247. desc_array['keyword'] = '关键字类型会根据搜索关键字跳转到商品搜索页面,输入框填写搜索关键字。';
  248. desc_array['special'] = '专题编号会跳转到指定的专题,输入框填写专题编号。';
  249. desc_array['goods'] = '商品编号会跳转到指定的商品详细页面,输入框填写商品编号。';
  250. desc_array['url'] = '链接会跳转到指定链接,输入框填写完整的URL。';
  251. desc = desc_array[type];
  252. }
  253. $('#dialog_item_image_desc').text(desc);
  254. }
  255. $(document).delegate('a[data-toggle=\'image\']', 'click', function(e) {
  256. e.preventDefault();
  257. var index=$(this).attr('num');
  258. var element = this;
  259. if(index==undefined){
  260. $(element).popover({
  261. html: true,
  262. placement: 'right',
  263. trigger: 'manual',
  264. content: function() {
  265. return '<button type="button" id="thumb-image" class="btn btn-primary"><i class="icon-edit"></i></button> <button type="button" id="button-clear" class="btn btn-danger"><i class="icon-trash"></i></button>';
  266. }
  267. });
  268. }else{
  269. $(element).popover({
  270. html: true,
  271. placement: 'right',
  272. trigger: 'manual',
  273. content: function() {
  274. return '<button type="button" n="'+index+'" class="btn btn-primary button-image"><i class="icon-edit"></i></button> <button type="button" id="button-clear" class="btn btn-danger"><i class="icon-trash"></i></button>';
  275. }
  276. });
  277. }
  278. $(element).popover('toggle');
  279. //图片
  280. $('#thumb-image').on('click', function() {
  281. $('#modal-image').remove();
  282. $('#form-upload').remove();
  283. $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input osctype="btn_upload_image" type="file" name="file" /></form>');
  284. $('#form-upload input[name=\'file\']').trigger('click');
  285. $(element).popover('hide');
  286. $('[osctype="btn_upload_image"]').fileupload({
  287. dataType: 'json',
  288. url: "{:U('Image/upload_image',array('dir'=>'blog2'))}",
  289. add: function(e, data) {
  290. $parent = $('#thumb');
  291. $input = $parent.find('[osctype="image_input"]');
  292. $img = $parent.find('[osctype="image"]');
  293. data.formData = {old_blog_images:$input.val()};
  294. $img.attr('src', "__IMG__/loading.gif");
  295. data.submit();
  296. },
  297. done: function (e,data) {
  298. var image=data.result;
  299. $parent = $('#thumb');
  300. $input = $parent.find('[osctype="image_input"]');
  301. $img = $parent.find('[osctype="image"]');
  302. if(image) {
  303. // $img.prev('i').hide();
  304. $img.attr('src', '__ROOT__'+image.image_thumb);
  305. $img.show();
  306. $input.val(image.image);
  307. $dialog_item_image.attr('src', '/Uploads/image/'+image.image);
  308. //$dialog_item_image.show();
  309. $dialog_item_image_name.val(image.image);
  310. } else {
  311. alert('上传失败');
  312. }
  313. }
  314. });
  315. });
  316. $('#button-clear').on('click', function() {
  317. $(element).find('img').attr('src', $(element).find('img').attr('data-placeholder'));
  318. $(element).parent().find('input').attr('value', '');
  319. $(element).popover('hide');
  320. });
  321. });
  322. });
  323. </script>
  324. </block>