截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

edit.html 16KB

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