Commit a513332ec3a51947c158c911502fc2b77f7e9c22

Authored by yvan.ni
1 parent 551e7b7b

指定门店,购物车的优化, 和积分购普通购买多规格的优化

pages/cart/cart/cart.js
... ... @@ -1359,6 +1359,8 @@ Page({
1359 1359 }
1360 1360 }
1361 1361 },
  1362 +
  1363 +
1362 1364 //删除商品
1363 1365 delete_th_item: function (t) {
1364 1366 var e = this;
... ... @@ -1416,28 +1418,37 @@ Page({
1416 1418 var b = t.currentTarget.dataset.pitems;
1417 1419 a = this.data.requestData[b].goods[a];
1418 1420  
1419   - console.log('add+');
1420   - if (a.goods_num < a.store_count) {
  1421 + console.log('add+');
  1422 +
  1423 + if(this.data.sales_rules <2 || a.whsle_id || [1,2,4,6,8,9].indexOf(a.prom_type)>-1 ) {
  1424 +
  1425 + if (a.goods_num < a.store_count) {
  1426 +
  1427 + // wx.showModal({
  1428 + // title: '提示',
  1429 + // content: '购买的数量不能超出库存数量',
  1430 + // });
  1431 + wx.showToast({
  1432 + title: '购买的数量不能超出库存数量',
  1433 + icon: 'none',
  1434 + });
  1435 + // getApp().my_warnning('购买的数量不能超出库存数量', 0, this);
  1436 + this.data.up_dating = 0;
  1437 +
  1438 + return false;
  1439 + }
  1440 + }
  1441 +
  1442 +
1421 1443 var e = {
1422   - goods_num: a.goods_num + 1,
  1444 + goods_num: a.goods_num + 1,
1423 1445 id: a.id,
1424 1446 goods_id: a.goods_id,
1425 1447 store_id: oo.stoid
1426 1448 };
1427 1449 // console.log('goods_num', e.goods_num);
1428 1450 this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1429   - } else {
1430   - // wx.showModal({
1431   - // title: '提示',
1432   - // content: '购买的数量不能超出库存数量',
1433   - // });
1434   - wx.showToast({
1435   - title: '购买的数量不能超出库存数量',
1436   - icon: 'none',
1437   - });
1438   - // getApp().my_warnning('购买的数量不能超出库存数量', 0, this);
1439   - this.data.up_dating = 0;
1440   - }
  1451 +
1441 1452 },
1442 1453 //-------------减数量---------------------
1443 1454 subNum: function (t) {
... ... @@ -1455,6 +1466,8 @@ Page({
1455 1466 return false;
1456 1467 }
1457 1468  
  1469 +
  1470 +
1458 1471 if (1 != a.goods_num) {
1459 1472 var e = {
1460 1473 goods_num: a.goods_num - 1,
... ... @@ -1751,7 +1764,7 @@ Page({
1751 1764 },
1752 1765 //------门店全选按钮,要判断是否门店的匹配方式一致---------
1753 1766 check_th_all_item: async function (ele) {
1754   - var e = this,
  1767 + var e = this,th=this,
1755 1768 pitems = ele.currentTarget.dataset.pitems,
1756 1769 item = this.data.requestData[pitems].goods,
1757 1770 sele = this.data.requestData[pitems].selected;
... ... @@ -1808,6 +1821,50 @@ Page({
1808 1821  
1809 1822 for (var i = 0; i < item.length; i++) {
1810 1823 var txt = "requestData[" + pitems + "].goods[" + i + "].selected";
  1824 +
  1825 + var gd_info=item[i];
  1826 + if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1,2,4,6,8,9].indexOf(gd_info.prom_type)==-1 ) {
  1827 + var ob = {};
  1828 + await th.check_down_line_next(gd_info, pitems, i, gd_info.erpwareid, function (res) {
  1829 + ob = res;
  1830 + });
  1831 +
  1832 + if (ob.code == -1) {
  1833 +
  1834 + wx.showToast({
  1835 + title: '购买数量超出商品库存',
  1836 + icon: 'none',
  1837 + });
  1838 +
  1839 + return false;
  1840 + }else{
  1841 + if(th.data.sales_rules==3){
  1842 + var goods_id=gd_info.goods_id;
  1843 + var num=0;
  1844 +
  1845 + for (let i = 0; i < th.data.requestData.length; i++) {
  1846 + if(pitems==i) continue;
  1847 + var it= th.data.requestData[i].goods.find((e)=>{
  1848 + return e.goods_id==goods_id;
  1849 + })
  1850 + if(it && it.selected) num+=it.goods_num
  1851 + }
  1852 +
  1853 + if(num>ob.CanOutQty){
  1854 + wx.showToast({
  1855 + title: '购买数量超出商品库存',
  1856 + icon: 'none',
  1857 + });
  1858 +
  1859 + return false;
  1860 + }
  1861 + }
  1862 + }
  1863 +
  1864 + }
  1865 +
  1866 +
  1867 +
1811 1868 e.setData({
1812 1869 [txt]: Number(!sele),
1813 1870 });
... ... @@ -1829,7 +1886,7 @@ Page({
1829 1886 },
1830 1887 //---------------单选,也要判断门店的配送方式是否一致--------------
1831 1888 check_th_item: async function (t) {
1832   - var e = this,
  1889 + var e = this,th=this,
1833 1890 item = t.currentTarget.dataset.item,
1834 1891 pitems = t.currentTarget.dataset.pitems;
1835 1892 a = this.data.requestData[pitems].goods[item];
... ... @@ -1884,6 +1941,51 @@ Page({
1884 1941 });
1885 1942 } else {
1886 1943 var txt = "requestData[" + pitems + "].goods[" + item + "].selected";
  1944 + var gd_info=a;
  1945 +
  1946 + var erpwareid = gd_info.erpwareid;
  1947 + if (th.data.sales_rules >= 2 && !gd_info.whsle_id && [1,2,4,6,8,9].indexOf(gd_info.prom_type)==-1 ) {
  1948 + var ob = {};
  1949 + await th.check_down_line_next(gd_info, pitems, item, erpwareid, function (res) {
  1950 + ob = res;
  1951 + });
  1952 +
  1953 + if (ob.code == -1) {
  1954 +
  1955 + wx.showToast({
  1956 + title: '购买数量超出商品库存',
  1957 + icon: 'none',
  1958 + });
  1959 +
  1960 + return false;
  1961 + }else{
  1962 + if(th.data.sales_rules==3){
  1963 + var goods_id=gd_info.goods_id;
  1964 + var num=0;
  1965 +
  1966 + for (let i = 0; i < th.data.requestData.length; i++) {
  1967 + if(pitems==i) continue;
  1968 + var it= th.data.requestData[i].goods.find((e)=>{
  1969 + return e.goods_id==goods_id;
  1970 + })
  1971 + if(it && it.selected) num+=it.goods_num
  1972 + }
  1973 +
  1974 + if(num>ob.CanOutQty){
  1975 + wx.showToast({
  1976 + title: '购买数量超出商品库存',
  1977 + icon: 'none',
  1978 + });
  1979 +
  1980 + return false;
  1981 + }
  1982 + }
  1983 + }
  1984 +
  1985 + }
  1986 +
  1987 +
  1988 +
1887 1989 e.setData({
1888 1990 [txt]: Number(!a.selected),
1889 1991 });
... ... @@ -2708,7 +2810,43 @@ Page({
2708 2810 });
2709 2811 th.doCheckAll();
2710 2812 t.goods_num = ob.CanOutQty;
  2813 + }else{
  2814 +
  2815 + var this_obj=this.data.requestData[pitem].goods[item];
  2816 +
  2817 + if(th.data.sales_rules==3 && this_obj.selected){
  2818 +
  2819 +
  2820 + var goods_id=this_obj.goods_id;
  2821 +
  2822 + var num=0;
  2823 +
  2824 + for (let i = 0; i < this.data.requestData.length; i++) {
  2825 + if(pitem==i) continue;
  2826 + var it= this.data.requestData[i].goods.find((e)=>{
  2827 + return e.goods_id==goods_id;
  2828 + })
  2829 + if(it && it.selected) num+=it.goods_num
  2830 + }
  2831 +
  2832 + if(num>ob.CanOutQty){
  2833 + wx.showToast({
  2834 + title: '购买数量超出商品库存',
  2835 + icon: 'none',
  2836 + });
  2837 +
  2838 + th.data.up_dating = 0;
  2839 + return false;
  2840 + }
  2841 +
  2842 +
  2843 +
  2844 + }
2711 2845 }
  2846 +
  2847 +
  2848 +
  2849 +
2712 2850 this.update_cart(t, pitem, item);
2713 2851 },
2714 2852  
... ... @@ -2792,7 +2930,11 @@ Page({
2792 2930 ob.code = -1;
2793 2931 ob.CanOutQty = plist.CanOutQty - lock
2794 2932 if (ob.CanOutQty < 0) ob.CanOutQty = 0;
  2933 + }else{
  2934 + ob.CanOutQty=plist.CanOutQty-c_num- lock;
2795 2935 }
  2936 +
  2937 +
2796 2938 func(ob)
2797 2939 },
2798 2940  
... ...
pages/goods/goodsInfo/buy_com_pop.wxml
... ... @@ -12,7 +12,7 @@
12 12  
13 13 <view class="flex">
14 14 <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view>
15   - <block wx:if="{{sales_rules==2}}">
  15 + <block wx:if="{{sales_rules>=2}}">
16 16 <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">
17 17 可售:{{def_pick_store.CanOutQty}}
18 18 </view>
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -2967,6 +2967,9 @@ Page({
2967 2967 });
2968 2968  
2969 2969  
  2970 + if(nor) that.get_sto(1);
  2971 + else that.get_sto();
  2972 +
2970 2973 if(!item.whsle_id) that.check_is_youhui(gid, that.data.is_normal);
2971 2974  
2972 2975 //默认门店要拿下门店库存
... ... @@ -3006,7 +3009,7 @@ Page({
3006 3009 // that.setData({def_pick_store: that.data.def_pick_store});
3007 3010 // })
3008 3011  
3009   - that.check_CanOutQty(th.data.sele_g,that.data.def_pick_store,function (CanOutQty){
  3012 + that.check_CanOutQty(that.data.sele_g,that.data.def_pick_store,function (CanOutQty){
3010 3013 that.data.def_pick_store.CanOutQty = CanOutQty;
3011 3014 //--给门店赋值线下库存--
3012 3015 that.setData({def_pick_store: that.data.def_pick_store});
... ... @@ -6096,6 +6099,8 @@ Page({
6096 6099 var ind = ee.currentTarget.dataset.ind;
6097 6100 var bconfig = th.data.bconfig;
6098 6101  
  6102 + debugger
  6103 +
6099 6104 //如果开启了,则不在选择门店
6100 6105 if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
6101 6106 return false;
... ...