浏览代码

Merge remote-tracking branch 'origin/master'

chendt 2 年之前
父节点
当前提交
93e5680d3b
共有 1 个文件被更改,包括 38 次插入2 次删除
  1. 38 2
      mall4uni/pages/index/index.vue

+ 38 - 2
mall4uni/pages/index/index.vue

@@ -141,7 +141,7 @@
 		                <text class="small-num">.{{wxs.parsePrice(prod.price)[1]}}</text>
 		                <text class="small-num">.{{wxs.parsePrice(prod.price)[1]}}</text>
 		              </view>
 		              </view>
 		              <!-- <view class='go-to-buy'>立即购买</view> -->
 		              <!-- <view class='go-to-buy'>立即购买</view> -->
-		              <image src="/static/images/tabbar/basket-sel.png" class="basket-img"></image>
+		              <image src="/static/images/tabbar/basket-sel.png" @tap.stop="addToCart(prod)" class="basket-img"></image>
 		            </view>
 		            </view>
 		          </view>
 		          </view>
 		        </view>
 		        </view>
@@ -251,6 +251,42 @@ export default {
         });
         });
       }
       }
     },
     },
+    // 加入购物车
+    addToCart: function (item) {
+      uni.showLoading({
+        mask: true
+      });
+      var params = {
+        url: "/prod/prodInfo",
+        method: "GET",
+        data: {
+          prodId: item.prodId
+        },
+        callBack: res => {
+          var params1 = {
+            url: "/p/shopCart/changeItem",
+            method: "POST",
+            data: {
+              basketId: 0,
+              count: 1,
+              prodId: res.prodId,
+              shopId: res.shopId,
+              skuId: res.skuList[0].skuId
+            },
+            callBack: res => {
+              //console.log(res);
+              uni.hideLoading();
+              uni.showToast({
+                title: "加入购物车成功",
+                icon: "none"
+              });
+            }
+          };
+          http.request(params1);
+        }
+      };
+      http.request(params);
+    },
     toCouponCenter: function () {
     toCouponCenter: function () {
       uni.showToast({
       uni.showToast({
         icon: "none",
         icon: "none",
@@ -334,12 +370,12 @@ export default {
           this.setData({
           this.setData({
             taglist: res
             taglist: res
           });
           });
+
           for (var i = 0; i < res.length; i++) {
           for (var i = 0; i < res.length; i++) {
 						this.updata = false
 						this.updata = false
 						this.updata = true
 						this.updata = true
             this.getTagProd(res[i].id, i);
             this.getTagProd(res[i].id, i);
           }
           }
-          console.log('taglist:', this.taglist)
         }
         }
       };
       };
       http.request(params);
       http.request(params);