Commit 1ca5e1b63ae40f6520c636af5e46dfa89ce6268b

Authored by 泉州测试
1 parent 296ab86e

fix优化购物车多门店问题

packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -895,15 +895,19 @@ Page({
895 895  
896 896 // 购物车
897 897 if (action != "buy") {
898   - await getApp().request.promiseGet("/api/weshop/cartService/page?store_id="+os.stoid+"&user_id="+oo.user_id+"&service_id="+th.data.data.id+"&pick_id="+th.data.sto_sele_id,
  898 + await getApp().request.promiseGet("/api/weshop/cartService/page?store_id="+os.stoid+"&user_id="+oo.user_id+"&service_id="+th.data.data.id,
899 899 { }).then(res => {
900 900 if (res.data.data.pageData.length > 0) {
901   - const tmpObj = res.data.data.pageData[0];
902   - cartGoodsNum = !tmpObj.goods_num ? 0 : tmpObj.goods_num;
  901 + const tmpObj = res.data.data.pageData;
  902 +
  903 + tmpObj.forEach(v => {
  904 + cartGoodsNum += parseInt(v.goods_num);
  905 + });
  906 +
903 907 }
904 908  
905 909 });
906   -
  910 +
907 911 // 输入的数量 + 购物车同款商品的数量
908 912 t = parseInt(t) + parseInt(cartGoodsNum);
909 913 }
... ... @@ -1014,7 +1018,13 @@ Page({
1014 1018 // console.log('newd++++++++', newd);
1015 1019 th.buyNow(newd);
1016 1020 } else { // 购物车
1017   -
  1021 +
  1022 + // 购买数量大于0的才能加入到购物车
  1023 + if (th.data.goodsInputNum <= 0) {
  1024 + th.closeSpecModal();
  1025 + return false;
  1026 + }
  1027 +
1018 1028 var newd = {
1019 1029 service_id: th.data.data.id,
1020 1030 service_sn:th.data.data.service_sn,
... ...