Commit 484162f671be8b5e65984831cc3264f2b00697ed

Authored by yvan.ni
1 parent 17eb788d

再来一单的优化

packageE/pages/cart/cart2/cart2.js
... ... @@ -336,8 +336,8 @@ Page({
336 336 });
337 337 }
338 338 })
339   -
340 339 },
  340 +
341 341 //购物车预存开启关闭
342 342 prestore(e) {
343 343 let ind = e.currentTarget.dataset.ind;
... ... @@ -2110,6 +2110,15 @@ Page({
2110 2110 quan_price += q_data[k].WareCashSum;
2111 2111 }
2112 2112 })
  2113 +
  2114 + if(cart_item.quan_youhui_list){
  2115 + for (var kk in cart_item.quan_youhui_list) {
  2116 + var you_item = cart_item.quan_youhui_list[kk];
  2117 + //-- 对券的价格进行平摊 --
  2118 + await th.split_set_goods_quanprice(you_item, cart_item);
  2119 + }
  2120 + }
  2121 +
2113 2122 }
2114 2123  
2115 2124  
... ... @@ -2144,9 +2153,12 @@ Page({
2144 2153 if( [1,2,6].indexOf(item[jc].prom_type)>-1){
2145 2154 if(!item[jc].is_order_yh){
2146 2155 no_order_yh+=item[jc].goods_price * item[jc].goods_num;
  2156 + if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去
  2157 +
2147 2158 }
2148 2159 if(!item[jc].is_post_temp){
2149 2160 no_post_temp+=item[jc].goods_price * item[jc].goods_num;
  2161 + if(item[jc].quan_num) no_post_temp-=item[jc].quan_num; //券要把他补回去
2150 2162 }
2151 2163 }
2152 2164 }
... ... @@ -5897,17 +5909,25 @@ Page({
5897 5909 }
5898 5910  
5899 5911 if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)) {
  5912 + var pri = Math.floor(coupon_price * 100) / 100 - Math.floor(q_s_num * 100) / 100
  5913 + var is_ok=0;
5900 5914 for (var ik in arr) {
5901 5915 if (arr[ik].goods_num == 1) {
5902 5916 var id = arr[ik].idx;
5903   - var pri = Math.floor(coupon_price * 100) / 100 - Math.floor(q_s_num * 100) / 100
5904 5917 t_item.goods[id].quan_num += pri;
  5918 + is_ok=1;
5905 5919 break;
5906 5920 }
5907 5921 }
  5922 + if(!is_ok){
  5923 + var id2 = arr[0].idx;
  5924 + t_item.goods[id2].quan_num += pri;
  5925 + }
  5926 +
5908 5927 }
5909 5928 }
5910 5929 },
  5930 +
5911 5931 //订阅消息提醒
5912 5932 sendsm: function (func) {
5913 5933 let th = this;
... ...
pages/user/order_list/order_list.js
... ... @@ -1471,22 +1471,31 @@ Page({
1471 1471 b_item.price = good[card_field];
1472 1472 }
1473 1473  
1474   - var url = "/api/weshop/activitylist/getGoodActInfo";
  1474 + var url = "/api/weshop/activitylist/listGoodActInfo2New";
1475 1475 var req_data = {
1476   - store_id: g_item.store_id, goodsidlist: g_item.goods_id, is_detail: 1, user_id: user_id, timetype: 0
  1476 + store_id: g_item.store_id, goods_id: g_item.goods_id, user_id: user_id
1477 1477 };
1478 1478 await getApp().request.promiseGet(url, { data: req_data }).then(res => {
1479 1479 if (res.data.code == 0) {
1480   - var list = res.data.data;
1481   - for (let i in list) {
1482   - let item = list[i];
1483   - if (item.prom_type == 1) { good.prom_type = 1; good.prom_id = item.act_id; }
  1480 +
  1481 + var arr = res.data.data;
  1482 + //-- 预热也要计算 --
  1483 + var arr2 = arr.filter(function (e) {
  1484 + return e.s_time < ut.gettimestamp();
  1485 + })
  1486 +
  1487 + if (arr2.length == 1) {
  1488 + good.prom_type = 1; good.prom_id = item.act_id;
  1489 + }
  1490 + else if (arr2.length > 1) {
  1491 + good.prom_type = g_item.prom_type; good.prom_id = g_item.prom_id;
1484 1492 }
1485 1493 }
1486 1494 })
1487   - if (!prom) {
1488   - //--判断商品当前的活动情况--
1489   - switch (good.prom_type) {
  1495 +
  1496 +
  1497 + //--判断商品当前的活动情况--
  1498 + switch (good.prom_type) {
1490 1499 case 1:
1491 1500 var flash = null;
1492 1501 await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + getApp().globalData.user_id + "/" + good.prom_id, {}).then(res => {
... ... @@ -1558,7 +1567,7 @@ Page({
1558 1567 })
1559 1568 break;
1560 1569 }
1561   - }
  1570 +
1562 1571  
1563 1572 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期
1564 1573 if ((g_item.prom_type == 3 || good.prom_type == 3) && good.whsle_id <= 0) {
... ... @@ -1896,11 +1905,15 @@ Page({
1896 1905 }
1897 1906  
1898 1907 if (g_item.prom_type) {
  1908 + //3,5,7,10加入购物车,统一prom_type为0
  1909 + if([3,5,7,10].indexOf(g_item.prom_type)>-1){
  1910 + g_item.prom_type=0;
  1911 + g_item.prom_id=0;
  1912 + }
1899 1913 newd['prom_type'] = g_item.prom_type;
1900 1914 newd['prom_id'] = g_item.prom_id;
1901 1915 }
1902 1916  
1903   -
1904 1917 var b_cart_goods = null;
1905 1918 await getApp().request.promiseGet("/api/weshop/cart/page", {
1906 1919 data: {
... ... @@ -1917,10 +1930,29 @@ Page({
1917 1930 }
1918 1931 })
1919 1932  
  1933 + //-- 判断购物车是不是有重复 --
  1934 + var is_has=0;
  1935 + if(b_cart_goods) {
  1936 + for (let jr = 0; jr < b_cart_goods.length; jr++) {
  1937 + var b_cart_item = b_cart_goods[jr];
  1938 + if (g_item.prom_type == 0) {
  1939 + if ([0, 3, 5, 7, 10].indexOf(b_cart_item.prom_type) > -1) {
  1940 + is_has = b_cart_item.id;
  1941 + break
  1942 + }
  1943 + } else {
  1944 + if (b_cart_goods.prom_type == g_item.prom_type && b_cart_goods.prom_id == g_item.prom_id) {
  1945 + is_has = b_cart_item.id;
  1946 + break
  1947 + }
  1948 + }
  1949 + }
  1950 + }
  1951 +
1920 1952 //-- 如果就加入过购物车 --
1921   - if (b_cart_goods) {
  1953 + if (is_has) {
1922 1954 var updata = {
1923   - id: b_cart_goods.id,
  1955 + id: is_has_cart,
1924 1956 goods_num: newd.goods_num + b_cart_goods.goods_num,
1925 1957 goods_price: newd.goods_price,
1926 1958 member_goods_price: newd.goods_price,
... ...