mansong_add.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="dssc-form-default">
  4. <div class="alert alert-block">
  5. <h4>{$Think.lang.ds_explain}{$Think.lang.ds_colon}</h4>
  6. <ul>
  7. <li>{$Think.lang.mansong_add_explain1}</li>
  8. <li>{$Think.lang.mansong_add_explain2}</li>
  9. <li>{$Think.lang.mansong_add_explain3}</li>
  10. </ul>
  11. </div>
  12. <form id="add_form" action="{:url('Sellerpromotionmansong/mansong_save')}" method="post">
  13. <input id="level2_flag" type="hidden" value="false" />
  14. <input id="level3_flag" type="hidden" value="false" />
  15. <dl>
  16. <dt><i class="required">*</i>{$Think.lang.mansong_name}{$Think.lang.ds_colon}</dt>
  17. <dd>
  18. <input id="mansong_name" name="mansong_name" type="text" maxlength="25" class="w400 text"/>
  19. <span class="error-message"></span>
  20. <p class="hint">{$Think.lang.mansong_name_explain}</p>
  21. </dd>
  22. </dl>
  23. <dl>
  24. <dt><i class="required">*</i>{$Think.lang.start_time}{$Think.lang.ds_colon}</dt>
  25. <dd>
  26. <input id="start_time" name="start_time" type="text" class="text w130"/><em class="add-on"><i class="iconfont">&#xe8d6;</i></em>
  27. <span class="error-message"></span>
  28. <p class="hint">{:sprintf(lang('mansong_add_start_time_explain'),date('Y-m-d H:i',$start_time))}</p>
  29. </dd>
  30. </dl>
  31. <dl>
  32. <dt><i class="required">*</i>{$Think.lang.end_time}{$Think.lang.ds_colon}</dt>
  33. <dd>
  34. <input id="end_time" name="end_time" type="text" class="text w130"/><em class="add-on"><i class="iconfont">&#xe8d6;</i></em>
  35. <span class="error-message"></span>
  36. <p class="hint">
  37. {if !$isPlatformStore}
  38. {:sprintf(lang('mansong_add_end_time_explain'),date('Y-m-d H:i',$end_time))}
  39. {/if}
  40. </p>
  41. </dd>
  42. </dl>
  43. <dl>
  44. <dt><i class="required">*</i>{$Think.lang.full_feed_rule}{$Think.lang.ds_colon}</dt>
  45. <dd>
  46. <input type="hidden" id="mansong_rule_count" name="rule_count">
  47. <ul id="mansong_rule_list" class="dssc-mansong-rule-list">
  48. </ul>
  49. <a href="javascript:void(0);" id="btn_add_rule" class="dssc-btn dssc-btn-acidblue"><i class="iconfont">&#xe6db;</i>{$Think.lang.add_rules}</a>
  50. <div id="div_add_rule" style="display:none;">
  51. <div class="dssc-mansong-error"><span id="mansong_price_error" style="display:none;"><i class="iconfont">&#xe64c;</i>{$Think.lang.rule_amount_cannot_empty}</span><span id="mansong_discount_error" style="display:none;"><i class="iconfont">&#xe64c;</i>{$Think.lang.full_minus_mustless_rule}</span></div>
  52. <div class="dssc-mansong-rule">
  53. <span>{$Think.lang.level_price}&nbsp;<input id="mansong_price" type="text" class="text w50"><em class="add-on"><i class="iconfont">&#xe65c;</i></em>,</span>
  54. <span>{$Think.lang.level_discount}&nbsp;<input id="mansong_discount" type="text" class="text w50"><em class="add-on"><i class="iconfont">&#xe65c;</i></em>,</span>
  55. <span>{$Think.lang.gift_name}&nbsp;<a href="javascript:void(0);" id="btn_show_search_goods" class="dssc-btn"><i class="iconfont">&#xe753;</i>{$Think.lang.choose_gifts}</a></span> <div id="mansong_goods_item" class="gift"></div>
  56. <div id="div_search_goods" class="div-goods-select mt10" style="display: none;">
  57. <table class="search-form">
  58. <tr>
  59. <th class="w150">
  60. <strong>{$Think.lang.search_store_items}</strong>
  61. </th>
  62. <td class="w160">
  63. <input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/>
  64. </td>
  65. <td class="w70 tc">
  66. <a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i>{$Think.lang.ds_search}</a>
  67. </td>
  68. <td class="w10"></td>
  69. <td>
  70. <p class="hint">{$Think.lang.show_all_goods_sold}</p>
  71. </td>
  72. </tr>
  73. </table>
  74. <a id="btn_hide_search_goods" class="close" href="javascript:void(0);">X</a>
  75. <div id="div_goods_search_result" class="search-result" style="width:739px;"></div>
  76. </div>
  77. </div>
  78. <div id="mansong_rule_error" style="display:none;">{$Think.lang.choose_least_one_promotion}</div>
  79. <div class="mt10">
  80. <a href="javascript:void(0);" id="btn_save_rule" class="dssc-btn dssc-btn-acidblue"><i class="iconfont">&#xe64d;</i>{$Think.lang.determine_rule_settings}</a>
  81. <a href="javascript:void(0);" id="btn_cancel_add_rule" class="dssc-btn dssc-btn-orange"><i class="iconfont">&#xe754;</i>{$Think.lang.ds_cancel}</a></div>
  82. </div>
  83. <span class="error-message"></span>
  84. <p class="hint">{$Think.lang.single_order_meets_amount}<br/>{$Think.lang.system_supports_rank_rules}</p>
  85. </dd>
  86. </dl>
  87. <dl>
  88. <dt>{$Think.lang.text_remark}{$Think.lang.ds_colon}</dt>
  89. <dd>
  90. <textarea name="remark" rows="3" id="remark" maxlength="100" class="textarea w400"></textarea>
  91. <p class="hint">{$Think.lang.mansong_remark_explain}</p>
  92. </dd>
  93. </dl>
  94. <div class="bottom">
  95. <input id="submit_button" type="submit" value="{$Think.lang.ds_submit}" class="submit">
  96. </div>
  97. </form>
  98. </div>
  99. <script id="mansong_rule_template" type="text/html">
  100. <li dstype="mansong_rule_item">
  101. <span>{$Think.lang.level_price}<strong><%=price%></strong>{$Think.lang.ds_yuan}, </span>
  102. <span>{$Think.lang.level_discount}<strong><%=discount%></strong>{$Think.lang.ds_yuan}, </span>
  103. <%if(goods_id>0){%>
  104. <span>{$Think.lang.gift_name} <%==goods%></span>
  105. <%}%>
  106. <input type="hidden" name="mansong_rule[]" value="<%=price%>,<%=discount%>,<%=goods_id%>">
  107. <a dstype="btn_del_mansong_rule" href="javascript:void(0);" class="dssc-btn-mini dssc-btn-red"><i class="iconfont">&#xe725;</i>{$Think.lang.ds_del}</a>
  108. </li>
  109. </script>
  110. <script id="mansong_goods_template" type="text/html">
  111. <div dstype="mansong_goods" class="selected-mansong-goods">
  112. <a href="<%=goods_url%>" title="<%=goods_name%>" class="goods-thumb" target="_blank">
  113. <img src="<%=goods_image_url%>"/>
  114. </a>
  115. <input dstype="mansong_goods_id" type="hidden" value="<%=goods_id%>">
  116. </div><a dstype="btn_del_mansong_goods" href="javascript:void(0);" class="dssc-btn-mini dssc-btn-red"><i class="iconfont">&#xe725;</i>{$Think.lang.delete_selected_gifts}</a>
  117. </script>
  118. <script src="{$Think.PLUGINS_SITE_ROOT}/template.min.js"></script>
  119. <link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
  120. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
  121. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
  122. <script type="text/javascript">
  123. $(document).ready(function(){
  124. $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  125. $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  126. jQuery.validator.methods.greaterThanDate = function(value, element, param) {
  127. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  128. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  129. return date1 < date2;
  130. };
  131. jQuery.validator.methods.lessThanDate = function(value, element, param) {
  132. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  133. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  134. return date1 > date2;
  135. };
  136. jQuery.validator.methods.greaterThanStartDate = function(value, element) {
  137. var start_date = $("#start_time").val();
  138. var date1 = new Date(Date.parse(start_date.replace(/-/g, "/")));
  139. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  140. return date1 < date2;
  141. };
  142. //页面输入内容验证
  143. $("#add_form").validate({
  144. errorPlacement: function(error, element){
  145. var error_td = element.parent('dd').children('span.error-message');
  146. error_td.append(error);
  147. },
  148. onfocusout: false,
  149. submitHandler:function(form){
  150. ds_ajaxpost('add_form', 'url', "{:url('Sellerpromotionmansong/index')}");
  151. },
  152. rules : {
  153. mansong_name : {
  154. required : true
  155. },
  156. start_time : {
  157. required : true,
  158. greaterThanDate : '{$start_time|date='Y-m-d H:i'}'
  159. },
  160. end_time : {
  161. required : true,
  162. {if !$isPlatformStore}
  163. lessThanDate : '{$end_time|date='Y-m-d H:i'}',
  164. {/if}
  165. greaterThanStartDate : true
  166. },
  167. rule_count: {
  168. required: true,
  169. min: 1
  170. }
  171. },
  172. messages : {
  173. mansong_name : {
  174. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.mansong_name_error}'
  175. },
  176. start_time : {
  177. required : '<i class="iconfont">&#xe64c;</i>{:sprintf(lang("mansong_add_start_time_explain"),date("Y-m-d H:i",$start_time))}',
  178. greaterThanDate : '<i class="iconfont">&#xe64c;</i>{:sprintf(lang("mansong_add_start_time_explain"),date("Y-m-d H:i",$start_time))}'
  179. },
  180. end_time : {
  181. required : '<i class="iconfont">&#xe64c;</i>{:sprintf(lang("mansong_add_end_time_explain"),date("Y-m-d H:i",$end_time))}',
  182. {if !$isPlatformStore}
  183. lessThanDate : '<i class="iconfont">&#xe64c;</i>{:sprintf(lang("mansong_add_end_time_explain"),date("Y-m-d H:i",$end_time))}',
  184. {/if}
  185. greaterThanStartDate : '<i class="iconfont">&#xe64c;</i>{$Think.lang.greater_than_start_time}'
  186. },
  187. rule_count: {
  188. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.add_rule_determine}',
  189. min: '<i class="iconfont">&#xe64c;</i>{$Think.lang.add_rule_determine}'
  190. }
  191. }
  192. });
  193. // 秒杀添加规则窗口
  194. $('#btn_add_rule').on('click', function() {
  195. $('#mansong_price').val('');
  196. $('#mansong_discount').val('');
  197. $('#mansong_goods_item').html('');
  198. $('#mansong_price_error').hide();
  199. $('#mansong_rule_error').hide();
  200. $('#div_add_rule').show();
  201. $('#btn_add_rule').hide();
  202. });
  203. // 规则保存
  204. $('#btn_save_rule').on('click', function() {
  205. var mansong = {};
  206. mansong.price = Number($('#mansong_price').val());
  207. if(isNaN(mansong.price) || mansong.price <= 0) {
  208. $('#mansong_price_error').show();
  209. return false;
  210. } else {
  211. $('#mansong_price_error').hide();
  212. }
  213. mansong.discount = Number($('#mansong_discount').val());
  214. if(isNaN(mansong.discount) || mansong.discount < 0 || mansong.discount > mansong.price) {
  215. $('#mansong_discount_error').show();
  216. return false;
  217. } else {
  218. $('#mansong_discount_error').hide();
  219. }
  220. mansong.goods = $('#mansong_goods_item').find('[dstype="mansong_goods"]').html();
  221. mansong.goods_id = Number($('#mansong_goods_item').find('[dstype="mansong_goods_id"]').val());
  222. if(isNaN(mansong.goods_id)) {
  223. mansong.goods_id = 0;
  224. }
  225. if(mansong.discount == 0 && mansong.goods_id == 0) {
  226. $('#mansong_rule_error').show();
  227. return false;
  228. } else {
  229. $('#mansong_rule_error').hide();
  230. }
  231. var mansong_rule_item = template.render('mansong_rule_template', mansong);
  232. $('#mansong_rule_list').append(mansong_rule_item);
  233. close_div_add_rule();
  234. });
  235. // 删除已添加的规则
  236. $('#mansong_rule_list').on('click', '[dstype="btn_del_mansong_rule"]', function() {
  237. $(this).parents('[dstype="mansong_rule_item"]').remove();
  238. close_div_add_rule();
  239. });
  240. // 取消添加规则
  241. $('#btn_cancel_add_rule').on('click', function() {
  242. close_div_add_rule();
  243. });
  244. // 关闭规则添加窗口
  245. function close_div_add_rule() {
  246. var rule_count = $('#mansong_rule_list').find('[dstype="mansong_rule_item"]').length;
  247. if( rule_count >= 3) {
  248. $('#btn_add_rule').hide();
  249. } else {
  250. $('#btn_add_rule').show();
  251. }
  252. $('#div_add_rule').hide();
  253. $('#mansong_rule_count').val(rule_count);
  254. }
  255. // 秒杀商品选择窗口
  256. $('#btn_show_search_goods').on('click', function() {
  257. $('#div_search_goods').show();
  258. });
  259. // 搜索商品
  260. $('#btn_search_goods').on('click', function() {
  261. var url = "{:url('Sellerpromotionmansong/search_goods')}";
  262. var datas = $.param({goods_name: $('#search_goods_name').val()});
  263. $('#div_goods_search_result').load(url,datas);
  264. });
  265. // 搜索商品翻页
  266. $('#div_goods_search_result').on('click', '.pagination li a', function() {
  267. $('#div_goods_search_result').load($(this).attr('href'));
  268. return false;
  269. });
  270. // 关闭商品选择窗口
  271. $('#btn_hide_search_goods').on('click', function() {
  272. $('#div_search_goods').hide();
  273. });
  274. // 选择商品
  275. $('#div_goods_search_result').on('click', '[dstype="btn_add_mansong_goods"]', function() {
  276. var goods = {};
  277. goods.goods_id = $(this).attr('data-goods-id');
  278. goods.goods_name = $(this).attr('data-goods-name');
  279. goods.goods_image_url = $(this).attr('data-goods-image-url');
  280. goods.goods_url = $(this).attr('data-goods-url');
  281. var mansong_goods_item = template.render('mansong_goods_template', goods);
  282. $('#mansong_goods_item').html(mansong_goods_item);
  283. $('#div_search_goods').hide();
  284. });
  285. // 删除以选的商品
  286. $('#mansong_goods_item').on('click', '[dstype="btn_del_mansong_goods"]', function() {
  287. $('#mansong_goods_item').html('');
  288. });
  289. });
  290. </script>
  291. {/block}