Merged
Merge Request #990 · created by 后端研发-苏明海


Dev


From dev into test

Merged by 后端研发-苏明海

1 participants

packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -897,7 +897,7 @@ Page({
897 897 canBuyNum = 0;
898 898 };
899 899  
900   - if(limited > res) {
  900 + if(canBuyNum > res) {
901 901 if(curNum > res) { // t当前增减的数量
902 902 wx.showModal({
903 903 title: '超出活动库存',
... ... @@ -909,8 +909,8 @@ Page({
909 909 };
910 910 };
911 911  
912   - if(limited <= res) {
913   - if(curNum > limited) {
  912 + if(canBuyNum <= res) {
  913 + if(curNum > canBuyNum) {
914 914 wx.showModal({
915 915 title: '超出限购数量',
916 916 });
... ... @@ -996,13 +996,66 @@ Page({
996 996 store_id: os.stoid,
997 997 user_id: oo.user_id,
998 998 service_id: th.data.data.id,
999   - pick_id: th.data.sto_sele_id,
1000 999 },
1001 1000 success: function(re) {
1002   -
1003   - //-------如果购物车中有相关的数据---------
  1001 + //-------如果购物车中有相关的数据---------
1004 1002 if (re.data.data.total > 0) {
1005   - var item = re.data.data.pageData[0];
  1003 + var item = null;
  1004 + // 多门店问题
  1005 + var cartGoodsNum = 0;
  1006 + const tmpObj = re.data.data.pageData;
  1007 + for (let i = 0; i < tmpObj.length; i++) {
  1008 + if (th.data.sto_sele_id != tmpObj[i].pick_id) {
  1009 + cartGoodsNum += parseInt(tmpObj[i].goods_num);
  1010 + } else {
  1011 + item = tmpObj[i];
  1012 + }
  1013 + }
  1014 + // 当前门店同类商品还没加入到购物车 但是有其他门店的同类商品
  1015 + if (th.data.prom_type == 1 && !th.data.is_normal && !item) {
  1016 +
  1017 + // 秒杀购物车购买 修正数量
  1018 + var snum = limitNum - boughtNum;
  1019 + if (snum <= 0) {
  1020 + wx.showModal({
  1021 + title: '超出限购数量',
  1022 + });
  1023 + return false;
  1024 + }
  1025 +
  1026 + var cSnum = snum- cartGoodsNum <= 0 ? 0 : snum- cartGoodsNum;
  1027 + var cRedisNums = redisNums- cartGoodsNum <= 0 ? 0 : redisNums- cartGoodsNum;
  1028 +
  1029 + if (newd['goods_num'] >= redisNums){
  1030 + if (redisNums > snum) {
  1031 + newd['goods_num'] = cSnum;
  1032 + } else {
  1033 + newd['goods_num'] = cRedisNums;
  1034 + }
  1035 + } else {
  1036 + if (newd['goods_num'] > snum) newd['goods_num'] = cSnum;
  1037 + }
  1038 +
  1039 + if (newd['goods_num'] <= 0) {
  1040 + getApp().my_warnning('加入购物车成功', 1, th, 450);
  1041 + th.closeSpecModal();
  1042 + return false;
  1043 + }
  1044 + getApp().request.post("/api/weshop/cartService/save", {
  1045 + data: newd,
  1046 + success: function(t) {
  1047 + getApp().my_warnning('加入购物车成功', 1, th, 450);
  1048 + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
  1049 + th.setData({
  1050 + cartGoodsNum: c_num
  1051 + });
  1052 + th.closeSpecModal();
  1053 + }
  1054 + });
  1055 + return false;
  1056 + }
  1057 +
  1058 + // 以下为当前门店同类商品已经加入到购物车
1006 1059 var totalNum = th.data.goodsInputNum + item.goods_num;
1007 1060  
1008 1061 // 秒杀购物车购买 修正数量
... ... @@ -1016,13 +1069,13 @@ Page({
1016 1069 }
1017 1070 if (totalNum >= redisNums){
1018 1071 if (redisNums > snum) {
1019   - totalNum = snum;
  1072 + totalNum = snum- cartGoodsNum;
1020 1073 } else {
1021   - totalNum = redisNums;
  1074 + totalNum = redisNums- cartGoodsNum;
1022 1075 }
1023 1076 } else {
1024 1077 if (totalNum > snum)
1025   - totalNum = snum;
  1078 + totalNum = snum- cartGoodsNum;
1026 1079 }
1027 1080 }
1028 1081  
... ... @@ -1061,7 +1114,6 @@ Page({
1061 1114 }
1062 1115 });
1063 1116 } else {
1064   -
1065 1117 getApp().request.post("/api/weshop/cartService/save", {
1066 1118 data: newd,
1067 1119 success: function(t) {
... ... @@ -3575,6 +3627,17 @@ Page({
3575 3627  
3576 3628 //-- 秒杀的普通购买 --
3577 3629 openSpecModel_Nor: function () {
  3630 +
  3631 + // 是否授权登陆
  3632 + var user_info = getApp().globalData.userInfo;
  3633 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  3634 + wx.navigateTo({
  3635 + url: '/pages/togoin/togoin',
  3636 + })
  3637 + return false;
  3638 + }
  3639 +
  3640 +
3578 3641 this.data.g_buy_num = new Map();
3579 3642 var th = this;
3580 3643 this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4
... ...