截流自动化的商城平台
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 14KB

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