groupbuy_add.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="dssc-form-default">
  4. <form id="add_form" action="{:url('Sellergroupbuy/groupbuy_save')}" method="post" enctype="multipart/form-data">
  5. <dl>
  6. <dt><i class="required">*</i>{$Think.lang.group_name}{$Think.lang.ds_colon}</dt>
  7. <dd>
  8. <input class="w400 text" name="groupbuy_name" type="text" id="groupbuy_name" value="" maxlength="30" />
  9. <span></span>
  10. <p class="hint">{$Think.lang.group_name_tip}</p>
  11. </dd>
  12. </dl>
  13. <dl>
  14. <dt>{$Think.lang.snap_up_subtitles}{$Think.lang.ds_colon}</dt>
  15. <dd>
  16. <input class="w400 text" name="remark" type="text" id="remark" value="" maxlength="30" />
  17. <span></span>
  18. <p class="hint">{$Think.lang.snap_up_subtitle_word_limit}</p>
  19. </dd>
  20. </dl>
  21. <dl>
  22. <dt><i class="required">*</i>{$Think.lang.start_time}{$Think.lang.ds_colon}</dt>
  23. <dd>
  24. <input id="start_time" name="start_time" type="text" class="text w130" /><em class="add-on"><i class="iconfont">&#xe8d6;</i></em><span></span>
  25. <p class="hint">{$Think.lang.start_time_cannot_less_than}{$groupbuy_starttime|date="Y-m-d H:i"}</p>
  26. </dd>
  27. </dl>
  28. <dl>
  29. <dt><i class="required">*</i>{$Think.lang.end_time}{$Think.lang.ds_colon}</dt>
  30. <dd>
  31. <input id="end_time" name="end_time" type="text" class="text w130"/><em class="add-on"><i class="iconfont">&#xe8d6;</i></em><span></span>
  32. <p class="hint">
  33. {notpresent name="isPlatformStore"}
  34. {$Think.lang.start_time_cannot_greater_than}{$current_groupbuy_quota.groupbuyquota_endtime|date="Y-m-d H:i"}
  35. {/notpresent}
  36. </p>
  37. </dd>
  38. </dl>
  39. <dl>
  40. <dt><i class="required">*</i>{$Think.lang.groupbuy_goods}{$Think.lang.ds_colon}</dt>
  41. <dd>
  42. <div dstype="groupbuy_goods_info" class="selected-group-goods " style="display:none;">
  43. <div class="goods-thumb"><img id="groupbuy_goods_image" src=""/></div>
  44. <div class="goods-name">
  45. <a dstype="groupbuy_goods_href" id="groupbuy_goods_name" href="" target="_blank"></a>
  46. </div>
  47. <div class="goods-price">{$Think.lang.store_price}:¥<span dstype="groupbuy_goods_price"></span></div>
  48. </div>
  49. <a href="javascript:void(0);" id="btn_show_search_goods" class="dssc-btn dssc-btn-acidblue">{$Think.lang.groupbuy_index_choose_goods}</a>
  50. <input id="groupbuy_goods_id" name="groupbuy_goods_id" type="hidden" value=""/>
  51. <span></span>
  52. <div id="div_search_goods" class="div-goods-select mt10" style="display: none;">
  53. <table class="search-form">
  54. <tr>
  55. <th class="w150">
  56. <strong>{$Think.lang.search_store_items}</strong>
  57. </th>
  58. <td class="w160">
  59. <input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/>
  60. </td>
  61. <td class="w70 tc">
  62. <a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i>{$Think.lang.ds_search}</a></td>
  63. <td class="w10"></td>
  64. <td>
  65. <p class="hint">{$Think.lang.special_goods_not_allowed}</p>
  66. </td>
  67. </tr>
  68. </table>
  69. <div id="div_goods_search_result" class="search-result" style="width:739px;"></div>
  70. <a id="btn_hide_search_goods" class="close" href="javascript:void(0);">X</a>
  71. </div>
  72. <p class="hint">{$Think.lang.groupbuy_goods_explain}</br><span class="red">{$Think.lang.implement_uniform_purchase_prices}</span></p>
  73. </dd>
  74. </dl>
  75. <dl dstype="groupbuy_goods_info" style="display:none;">
  76. <dt>{$Think.lang.groupbuy_index_store_price}{$Think.lang.ds_colon}</dt>
  77. <dd> {$Think.lang.currency}<span dstype="groupbuy_goods_price"></span><input id="input_groupbuy_goods_price" type="hidden"></dd>
  78. </dl>
  79. <dl>
  80. <dt><i class="required">*</i>{$Think.lang.groupbuy_price}{$Think.lang.ds_colon}</dt>
  81. <dd>
  82. <input class="w70 text" id="groupbuy_price" name="groupbuy_price" type="text" value=""/><em class="add-on"><i class="iconfont">&#xe65c;</i></em> <span></span>
  83. <p class="hint">{$Think.lang.groupbuy_price_tip|raw}</p>
  84. </dd>
  85. </dl>
  86. <dl>
  87. <dt><i class="required">*</i>{$Think.lang.snap_up_photos}{$Think.lang.ds_colon}</dt>
  88. <dd>
  89. <div class="dssc-upload-thumb groupbuy-pic">
  90. <p><i class="iconfont">&#xe72a;</i>
  91. <img dstype="img_groupbuy_image" style="display:none;" src=""/></p>
  92. </div>
  93. <input dstype="groupbuy_image" name="groupbuy_image" type="hidden" value="">
  94. <div class="dssc-upload-btn">
  95. <a href="javascript:void(0);">
  96. <span>
  97. <input type="file" hidefocus="true" size="1" class="input-file" name="groupbuy_image" dstype="btn_upload_image"/>
  98. </span>
  99. <p><i class="iconfont">&#xe733;</i>{$Think.lang.image_upload}</p>
  100. </a>
  101. </div>
  102. <span></span>
  103. <p class="hint">{$Think.lang.group_pic_explain|raw}</p>
  104. </dd>
  105. </dl>
  106. <dl>
  107. <dt>{$Think.lang.snap_recommended_images}{$Think.lang.ds_colon}</dt>
  108. <dd>
  109. <div class="dssc-upload-thumb groupbuy-commend-pic">
  110. <p><i class="iconfont">&#xe72a;</i>
  111. <img dstype="img_groupbuy_image" style="display:none;" src=""/></p>
  112. </div>
  113. <input dstype="groupbuy_image" name="groupbuy_image1" type="hidden" value="">
  114. <span></span>
  115. <div class="dssc-upload-btn">
  116. <a href="javascript:void(0);">
  117. <span>
  118. <input type="file" hidefocus="true" size="1" class="input-file" name="groupbuy_image" dstype="btn_upload_image"/>
  119. </span>
  120. <p><i class="iconfont">&#xe733;</i>{$Think.lang.image_upload}</p>
  121. </a>
  122. </div>
  123. <p class="hint">{$Think.lang.group_pic_explain2|raw}</p>
  124. </dd>
  125. </dl>
  126. <dl>
  127. <dt>{$Think.lang.groupbuy_class}{$Think.lang.ds_colon}</dt>
  128. <dd>
  129. <select id="gclass_id" name="gclass_id" class="w80">
  130. <option value="0">{$Think.lang.text_no_limit}</option>
  131. </select>
  132. <select id="s_gclass_id" name="s_gclass_id" class="w80">
  133. <option value="0">{$Think.lang.text_no_limit}</option>
  134. </select>
  135. <span></span>
  136. <p class="hint">{$Think.lang.groupbuy_class_tip}</p>
  137. </dd>
  138. </dl>
  139. <dl>
  140. <dt>{$Think.lang.virtual_quantity}{$Think.lang.ds_colon}</dt>
  141. <dd>
  142. <input class="w70 text" id="virtual_quantity" name="virtual_quantity" type="text" value="0"/>
  143. <span></span>
  144. <p class="hint">{$Think.lang.virtual_quantity_explain}</p>
  145. </dd>
  146. </dl>
  147. <dl>
  148. <dt>{$Think.lang.sale_quantity}{$Think.lang.ds_colon}</dt>
  149. <dd>
  150. <input class="w70 text" id="upper_limit" name="upper_limit" type="text" value="0"/>
  151. <span></span>
  152. <p class="hint">{$Think.lang.sale_quantity_explain}</p>
  153. </dd>
  154. </dl>
  155. <dl>
  156. <dt>{$Think.lang.group_intro}{$Think.lang.ds_colon}</dt>
  157. <dd>
  158. {:build_editor(['name'=>'groupbuy_intro'])}
  159. <textarea name="groupbuy_intro" id="groupbuy_intro"></textarea>
  160. <p class="hr8"><a class="des_demo dssc-btn" href="{:url('Selleralbum/pic_list',['item'=>'groupbuy'])}"><i class="iconfont">&#xe72a;</i>{$Think.lang.store_goods_album_insert_users_photo}</a></p>
  161. <p id="des_demo" style="display:none;"></p>
  162. </dd>
  163. </dl>
  164. <div class="bottom">
  165. <input type="submit" class="submit" value="{$Think.lang.ds_submit}">
  166. </div>
  167. </form>
  168. </div>
  169. <link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
  170. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
  171. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
  172. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-file-upload/jquery.fileupload.js"></script>
  173. <script src="{$Think.PLUGINS_SITE_ROOT}/jquery.ajaxContent.pack.js"></script>
  174. <script type="text/javascript">
  175. $(document).ready(function(){
  176. $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  177. $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  178. $('#btn_show_search_goods').on('click', function() {
  179. $('#div_search_goods').show();
  180. });
  181. $('#btn_hide_search_goods').on('click', function() {
  182. $('#div_search_goods').hide();
  183. });
  184. //搜索商品
  185. $('#btn_search_goods').on('click', function() {
  186. var url = "{:url('Sellergroupbuy/search_goods')}";
  187. var datas = $.param({goods_name: $('#search_goods_name').val()});
  188. $('#div_goods_search_result').load(url,datas);
  189. });
  190. $('#div_goods_search_result').on('click', '.pagination li a', function() {
  191. $('#div_goods_search_result').load($(this).attr('href'));
  192. return false;
  193. });
  194. //选择商品
  195. $('#div_goods_search_result').on('click', '[dstype="btn_add_groupbuy_goods"]', function() {
  196. var goods_commonid = $(this).attr('data-goods-commonid');
  197. $.get("{:url('Sellergroupbuy/groupbuy_goods_info')}", {goods_commonid: goods_commonid}, function(data) {
  198. if(data.result) {
  199. $('#groupbuy_goods_id').val(data.goods_id);
  200. $('#groupbuy_goods_image').attr('src', data.goods_image);
  201. $('#groupbuy_goods_name').text(data.goods_name);
  202. $('[dstype="groupbuy_goods_price"]').text(data.goods_price);
  203. $('#input_groupbuy_goods_price').val(data.goods_price);
  204. $('[dstype="groupbuy_goods_href"]').attr('href', data.goods_href);
  205. $('[dstype="groupbuy_goods_info"]').show();
  206. $('#div_search_goods').hide();
  207. } else {
  208. layer.msg(data.message);
  209. }
  210. }, 'json');
  211. });
  212. //图片上传
  213. $('[dstype="btn_upload_image"]').fileupload({
  214. dataType: 'json',
  215. url: "{:url('Sellergroupbuy/image_upload')}",
  216. add: function(e, data) {
  217. $parent = $(this).parents('dd');
  218. $input = $parent.find('[dstype="groupbuy_image"]');
  219. $img = $parent.find('[dstype="img_groupbuy_image"]');
  220. data.formData = {old_groupbuy_image:$input.val()};
  221. $img.attr('src', "{$Think.HOME_SITE_ROOT}/images/loading.gif");
  222. data.submit();
  223. },
  224. done: function (e,data) {
  225. var result = data.result;
  226. $parent = $(this).parents('dd');
  227. $input = $parent.find('[dstype="groupbuy_image"]');
  228. $img = $parent.find('[dstype="img_groupbuy_image"]');
  229. if(result.result) {
  230. $img.prev('i').hide();
  231. $img.attr('src', result.file_url);
  232. $img.show();
  233. $input.val(result.file_name);
  234. } else {
  235. layer.msg(data.message);
  236. }
  237. }
  238. });
  239. jQuery.validator.methods.greaterThanDate = function(value, element, param) {
  240. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  241. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  242. return date1 < date2;
  243. };
  244. jQuery.validator.methods.lessThanDate = function(value, element, param) {
  245. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  246. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  247. return date1 > date2;
  248. };
  249. jQuery.validator.methods.greaterThanStartDate = function(value, element) {
  250. var start_date = $("#start_time").val();
  251. var date1 = new Date(Date.parse(start_date.replace(/-/g, "/")));
  252. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  253. return date1 < date2;
  254. };
  255. jQuery.validator.methods.lessThanGoodsPrice= function(value, element) {
  256. var goods_price = $("#input_groupbuy_goods_price").val();
  257. return Number(value) < Number(goods_price);
  258. };
  259. jQuery.validator.methods.checkGroupbuyGoods = function(value, element) {
  260. var start_time = $("#start_time").val();
  261. var result = true;
  262. $.ajax({
  263. type:"GET",
  264. url:"{:url('Sellergroupbuy/check_groupbuy_goods')}",
  265. async:false,
  266. data:{start_time: start_time, goods_id: value},
  267. dataType: 'json',
  268. success: function(data){
  269. if(!data.result) {
  270. result = false;
  271. }
  272. }
  273. });
  274. return result;
  275. };
  276. //页面输入内容验证
  277. $("#add_form").validate({
  278. errorPlacement: function(error, element){
  279. var error_td = element.parent('dd').children('span');
  280. error_td.append(error);
  281. },
  282. onfocusout: false,
  283. rules : {
  284. groupbuy_name: {
  285. required : true
  286. },
  287. start_time : {
  288. required : true,
  289. greaterThanDate : "{$groupbuy_starttime|date='Y-m-d H:i:s'}"
  290. },
  291. end_time : {
  292. required : true,
  293. {notpresent name='isPlatformStore'}
  294. lessThanDate : "{$current_groupbuy_quota.groupbuyquota_endtime|date='Y-m-d H:i'}",
  295. {/notpresent}
  296. greaterThanStartDate : true
  297. },
  298. groupbuy_goods_id: {
  299. required : true,
  300. checkGroupbuyGoods: true
  301. },
  302. groupbuy_price: {
  303. required : true,
  304. number : true,
  305. lessThanGoodsPrice: false,
  306. min : 0.01,
  307. max : 1000000
  308. },
  309. virtual_quantity: {
  310. required : true,
  311. digits : true
  312. },
  313. upper_limit: {
  314. required : true,
  315. digits : true
  316. },
  317. groupbuy_image1: {
  318. required : true
  319. }
  320. },
  321. messages : {
  322. groupbuy_name: {
  323. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.group_name_error}'
  324. },
  325. start_time : {
  326. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.start_time_cannot_empty}',
  327. greaterThanDate : "<i class='iconfont'>&#xe64c;</i>{$Think.lang.start_time_must_greater}{$groupbuy_starttime|date='Y-m-d H:i'}"
  328. },
  329. end_time : {
  330. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.end_snap_time_cannot_empty}',
  331. {notpresent name="isPlatformStore"}
  332. lessThanDate : "<i class='iconfont'>&#xe64c;</i>{$Think.lang.snap_must_less}{present name='current_groupbuy_quota'}{$current_groupbuy_quota.groupbuyquota_endtime|date='Y-m-d H:i'}{/present}",
  333. {/notpresent}
  334. greaterThanStartDate : '<i class="iconfont">&#xe64c;</i>{$Think.lang.must_greater_start_time}'
  335. },
  336. groupbuy_goods_id: {
  337. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.group_goods_error}',
  338. checkGroupbuyGoods: '{$Think.lang.product_participated_simultaneous_events}'
  339. },
  340. groupbuy_price: {
  341. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.groupbuy_price_error}',
  342. number : '<i class="iconfont">&#xe64c;</i>{$Think.lang.groupbuy_price_error}',
  343. lessThanGoodsPrice: '<i class="iconfont">&#xe64c;</i>{$Think.lang.price_must_less_price_goods}',
  344. min : '<i class="iconfont">&#xe64c;</i>{$Think.lang.groupbuy_price_error}',
  345. max : '<i class="iconfont">&#xe64c;</i>{$Think.lang.groupbuy_price_error}'
  346. },
  347. virtual_quantity: {
  348. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.virtual_quantity_error}',
  349. digits : '<i class="iconfont">&#xe64c;</i>{$Think.lang.virtual_quantity_error}'
  350. },
  351. upper_limit: {
  352. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.sale_quantity_error}',
  353. digits : '<i class="iconfont">&#xe64c;</i>{$Think.lang.sale_quantity_error}'
  354. },
  355. groupbuy_image1: {
  356. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.snap_images_cannot_empty}'
  357. }
  358. }
  359. });
  360. $('#li_1').click(function(){
  361. $('#li_1').attr('class','active');
  362. $('#li_2').attr('class','');
  363. $('#demo').hide();
  364. });
  365. $('#goods_demo').click(function(){
  366. $('#li_1').attr('class','');
  367. $('#li_2').attr('class','active');
  368. $('#demo').show();
  369. });
  370. $('.des_demo').click(function(){
  371. if($('#des_demo').css('display') == 'none'){
  372. $('#des_demo').show();
  373. }else{
  374. $('#des_demo').hide();
  375. }
  376. });
  377. $('.des_demo').ajaxContent({
  378. event:'click', //mouseover
  379. loaderType:"img",
  380. loadingMsg:"{$Think.HOME_SITE_ROOT}/images/loading.gif",
  381. target:'#des_demo'
  382. });
  383. });
  384. function insert_editor(file_path){
  385. ue.execCommand('insertimage', {src:file_path});
  386. }
  387. (function(data) {
  388. var s = '<option value="0">{$Think.lang.text_no_limit}</option>';
  389. if (typeof data.children != 'undefined') {
  390. if (data.children[0]) {
  391. $.each(data.children[0], function(k, v) {
  392. s += '<option value="'+v+'">'+data['name'][v]+'</option>';
  393. });
  394. }
  395. }
  396. $('#gclass_id').html(s).change(function() {
  397. var ss = '<option value="0">{$Think.lang.text_no_limit}</option>';
  398. var v = this.value;
  399. if (parseInt(v) && data.children[v]) {
  400. $.each(data.children[v], function(kk, vv) {
  401. ss += '<option value="'+vv+'">'+data['name'][vv]+'</option>';
  402. });
  403. }
  404. $('#s_gclass_id').html(ss);
  405. });
  406. })($.parseJSON('{:json_encode($groupbuy_classes)}'));
  407. </script>
  408. {/block}