goods_add.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="dssc-form-default">
  4. <form id="add_form" method="post">
  5. {empty name="goods_info"}
  6. <dl>
  7. <dt><i class="required">*</i>{$Think.lang.inviter_goods}{$Think.lang.ds_colon}</dt>
  8. <dd>
  9. <div dstype="inviter_goods_info" class="selected-group-goods " style="display:none;">
  10. <div class="goods-thumb"><img id="inviter_goods_image" src=""/></div>
  11. <div class="goods-name">
  12. <a dstype="inviter_goods_href" id="inviter_goods_name" href="" target="_blank"></a>
  13. </div>
  14. <div class="goods-price">{$Think.lang.mall_price}:¥<span dstype="inviter_goods_price"></span></div>
  15. </div>
  16. <a href="javascript:void(0);" id="btn_show_search_goods" class="dssc-btn dssc-btn-acidblue">{$Think.lang.choose_goods}</a>
  17. <input id="inviter_goods_commonid" name="inviter_goods_commonid" type="hidden" />
  18. <span></span>
  19. <div id="div_search_goods" class="div-goods-select mt10" style="display: none;">
  20. <table class="search-form">
  21. <tr>
  22. <th class="w150">
  23. <strong>{$Think.lang.search_store_items}</strong>
  24. </th>
  25. <td class="w160">
  26. <input id="search_goods_name" type="text w150" class="text" name="goods_name" value=""/>
  27. </td>
  28. <td class="w70 tc">
  29. <a href="javascript:void(0);" id="btn_search_goods" class="dssc-btn"/><i class="iconfont">&#xe718;</i>{$Think.lang.ds_search}</a></td>
  30. <td class="w10"></td>
  31. <td>
  32. <p class="hint"></p>
  33. </td>
  34. </tr>
  35. </table>
  36. <div id="div_goods_search_result" class="search-result" style="width:739px;"></div>
  37. <a id="btn_hide_search_goods" class="close" href="javascript:void(0);">X</a>
  38. </div>
  39. <p class="hint"></p>
  40. </dd>
  41. </dl>
  42. {else/}
  43. <dl>
  44. <dt>{$Think.lang.inviter_goods}{$Think.lang.ds_colon}</dt>
  45. <dd>
  46. {$goods_info.goods_name}
  47. <input id="inviter_goods_commonid" name="inviter_goods_commonid" type="hidden" value="{$goods_info.goods_commonid}" />
  48. </dd>
  49. </dl>
  50. {/empty}
  51. <dl>
  52. <dt><i class="required">*</i>{$Think.lang.inviter_ratio}{$Think.lang.ds_colon}</dt>
  53. <dd>
  54. <input id="inviter_ratio" name="inviter_ratio" type="text" class="text w130" value="{$goods_info.inviter_ratio|default=''}"/>{$Think.lang.ds_percent}<span></span>
  55. <p class="hint">{$Think.lang.cannot_exceed}100{$Think.lang.ds_percent}</p>
  56. </dd>
  57. </dl>
  58. <div class="bottom">
  59. <input id="submit_button" type="submit" class="submit" value="{$Think.lang.ds_submit}">
  60. </div>
  61. </form>
  62. </div>
  63. <link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.css">
  64. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/jquery-ui-timepicker-addon.min.js"></script>
  65. <script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery-ui-timepicker/i18n/jquery-ui-timepicker-zh-CN.js"></script>
  66. <script>
  67. $(function () {
  68. $('#btn_show_search_goods').on('click', function() {
  69. $('#div_search_goods').show();
  70. });
  71. $('#btn_hide_search_goods').on('click', function() {
  72. $('#div_search_goods').hide();
  73. });
  74. //搜索商品
  75. $('#btn_search_goods').on('click', function() {
  76. var url = "{:url('Sellerinviter/search_goods')}";
  77. var datas = $.param({goods_name: $('#search_goods_name').val()});
  78. $('#div_goods_search_result').load(url,datas);
  79. });
  80. $('#div_goods_search_result').on('click', '.pagination li a', function() {
  81. $('#div_goods_search_result').load($(this).attr('href'));
  82. return false;
  83. });
  84. //选择商品
  85. $('#div_goods_search_result').on('click', '[dstype="btn_add_inviter_goods"]', function() {
  86. var goods_commonid = $(this).attr('data-goods-commonid');
  87. $.get("{:url('Sellerinviter/inviter_goods_info')}", {goods_commonid: goods_commonid}, function(data) {
  88. if(data.result) {
  89. $('#inviter_goods_commonid').val(data.goods_commonid);
  90. $('#inviter_goods_image').attr('src', data.goods_image);
  91. $('#inviter_goods_name').text(data.goods_name);
  92. $('[dstype="inviter_goods_price"]').text(data.goods_price);
  93. $('[dstype="inviter_goods_href"]').attr('href', data.goods_href);
  94. $('[dstype="inviter_goods_info"]').show();
  95. $('#div_search_goods').hide();
  96. } else {
  97. layer.msg(data.message);
  98. }
  99. }, 'json');
  100. });
  101. {empty name = "goods_info"}
  102. $('#start_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  103. $('#end_time').datetimepicker({dateFormat: 'yy-mm-dd'});
  104. {/empty}
  105. jQuery.validator.methods.greaterThanDate = function(value, element, param) {
  106. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  107. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  108. return date1 < date2;
  109. };
  110. jQuery.validator.methods.lessThanDate = function(value, element, param) {
  111. var date1 = new Date(Date.parse(param.replace(/-/g, "/")));
  112. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  113. return date1 > date2;
  114. };
  115. jQuery.validator.methods.greaterThanStartDate = function(value, element) {
  116. var start_date = $("#start_time").val();
  117. var date1 = new Date(Date.parse(start_date.replace(/-/g, "/")));
  118. var date2 = new Date(Date.parse(value.replace(/-/g, "/")));
  119. return date1 < date2;
  120. };
  121. jQuery.validator.methods.lessThanGoodsPrice= function(value, element) {
  122. var goods_price = $("#input_groupbuy_goods_price").val();
  123. return Number(value) < Number(goods_price);
  124. };
  125. //页面输入内容验证
  126. $("#add_form").validate({
  127. errorPlacement: function (error, element) {
  128. var error_td = element.parent('dd').children('span');
  129. error_td.append(error);
  130. },
  131. onfocusout: false,
  132. submitHandler: function (form) {
  133. ds_ajaxpost('add_form', 'url', "{:url('Sellerinviter/goods_list')}");
  134. },
  135. rules: {
  136. inviter_goods_commonid: {
  137. required: true
  138. },
  139. inviter_ratio: {
  140. required: true,
  141. number:true,
  142. max : 100
  143. },
  144. },
  145. messages : {
  146. inviter_goods_commonid : {
  147. required : '<i class="iconfont">&#xe64c;</i>{$Think.lang.inviter_goods_commonid_required}'
  148. },
  149. inviter_ratio: {
  150. required: '<i class="iconfont">&#xe64c;</i>{$Think.lang.inviter_ratio_required}',
  151. number:'<i class="iconfont">&#xe64c;</i>{$Think.lang.inviter_ratio_number}',
  152. max : '<i class="iconfont">&#xe64c;</i>{$Think.lang.inviter_ratio_max}100{$Think.lang.ds_percent}'
  153. },
  154. }
  155. });
  156. });
  157. </script>
  158. {/block}