Commit 09659c0787812310f1f64e147f0a865430bdd1d8

Authored by yvan.ni
1 parent f51f020e

商品价格发生变化的优化

Showing 1 changed file with 29 additions and 1 deletions
pages/cart/cart/cart.js
... ... @@ -60,7 +60,9 @@ Page({
60 60 is_cart:1, //标记是购物车计算的时候
61 61  
62 62 //送赠品的优化
63   - cart_zp:{}
  63 + cart_zp:{},
  64 + //-- dp_cart深拷贝的缓存 --
  65 + dp_cart:null
64 66  
65 67 },
66 68  
... ... @@ -933,6 +935,8 @@ Page({
933 935 }
934 936 }
935 937  
  938 + //-- 2024-2-3 深拷贝数据缓存 --
  939 + th.data.dp_car=ut.deep_cp(arr);
936 940 th.setData({
937 941 requestData: arr,
938 942 all_num: all_num,
... ... @@ -2463,6 +2467,9 @@ Page({
2463 2467 th.data.pitems=-1;
2464 2468 }
2465 2469  
  2470 +
  2471 +
  2472 +
2466 2473 for (var a = 0; a < car.length; a++) {
2467 2474 var ite1 = car[a].goods;
2468 2475 if(car.length>1 && c_ind>-1 && a==c_ind ){
... ... @@ -2587,6 +2594,7 @@ Page({
2587 2594 zh_calc.remove_zhprom(car, a, obj);
2588 2595 ladder_calc.remove_ladder_prom(car, a, obj);
2589 2596  
  2597 + //-- 如果是未选中的时候 --
2590 2598 if (item[c].selected == 0) {
2591 2599 ischeck = 0;
2592 2600 is_s_sele = 0;
... ... @@ -2600,9 +2608,16 @@ Page({
2600 2608 ladder_calc.add_ladder_prom(car, a, obj);
2601 2609 }
2602 2610  
  2611 + //-- 如果价格有发生变动,要更新界面中的价格显示,还原价格 --
  2612 + let txt='requestData['+a+'].goods['+c+'].goods_price';
  2613 + th.setData({
  2614 + [txt]:th.data.dp_car[a].goods[c].goods_price
  2615 + })
  2616 +
2603 2617  
2604 2618 } else {
2605 2619  
  2620 + //-- 如果是选中的时候 --
2606 2621 if (item[c].prom_type == 7) {
2607 2622 //先把商品放入组合计算的专用的区域
2608 2623 console.log('是组合商品---')
... ... @@ -2617,10 +2632,23 @@ Page({
2617 2632 //console.log("索引:"+c+",数量:"+item[c].goods_num+",单价:"+item[c].goods_price+",合计:"+item[c].goods_num * item[c].goods_price+",商品:"+item[c].goods_name);
2618 2633 tfeel += item[c].goods_num * item[c].goods_price;
2619 2634 //console.log("累计:"+tfeel);
  2635 +
  2636 + //-- 如果价格有发生变动,要更新界面中的价格显示 --
  2637 + if(item[c].goods_price!=th.data.dp_car[a].goods[c].goods_price){
  2638 + let txt='requestData['+a+'].goods['+c+'].goods_price';
  2639 + th.setData({
  2640 + [txt]:item[c].goods_price
  2641 + })
  2642 + }
  2643 +
2620 2644 }
2621 2645 t_num += item[c].goods_num;
2622 2646 }
2623 2647  
  2648 +
  2649 +
  2650 +
  2651 +
2624 2652 //-- 如果这个商品是线下取价的时候 --
2625 2653 if (item[c].is_offline && item[c].prom_type != 7) {
2626 2654 offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
... ...