diff --git a/mall4m/pages/index/index.js b/mall4m/pages/index/index.js index 435aa99..422a588 100644 --- a/mall4m/pages/index/index.js +++ b/mall4m/pages/index/index.js @@ -71,13 +71,6 @@ Page({ }) }, - //跳转公告列表页面 - onNewsPage: function() { - wx.navigateTo({ - url: '/pages/recent-news/recent-news', - }) - }, - //跳转限时特惠页面 toLimitedTimeOffer: function(e) { wx.showToast({ @@ -86,6 +79,13 @@ Page({ }) }, + //跳转公告列表页面 + onNewsPage: function() { + wx.navigateTo({ + url: '/pages/recent-news/recent-news', + }) + }, + onShow: function() { }, getAllData() { @@ -125,6 +125,47 @@ Page({ http.request(params); }, + /** + * 加入购物车 + */ + addToCart(e) { + const prodId = e.currentTarget.dataset.prodid + const ths = this + wx.showLoading(); + var params = { + url: "/prod/prodInfo", + method: "GET", + data: { + prodId + }, + callBack: (res) => { + var params = { + url: "/p/shopCart/changeItem", + method: "POST", + data: { + basketId: 0, + count: 1, + prodId: res.prodId, + shopId: res.shopId, + skuId: res.skuList[0].skuId + }, + callBack: function(res) { + ths.setData({ + totalCartNum: ths.data.totalCartNum + ths.data.prodNum + }); + wx.hideLoading(); + wx.showToast({ + title: "加入购物车成功", + icon: "none" + }) + } + }; + http.request(params); + } + }; + http.request(params); + }, + // 加载商品标题分组列表 getTag() { diff --git a/mall4m/pages/index/index.wxml b/mall4m/pages/index/index.wxml index 7613a60..d0fc9c5 100644 --- a/mall4m/pages/index/index.wxml +++ b/mall4m/pages/index/index.wxml @@ -139,7 +139,7 @@ .{{wxs.parsePrice(prod.price)[1]}} - +