From 827770ab409690767d17217ff4a0c274c6d979f9 Mon Sep 17 00:00:00 2001
From: liaoanqi <1776106376@qq.com>
Date: Mon, 29 Aug 2022 10:32:27 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=A0=E5=85=A5=E8=B4=AD?=
=?UTF-8?q?=E7=89=A9=E8=BD=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mall4m/pages/index/index.js | 55 ++++++++++++++++++++++++++++++-----
mall4m/pages/index/index.wxml | 2 +-
2 files changed, 49 insertions(+), 8 deletions(-)
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]}}
-
+