Commit bb6d5f0d25dab8f60d022dfa0cbce27b25a0d077

Authored by yvan.ni
1 parent 923ad572

商品详情的优化

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -1914,10 +1914,19 @@ Page({
1914 1914 //-------如果购物车中有相关的数据---------
1915 1915 if (re.data.data.total > 0) {
1916 1916 for (var j=0; j<re.data.data.pageData.length; j++) {
1917   - if(!th.check_is_like(re.data.data.pageData[j],newd)) continue;
  1917 + if(!th.check_is_like(re.data.data.pageData[j],newd,1)) continue;
1918 1918 item=re.data.data.pageData[j];
1919 1919 break;
1920 1920 }
  1921 +
  1922 + if(!item){
  1923 + for (var j=0; j<re.data.data.pageData.length; j++) {
  1924 + if(!th.check_is_like(re.data.data.pageData[j],newd)) continue;
  1925 + item=re.data.data.pageData[j];
  1926 + break;
  1927 + }
  1928 + }
  1929 +
1921 1930 }
1922 1931  
1923 1932 if(item){
... ... @@ -1942,6 +1951,15 @@ Page({
1942 1951 return false;
1943 1952 //return s.my_warnning("库存不足!", 0, th);
1944 1953 }
  1954 +
  1955 + if (item.goods_num + th.data.goodsInputNum+th.data.prom_buy_num > th.data.prom_buy_limit && (th.data.prom_type==1 || th.data.prom_type==2)) {
  1956 + wx.showToast({
  1957 + title: '此商品已在购物车,去购物车结算!',
  1958 + icon: 'none',
  1959 + });
  1960 + return false;
  1961 + //return s.my_warnning("库存不足!", 0, th);
  1962 + }
1945 1963 }
1946 1964  
1947 1965 var updata = {
... ... @@ -2188,13 +2206,16 @@ Page({
2188 2206 },
2189 2207  
2190 2208 //因为在购物车 普通商品和 优惠促销,搭配购,组合购 阶梯购是一样的
2191   - check_is_like(e,newd){
  2209 + check_is_like(e,newd,idx){
2192 2210 if(e.prom_type ==newd.prom_type) return true;
2193   - if(e.prom_type==0){
2194   - if([3,5,7,10].indexOf(newd.prom_type)>-1) return true;
2195   - }
2196   - if(newd.prom_type==0){
2197   - if([3,5,7,10].indexOf(e.prom_type)>-1) return true;
  2211 +
  2212 + if(!idx) {
  2213 + if (e.prom_type == 0) {
  2214 + if ([3, 5, 7, 10].indexOf(newd.prom_type) > -1) return true;
  2215 + }
  2216 + if (newd.prom_type == 0) {
  2217 + if ([3, 5, 7, 10].indexOf(e.prom_type) > -1) return true;
  2218 + }
2198 2219 }
2199 2220 return false;
2200 2221 },
... ... @@ -4629,7 +4650,6 @@ Page({
4629 4650 }, 1000);
4630 4651 },
4631 4652  
4632   -
4633 4653 //-------------获取购买数量的总函数----------------
4634 4654 get_buy_num: function (gd, func) {
4635 4655 var map = this.data.g_buy_num,
... ... @@ -4731,7 +4751,6 @@ Page({
4731 4751 //--点击弹起拼单--
4732 4752 openSpecModel_pt: function (e) {
4733 4753  
4734   -
4735 4754 this.setData({
4736 4755 open_ind_store: 4,
4737 4756 goodsInputNum: 1
... ...