Commit 81d8932b60553540e9c815a328569741dba97dbd
1 parent
165dd04f
限购的优化
Showing
11 changed files
with
71 additions
and
22 deletions
components/add_purchase/add_purchase.js
@@ -3131,7 +3131,8 @@ Component({ | @@ -3131,7 +3131,8 @@ Component({ | ||
3131 | data: { | 3131 | data: { |
3132 | store_id: os.stoid, | 3132 | store_id: os.stoid, |
3133 | user_id: user_id, | 3133 | user_id: user_id, |
3134 | - goods_id: gd.goods_id, isnew: 1 | 3134 | + goods_id: gd.goods_id, isnew: 1, |
3135 | + timetype:gd.viplimited_timetype | ||
3135 | }, | 3136 | }, |
3136 | success: function (t) { | 3137 | success: function (t) { |
3137 | if (t.data.code == 0) { | 3138 | if (t.data.code == 0) { |
packageA/pages/prom_list/prom_list.js
@@ -783,7 +783,7 @@ Page({ | @@ -783,7 +783,7 @@ Page({ | ||
783 | }); | 783 | }); |
784 | 784 | ||
785 | var num= th.data.data.viplimited-gd_buy_num; | 785 | var num= th.data.data.viplimited-gd_buy_num; |
786 | - if(num<0) num=0; | 786 | + if(num<=0) num=1 |
787 | th.setData({goodsInputNum:num}) | 787 | th.setData({goodsInputNum:num}) |
788 | return false; | 788 | return false; |
789 | } | 789 | } |
@@ -797,7 +797,7 @@ Page({ | @@ -797,7 +797,7 @@ Page({ | ||
797 | }); | 797 | }); |
798 | 798 | ||
799 | var num=th.data.prom_buy_limit- th.data.prom_buy_num ; | 799 | var num=th.data.prom_buy_limit- th.data.prom_buy_num ; |
800 | - if(num<0) num=0; | 800 | + if(num<=0) num=1; |
801 | th.setData({goodsInputNum:num}) | 801 | th.setData({goodsInputNum:num}) |
802 | return false; | 802 | return false; |
803 | } | 803 | } |
@@ -1472,7 +1472,8 @@ Page({ | @@ -1472,7 +1472,8 @@ Page({ | ||
1472 | store_id: os.stoid, | 1472 | store_id: os.stoid, |
1473 | user_id: user_id, | 1473 | user_id: user_id, |
1474 | goods_id: gd.goods_id, | 1474 | goods_id: gd.goods_id, |
1475 | - isnew:1 | 1475 | + isnew:1, |
1476 | + timetype:gd.viplimited_timetype | ||
1476 | }, | 1477 | }, |
1477 | success: function(t) { | 1478 | success: function(t) { |
1478 | if (t.data.code == 0) { | 1479 | if (t.data.code == 0) { |
packageB/pages/zuhegou/index/index.js
@@ -869,7 +869,7 @@ Page({ | @@ -869,7 +869,7 @@ Page({ | ||
869 | //开始调用接口 | 869 | //开始调用接口 |
870 | getApp().request.get(url, { | 870 | getApp().request.get(url, { |
871 | data: req_data, | 871 | data: req_data, |
872 | - success: function (res) { | 872 | + success: async function (res) { |
873 | th.data.loading = 0; | 873 | th.data.loading = 0; |
874 | th.setData({ | 874 | th.setData({ |
875 | is_get: 1 | 875 | is_get: 1 |
@@ -879,6 +879,16 @@ Page({ | @@ -879,6 +879,16 @@ Page({ | ||
879 | var list = th.data.list; | 879 | var list = th.data.list; |
880 | if (!list) list = []; | 880 | if (!list) list = []; |
881 | 881 | ||
882 | + for (let it = 0; it < res.data.data.pageData.length; it++) { | ||
883 | + var g_ite=res.data.data.pageData[it]; | ||
884 | + //获取单品的现在的活动状态 | ||
885 | + var rs_gd=await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + g_ite.goods_id, {}); | ||
886 | + if(rs_gd && rs_gd.data.code==0 && rs_gd.data.data){ | ||
887 | + g_ite.viplimited_timetype= rs_gd.data.data.viplimited_timetype; | ||
888 | + } | ||
889 | + | ||
890 | + } | ||
891 | + | ||
882 | //当是下拉刷新的时候 | 892 | //当是下拉刷新的时候 |
883 | if (th.data.page > 1 && th.data.cart_list) { | 893 | if (th.data.page > 1 && th.data.cart_list) { |
884 | //下拉之后也要重新计算一下金额 | 894 | //下拉之后也要重新计算一下金额 |
@@ -2392,7 +2402,8 @@ Page({ | @@ -2392,7 +2402,8 @@ Page({ | ||
2392 | goods_id: gd.goods_id, | 2402 | goods_id: gd.goods_id, |
2393 | prom_type: 7, | 2403 | prom_type: 7, |
2394 | prom_id: th.data.act.id, | 2404 | prom_id: th.data.act.id, |
2395 | - isnew:1 | 2405 | + isnew:1, |
2406 | + timetype:gd.viplimited_timetype | ||
2396 | }, | 2407 | }, |
2397 | }).then(res2 => { | 2408 | }).then(res2 => { |
2398 | var g_buy_num = 0; | 2409 | var g_buy_num = 0; |
@@ -2887,7 +2898,8 @@ Page({ | @@ -2887,7 +2898,8 @@ Page({ | ||
2887 | goods_id: item_j.goods_id, | 2898 | goods_id: item_j.goods_id, |
2888 | prom_type: 7, | 2899 | prom_type: 7, |
2889 | prom_id: th.data.act.id, | 2900 | prom_id: th.data.act.id, |
2890 | - isnew:1 | 2901 | + isnew:1, |
2902 | + timetype:item_j.viplimited_timetype | ||
2891 | }, | 2903 | }, |
2892 | }).then(res2 => { | 2904 | }).then(res2 => { |
2893 | if (res2.data.code == 0) { | 2905 | if (res2.data.code == 0) { |
@@ -2964,7 +2976,8 @@ Page({ | @@ -2964,7 +2976,8 @@ Page({ | ||
2964 | goods_id: item_j.goods_id, | 2976 | goods_id: item_j.goods_id, |
2965 | prom_type: 7, | 2977 | prom_type: 7, |
2966 | prom_id: th.data.act.id, | 2978 | prom_id: th.data.act.id, |
2967 | - isnew:1 | 2979 | + isnew:1, |
2980 | + timetype:item_j.viplimited_timetype | ||
2968 | }, | 2981 | }, |
2969 | }).then(res2 => { | 2982 | }).then(res2 => { |
2970 | if (res2.data.code == 0) { | 2983 | if (res2.data.code == 0) { |
packageB/pages/zuhegou/preindex/index.js
@@ -1745,7 +1745,8 @@ Page({ | @@ -1745,7 +1745,8 @@ Page({ | ||
1745 | goods_id: gd.goods_id, | 1745 | goods_id: gd.goods_id, |
1746 | prom_type: 7, | 1746 | prom_type: 7, |
1747 | prom_id: th.data.act.id, | 1747 | prom_id: th.data.act.id, |
1748 | - isnew:1 | 1748 | + isnew:1, |
1749 | + timetype:gd.viplimited_timetype | ||
1749 | }, | 1750 | }, |
1750 | }).then(res2 => { | 1751 | }).then(res2 => { |
1751 | var g_buy_num = 0; | 1752 | var g_buy_num = 0; |
@@ -2122,7 +2123,8 @@ Page({ | @@ -2122,7 +2123,8 @@ Page({ | ||
2122 | goods_id: item_j.goods_id, | 2123 | goods_id: item_j.goods_id, |
2123 | prom_type: 7, | 2124 | prom_type: 7, |
2124 | prom_id: th.data.act.id, | 2125 | prom_id: th.data.act.id, |
2125 | - isnew:1 | 2126 | + isnew:1, |
2127 | + timetype:item_j.viplimited_timetype | ||
2126 | }, | 2128 | }, |
2127 | }).then(res2 => { | 2129 | }).then(res2 => { |
2128 | if (res2.data.code == 0) { | 2130 | if (res2.data.code == 0) { |
@@ -2199,7 +2201,8 @@ Page({ | @@ -2199,7 +2201,8 @@ Page({ | ||
2199 | goods_id: item_j.goods_id, | 2201 | goods_id: item_j.goods_id, |
2200 | prom_type: 7, | 2202 | prom_type: 7, |
2201 | prom_id: th.data.act.id, | 2203 | prom_id: th.data.act.id, |
2202 | - isnew:1 | 2204 | + isnew:1, |
2205 | + timetype:item_j.viplimited_timetype | ||
2203 | }, | 2206 | }, |
2204 | }).then(res2 => { | 2207 | }).then(res2 => { |
2205 | if (res2.data.code == 0) { | 2208 | if (res2.data.code == 0) { |
packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
@@ -479,7 +479,8 @@ Page({ | @@ -479,7 +479,8 @@ Page({ | ||
479 | goods_id: item1.goods_id, | 479 | goods_id: item1.goods_id, |
480 | prom_type: item1.prom_type, | 480 | prom_type: item1.prom_type, |
481 | prom_id: item1.prom_id, | 481 | prom_id: item1.prom_id, |
482 | - isnew:1 | 482 | + isnew:1, |
483 | + timetype:item1.viplimited_timetype | ||
483 | }, | 484 | }, |
484 | }).then(res => { | 485 | }).then(res => { |
485 | var buy_num_data = res.data.data; | 486 | var buy_num_data = res.data.data; |
packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js
@@ -768,6 +768,8 @@ Page({ | @@ -768,6 +768,8 @@ Page({ | ||
768 | store_id: os.stoid, | 768 | store_id: os.stoid, |
769 | user_id: getApp().globalData.user_id, | 769 | user_id: getApp().globalData.user_id, |
770 | goods_id: good.goods_id, | 770 | goods_id: good.goods_id, |
771 | + timetype:good.viplimited_timetype | ||
772 | + | ||
771 | }; | 773 | }; |
772 | if(b_item.prom_type==7){ | 774 | if(b_item.prom_type==7){ |
773 | req_data.prom_type=7; | 775 | req_data.prom_type=7; |
@@ -839,6 +841,7 @@ Page({ | @@ -839,6 +841,7 @@ Page({ | ||
839 | store_id: os.stoid, | 841 | store_id: os.stoid, |
840 | user_id: getApp().globalData.user_id, | 842 | user_id: getApp().globalData.user_id, |
841 | goods_id: good.goods_id, | 843 | goods_id: good.goods_id, |
844 | + timetype:good.viplimited_timetype | ||
842 | }; | 845 | }; |
843 | 846 | ||
844 | if(prom){ | 847 | if(prom){ |
packageC/pages/payForAnother/payForAnother.js
@@ -447,7 +447,8 @@ Page({ | @@ -447,7 +447,8 @@ Page({ | ||
447 | goods_id: item1.goods_id, | 447 | goods_id: item1.goods_id, |
448 | prom_type: item1.prom_type, | 448 | prom_type: item1.prom_type, |
449 | prom_id: item1.prom_id, | 449 | prom_id: item1.prom_id, |
450 | - isnew:1 | 450 | + isnew:1, |
451 | + timetype:item1.viplimited_timetype | ||
451 | }, | 452 | }, |
452 | }).then(res => { | 453 | }).then(res => { |
453 | var buy_num_data = res.data.data; | 454 | var buy_num_data = res.data.data; |
packageC/pages/presell/cart/cart.js
@@ -3333,7 +3333,8 @@ Page({ | @@ -3333,7 +3333,8 @@ Page({ | ||
3333 | goods_id: good.goods_id, | 3333 | goods_id: good.goods_id, |
3334 | prom_type: good.prom_type, | 3334 | prom_type: good.prom_type, |
3335 | prom_id: good.prom_id, | 3335 | prom_id: good.prom_id, |
3336 | - isnew: 1 | 3336 | + isnew: 1, |
3337 | + timetype:good.viplimited_timetype | ||
3337 | }, | 3338 | }, |
3338 | }).then(res => { | 3339 | }).then(res => { |
3339 | var buy_num_data = res.data.data; | 3340 | var buy_num_data = res.data.data; |
packageC/pages/presell/pregoodsInfo/goodsInfo.js
@@ -2570,7 +2570,8 @@ Page({ | @@ -2570,7 +2570,8 @@ Page({ | ||
2570 | store_id: os.stoid, | 2570 | store_id: os.stoid, |
2571 | user_id: user_id, | 2571 | user_id: user_id, |
2572 | goods_id: gd.goods_id, | 2572 | goods_id: gd.goods_id, |
2573 | - isnew:1 | 2573 | + isnew:1, |
2574 | + timetype:gd.viplimited_timetype | ||
2574 | }, | 2575 | }, |
2575 | success: function (t) { | 2576 | success: function (t) { |
2576 | if (t.data.code == 0) { | 2577 | if (t.data.code == 0) { |
packageD/pages/shop/order_detail/order_detail.js
@@ -341,7 +341,8 @@ Page({ | @@ -341,7 +341,8 @@ Page({ | ||
341 | user_id: getApp().globalData.user_id, | 341 | user_id: getApp().globalData.user_id, |
342 | goods_id: good.goods_id, | 342 | goods_id: good.goods_id, |
343 | prom_type: good.prom_type, | 343 | prom_type: good.prom_type, |
344 | - prom_id: good.prom_id | 344 | + prom_id: good.prom_id, |
345 | + timetype:good.viplimited_timetype | ||
345 | }, | 346 | }, |
346 | }).then(res => { | 347 | }).then(res => { |
347 | var buy_num_data = res.data.data; | 348 | var buy_num_data = res.data.data; |
@@ -1283,6 +1284,7 @@ Page({ | @@ -1283,6 +1284,7 @@ Page({ | ||
1283 | store_id: os.stoid, | 1284 | store_id: os.stoid, |
1284 | user_id: getApp().globalData.user_id, | 1285 | user_id: getApp().globalData.user_id, |
1285 | goods_id: good.goods_id, | 1286 | goods_id: good.goods_id, |
1287 | + timetype:good.viplimited_timetype | ||
1286 | }; | 1288 | }; |
1287 | if(b_item.prom_type==7){ | 1289 | if(b_item.prom_type==7){ |
1288 | req_data.prom_type=7; | 1290 | req_data.prom_type=7; |
@@ -1354,6 +1356,7 @@ Page({ | @@ -1354,6 +1356,7 @@ Page({ | ||
1354 | store_id: os.stoid, | 1356 | store_id: os.stoid, |
1355 | user_id: getApp().globalData.user_id, | 1357 | user_id: getApp().globalData.user_id, |
1356 | goods_id: good.goods_id, | 1358 | goods_id: good.goods_id, |
1359 | + timetype:good.viplimited_timetype | ||
1357 | }; | 1360 | }; |
1358 | 1361 | ||
1359 | if(prom){ | 1362 | if(prom){ |
packageG/pages/team/team_show/team_show.js
@@ -331,13 +331,14 @@ Page({ | @@ -331,13 +331,14 @@ Page({ | ||
331 | var user_id=getApp().globalData.user_id; | 331 | var user_id=getApp().globalData.user_id; |
332 | var promgoodsbuynum=0; | 332 | var promgoodsbuynum=0; |
333 | var goodsbuynum=0; | 333 | var goodsbuynum=0; |
334 | - getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { | 334 | + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { |
335 | data: { | 335 | data: { |
336 | store_id: os.stoid, | 336 | store_id: os.stoid, |
337 | user_id: user_id, | 337 | user_id: user_id, |
338 | goods_id: gd.goods_id, | 338 | goods_id: gd.goods_id, |
339 | - prom_type: gd.prom_type, | ||
340 | - prom_id: gd.prom_id, isnew:1 | 339 | + prom_type: 6, |
340 | + prom_id: th.data.teamlist.id, isnew:1, | ||
341 | + timetype:gd.viplimited_timetype | ||
341 | 342 | ||
342 | }, | 343 | }, |
343 | }).then(res=>{ | 344 | }).then(res=>{ |
@@ -349,15 +350,18 @@ Page({ | @@ -349,15 +350,18 @@ Page({ | ||
349 | //先判断限购 | 350 | //先判断限购 |
350 | if (num+goodsbuynum>gd.viplimited && gd.viplimited>0) { | 351 | if (num+goodsbuynum>gd.viplimited && gd.viplimited>0) { |
351 | getApp().confirmBox("超出商品限购"); | 352 | getApp().confirmBox("超出商品限购"); |
353 | + th.inp_val(gd.viplimited-goodsbuynum); | ||
352 | return false; | 354 | return false; |
353 | } | 355 | } |
354 | if (num+promgoodsbuynum>th.data.teamlist.buy_limit && th.data.teamlist.buy_limit>0) { | 356 | if (num+promgoodsbuynum>th.data.teamlist.buy_limit && th.data.teamlist.buy_limit>0) { |
355 | getApp().confirmBox("超出活动限购"); | 357 | getApp().confirmBox("超出活动限购"); |
358 | + th.inp_val(th.data.teamlist.buy_limit-promgoodsbuynum); | ||
356 | return false; | 359 | return false; |
357 | } | 360 | } |
358 | //判断库存 | 361 | //判断库存 |
359 | if ( num>gd.store_count) { | 362 | if ( num>gd.store_count) { |
360 | getApp().confirmBox("超出商品库存"); | 363 | getApp().confirmBox("超出商品库存"); |
364 | + th.inp_val(gd.store_count); | ||
361 | return false; | 365 | return false; |
362 | } | 366 | } |
363 | var r_num=0; | 367 | var r_num=0; |
@@ -372,6 +376,7 @@ Page({ | @@ -372,6 +376,7 @@ Page({ | ||
372 | //--判断库存--- | 376 | //--判断库存--- |
373 | if ( num>r_num) { | 377 | if ( num>r_num) { |
374 | getApp().confirmBox("超出商品库存"); | 378 | getApp().confirmBox("超出商品库存"); |
379 | + th.inp_val(r_num); | ||
375 | return false; | 380 | return false; |
376 | } | 381 | } |
377 | 382 | ||
@@ -380,11 +385,12 @@ Page({ | @@ -380,11 +385,12 @@ Page({ | ||
380 | minusStatus: minusStatus, | 385 | minusStatus: minusStatus, |
381 | }) | 386 | }) |
382 | 387 | ||
388 | + return true; | ||
389 | + | ||
383 | }, | 390 | }, |
384 | 391 | ||
385 | - /*输入框事件*/ | ||
386 | - bindManual: function(e) { | ||
387 | - var num = e.detail.value; | 392 | + inp_val(num){ |
393 | + if(!num || num<1) num=1; | ||
388 | var minusStatus = num > 1 ? 'normal' : 'disable'; | 394 | var minusStatus = num > 1 ? 'normal' : 'disable'; |
389 | this.setData({ | 395 | this.setData({ |
390 | num: num, | 396 | num: num, |
@@ -392,6 +398,17 @@ Page({ | @@ -392,6 +398,17 @@ Page({ | ||
392 | }) | 398 | }) |
393 | }, | 399 | }, |
394 | 400 | ||
401 | + /*输入框事件*/ | ||
402 | + bindManual: async function(e) { | ||
403 | + var num = e.detail.value; | ||
404 | + var minusStatus = num > 1 ? 'normal' : 'disable'; | ||
405 | + // this.setData({ | ||
406 | + // num: num, | ||
407 | + // minusStatus: minusStatus | ||
408 | + // }) | ||
409 | + this.check_num(num,minusStatus); | ||
410 | + }, | ||
411 | + | ||
395 | //---------------初始化代码---------------- | 412 | //---------------初始化代码---------------- |
396 | async init(tg_id) { | 413 | async init(tg_id) { |
397 | var goods_id = 0, //商品ID, | 414 | var goods_id = 0, //商品ID, |
@@ -898,6 +915,10 @@ Page({ | @@ -898,6 +915,10 @@ Page({ | ||
898 | 915 | ||
899 | //购买前的判断redis | 916 | //购买前的判断redis |
900 | async buy_check_redis(func){ | 917 | async buy_check_redis(func){ |
918 | + | ||
919 | + var ck= await this.check_num(this.data.num,1); | ||
920 | + if(!ck) return false; | ||
921 | + | ||
901 | //获取redis中的数量 | 922 | //获取redis中的数量 |
902 | var r_num=0,prom_type=6,prom_id=this.data.teamlist.id; | 923 | var r_num=0,prom_type=6,prom_id=this.data.teamlist.id; |
903 | await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | 924 | await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { |