Commit 00becdb95d0464eda466581aa904a66c72672f85
1 parent
85734f41
cart2的优化
Showing
1 changed file
with
100 additions
and
93 deletions
packageE/pages/cart/cart2/cart2.js
@@ -1256,25 +1256,6 @@ Page({ | @@ -1256,25 +1256,6 @@ Page({ | ||
1256 | //计算佣金的商品 | 1256 | //计算佣金的商品 |
1257 | var commission_gds = []; | 1257 | var commission_gds = []; |
1258 | for (var c = 0; c < item.length; c++) { | 1258 | for (var c = 0; c < item.length; c++) { |
1259 | - | ||
1260 | - | ||
1261 | - //-- 要判断总开关有没有同城配送 -- | ||
1262 | - if(th.data.is_same_city) { | ||
1263 | - //----- 判断每一个商品的配送方式,和门店的配送方式 ------- | ||
1264 | - for (var ik = 0; ik < arr.length; ik++) { | ||
1265 | - if (!arr[ik].sto.is_same_city) continue; | ||
1266 | - var fd = arr[ik].goods.filter(function (e) { | ||
1267 | - return e.is_same_city != 1 || e.whsle_id > 0 | ||
1268 | - }) | ||
1269 | - if (!fd || fd.length == 0) { | ||
1270 | - arr[ik].show_same_city = 1; | ||
1271 | - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 2) { | ||
1272 | - arr[ik].exp_type=2; | ||
1273 | - th.setData({ is_all_zt: 0 }); | ||
1274 | - } | ||
1275 | - | ||
1276 | - } | ||
1277 | - | ||
1278 | if (!item[c].is_gift) { | 1259 | if (!item[c].is_gift) { |
1279 | var hr = { | 1260 | var hr = { |
1280 | goods_id: item[c].goods_id, | 1261 | goods_id: item[c].goods_id, |
@@ -1403,6 +1384,8 @@ Page({ | @@ -1403,6 +1384,8 @@ Page({ | ||
1403 | }, 500) | 1384 | }, 500) |
1404 | }, | 1385 | }, |
1405 | 1386 | ||
1387 | + | ||
1388 | + | ||
1406 | //-----单个商品购买的入口判断---- | 1389 | //-----单个商品购买的入口判断---- |
1407 | get_buy_goods: function (e) { | 1390 | get_buy_goods: function (e) { |
1408 | var th = this; | 1391 | var th = this; |
@@ -1997,7 +1980,7 @@ Page({ | @@ -1997,7 +1980,7 @@ Page({ | ||
1997 | }, | 1980 | }, |
1998 | 1981 | ||
1999 | calc_per: async function (c_arr) { | 1982 | calc_per: async function (c_arr) { |
2000 | - | 1983 | + |
2001 | var send_gf = {}; | 1984 | var send_gf = {}; |
2002 | var duo_zp_num_arr = {}; | 1985 | var duo_zp_num_arr = {}; |
2003 | var th = this; | 1986 | var th = this; |
@@ -2035,7 +2018,7 @@ Page({ | @@ -2035,7 +2018,7 @@ Page({ | ||
2035 | }).then(res => { | 2018 | }).then(res => { |
2036 | if (res.data.code == 0 && res.data.data.condition) { | 2019 | if (res.data.code == 0 && res.data.data.condition) { |
2037 | var get_data = res.data.data; | 2020 | var get_data = res.data.data; |
2038 | - item_map.cy_cx=1; | 2021 | + item_map.cy_cx = 1; |
2039 | item_map.is_bz = get_data.is_bz; //是不是倍增 | 2022 | item_map.is_bz = get_data.is_bz; //是不是倍增 |
2040 | item_map.bs = get_data.bs; //是不是倍数 | 2023 | item_map.bs = get_data.bs; //是不是倍数 |
2041 | item_map.is_past = get_data.is_past; //是不是包邮 | 2024 | item_map.is_past = get_data.is_past; //是不是包邮 |
@@ -2049,8 +2032,8 @@ Page({ | @@ -2049,8 +2032,8 @@ Page({ | ||
2049 | item_map.monthlbtitle = get_data.monthlbtitle; | 2032 | item_map.monthlbtitle = get_data.monthlbtitle; |
2050 | //------end------- | 2033 | //------end------- |
2051 | if (get_data.gift_id && parseInt(get_data.zp_mode) != 1 | 2034 | if (get_data.gift_id && parseInt(get_data.zp_mode) != 1 |
2052 | - && get_data.zp_num * item_map.bs <= get_data.limit_num | ||
2053 | - && get_data.zp_num * item_map.bs <= get_data.gift_storecount | 2035 | + && get_data.zp_num * item_map.bs <= get_data.limit_num |
2036 | + && get_data.zp_num * item_map.bs <= get_data.gift_storecount | ||
2054 | ) { | 2037 | ) { |
2055 | 2038 | ||
2056 | item_map.gift_id = get_data.gift_id; | 2039 | item_map.gift_id = get_data.gift_id; |
@@ -2104,8 +2087,7 @@ Page({ | @@ -2104,8 +2087,7 @@ Page({ | ||
2104 | duo_zp_num_arr[item_map.prom_id] = t_zp_num; | 2087 | duo_zp_num_arr[item_map.prom_id] = t_zp_num; |
2105 | } | 2088 | } |
2106 | } | 2089 | } |
2107 | - } | ||
2108 | - else item_map.cy_cx=0; | 2090 | + } else item_map.cy_cx = 0; |
2109 | }) | 2091 | }) |
2110 | } | 2092 | } |
2111 | 2093 | ||
@@ -2174,85 +2156,108 @@ Page({ | @@ -2174,85 +2156,108 @@ Page({ | ||
2174 | ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; | 2156 | ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; |
2175 | ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; | 2157 | ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; |
2176 | 2158 | ||
2177 | - //-- 如果有参与促销才来进行计算 -- | ||
2178 | - if(item_map.cy_cx) { | ||
2179 | - //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- | ||
2180 | - for (var j = 0; j < ord_goods.length; j++) { | ||
2181 | - if (ord_goods[j].is_gift) continue; | ||
2182 | - if (ord_goods[j].whsle_id) continue; | ||
2183 | - if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { | ||
2184 | - ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh; | ||
2185 | - ord_goods[j].is_past = item_map.is_past; | ||
2186 | - ord_goods[j].is_order_yh = item_map.is_order_yh; | ||
2187 | - ord_goods[j].is_post_temp = item_map.is_post_temp; | ||
2188 | - | ||
2189 | - ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir; | ||
2190 | - ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; | ||
2191 | - ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; | ||
2192 | - ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; | 2159 | + //-- 如果有参与促销才来进行计算 -- |
2160 | + if (item_map.cy_cx) { | ||
2161 | + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- | ||
2162 | + for (var j = 0; j < ord_goods.length; j++) { | ||
2163 | + if (ord_goods[j].is_gift) continue; | ||
2164 | + if (ord_goods[j].whsle_id) continue; | ||
2165 | + if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { | ||
2166 | + ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh; | ||
2167 | + ord_goods[j].is_past = item_map.is_past; | ||
2168 | + ord_goods[j].is_order_yh = item_map.is_order_yh; | ||
2169 | + ord_goods[j].is_post_temp = item_map.is_post_temp; | ||
2170 | + | ||
2171 | + ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir; | ||
2172 | + ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; | ||
2173 | + ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; | ||
2174 | + ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; | ||
2175 | + } | ||
2176 | + } | ||
2193 | } | 2177 | } |
2194 | - } | ||
2195 | - } | ||
2196 | 2178 | ||
2197 | 2179 | ||
2198 | - if (item_map.price != undefined && item_map.price != null | ||
2199 | - && item_map.prom_price != undefined && item_map.prom_price != null) | ||
2200 | - cart_item.cut_price += (item_map.price - item_map.prom_price); | ||
2201 | - //---如果有送积分--- | ||
2202 | - if (item_map.s_intValue) { | ||
2203 | - if (!cart_item.s_intValue) cart_item.s_intValue = 0; | ||
2204 | - cart_item.s_intValue += item_map.s_intValue; | ||
2205 | - } | ||
2206 | - //-- 如果有送优惠券的情况 -- | ||
2207 | - if (item_map.s_coupon_id) { | ||
2208 | - if (!cart_item.s_coupon_id) { | ||
2209 | - cart_item.s_coupon_id = item_map.s_coupon_id + ""; | ||
2210 | - cart_item.g_coupon_num = [{ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }]; | ||
2211 | - } | ||
2212 | - else { | ||
2213 | - cart_item.s_coupon_id += "," + item_map.s_coupon_id; | ||
2214 | - cart_item.g_coupon_num.push({ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }) | ||
2215 | - } | ||
2216 | - } | 2180 | + if (item_map.price != undefined && item_map.price != null |
2181 | + && item_map.prom_price != undefined && item_map.prom_price != null) | ||
2182 | + cart_item.cut_price += (item_map.price - item_map.prom_price); | ||
2183 | + //---如果有送积分--- | ||
2184 | + if (item_map.s_intValue) { | ||
2185 | + if (!cart_item.s_intValue) cart_item.s_intValue = 0; | ||
2186 | + cart_item.s_intValue += item_map.s_intValue; | ||
2187 | + } | ||
2188 | + //-- 如果有送优惠券的情况 -- | ||
2189 | + if (item_map.s_coupon_id) { | ||
2190 | + if (!cart_item.s_coupon_id) { | ||
2191 | + cart_item.s_coupon_id = item_map.s_coupon_id + ""; | ||
2192 | + cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}]; | ||
2193 | + } else { | ||
2194 | + cart_item.s_coupon_id += "," + item_map.s_coupon_id; | ||
2195 | + cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}) | ||
2196 | + } | ||
2197 | + } | ||
2217 | 2198 | ||
2218 | - //-- 如果有送礼包的情况 -- | ||
2219 | - if (item_map.s_libao) { | ||
2220 | - if (!cart_item.s_libao) { | ||
2221 | - cart_item.s_libao = item_map.s_libao + ""; | ||
2222 | - cart_item.g_lb_num = [{ 'l_id': item_map.s_libao, "num": item_map.s_lb_num, 'lbtitle': item_map.lbtitle }]; | ||
2223 | - } | ||
2224 | - else { | ||
2225 | - cart_item.s_libao += "," + item_map.s_libao; | ||
2226 | - cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num, 'lbtitle': item_map.lbtitle }) | ||
2227 | - } | ||
2228 | - } | 2199 | + //-- 如果有送礼包的情况 -- |
2200 | + if (item_map.s_libao) { | ||
2201 | + if (!cart_item.s_libao) { | ||
2202 | + cart_item.s_libao = item_map.s_libao + ""; | ||
2203 | + cart_item.g_lb_num = [{ | ||
2204 | + 'l_id': item_map.s_libao, | ||
2205 | + "num": item_map.s_lb_num, | ||
2206 | + 'lbtitle': item_map.lbtitle | ||
2207 | + }]; | ||
2208 | + } else { | ||
2209 | + cart_item.s_libao += "," + item_map.s_libao; | ||
2210 | + cart_item.g_lb_num.push({ | ||
2211 | + 'l_id': item_map.s_libao, | ||
2212 | + "num": item_map.s_lb_num, | ||
2213 | + 'lbtitle': item_map.lbtitle | ||
2214 | + }) | ||
2215 | + } | ||
2216 | + } | ||
2229 | 2217 | ||
2230 | - if (item_map.zx_libao) { | ||
2231 | - if (!cart_item.zx_libao) { | ||
2232 | - cart_item.zx_libao = item_map.zx_libao + ""; | ||
2233 | - cart_item.g_zxlb_num = [{ 'l_id': item_map.zx_libao, "num": item_map.zx_lb_num, 'zxlbtitle': item_map.zxlbtitle }]; | ||
2234 | - } | ||
2235 | - else { | ||
2236 | - cart_item.zx_libao += "," + item_map.zx_libao; | ||
2237 | - cart_item.g_zxlb_num.push({ 'l_id': item_map.zx_libao, "num": item_map.zx_lb_num, 'zxlbtitle': item_map.zxlbtitle }) | ||
2238 | - } | ||
2239 | - } | ||
2240 | - //每月礼包 | ||
2241 | - if (item_map.monthlibao) { | ||
2242 | - if (!cart_item.monthlibao) { | ||
2243 | - cart_item.monthlibao = item_map.monthlibao + ""; | ||
2244 | - cart_item.g_monthlb_num = [{ 'month_id': item_map.monthlibao, "monthnum": item_map.monthlb_num, 'monthlbtitle': item_map.monthlbtitle }]; | ||
2245 | - } else { | ||
2246 | - cart_item.monthlibao += "," + item_map.monthlibao; | ||
2247 | - cart_item.g_monthlb_num.push({ 'month_id': item_map.monthlibao, "monthnum": item_map.monthlb_num, 'monthlbtitle': item_map.monthlbtitle }) | 2218 | + if (item_map.zx_libao) { |
2219 | + if (!cart_item.zx_libao) { | ||
2220 | + cart_item.zx_libao = item_map.zx_libao + ""; | ||
2221 | + cart_item.g_zxlb_num = [{ | ||
2222 | + 'l_id': item_map.zx_libao, | ||
2223 | + "num": item_map.zx_lb_num, | ||
2224 | + 'zxlbtitle': item_map.zxlbtitle | ||
2225 | + }]; | ||
2226 | + } else { | ||
2227 | + cart_item.zx_libao += "," + item_map.zx_libao; | ||
2228 | + cart_item.g_zxlb_num.push({ | ||
2229 | + 'l_id': item_map.zx_libao, | ||
2230 | + "num": item_map.zx_lb_num, | ||
2231 | + 'zxlbtitle': item_map.zxlbtitle | ||
2232 | + }) | ||
2233 | + } | ||
2234 | + } | ||
2235 | + //每月礼包 | ||
2236 | + if (item_map.monthlibao) { | ||
2237 | + if (!cart_item.monthlibao) { | ||
2238 | + cart_item.monthlibao = item_map.monthlibao + ""; | ||
2239 | + cart_item.g_monthlb_num = [{ | ||
2240 | + 'month_id': item_map.monthlibao, | ||
2241 | + "monthnum": item_map.monthlb_num, | ||
2242 | + 'monthlbtitle': item_map.monthlbtitle | ||
2243 | + }]; | ||
2244 | + } else { | ||
2245 | + cart_item.monthlibao += "," + item_map.monthlibao; | ||
2246 | + cart_item.g_monthlb_num.push({ | ||
2247 | + 'month_id': item_map.monthlibao, | ||
2248 | + "monthnum": item_map.monthlb_num, | ||
2249 | + 'monthlbtitle': item_map.monthlbtitle | ||
2250 | + }) | ||
2251 | + } | ||
2252 | + } | ||
2253 | + //------------end-------- | ||
2248 | } | 2254 | } |
2249 | } | 2255 | } |
2250 | - //------------end-------- | ||
2251 | } | 2256 | } |
2252 | } | 2257 | } |
2253 | } | 2258 | } |
2254 | 2259 | ||
2255 | - | 2260 | + |
2256 | var arr = Object.keys(send_gf); | 2261 | var arr = Object.keys(send_gf); |
2257 | var arr2 = Object.keys(th.data.send_gf); | 2262 | var arr2 = Object.keys(th.data.send_gf); |
2258 | if (arr2.length > 0) return false; | 2263 | if (arr2.length > 0) return false; |
@@ -2266,6 +2271,8 @@ Page({ | @@ -2266,6 +2271,8 @@ Page({ | ||
2266 | }, | 2271 | }, |
2267 | 2272 | ||
2268 | 2273 | ||
2274 | + | ||
2275 | + | ||
2269 | calclate_lbNum(r_data) { | 2276 | calclate_lbNum(r_data) { |
2270 | 2277 | ||
2271 | if(!r_data) return false; | 2278 | if(!r_data) return false; |