Commit 8834c259ac3de5c95169f31537706ea39b71bfeb

Authored by 后端研发-苏泰源
1 parent d372f4b3

服务卡秒杀修改

packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -949,7 +949,7 @@ Page({
949 949 pick_id: th.data.sto_sele_id,
950 950 user_id:oo.user_id,
951 951 store_id:os.stoid,
952   - money:th.data.data.shop_price
  952 + money:th.data.data.shop_price,
953 953 };
954 954 if(getApp().globalData.guide_id) {
955 955 newd['guide_id'] = getApp().globalData.guide_id;
... ... @@ -957,8 +957,11 @@ Page({
957 957 };
958 958 // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价
959 959 if(th.data.options.prom_type == 1) {
  960 + newd['prom_type'] = th.data.options.prom_type;
  961 + newd['prom_id'] = th.data.options.prom_id;
960 962 if(th.data.openSpecModal_flash_normal) {
961 963 newd['money'] = th.data.data.shop_price;
  964 + newd['is_pd_normal'] = 1;
962 965 } else {
963 966 newd['money'] = th.data.prom_price;
964 967 };
... ... @@ -987,8 +990,11 @@ Page({
987 990  
988 991 // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价
989 992 if(th.data.options.prom_type == 1) {
  993 + // updata['prom_type'] = th.data.options.prom_type;
  994 + // updata['prom_id'] = th.data.options.prom_id;
990 995 if(th.data.openSpecModal_flash_normal) {
991 996 updata['money'] = th.data.data.shop_price;
  997 + updata['is_pd_normal'] = 1;
992 998 } else {
993 999 updata['money'] = th.data.prom_price;
994 1000 };
... ... @@ -1367,7 +1373,7 @@ Page({
1367 1373  
1368 1374  
1369 1375 var url="/packageA/pages/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
1370   - if(getApp().globalData.user_id){
  1376 + if(getApp().globalData.user_id) {
1371 1377 url+="&first_leader="+getApp().globalData.user_id;
1372 1378 }
1373 1379  
... ... @@ -3436,63 +3442,6 @@ Page({
3436 3442 "function" == typeof func && func();
3437 3443 };
3438 3444  
3439   - // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
3440   - // data: {
3441   - // store_id: os.stoid,
3442   - // user_id: user_id,
3443   - // card_id: gd.goods_id,
3444   - // prom_type: th.data.options.prom_type,
3445   - // prom_id: th.data.options.prom_id,
3446   - // },
3447   - // success: function (t) {
3448   - // if (t.data.code == 0) {
3449   - // // var g_buy_num = t.data.data.goodsbuynum;
3450   -
3451   - // //如果是秒杀的时候
3452   - // // if (th.data.prom_type == 0 && gd.prom_type == 1) {
3453   - // // gd.prom_type = 0;
3454   - // // }
3455   - // // //如果全场优惠,商品做了秒杀
3456   - // // if (th.data.prom_type == 3 && gd.prom_type == 1) {
3457   - // // gd.prom_type = 0;
3458   - // // }
3459   - // // //如果全场阶梯优惠,商品做了秒杀
3460   - // // if (th.data.prom_type == 10 && gd.prom_type == 1) {
3461   - // // gd.prom_type = 0;
3462   - // // }
3463   -
3464   -
3465   - // if (th.data.prom_type == 1) {
3466   - // //----获取活动购买数----
3467   - // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
3468   - // data: {
3469   - // store_id: os.stoid,
3470   - // user_id: user_id,
3471   - // card_id: th.data.options.goods_id,
3472   - // prom_type: th.data.options.prom_type,
3473   - // prom_id: th.data.options.prom_id
3474   - // },
3475   - // //-----获取-----
3476   - // success: function (tt) {
3477   - // if (tt.data.code == 0) {
3478   - // // map.set(gd.goods_id, g_buy_num);
3479   - // th.setData({
3480   - // // g_buy_num: map,
3481   - // promcardbuynum: tt.data.data.promcardbuynum,
3482   - // cardbuynum: t.data.data.cardbuynum,
3483   - // });
3484   - // "function" == typeof func && func();
3485   - // }
3486   - // }
3487   - // });
3488   - // } else {
3489   - // "function" == typeof func && func();
3490   - // };
3491   - // }
3492   - // },
3493   -
3494   - // });
3495   - // }
3496 3445 },
3497 3446  
3498 3447  
... ... @@ -4059,7 +4008,7 @@ Page({
4059 4008 getApp().goto("/pages/cart/cart2/cart2?state=1");
4060 4009 }
4061 4010 });
4062   - }
  4011 + },
4063 4012 })
4064 4013 return false;
4065 4014 }
... ...
pages/cart/cart/cart.js
... ... @@ -1082,6 +1082,15 @@ Page({
1082 1082 id: e.id,
1083 1083 store_id: oo.stoid
1084 1084 };
  1085 + if(a.prom_type) {
  1086 + s.prom_type = a.prom_type;
  1087 + };
  1088 + if(a.prom_id) {
  1089 + s.prom_id = a.prom_id;
  1090 + };
  1091 + if(a.is_pd_normal) {
  1092 + s.is_pd_normal = a.is_pd_normal;
  1093 + };
1085 1094 th.postCardList_ser(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1086 1095 }
1087 1096 },
... ... @@ -1098,9 +1107,19 @@ Page({
1098 1107 var e = {
1099 1108 goods_num: a.goods_num + 1,
1100 1109 id: a.id,
1101   - goods_id: a.goods_id,
1102   - store_id: oo.stoid
  1110 + goods_id: a.service_id,
  1111 + store_id: oo.stoid,
  1112 + card_id: a.service_id,
1103 1113 };
  1114 + if(a.prom_type) {
  1115 + e.prom_type = a.prom_type;
  1116 + };
  1117 + if(a.prom_id) {
  1118 + e.prom_id = a.prom_id;
  1119 + };
  1120 + if(a.is_pd_normal) {
  1121 + e.is_pd_normal = a.is_pd_normal;
  1122 + };
1104 1123 this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1105 1124  
1106 1125 },
... ... @@ -1987,7 +2006,7 @@ Page({
1987 2006 },
1988 2007  
1989 2008 //----------------------更新购物数量,加减,调用接口---------------------
1990   - postCardList_ser: function (t, item, pitem) {
  2009 + postCardList_ser: async function (t, item, pitem) {
1991 2010 var e = this,
1992 2011 th = e;
1993 2012 var user_id = getApp().globalData.user_id;
... ... @@ -1995,9 +2014,112 @@ Page({
1995 2014 e.setData({
1996 2015 [txt]: t.goods_num
1997 2016 });
1998   - e.doCheckAll();
1999   - e.update_cart_ser(t, pitem, item);
  2017 + // if(t.prom_type == 1) {
  2018 +
  2019 + // } else {
  2020 +
  2021 +
  2022 + // };
  2023 + if(t.prom_type == 1) {
  2024 + await e.checkCartNum(t, item, pitem);
  2025 + }
  2026 +
  2027 + await e.doCheckAll();
  2028 + await e.update_cart_ser(t, pitem, item);
  2029 +
  2030 +
2000 2031 },
  2032 +
  2033 +
  2034 + // 检查购物车数量
  2035 + async checkCartNum(t, item, pitem) {
  2036 + var th = this;
  2037 + if(t.is_pd_normal) return false;
  2038 + if (t.prom_type == 1) {
  2039 + var txt = "service_data[" + pitem + "].goods[" + item + "].goods_num";
  2040 + var redis_num = 0;
  2041 + //------判断活动是否抢光-----
  2042 + // await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  2043 + // t.store_id + "/" + t.prom_type + "/" + t.prom_id, {
  2044 + // 1: 1
  2045 + // }).then(res => {
  2046 + // redis_num = res.data.data;
  2047 + // if(redis_num == 0) {
  2048 + // wx.showModal({
  2049 + // title: '来晚了,已被抢光~',
  2050 + // });
  2051 + // return false;
  2052 + // };
  2053 + // if(t.goods_num > redis_num) {
  2054 + // wx.showModal({
  2055 + // title: '超出商品活动限购数量2',
  2056 + // // title: '来晚了,已被抢光~',
  2057 + // });
  2058 + // // th.setData({goodsInputNum: redis_num})
  2059 + // return false;
  2060 + // };
  2061 + // });
  2062 +
  2063 +
  2064 +
  2065 + //----获取活动购买数----
  2066 + await getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  2067 + data: {
  2068 + store_id: t.store_id,
  2069 + user_id: getApp().globalData.user_id,
  2070 + card_id: t.goods_id,
  2071 + prom_type: t.prom_type,
  2072 + prom_id: t.prom_id
  2073 + },
  2074 + //-----获取-----
  2075 + success: function (tt) {
  2076 + if (tt.data.code == 0) {
  2077 + th.setData({
  2078 + promcardbuynum: tt.data.data.promcardbuynum,
  2079 + cardbuynum: tt.data.data.cardbuynum,
  2080 + });
  2081 + };
  2082 + },
  2083 +
  2084 + });
  2085 +
  2086 +
  2087 +
  2088 + await getApp().request.get("/api/ms/flash_sale/getNew/" + t.store_id + "/" + getApp().globalData.user_id + "/" + t.prom_id, {
  2089 + success: function (res) {
  2090 + if(res.data.code == 0) {
  2091 + th.data.sele_g = res.data.data;
  2092 + th.data.sele_g.viplimited = res.data.data.buy_limit;
  2093 + //--秒杀:判断商品是否超出活动限购--
  2094 + if (th.data.sele_g.viplimited > 0) {
  2095 + var gd_buy_num = th.data.promcardbuynum;
  2096 +
  2097 + if (t.goods_num + gd_buy_num> th.data.sele_g.viplimited) {
  2098 + wx.showModal({
  2099 + title: '超出活动限购数量',
  2100 + });
  2101 +
  2102 + var num = th.data.sele_g.viplimited - gd_buy_num;
  2103 + if (num <= 0) num = 1;
  2104 +
  2105 + th.setData({
  2106 + [txt]: num,
  2107 + gdnum: num,
  2108 + });
  2109 + t.goods_num = num;
  2110 + th.doCheckAll();
  2111 + th.update_cart_ser(t, pitem, item);
  2112 + // return false;
  2113 + }
  2114 + };
  2115 +
  2116 + };
  2117 + },
  2118 + });
  2119 +
  2120 +
  2121 + };
  2122 + },
2001 2123  
2002 2124  
2003 2125  
... ... @@ -2117,6 +2239,10 @@ Page({
2117 2239 //--更新购物车---
2118 2240 update_cart_ser: function (t, pitem, item) {
2119 2241 var e = this;
  2242 + // if(t.prom_type == 1) {
  2243 + // t.goods_num = e.data.gdnum;
  2244 + // }
  2245 + console.log('t===>', t);
2120 2246 getApp().request.put("/api/weshop/cartService/update", {
2121 2247 data: t,
2122 2248 success: async function (ee) {
... ... @@ -2876,6 +3002,14 @@ Page({
2876 3002 getApp().goto(good_url);
2877 3003 }
2878 3004 })
2879   - }
  3005 + },
  3006 +
  3007 +
  3008 +
  3009 +
  3010 +
  3011 +
  3012 +
  3013 +
2880 3014  
2881 3015 });
2882 3016 \ No newline at end of file
... ...