xianshi_manage.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_btn"}
  3. {if $xianshi_info.editable}
  4. <a id="btn_show_goods_select" class="dssc-btn dssc-btn-green" href="javascript:;"><i></i>{$Think.lang.goods_add}</a>
  5. {/if}
  6. {/block}
  7. {block name="seller_main"}
  8. <table class="dssc-default-table">
  9. <tbody>
  10. <tr>
  11. <td class="w90 tr"><strong>{$Think.lang.xianshi_name}{$Think.lang.ds_colon}</strong></td>
  12. <td class="w120 tl">{$xianshi_info.xianshi_name}</td>
  13. <td class="w90 tr"><strong>{$Think.lang.start_time}{$Think.lang.ds_colon}</strong></td>
  14. <td class="w120 tl">{$xianshi_info.xianshi_starttime|date="Y-m-d H:i"}</td>
  15. <td class="w90 tr"><strong>{$Think.lang.end_time}{$Think.lang.ds_colon}</strong></td>
  16. <td class="w120 tl">{$xianshi_info.xianshi_end_time|date="Y-m-d H:i"}</td>
  17. <td class="w90 tr"><strong>{$Think.lang.buy_lower_limit}{$Think.lang.ds_colon}</strong></td>
  18. <td class="w120 tl">{$xianshi_info.xianshi_lower_limit}</td>
  19. <td class="w90 tr"><strong>{$Think.lang.ds_state}{$Think.lang.ds_colon}</strong></td>
  20. <td class="w120 tl">{$xianshi_info.xianshi_state_text}</td>
  21. </tr>
  22. </table>
  23. <div class="alert">
  24. <strong>{$Think.lang.ds_explain}{$Think.lang.ds_colon}</strong>
  25. <ul>
  26. <li>{$Think.lang.xianshi_manage_goods_explain1}</li>
  27. <li>{$Think.lang.xianshi_manage_goods_explain2}</li>
  28. </ul>
  29. </div>
  30. <!-- 商品搜索 -->
  31. <div id="div_goods_select" class="div-goods-select" style="display: none;">
  32. <table class="search-form">
  33. <tr><th class="w150"><strong>{$Think.lang.search_store_items}</strong></th><td class="w160"><input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/></td>
  34. <td class="w70 tc"><a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i>{$Think.lang.ds_search}</a></td><td class="w10"></td><td><p class="hint">{$Think.lang.special_goods_not_allowed}</p></td>
  35. </tr>
  36. </table>
  37. <div id="div_goods_search_result" class="search-result"></div>
  38. <a id="btn_hide_goods_select" class="close" href="javascript:void(0);">X</a> </div>
  39. <table class="dssc-default-table">
  40. <thead>
  41. <tr>
  42. <th class="w10"></th>
  43. <th class="w50"></th>
  44. <th class="tl">{$Think.lang.goods_name}</th>
  45. <th class="w90">{$Think.lang.goods_store_price}</th>
  46. <th class="w120">{$Think.lang.discount_price}</th>
  47. <th class="w120">{$Think.lang.discount}</th>
  48. <th class="w120">{$Think.lang.ds_handle}</th>
  49. </tr>
  50. </thead>
  51. <tbody id="xianshi_goods_list">
  52. <tr id="xianshi_goods_list_norecord" style="display:none">
  53. <td class="norecord" colspan="20"><div class="warning-option"><i class="iconfont">&#xe64c;</i><span>{$Think.lang.no_record}</span></div></td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. <div class="bottom">
  58. <input type="submit" class="submit" id="submit_back" value="{$Think.lang.ds_back}{$Think.lang.xianshi_index}" onclick="window.location = '{:url('Sellerpromotionxianshi/index')}'">
  59. </div>
  60. <div id="dialog_edit_xianshi_goods" class="eject_con" style="display:none;">
  61. <input id="dialog_xianshigoods_id" type="hidden">
  62. <dl><dt>{$Think.lang.goods_store_price}:</dt><dd><span id="dialog_edit_goods_price"></span></dd></dl>
  63. <dl><dt>{$Think.lang.discount_price}:</dt><dd><input id="dialog_edit_xianshi_price" type="text" class="text w70"><em class="add-on"><i class="iconfont">&#xe65c;</i></em>
  64. <p id="dialog_edit_xianshi_goods_error" style="display:none;"><label for="dialog_edit_xianshi_goods_error" class="error"><i class='iconfont'>&#xe64c;</i>{$Think.lang.discount_price_cannot_empty}</label></p>
  65. </dl>
  66. <div class="eject_con">
  67. <div class="bottom pt10 pb10"><a id="btn_edit_xianshi_goods_submit" class="submit" href="javascript:void(0);">{$Think.lang.ds_submit}</a></div>
  68. </div>
  69. </div>
  70. <script id="xianshi_goods_list_template" type="text/html">
  71. <tr class="bd-line">
  72. <td></td>
  73. <td><div class="pic-thumb"><a href="<%=goods_url%>" target="_blank"><img src="<%=image_url%>" alt=""></a></div></td>
  74. <td class="tl"><dl class="goods-name"><dt><a href="<%=goods_url%>" target="_blank"><%=goods_name%></a></dt></dl></td>
  75. <td>{$Think.lang.currency}<%=goods_price%></td>
  76. <td>{$Think.lang.currency}<span dstype="xianshi_price"><%=xianshigoods_price%></span></td>
  77. <td><span dstype="xianshi_discount"><%=xianshi_discount%></span></td>
  78. <td class="dscs-table-handle">
  79. {if $xianshi_info.editable}
  80. <span><a dstype="btn_edit_xianshi_goods" class="btn-blue" data-xianshi-goods-id="<%=xianshigoods_id%>" data-goods-price="<%=goods_price%>" href="javascript:void(0);"><i class="iconfont">&#xe731;</i><p>{$Think.lang.ds_edit}</p></a></span>
  81. <span><a dstype="btn_del_xianshi_goods" class="btn-red" data-xianshi-goods-id="<%=xianshigoods_id%>" href="javascript:void(0);"><i class="iconfont">&#xe725;</i><p>{$Think.lang.ds_del}</p></a></span>
  82. {/if}
  83. </td>
  84. </tr>
  85. </script>
  86. <script src="{$Think.PLUGINS_SITE_ROOT}/template.min.js"></script>
  87. <script type="text/javascript">
  88. $(document).ready(function () {
  89. // 当前编辑对象,默认为空
  90. $edit_item = {};
  91. //现实商品搜索
  92. $('#btn_show_goods_select').on('click', function () {
  93. $('#div_goods_select').show();
  94. });
  95. //隐藏商品搜索
  96. $('#btn_hide_goods_select').on('click', function () {
  97. $('#div_goods_select').hide();
  98. });
  99. //搜索商品
  100. $('#btn_search_goods').on('click', function () {
  101. var url = "{:url('Sellerpromotionxianshi/goods_select')}";
  102. var datas = $.param({goods_name: $('#search_goods_name').val()});
  103. $('#div_goods_search_result').load(url, datas);
  104. });
  105. $('#div_goods_search_result').on('click', '.pagination li a', function () {
  106. $('#div_goods_search_result').load($(this).attr('href'));
  107. return false;
  108. });
  109. //添加秒杀商品弹出窗口
  110. $('#div_goods_search_result').on('click', '[dstype="btn_add_xianshi_goods"]', function () {
  111. $('#dialog_goods_id').val($(this).attr('data-goods-id'));
  112. $('#dialog_goods_name').text($(this).attr('data-goods-name'));
  113. $('#dialog_goods_price').text($(this).attr('data-goods-price'));
  114. $('#dialog_input_goods_price').val($(this).attr('data-goods-price'));
  115. $('#dialog_goods_img').attr('src', $(this).attr('data-goods-img'));
  116. $('#dialog_add_xianshi_goods').ds_show_dialog({width: 450, title: '{$Think.lang.promotion_add_goods}'});
  117. $('#dialog_xianshi_price').val('');
  118. $('#dialog_add_xianshi_goods_error').hide();
  119. });
  120. //添加秒杀商品
  121. $('#div_goods_search_result').on('click', '#btn_submit', function () {
  122. var goods_id = $('#dialog_goods_id').val();
  123. var xianshi_id = '{$Request.param.xianshi_id}';
  124. var goods_price = Number($('#dialog_input_goods_price').val());
  125. var xianshi_price = Number($('#dialog_xianshi_price').val());
  126. if (!isNaN(xianshi_price) && xianshi_price > 0 && xianshi_price < goods_price) {
  127. $.post("{:url('Sellerpromotionxianshi/xianshi_goods_add')}",
  128. {goods_id: goods_id, xianshi_id: xianshi_id, xianshi_price: xianshi_price},
  129. function (data) {
  130. if (data.result) {
  131. $('#dialog_add_xianshi_goods').hide();
  132. $('#xianshi_goods_list').prepend(template.render('xianshi_goods_list_template', data.xianshi_goods)).hide().fadeIn('slow');
  133. $('#xianshi_goods_list_norecord').hide();
  134. layer.msg(data.message);
  135. } else {
  136. layer.msg(data.message);
  137. }
  138. },
  139. 'json');
  140. } else {
  141. $('#dialog_add_xianshi_goods_error').show();
  142. }
  143. });
  144. //编辑秒杀活动商品
  145. $('#xianshi_goods_list').on('click', '[dstype="btn_edit_xianshi_goods"]', function () {
  146. $edit_item = $(this).parents('tr.bd-line');
  147. var xianshigoods_id = $(this).attr('data-xianshi-goods-id');
  148. var xianshi_price = $edit_item.find('[dstype="xianshi_price"]').text();
  149. var goods_price = $(this).attr('data-goods-price');
  150. $('#dialog_xianshigoods_id').val(xianshigoods_id);
  151. $('#dialog_edit_goods_price').text(goods_price);
  152. $('#dialog_edit_xianshi_price').val(xianshi_price);
  153. $('#dialog_edit_xianshi_goods').ds_show_dialog({width: 450, title: '{$Think.lang.modify_price}'});
  154. });
  155. $('#btn_edit_xianshi_goods_submit').on('click', function () {
  156. var xianshigoods_id = $('#dialog_xianshigoods_id').val();
  157. var xianshi_price = Number($('#dialog_edit_xianshi_price').val());
  158. var goods_price = Number($('#dialog_edit_goods_price').text());
  159. if (!isNaN(xianshi_price) && xianshi_price > 0 && xianshi_price < goods_price) {
  160. $.post("{:url('Sellerpromotionxianshi/xianshi_goods_price_edit')}",
  161. {xianshigoods_id: xianshigoods_id, xianshi_price: xianshi_price},
  162. function (data) {
  163. if (data.result) {
  164. $edit_item.find('[dstype="xianshi_price"]').text(data.xianshi_price);
  165. $edit_item.find('[dstype="xianshi_discount"]').text(data.xianshi_discount);
  166. $('#dialog_edit_xianshi_goods').hide();
  167. } else {
  168. layer.msg(data.message);
  169. }
  170. }, 'json'
  171. );
  172. } else {
  173. $('#dialog_edit_xianshi_goods_error').show();
  174. }
  175. });
  176. //删除秒杀活动商品
  177. $('#xianshi_goods_list').on('click', '[dstype="btn_del_xianshi_goods"]', function () {
  178. var $this = $(this);
  179. layer.confirm('{$Think.lang.ds_ensure_del}', {
  180. btn: ['{$Think.lang.ds_ok}', '{$Think.lang.ds_cancel}'],
  181. title: false,
  182. }, function () {
  183. var xianshigoods_id = $this.attr('data-xianshi-goods-id');
  184. $.post("{:url('Sellerpromotionxianshi/xianshi_goods_delete')}",{xianshigoods_id: xianshigoods_id},function (data) {
  185. if (data.result) {
  186. $this.parents('tr').hide('slow', function () {
  187. var xianshi_goods_count = $('#xianshi_goods_list').find('.bd-line:visible').length;
  188. if (xianshi_goods_count <= 0) {
  189. $('#xianshi_goods_list_norecord').show();
  190. }
  191. });
  192. layer.msg('删除成功');
  193. } else {
  194. layer.msg(data.message);
  195. }
  196. }, 'json');
  197. });
  198. });
  199. //渲染秒杀商品列表
  200. xianshi_goods_array = {:json_encode($xianshi_goods_list)};
  201. if (xianshi_goods_array.length > 0) {
  202. var xianshi_goods_list = '';
  203. $.each(xianshi_goods_array, function (index, xianshi_goods) {
  204. xianshi_goods_list += template.render('xianshi_goods_list_template', xianshi_goods);
  205. });
  206. $('#xianshi_goods_list').prepend(xianshi_goods_list);
  207. } else {
  208. $('#xianshi_goods_list_norecord').show();
  209. }
  210. });
  211. </script>
  212. {/block}