Commit 81d8932b60553540e9c815a328569741dba97dbd

Authored by yvan.ni
1 parent 165dd04f

限购的优化

components/add_purchase/add_purchase.js
... ... @@ -3131,7 +3131,8 @@ Component({
3131 3131 data: {
3132 3132 store_id: os.stoid,
3133 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 3137 success: function (t) {
3137 3138 if (t.data.code == 0) {
... ...
packageA/pages/prom_list/prom_list.js
... ... @@ -783,7 +783,7 @@ Page({
783 783 });
784 784  
785 785 var num= th.data.data.viplimited-gd_buy_num;
786   - if(num<0) num=0;
  786 + if(num<=0) num=1
787 787 th.setData({goodsInputNum:num})
788 788 return false;
789 789 }
... ... @@ -797,7 +797,7 @@ Page({
797 797 });
798 798  
799 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 801 th.setData({goodsInputNum:num})
802 802 return false;
803 803 }
... ... @@ -1472,7 +1472,8 @@ Page({
1472 1472 store_id: os.stoid,
1473 1473 user_id: user_id,
1474 1474 goods_id: gd.goods_id,
1475   - isnew:1
  1475 + isnew:1,
  1476 + timetype:gd.viplimited_timetype
1476 1477 },
1477 1478 success: function(t) {
1478 1479 if (t.data.code == 0) {
... ...
packageB/pages/zuhegou/index/index.js
... ... @@ -869,7 +869,7 @@ Page({
869 869 //开始调用接口
870 870 getApp().request.get(url, {
871 871 data: req_data,
872   - success: function (res) {
  872 + success: async function (res) {
873 873 th.data.loading = 0;
874 874 th.setData({
875 875 is_get: 1
... ... @@ -879,6 +879,16 @@ Page({
879 879 var list = th.data.list;
880 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 893 if (th.data.page > 1 && th.data.cart_list) {
884 894 //下拉之后也要重新计算一下金额
... ... @@ -2392,7 +2402,8 @@ Page({
2392 2402 goods_id: gd.goods_id,
2393 2403 prom_type: 7,
2394 2404 prom_id: th.data.act.id,
2395   - isnew:1
  2405 + isnew:1,
  2406 + timetype:gd.viplimited_timetype
2396 2407 },
2397 2408 }).then(res2 => {
2398 2409 var g_buy_num = 0;
... ... @@ -2887,7 +2898,8 @@ Page({
2887 2898 goods_id: item_j.goods_id,
2888 2899 prom_type: 7,
2889 2900 prom_id: th.data.act.id,
2890   - isnew:1
  2901 + isnew:1,
  2902 + timetype:item_j.viplimited_timetype
2891 2903 },
2892 2904 }).then(res2 => {
2893 2905 if (res2.data.code == 0) {
... ... @@ -2964,7 +2976,8 @@ Page({
2964 2976 goods_id: item_j.goods_id,
2965 2977 prom_type: 7,
2966 2978 prom_id: th.data.act.id,
2967   - isnew:1
  2979 + isnew:1,
  2980 + timetype:item_j.viplimited_timetype
2968 2981 },
2969 2982 }).then(res2 => {
2970 2983 if (res2.data.code == 0) {
... ...
packageB/pages/zuhegou/preindex/index.js
... ... @@ -1745,7 +1745,8 @@ Page({
1745 1745 goods_id: gd.goods_id,
1746 1746 prom_type: 7,
1747 1747 prom_id: th.data.act.id,
1748   - isnew:1
  1748 + isnew:1,
  1749 + timetype:gd.viplimited_timetype
1749 1750 },
1750 1751 }).then(res2 => {
1751 1752 var g_buy_num = 0;
... ... @@ -2122,7 +2123,8 @@ Page({
2122 2123 goods_id: item_j.goods_id,
2123 2124 prom_type: 7,
2124 2125 prom_id: th.data.act.id,
2125   - isnew:1
  2126 + isnew:1,
  2127 + timetype:item_j.viplimited_timetype
2126 2128 },
2127 2129 }).then(res2 => {
2128 2130 if (res2.data.code == 0) {
... ... @@ -2199,7 +2201,8 @@ Page({
2199 2201 goods_id: item_j.goods_id,
2200 2202 prom_type: 7,
2201 2203 prom_id: th.data.act.id,
2202   - isnew:1
  2204 + isnew:1,
  2205 + timetype:item_j.viplimited_timetype
2203 2206 },
2204 2207 }).then(res2 => {
2205 2208 if (res2.data.code == 0) {
... ...
packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
... ... @@ -479,7 +479,8 @@ Page({
479 479 goods_id: item1.goods_id,
480 480 prom_type: item1.prom_type,
481 481 prom_id: item1.prom_id,
482   - isnew:1
  482 + isnew:1,
  483 + timetype:item1.viplimited_timetype
483 484 },
484 485 }).then(res => {
485 486 var buy_num_data = res.data.data;
... ...
packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js
... ... @@ -768,6 +768,8 @@ Page({
768 768 store_id: os.stoid,
769 769 user_id: getApp().globalData.user_id,
770 770 goods_id: good.goods_id,
  771 + timetype:good.viplimited_timetype
  772 +
771 773 };
772 774 if(b_item.prom_type==7){
773 775 req_data.prom_type=7;
... ... @@ -839,6 +841,7 @@ Page({
839 841 store_id: os.stoid,
840 842 user_id: getApp().globalData.user_id,
841 843 goods_id: good.goods_id,
  844 + timetype:good.viplimited_timetype
842 845 };
843 846  
844 847 if(prom){
... ...
packageC/pages/payForAnother/payForAnother.js
... ... @@ -447,7 +447,8 @@ Page({
447 447 goods_id: item1.goods_id,
448 448 prom_type: item1.prom_type,
449 449 prom_id: item1.prom_id,
450   - isnew:1
  450 + isnew:1,
  451 + timetype:item1.viplimited_timetype
451 452 },
452 453 }).then(res => {
453 454 var buy_num_data = res.data.data;
... ...
packageC/pages/presell/cart/cart.js
... ... @@ -3333,7 +3333,8 @@ Page({
3333 3333 goods_id: good.goods_id,
3334 3334 prom_type: good.prom_type,
3335 3335 prom_id: good.prom_id,
3336   - isnew: 1
  3336 + isnew: 1,
  3337 + timetype:good.viplimited_timetype
3337 3338 },
3338 3339 }).then(res => {
3339 3340 var buy_num_data = res.data.data;
... ...
packageC/pages/presell/pregoodsInfo/goodsInfo.js
... ... @@ -2570,7 +2570,8 @@ Page({
2570 2570 store_id: os.stoid,
2571 2571 user_id: user_id,
2572 2572 goods_id: gd.goods_id,
2573   - isnew:1
  2573 + isnew:1,
  2574 + timetype:gd.viplimited_timetype
2574 2575 },
2575 2576 success: function (t) {
2576 2577 if (t.data.code == 0) {
... ...
packageD/pages/shop/order_detail/order_detail.js
... ... @@ -341,7 +341,8 @@ Page({
341 341 user_id: getApp().globalData.user_id,
342 342 goods_id: good.goods_id,
343 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 347 }).then(res => {
347 348 var buy_num_data = res.data.data;
... ... @@ -1283,6 +1284,7 @@ Page({
1283 1284 store_id: os.stoid,
1284 1285 user_id: getApp().globalData.user_id,
1285 1286 goods_id: good.goods_id,
  1287 + timetype:good.viplimited_timetype
1286 1288 };
1287 1289 if(b_item.prom_type==7){
1288 1290 req_data.prom_type=7;
... ... @@ -1354,6 +1356,7 @@ Page({
1354 1356 store_id: os.stoid,
1355 1357 user_id: getApp().globalData.user_id,
1356 1358 goods_id: good.goods_id,
  1359 + timetype:good.viplimited_timetype
1357 1360 };
1358 1361  
1359 1362 if(prom){
... ...
packageG/pages/team/team_show/team_show.js
... ... @@ -331,13 +331,14 @@ Page({
331 331 var user_id=getApp().globalData.user_id;
332 332 var promgoodsbuynum=0;
333 333 var goodsbuynum=0;
334   - getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  334 + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
335 335 data: {
336 336 store_id: os.stoid,
337 337 user_id: user_id,
338 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 344 }).then(res=>{
... ... @@ -349,15 +350,18 @@ Page({
349 350 //先判断限购
350 351 if (num+goodsbuynum>gd.viplimited && gd.viplimited>0) {
351 352 getApp().confirmBox("超出商品限购");
  353 + th.inp_val(gd.viplimited-goodsbuynum);
352 354 return false;
353 355 }
354 356 if (num+promgoodsbuynum>th.data.teamlist.buy_limit && th.data.teamlist.buy_limit>0) {
355 357 getApp().confirmBox("超出活动限购");
  358 + th.inp_val(th.data.teamlist.buy_limit-promgoodsbuynum);
356 359 return false;
357 360 }
358 361 //判断库存
359 362 if ( num>gd.store_count) {
360 363 getApp().confirmBox("超出商品库存");
  364 + th.inp_val(gd.store_count);
361 365 return false;
362 366 }
363 367 var r_num=0;
... ... @@ -372,6 +376,7 @@ Page({
372 376 //--判断库存---
373 377 if ( num>r_num) {
374 378 getApp().confirmBox("超出商品库存");
  379 + th.inp_val(r_num);
375 380 return false;
376 381 }
377 382  
... ... @@ -380,11 +385,12 @@ Page({
380 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 394 var minusStatus = num > 1 ? 'normal' : 'disable';
389 395 this.setData({
390 396 num: num,
... ... @@ -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 413 async init(tg_id) {
397 414 var goods_id = 0, //商品ID,
... ... @@ -898,6 +915,10 @@ Page({
898 915  
899 916 //购买前的判断redis
900 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 922 //获取redis中的数量
902 923 var r_num=0,prom_type=6,prom_id=this.data.teamlist.id;
903 924 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
... ...