Commit 2dcbeb36ebe424f9192c88b9f992082e65af491a

Authored by yvan.ni
1 parent 85254bb9

组合购多余的商品有店铺优惠的时候的bug优化

pages/cart/cart/cart.js
... ... @@ -828,7 +828,7 @@ Page({
828 828  
829 829 //---------------全选,全选的时候要判断是否门店的匹配方式一致--------------
830 830 checkAll: function() {
831   - var e = this,
  831 + var e = this,th=this,
832 832 dda = e.data.requestData,
833 833 sdda = e.data.service_data,
834 834 tfeel = 0,
... ... @@ -846,11 +846,17 @@ Page({
846 846  
847 847 this.data.btn_click=1;
848 848  
  849 +
  850 +
  851 + var offline_price=0;
  852 + var offline_num=0;
  853 +
  854 +
849 855 if(dda && dda.length>0){
850 856 for (var i = 0; i < dda.length; i++) {
851 857 var item = dda[i].goods;
852 858  
853   - if (!e.data.checkAllToggle) {
  859 + if (e.data.checkAllToggle) {
854 860 var txt = "requestData[" + i + "].selected";
855 861 e.setData({
856 862 [txt]: 0,
... ... @@ -889,6 +895,13 @@ Page({
889 895 tfeel += item[j].goods_num * item[j].goods_price;
890 896 t_num += item[j].goods_num;
891 897 }
  898 +
  899 + //-- 如果这个商品是线下取价的时候 --
  900 + if(item[j].is_offline && item[j].prom_type!=7){
  901 + offline_price+= (item[j].goods_price-item[j].offline_price)*item[j].goods_num;
  902 + offline_num+=item[j].goods_num;
  903 + }
  904 +
892 905 }
893 906 }
894 907  
... ... @@ -900,13 +913,42 @@ Page({
900 913 });
901 914 return false;
902 915 } else {
903   -
  916 +
904 917 for (var i = 0; i < dda.length; i++) {
  918 +
  919 + if (!e.data.checkAllToggle) {
  920 + var txt = "requestData[" + i + "].selected";
  921 + e.setData({
  922 + [txt]: 1,
  923 + });
  924 + }
  925 +
905 926 //总的价格,把组合商品的价格拿出来
906 927 var zh_calc_res=zh_calc.calculate_zh(dda,i,this);
907 928 tfeel+=zh_calc_res.tfeel;
  929 + offline_price+=zh_calc_res.offline_price;
  930 + offline_num+=zh_calc_res.offline_num;
  931 +
  932 + //当有线下取价的时候
  933 + if(offline_price){
  934 + var txt1= "requestData[" + i + "].offline_price";
  935 + var txt2= "requestData[" + i+ "].offline_num";
  936 + th.setData({
  937 + [txt1]: offline_price.toFixed(2),
  938 + [txt2]: offline_num,
  939 + });
  940 + }else{
  941 + if(dda[i].offline_price>0){
  942 + var txt1= "requestData[" + i + "].offline_price";
  943 + var txt2= "requestData[" + i + "].offline_num";
  944 + th.setData({
  945 + [txt1]: 0,
  946 + [txt2]: 0
  947 + });
  948 + }
  949 + }
908 950 }
909   -
  951 +
910 952 e.setData({
911 953 checkAllToggle: !e.data.checkAllToggle,
912 954 total_fee: tfeel.toFixed(2),
... ... @@ -922,7 +964,7 @@ Page({
922 964 if(sdda && sdda.length>0){
923 965 for (var i = 0; i < sdda.length; i++) {
924 966 var item = sdda[i].goods;
925   - if (!e.data.checkAllToggle) {
  967 + if (e.data.checkAllToggle) {
926 968 var txt = "service_data[" + i + "].selected";
927 969 e.setData({
928 970 [txt]: 0,
... ...
pages/cart/cart2/cart2.js
... ... @@ -2324,8 +2324,8 @@ Page({
2324 2324 'store_id': oo.stoid,
2325 2325 };
2326 2326  
2327   - //-- 线下取价也要写入 --
2328   - if (g_item.offline_price && t_item.is_offline == 1) {
  2327 + //-- 线下取价也要写入,组合购的商品不能去线下价格 --
  2328 + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) {
2329 2329 goods.goods_price = g_item.offline_price;
2330 2330 goods.member_goods_price = g_item.offline_price;
2331 2331 goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
... ...
pages/cart/cart2/zh_calculate.js
... ... @@ -42,14 +42,14 @@ module.exports = {
42 42 if (item.num > item.zhqty) {
43 43 for (let i = 0; i < item.num - item.zhqty; i++) {
44 44 no_in_arr.push({
45   - price: item.goods_price, goods_id: item.goods_id, offline_price: item.offline_price
  45 + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
46 46 })
47 47 }
48 48 }
49 49 } else {
50 50 for (let j = 0; j < item.num; j++) {
51 51 no_in_arr.push({
52   - price: item.goods_price, goods_id: item.goods_id, offline_price: item.offline_price
  52 + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price
53 53 })
54 54 }
55 55 }
... ... @@ -92,7 +92,7 @@ module.exports = {
92 92 for (let ii in no_in_arr) {
93 93 let item = no_in_arr[ii];
94 94 if (item.offline_price) {
95   - offline_price += item.goods_price - item.offline_price;
  95 + offline_price += item.price - item.offline_price;
96 96 offline_num += 1;
97 97 }
98 98 if (goods_map[item.goods_id]) {
... ...