截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

add.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. {layout name="layout2" /}
  2. <style>
  3. .layui-form-label {
  4. width: 110px;
  5. }
  6. </style>
  7. <div class="layui-card layui-form">
  8. <div class="layui-card-body">
  9. <!-- 选择商品 -->
  10. <div class="layui-form-item">
  11. <label class="layui-form-label"><font color="red">*</font>砍价商品:</label>
  12. <div class="layui-input-block">
  13. <a class="layui-btn layui-btn-normal select-goods">选择砍价商品</a>
  14. </div>
  15. </div>
  16. <!-- 商品信息 -->
  17. <div class="layui-form-item">
  18. <label class="layui-form-label"></label>
  19. <div class="layui-input-block">
  20. <div class="goods_info"></div>
  21. <table id="goods_list" class="layui-table" lay-size="sm" style="display:none;width:630px;">
  22. <thead>
  23. <tr style="background-color: #f3f5f9">
  24. <th style="width: 120px;text-align: center">商品规格</th>
  25. <th style="width: 60px;text-align: center">商品价格</th>
  26. <th style="width: 40px;text-align: center">活动底价</th>
  27. <th style="width: 40px;text-align: center">首刀金额</th>
  28. <th style="width: 40px;text-align: center">商品库存</th>
  29. </tr>
  30. </thead>
  31. <tbody></tbody>
  32. </table>
  33. </div>
  34. </div>
  35. <!-- 砍价有效时长 -->
  36. <div class="layui-form-item" style="margin-bottom: 0;">
  37. <label for="time_limit" class="layui-form-label"><font color="red">*</font>砍价有效时长:</label>
  38. <div class="layui-input-inline">
  39. <input type="number" min="0" id="time_limit" name="time_limit" class="layui-input" autocomplete="off"
  40. onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
  41. lay-verType="tips" lay-verify="required|number|time_limit">
  42. </div>
  43. <div class="layui-form-mid layui-word-aux">小时</div>
  44. </div>
  45. <div class="layui-form-item">
  46. <label class="layui-form-label"></label>
  47. <div class="layui-input-block">
  48. <div class="layui-form-mid layui-word-aux">本次发起砍价活动有效时长。</div>
  49. </div>
  50. </div>
  51. <!-- 拼团活动时间 -->
  52. <div class="layui-form-item" style="margin-bottom: 0;">
  53. <label class="layui-form-label" style="width:110px;"><font color="red">*</font>砍价活动时间:</label>
  54. <div class="layui-inline">
  55. <div class="layui-input-inline">
  56. <input type="text" id="activity_start_time" name="activity_start_time" placeholder="开始时间" class="layui-input" autocomplete="off" lay-verType="tips" lay-verify="required">
  57. </div>
  58. </div>
  59. <div class="layui-inline">
  60. <div class="layui-input-inline">
  61. <input type="text" id="activity_end_time" name="activity_end_time" placeholder="结束时间" class="layui-input" autocomplete="off" lay-verType="tips" lay-verify="required">
  62. </div>
  63. </div>
  64. </div>
  65. <div class="layui-form-item">
  66. <label class="layui-form-label" style="width:110px;"></label>
  67. <div class="layui-input-block">
  68. <div class="layui-form-mid layui-word-aux">本商品参与砍价活动的时间范围。</div>
  69. </div>
  70. </div>
  71. <!-- 砍价分享标题 -->
  72. <div class="layui-form-item" style="margin-bottom: 0;">
  73. <label for="share_title" class="layui-form-label" style="width:110px;">砍价分享标题:</label>
  74. <div class="layui-input-inline" style="width: 300px;">
  75. <input type="text" id="share_title" name="share_title" class="layui-input" autocomplete="off" lay-verType="tips">
  76. </div>
  77. </div>
  78. <div class="layui-form-item">
  79. <label class="layui-form-label" style="width:110px;"></label>
  80. <div class="layui-input-block">
  81. <div class="layui-form-mid layui-word-aux">分享砍价活动时的标题,为空时默认使用商品标题</div>
  82. </div>
  83. </div>
  84. <!-- 砍价分享简介 -->
  85. <div class="layui-form-item" style="margin-bottom: 0;">
  86. <label for="share_intro" class="layui-form-label" style="width:110px;">砍价分享简介:</label>
  87. <div class="layui-input-inline" style="width: 300px;">
  88. <input type="text" id="share_intro" name="share_intro" class="layui-input" autocomplete="off" lay-verType="tips">
  89. </div>
  90. </div>
  91. <div class="layui-form-item">
  92. <label class="layui-form-label" style="width:110px;"></label>
  93. <div class="layui-input-block">
  94. <div class="layui-form-mid layui-word-aux">分享砍价活动时的简介,为空时默认使用商品简介</div>
  95. </div>
  96. </div>
  97. <!-- 购买方式 -->
  98. <div class="layui-form-item" style="margin-bottom: 0;">
  99. <label class="layui-form-label"><font color="red">*</font>购买方式:</label>
  100. <div class="layui-input-block">
  101. <input type="radio" name="payment_where" value="1" title="砍到指定底价才可购买" checked>
  102. <input type="radio" name="payment_where" value="2" title="任意金额可购买">
  103. </div>
  104. </div>
  105. <!-- 每刀金额 -->
  106. <div class="layui-form-item">
  107. <label class="layui-form-label"><font color="red">*</font>每刀金额:</label>
  108. <div class="layui-input-block">
  109. <div class="layui-inline">
  110. <input type="radio" name="knife_type" value="1" title="随机金额" checked>
  111. </div>
  112. <div class="layui-inline">
  113. <input type="text" name="min_knife_price" class="layui-input" autocomplete="off"
  114. lay-verType="tips" lay-verify="min_knife_price" style="width:100px;" placeholder="最小金额"
  115. onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
  116. </div>
  117. <div class="layui-inline"><span>~</span></div>
  118. <div class="layui-inline">
  119. <input type="text" name="max_knife_price" class="layui-input" autocomplete="off"
  120. lay-verType="tips" lay-verify="max_knife_price" style="width:100px;" placeholder="最大金额"
  121. onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
  122. </div>
  123. </div>
  124. <label class="layui-form-label"></label>
  125. <div class="layui-input-block">
  126. <div class="layui-inline">
  127. <input type="radio" name="knife_type" value="2" title="固定金额">
  128. </div>
  129. <div class="layui-inline">
  130. <input type="text" name="fixed_knife_price" class="layui-input" autocomplete="off"
  131. lay-verType="tips" lay-verify="fixed_knife_price" style="width:100px;" placeholder="元"
  132. onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')">
  133. </div>
  134. </div>
  135. </div>
  136. <!-- 活动状态 -->
  137. <div class="layui-form-item" style="margin-bottom: 0;">
  138. <label class="layui-form-label"><font color="red">*</font>活动状态:</label>
  139. <div class="layui-input-block">
  140. <input type="radio" name="status" value="1" title="开启">
  141. <input type="radio" name="status" value="0" title="关闭" checked>
  142. </div>
  143. </div>
  144. <div class="layui-form-item">
  145. <label class="layui-form-label"></label>
  146. <div class="layui-input-block">
  147. <div class="layui-form-mid layui-word-aux">活动开启并且在砍价活动时间内才能发起新的砍价活动</div>
  148. </div>
  149. </div>
  150. <!-- 确认按钮 -->
  151. <div class="layui-form-item layui-hide">
  152. <input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
  153. </div>
  154. </div>
  155. </div>
  156. <script>
  157. layui.config({
  158. base: '/static/plug/layui-admin/dist/layuiadmin/' //静态资源所在路径
  159. }).extend({
  160. index: 'lib/index'
  161. }).use(['index', 'form', 'like', 'laydate'], function() {
  162. var $ = layui.$
  163. , form = layui.form
  164. , like = layui.like
  165. , laydate = layui.laydate;
  166. // 开始时间
  167. laydate.render({
  168. type: 'datetime'
  169. ,elem: '#activity_start_time'
  170. ,trigger: 'click'
  171. });
  172. // 结束时间
  173. laydate.render({
  174. type: 'datetime'
  175. ,elem: '#activity_end_time'
  176. ,trigger: 'click'
  177. });
  178. // 选择商品
  179. $(document).on('click','.select-goods',function () {
  180. layer.open({
  181. type: 2
  182. ,title: '选择商品'
  183. ,content: '{:url("common/selectGoodsTwo")}'
  184. ,area: ['90%', '90%']
  185. ,btn: ['确认', '取消']
  186. ,yes: function(index, layero){
  187. var data = window["layui-layer-iframe" + index].callbackdata();
  188. if(data.length){
  189. goods_ids = [];
  190. $('#goods_list tbody').remove();
  191. }
  192. data.forEach(function(item, index) {
  193. console.log(item);
  194. var goods_info_html = '<img src="'+item.image+'" alt="商品图片" style="width:80px;height:80px;">\n' +
  195. '<span style="margin-left:5px;">'+item.name+'</span>\n' +
  196. '<input type="hidden" name="goods_id" value="'+item.id+'">';
  197. $(".goods_info").html(goods_info_html);
  198. $("#goods_list").show();
  199. for(var i = 0; item.goods_item.length > i; i++){
  200. var goods_item = item.goods_item[i];
  201. if(goods_ids.indexOf(goods_item.id) === -1) {
  202. goods_ids.push(goods_item.id);
  203. var goods_html = '<tr>\n' +
  204. '<td style="text-align: center">'+goods_item.spec_value_str+'</td>\n' +
  205. '<td style="text-align: center">'+goods_item.price+'</td>\n' +
  206. '<td style="width: 40px;"><input type="text" name=floor_price['+item.id+']['+goods_item.id+'] class="layui-input" autocomplete="off"\n' +
  207. ' onkeyup="value=value.replace(/^\\D*(\\d*(?:\\.\\d{0,2})?).*$/g, \'$1\')"></td>\n' +
  208. '<td style="width: 40px;"><input type="text" name=first_knife_price['+item.id+']['+goods_item.id+'] class="layui-input" autocomplete="off"\n' +
  209. ' onkeyup="value=value.replace(/^\\D*(\\d*(?:\\.\\d{0,2})?).*$/g, \'$1\')"></td>\n' +
  210. '<td style="width: 40px;text-align: center">'+item.stock+'</td>\n' +
  211. '</tr>';
  212. $('#goods_list').append(goods_html);
  213. }
  214. }
  215. });
  216. $('.goods').show();
  217. }
  218. })
  219. });
  220. // 表单验证
  221. form.verify({
  222. min_knife_price: function(value){
  223. var type = $('input[name=knife_type]:checked').val();
  224. if (type === '1') {
  225. if (!value || value === '') {
  226. return '请填写最小砍价金额';
  227. }
  228. if(parseFloat(value) < 0){
  229. return '最小砍价金额不能小于0';
  230. }
  231. }
  232. },
  233. max_knife_price: function(value){
  234. var type = $('input[name=knife_type]:checked').val();
  235. if (type === '1') {
  236. if (!value || value === '') {
  237. return '请填写最大砍价金额';
  238. }
  239. if(parseFloat(value) < 0){
  240. return '最大砍价金额不能小于0';
  241. }
  242. }
  243. },
  244. fixed_knife_price: function (value) {
  245. var type = $('input[name=knife_type]:checked').val();
  246. if (type === '2') {
  247. if (!value || value === '') {
  248. return '请填写固定砍价金额';
  249. }
  250. if(parseFloat(value) < 0){
  251. return '固定砍价金额不能小于0';
  252. }
  253. }
  254. },
  255. first_knife_price: function (value, that) {
  256. var goods_price = $(that).parent().prev().prev().html();
  257. if (parseFloat(value) > parseFloat(goods_price)) {
  258. return '首刀价格不能大于商品价格';
  259. }
  260. }
  261. });
  262. });
  263. </script>