فهرست منبع

Merge branch 'yann_0511' of baolei/GululuQ-mp into dev

yann 6 ماه پیش
والد
کامیت
073b45881f
49فایلهای تغییر یافته به همراه1541 افزوده شده و 226 حذف شده
  1. 10 7
      app.json
  2. 98 0
      components/addCartModel/addCartModel.js
  3. 3 0
      components/addCartModel/addCartModel.json
  4. 47 0
      components/addCartModel/addCartModel.wxml
  5. 193 0
      components/addCartModel/addCartModel.wxss
  6. 19 0
      components/header/header.js
  7. 3 0
      components/header/header.json
  8. 18 0
      components/header/header.wxml
  9. 58 0
      components/header/header.wxss
  10. 106 0
      components/product-list/product-list.js
  11. 3 0
      components/product-list/product-list.json
  12. 32 0
      components/product-list/product-list.wxml
  13. 81 0
      components/product-list/product-list.wxss
  14. BIN
      images/cart/empty.png
  15. BIN
      images/index/fav.png
  16. BIN
      images/mall/cart.png
  17. BIN
      images/mall/fav.png
  18. BIN
      images/mall/hot.png
  19. BIN
      images/mall/new.png
  20. BIN
      images/mall/presale.png
  21. BIN
      images/mall/search.png
  22. 66 0
      pages/Mall/hotCommodity/hotCommodity.js
  23. 8 0
      pages/Mall/hotCommodity/hotCommodity.json
  24. 7 0
      pages/Mall/hotCommodity/hotCommodity.wxml
  25. 1 0
      pages/Mall/hotCommodity/hotCommodity.wxss
  26. 66 0
      pages/Mall/newCommodity/newCommodity.js
  27. 8 0
      pages/Mall/newCommodity/newCommodity.json
  28. 7 0
      pages/Mall/newCommodity/newCommodity.wxml
  29. 1 0
      pages/Mall/newCommodity/newCommodity.wxss
  30. 66 0
      pages/Mall/presaleCommodity/presaleCommodity.js
  31. 8 0
      pages/Mall/presaleCommodity/presaleCommodity.json
  32. 7 0
      pages/Mall/presaleCommodity/presaleCommodity.wxml
  33. 1 0
      pages/Mall/presaleCommodity/presaleCommodity.wxss
  34. 109 0
      pages/Mall/sortCommodity/sortCommodity.js
  35. 8 0
      pages/Mall/sortCommodity/sortCommodity.json
  36. 32 0
      pages/Mall/sortCommodity/sortCommodity.wxml
  37. 42 0
      pages/Mall/sortCommodity/sortCommodity.wxss
  38. 142 1
      pages/cart/cart.js
  39. 4 2
      pages/cart/cart.json
  40. 48 1
      pages/cart/cart.wxml
  41. 117 0
      pages/cart/cart.wxss
  42. 17 22
      pages/index/index.js
  43. 6 1
      pages/index/index.json
  44. 11 34
      pages/index/index.wxml
  45. 0 137
      pages/index/index.wxss
  46. 15 2
      project.config.json
  47. 23 8
      project.private.config.json
  48. 48 9
      service/api.js
  49. 2 2
      utils/http.js

+ 10 - 7
app.json

@@ -1,11 +1,15 @@
 {
   "pages": [
-    "pages/index/index",
-    "pages/all/all",
-    "pages/cart/cart",
-    "pages/my/my",
-    "pages/detail/detail",
-    "pages/login/login"
+      "pages/index/index",
+      "pages/all/all",
+      "pages/cart/cart",
+      "pages/my/my",
+      "pages/detail/detail",
+      "pages/login/login",
+      "pages/Mall/sortCommodity/sortCommodity",
+      "pages/Mall/presaleCommodity/presaleCommodity",
+      "pages/Mall/newCommodity/newCommodity",
+      "pages/Mall/hotCommodity/hotCommodity"
   ],
   "window": {
     "backgroundColor": "#FFFFFF",
@@ -16,7 +20,6 @@
     "pageOrientation": "portrait"
   },
   "style": "v2",
-  "renderer": "skyline",
   "rendererOptions": {
     "skyline": {
       "defaultDisplayBlock": true,

+ 98 - 0
components/addCartModel/addCartModel.js

@@ -0,0 +1,98 @@
+import { API } from "../../service/api";
+
+// components/addCartModel/addCartModel.js
+Component({
+    properties: {
+      visible: {
+        type: Boolean,
+        value: false
+      },
+      product: {
+        type: Object,
+        value: {}
+      }
+    },
+  
+    data: {
+      selectedSpecs: [], // 选择的规格索引 [0,1]表示第一个规格的第0个选项,第二个规格的第1个选项
+      quantity: 1,
+      selectIndex:0, // 属性索引
+    },
+  
+    observers: {
+      'product': function(specs) {
+        // console.log("888888888888",specs);
+        specs && this.getProdDetail(specs);
+      }
+    },
+  
+    methods: {
+      // 获取商品详情
+      getProdDetail(e){
+        let data = {
+            pageNum:1,
+            pageSize:1,
+            mercId:e.mercId,
+            prodId:e.prodId
+        }  
+        API.getProdDetail(data).then(res=>{
+            this.setData({
+                productDetail:res
+            })
+        })
+      },
+
+      // 关闭模态框
+      handleClose() {
+        this.triggerEvent('close');
+      },
+      
+      // 选择属性
+      selectSpec(e) {
+        let index = e.currentTarget.dataset.index;
+        let availQty = this.data.productDetail.prodAttrList[index].availQty;
+        this.setData({ 
+            selectIndex:index,
+            quantity:availQty > 0?1:0
+        });
+      },
+      
+      // 添加数量
+      increaseQuantity() {
+        const { quantity, productDetail,selectIndex } = this.data;
+        if (quantity < productDetail.prodAttrList[selectIndex].availQty) {
+          this.setData({ quantity: quantity + 1 });
+        }
+      },
+      
+      // 减少数量
+      decreaseQuantity() {
+        const { quantity } = this.data;
+        if (quantity > 1) {
+          this.setData({ quantity: quantity - 1 });
+        }
+      },
+      
+      handleAddToCart() { 
+        let {mercId,prodAttrList,prodId} = this.data.productDetail;  
+        const cartItem = {
+            prodAttrId: prodAttrList[this.data.selectIndex].prodAttrId,
+            mercId,
+            prodId,
+            count:this.data.quantity
+        };
+        API.addCarts(cartItem).then(res=>{
+            // 可以显示添加成功的提示
+            wx.showToast({
+                title: '已加入购物车',
+                icon: 'success'
+            });
+            this.triggerEvent('close', { item: cartItem });
+        })
+      }
+    },
+    
+    computed: {
+      
+    }
+  });

+ 3 - 0
components/addCartModel/addCartModel.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 47 - 0
components/addCartModel/addCartModel.wxml

@@ -0,0 +1,47 @@
+<!--components/addCartModel/addCartModel.wxml-->
+<view class="modal-container {{visible ? 'modal-show' : ''}}">
+  <view class="modal-mask" bindtap="handleClose"></view>
+  <view class="modal-content">
+    <!-- 头部关闭按钮 -->
+    <view class="modal-header">
+      <text class="title">选择规格</text>
+      <text class="close-btn" bindtap="handleClose">×</text>
+    </view>
+    
+    <!-- 商品信息 -->
+    <view class="product-info">
+      <image class="product-image" src="{{productDetail.prodPicList[0].picUrl}}" mode="aspectFill"></image>
+      <view class="product-detail">
+        <view class="prodName">{{productDetail.prodName}}</view>
+        <view class="product-attr">
+            <text class="price">¥{{productDetail.prodAttrList[selectIndex].prodAttrPrice.price}}</text>
+            <text class="stock">剩余:{{productDetail.prodAttrList[selectIndex].availQty}}</text>
+        </view>
+      </view>
+    </view>
+
+    <!-- 数量选择 -->
+    <view class="quantity-section">
+      <view class="quantity-title">购买数量</view>
+      <view class="quantity-control">
+        <text class="btn-minus" bindtap="decreaseQuantity" disabled="{{quantity <= 1}}">-</text>
+        <input class="quantity-input" type="number" value="{{quantity}}" disabled />
+        <text class="btn-plus" bindtap="increaseQuantity" disabled="{{quantity >= productDetail.stock}}">+</text>
+      </view>
+    </view>
+    
+    <!-- 规格选择 -->
+    <view class="spec-section">
+      <text class="spec-title">规格</text>
+      <view class="spec-option">
+        <text class="spec-name {{index === selectIndex?'selected':''}}" data-index="{{index}}" wx:for="{{productDetail.prodAttrList}}" wx:key="name" bindtap="selectSpec">{{item.attrName}}</text>
+      </view>
+    </view>
+    
+    
+    <!-- 底部按钮 -->
+    <view class="footer">
+      <button class="add-btn" bindtap="handleAddToCart">加入购物车</button>
+    </view>
+  </view>
+</view>

+ 193 - 0
components/addCartModel/addCartModel.wxss

@@ -0,0 +1,193 @@
+/* components/addCartModel/addCartModel.wxss */
+.modal-container {
+    position: fixed;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 999;
+    visibility: hidden;
+    opacity: 0;
+    transition: all 0.3s ease;
+  }
+  
+  .modal-container.modal-show {
+    visibility: visible;
+    opacity: 1;
+  }
+  
+  .modal-mask {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    background: rgba(0, 0, 0, 0.5);
+  }
+  
+  .modal-content {
+    position: absolute;
+    bottom: 0;
+    left: 0;
+    width: 100%;
+    max-height: 80vh;
+    background: #fff;
+    border-radius: 24rpx 24rpx 0 0;
+    box-sizing: border-box;
+    padding: 32rpx;
+    transform: translateY(100%);
+    transition: transform 0.3s ease;
+    overflow-y:scroll;
+  }
+  
+  .modal-show .modal-content {
+    transform: translateY(0);
+  }
+  
+  .modal-header {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 32rpx;
+  }
+  
+  .modal-header .title {
+    font-size: 32rpx;
+    font-weight: bold;
+  }
+  
+  .close-btn {
+    margin: 0;
+    padding: 0;
+    width: 48rpx;
+    height: 48rpx;
+    line-height: 48rpx;
+    font-size: 36rpx;
+    background: transparent;
+    border: none;
+  }
+  
+  .product-info {
+    display: flex;
+    margin-bottom: 32rpx;
+  }
+  
+  .product-image {
+    width: 221rpx;
+    height: 221rpx;
+    border-radius: 30rpx;
+    margin-right: 24rpx;
+  }
+  
+  .product-detail {
+    flex: 1;
+  }
+  
+  .product-attr{
+      display: flex;
+      align-items: flex-end;
+      justify-content: space-between;
+  }
+
+  .price {
+    font-size: 36rpx;
+    color: #ff2e4d;
+    font-weight: bold;
+  }
+  
+  .stock {
+    font-size: 24rpx;
+    color: #000;
+  }
+  
+  .prodName {
+    font-size: 32rpx;
+    color: #000;
+    font-weight: 600;
+    margin-bottom: 130rpx;
+  }
+  
+  .spec-section {
+    margin-bottom: 32rpx;
+  }
+
+  .spec-option{
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+  }
+
+  .spec-title{
+    font-size: 28rpx;
+    margin-bottom: 19rpx;
+    display: inline-block;
+  }
+  
+  .spec-name {
+    width: 45%;
+    line-height: 63rpx;
+    font-size: 28rpx;
+    text-align: center;
+    margin-bottom: 27rpx;
+    background:#EFEFEF;
+    border-radius: 20rpx;
+    display: inline-block;
+  }
+  
+  .spec-name.selected {
+    background:#F9DFA4;
+  }
+  
+  .quantity-section {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 48rpx;
+  }
+  
+  .quantity-title {
+    font-size: 28rpx;
+  }
+  
+  .quantity-control {
+    display: flex;
+    align-items: center;
+  }
+  
+  .quantity-input {
+    width: 80rpx;
+    text-align: center;
+    margin: 0 16rpx;
+  }
+  
+  .btn-minus, .btn-plus {
+    width: 60rpx;
+    height: 60rpx;
+    line-height: 60rpx;
+    text-align: center;
+    padding: 0;
+    margin: 0;
+    border: 1rpx solid #eee;
+    background: #f7f7f7;
+    border-radius: 8rpx;
+  }
+  
+  .btn-minus[disabled], .btn-plus[disabled] {
+    opacity: 0.5;
+  }
+  
+  .footer {
+    width: 100%;
+    background: #fff;
+    padding-top: 16rpx;
+  }
+  
+  .add-btn {
+    width: 657rpx !important;
+    background: #89C6BE;
+    color: #fff;
+    border-radius: 20rpx;
+    line-height: 105rpx;
+    font-size: 30rpx;
+    padding: 0;
+  }

+ 19 - 0
components/header/header.js

@@ -0,0 +1,19 @@
+// components/header/header.js
+Component({
+    properties: {
+        // header嵌入的位置,index:首页
+        position:{
+            type:String,
+            value:''
+        }
+    },
+    data: {
+      index:0
+    },
+    methods: {
+        
+    },
+    ready: function(){
+        console.log(this.data.position);
+    }
+  })

+ 3 - 0
components/header/header.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 18 - 0
components/header/header.wxml

@@ -0,0 +1,18 @@
+<!--components/header/header.wxml-->
+<view class="header">
+    <view class="header-bg"></view>
+    <view class="logo logo-at-left">
+      <image src="/images/index/logo.png" class="logo-image"></image>
+    </view>
+    <view class="mark-icon" wx:if="{{position != 'index'}}">
+       <image class="mark-image" src="/images/mall/{{position}}.png" mode="widthFix"/>
+    </view>
+    <view class="search-and-cart" wx:if="{{position === 'index'}}">
+      <view class="search">
+        <image src="/images/index/search.png" class="search-icon"></image>
+      </view>
+      <view class="cart">
+        <image src="/images/index/cart.png" class="cart-icon"></image>
+      </view>
+    </view>
+  </view>

+ 58 - 0
components/header/header.wxss

@@ -0,0 +1,58 @@
+/* components/header/header.wxss */
+.header {
+    height: 330rpx;
+    position: relative;
+  }
+  .header .header-bg {
+    z-index: 1;
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100vw;
+    height: 295rpx;
+    background: #CFEAE5;
+  }
+  .header .logo {
+    width: 150rpx;
+    height: 150rpx;
+    z-index: 99;
+  }
+  .header .logo.logo-at-left {
+    position: absolute;
+    top: 96rpx;
+    left: 36rpx;
+  }
+  .header .logo-image {
+    width: 100%;
+    height: 100%;
+  }
+  .header .mark-icon{
+    width: 100%;
+    height: 295rpx;
+    position: absolute;
+    top:0;
+    right:0;
+    z-index: 2;
+  }
+  .header .mark-icon .mark-image{
+      width: 100%;
+      position: absolute;
+      right: 0;
+      bottom: 0;
+  }
+  .header .search-icon {
+    position: absolute;
+    z-index: 99;
+    top: 260rpx;
+    left: 30rpx;
+    height: 65rpx;
+    width: 530rpx;
+  }
+  .header .cart-icon {
+    position: absolute;
+    z-index: 99;
+    top: 260rpx;
+    right: 30rpx;
+    height: 65rpx;
+    width: 146rpx;
+  }

+ 106 - 0
components/product-list/product-list.js

@@ -0,0 +1,106 @@
+// components/product-list/product-list.js
+
+// 获取应用实例
+const {API} = require('../../service/api.js');
+
+
+Component({
+    properties: {
+        // header嵌入的位置,index:首页
+        position:{
+            type:String,
+            value:''
+        },
+        filterObj:{
+            type:Object,
+            value:{}
+        }
+    },
+    observers:{
+        "filterObj": function(newVal){
+           this.getClassifyCommodity();
+        }
+    },
+    data: {
+        goodsList: [],
+        pageNum:1,
+    },
+    methods: {
+        // 获取今日热门商品列表
+        getHotCommodity(){
+            API.getLeftProds().then(res=>{
+                if(res){
+                    this.setData({
+                        goodsList:res.prodList
+                    })
+                };
+            })
+        },
+        // 获取上新商品列表
+        getNewCommodity(){
+            API.getMiddleProds().then(res=>{
+                if(res){
+                    this.setData({
+                        goodsList:res.prodList
+                    })
+                };
+            })
+        },
+        // 获取预售商品列表
+        getPresaleCommodity(){
+            API.getRightProds().then(res=>{
+                if(res){
+                    this.setData({
+                        goodsList:res.prodList
+                    })
+                }
+            })
+        },
+        // 获取分类商品
+        getClassifyCommodity(){
+            let data = {
+                ...this.data.filterObj,
+                pageNum:this.data.pageNum,
+                pageSize:5
+            }
+            API.getProdsList(data).then(res=>{
+                if(res){
+                    this.setData({
+                        goodsList:this.data.pageNum === 1?res.mercProdList:[...this.data.goodsList,...res.mercProdList]
+                    })
+                }
+            })
+        },
+        // 添加购物车
+        addCart(prod){
+            console.log(prod);
+            let prodInfo = prod.currentTarget.dataset.prod;
+            this.triggerEvent('addCart',prodInfo);
+            // let data = {
+            //     mercId:prodInfo.mercId,
+            //     prodId:prodInfo.prodId,
+            //     prodAttrId:prodInfo.prodAttrList[0],
+            //     count:1
+            // }
+            // API.addCart(data).then(res=>{
+            //     console.log(res);
+            // })
+        },
+        // 观察滚动触底事件
+        onReachBottom(e){
+            this.setData({
+                pageNum:this.data.pageNum+1
+            });
+            this.observerFunction();
+        },
+        observerFunction(){
+            if(this.data.position === 'hot') this.getHotCommodity();
+            if(this.data.position === 'new') this.getNewCommodity();
+            if(this.data.position === 'presale') this.getPresaleCommodity();
+            if(this.data.position === 'sort' || this.data.position === 'index') this.getClassifyCommodity();
+        },
+    },
+    ready: function(){
+        this.observerFunction();
+    }
+})

+ 3 - 0
components/product-list/product-list.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 32 - 0
components/product-list/product-list.wxml

@@ -0,0 +1,32 @@
+<!--components/product-list/product-list.wxml-->
+<scroll-view class="scrollView {{position === 'index'&&'scrollViewIndex'}}" scroll-y bindscrolltolower="onReachBottom">
+    <view class="products">
+        <view class="goods-item" wx:for="{{goodsList}}" wx:key="index">
+            <view class="goods-image">
+                <image src="{{item.prodPicList[0].picUrl}}" mode="aspectFill" class="goods-image-inner"></image>
+            </view>
+            <view class="goods-info">
+                <text class="goods-name">{{item.prodName}}</text>
+                <text class="goods-price" wx:if="{{position !== 'presale'}}">¥{{item.prodPicList[0].price}}</text>
+            </view>
+            <view class="goods-action" wx:if="{{position !== 'presale'}}">
+                <view class="favorite">
+                    <image src="/images/index/fav.png" class="favorite-icon"></image>
+                </view>
+                <view class="goods-but">
+                    <image class="add-to-cart" src="/images/index/add-cart.png" mode="" data-prod="{{item}}" catchtap="addCart"/>
+                    <image class="buy-now" src="/images/index/buy-now.png" mode=""/>
+                </view>
+            </view>
+            <view class="goods-action" wx:else>
+                <text class="goods-price">¥{{item.price}}</text>
+                <view class="goods-but">
+                    <view class="favorite">
+                        <image src="/images/mall/fav.png" class="favorite-icon"></image>
+                    </view>
+                    <image class="shoppingCart" src="/images/mall/cart.png" mode="widthFix" data-prod="{{item}}" catchtap="addCart"/>
+                </view>
+            </view>
+        </view>
+    </view>
+</scroll-view>

+ 81 - 0
components/product-list/product-list.wxss

@@ -0,0 +1,81 @@
+/* components/product-list/product-list.wxss */
+.scrollView{
+    height: calc(100vh - 550rpx);
+}
+.scrollViewIndex{
+    height: 1080rpx;
+}
+.products{
+    padding:0 30rpx;
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+}
+.goods-item {
+    width: 326rpx; /* 313*1.0417 */
+    background: #fff;
+    border-radius: 25rpx; /* 20*1.0417 */
+    box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.05);
+    overflow: hidden;
+    display: flex;
+    flex-direction: column;
+    margin-bottom: 39rpx;
+    border: 4rpx solid #7AC7B5;
+}
+.goods-image {
+    width: 326rpx;
+    height: 326rpx;
+    background: #f7f7f7;
+}
+.goods-image-inner {
+    width: 100%;
+    height: 100%;
+    object-fit: cover;
+}
+.goods-info {
+    padding: 16rpx 21rpx 0 21rpx;
+}
+.goods-name {
+    font-size: 18rpx;
+    color: #333;
+    display: block;
+    margin-bottom: 8rpx;
+    font-weight: bold;
+    overflow: hidden;
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+    -webkit-line-clamp: 2;
+    text-overflow: ellipsis;      
+}
+.goods-price {
+    font-size: 30rpx;
+    color: #40665E;
+}
+.goods-action {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin: 16rpx 21rpx 21rpx 21rpx;
+}
+.favorite {
+  width: 32rpx;
+  height: 32rpx;
+}
+.favorite-icon {
+  width: 100%;
+  height: 100%;
+}
+.shoppingCart{
+    width: 40rpx;
+    margin:0 20rpx 0 40rpx;
+}
+.goods-but{
+    display: flex;
+}
+.add-to-cart,
+.buy-now {
+  width: 99rpx;
+  height: 39rpx;
+  border-radius: 6rpx;
+  margin-left: 8rpx;
+}

BIN
images/cart/empty.png


BIN
images/index/fav.png


BIN
images/mall/cart.png


BIN
images/mall/fav.png


BIN
images/mall/hot.png


BIN
images/mall/new.png


BIN
images/mall/presale.png


BIN
images/mall/search.png


+ 66 - 0
pages/Mall/hotCommodity/hotCommodity.js

@@ -0,0 +1,66 @@
+// pages/Mall/hotCommodity/hotCommodity.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 8 - 0
pages/Mall/hotCommodity/hotCommodity.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+      "header":"/components/header/header",
+      "product-list":"/components/product-list/product-list"
+  },
+  "navigationStyle":"custom",
+  "navigationBarTitleText":"热门商品"
+}

+ 7 - 0
pages/Mall/hotCommodity/hotCommodity.wxml

@@ -0,0 +1,7 @@
+<!--pages/Mall/hotCommodity/hotCommodity.wxml-->
+
+<!-- 头部 -->
+<header position="hot"></header>
+
+<!-- 商品列表 -->
+<product-list position="hot"></product-list>

+ 1 - 0
pages/Mall/hotCommodity/hotCommodity.wxss

@@ -0,0 +1 @@
+/* pages/Mall/hotCommodity/hotCommodity.wxss */

+ 66 - 0
pages/Mall/newCommodity/newCommodity.js

@@ -0,0 +1,66 @@
+// pages/Mall/newCommodity/newCommodity.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 8 - 0
pages/Mall/newCommodity/newCommodity.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+      "header":"/components/header/header",
+      "product-list":"/components/product-list/product-list"
+  },
+  "navigationStyle":"custom",
+  "navigationBarTitleText":"上新商品"
+}

+ 7 - 0
pages/Mall/newCommodity/newCommodity.wxml

@@ -0,0 +1,7 @@
+<!--pages/Mall/newCommodity/newCommodity.wxml-->
+
+<!-- 头部 -->
+<header position="new"></header>
+
+<!-- 商品列表 -->
+<product-list position="new"></product-list>

+ 1 - 0
pages/Mall/newCommodity/newCommodity.wxss

@@ -0,0 +1 @@
+/* pages/Mall/newCommodity/newCommodity.wxss */

+ 66 - 0
pages/Mall/presaleCommodity/presaleCommodity.js

@@ -0,0 +1,66 @@
+// pages/Mall/presaleCommodity/presaleCommodity.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 8 - 0
pages/Mall/presaleCommodity/presaleCommodity.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+      "header":"/components/header/header",
+      "product-list":"/components/product-list/product-list"
+  },
+  "navigationStyle":"custom",
+  "navigationBarTitleText":"预售商品"
+}

+ 7 - 0
pages/Mall/presaleCommodity/presaleCommodity.wxml

@@ -0,0 +1,7 @@
+<!--pages/Mall/presaleCommodity/presaleCommodity.wxml-->
+
+<!-- 头部 -->
+<header position="presale"></header>
+
+<!-- 商品列表 -->
+<product-list position="presale"></product-list>

+ 1 - 0
pages/Mall/presaleCommodity/presaleCommodity.wxss

@@ -0,0 +1 @@
+/* pages/Mall/presaleCommodity/presaleCommodity.wxss */

+ 109 - 0
pages/Mall/sortCommodity/sortCommodity.js

@@ -0,0 +1,109 @@
+// pages/Mall/sortCommodity/sortCommodity.js
+
+// 获取应用实例
+const {API} = require('../../../service/api.js');
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    ipInfoList:[
+        {ipName:'全部',ipId:''}
+    ],
+    filterIndex1:-1,
+    filterIndex2:-1,
+    filterObj:{} //筛选条件
+  },
+
+  // 监听筛选
+  selectFilter(e){
+      let {index,index2,item} = e.currentTarget.dataset;
+      let filterObj = this.data.filterObj;
+      if(index === 0) filterObj.ipId = item.ipId;
+      if(index === 1) filterObj.prodClassId = item.prodClassId;
+      this.setData({
+          [index === 0?'filterIndex1':'filterIndex2']:index2,
+          filterObj
+      })
+  },
+
+  // 获取IP分类
+  getIpList(){
+      API.getIpInfos().then(res=>{
+          if(res){
+              res.ipInfoList.push({ipName:"全部",ipId:''})
+              this.setData({
+                ipInfoList:res.ipInfoList
+              })
+          };
+      })
+  },
+  // 获取商品分类
+  getProdClasses(){
+      API.getProdClasses().then(res=>{
+          if(res){
+              res.prodClassList.push({className:"全部",prodClassId:''})
+              this.setData({
+                prodClassList:res.prodClassList
+              })
+          };
+      })
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.getProdClasses();
+    this.getIpList();
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 8 - 0
pages/Mall/sortCommodity/sortCommodity.json

@@ -0,0 +1,8 @@
+{
+    "usingComponents": {
+        "header":"/components/header/header",
+        "product-list":"/components/product-list/product-list"
+    },
+    "navigationStyle":"custom",
+    "navigationBarTitleText":"分类商品"
+  }

+ 32 - 0
pages/Mall/sortCommodity/sortCommodity.wxml

@@ -0,0 +1,32 @@
+<!--pages/Mall/sortCommodity/sortCommodity.wxml-->
+
+<!-- 头部 -->
+<header position="sort"></header>
+
+<!-- 分类 -->
+<view class="sortView">
+
+   <view class="filterCriteria" wx:for="{{2}}" wx:for-item="sort" wx:key="index">
+
+      <view class="searchIcon">
+
+        <image src="/images/mall/search.png" mode=""/>
+      
+      </view>
+
+    <scroll-view class="scrollView" scroll-x>
+    
+      <view wx:for="{{sort === 0?ipInfoList:prodClassList}}" wx:key="index" wx:for-index="index2" data-item="{{item}}" data-index="{{sort}}" data-index2="{{index2}}" class="filterText {{sort === 0 && filterIndex1 === index2?'selected':''}} {{sort === 1 && filterIndex2 === index2?'selected':''}}"  catchtap="selectFilter">
+         
+        <text>{{sort === 0?item.ipName:item.className}}</text>
+
+      </view>
+
+    </scroll-view>
+
+   </view>
+
+</view>
+
+<!-- 商品列表 -->
+<product-list position="sort" filterObj="{{filterObj}}"></product-list>

+ 42 - 0
pages/Mall/sortCommodity/sortCommodity.wxss

@@ -0,0 +1,42 @@
+/* pages/Mall/sortCommodity/sortCommodity.wxss */
+.sortView{
+    padding: 0 20px 10px 20px;
+}
+.sortView .filterCriteria{
+    height: 65rpx;
+    border-bottom: 1px solid #CFEAE5;
+    margin-top: 35rpx;
+    display: flex;
+}
+.sortView .filterCriteria .searchIcon image{
+    width: 50rpx;
+    height: 50rpx;
+    align-self: center;
+    padding-right: 20rpx;
+}
+.sortView .filterCriteria .filterText{
+    font-size: 23rpx;
+    color: #7A7A7A;
+    text-align: center;
+    background: linear-gradient(to top, 
+    white 0%, 
+    white 20%, 
+    #CFEAE5 20%, 
+    #CFEAE5 80%, 
+    white 60%, 
+    white 100%
+  ) right center / 2rpx 100% no-repeat;
+    line-height: 65rpx;
+    box-sizing: border-box;
+    padding: 0 10rpx;
+    flex: 1;
+    display: inline-block;
+}
+.sortView .filterCriteria .selected{
+    background: #CFEAE5;
+}
+.sortView .filterCriteria .scrollView{
+    white-space: nowrap;
+    display: flex;
+    overflow: hidden;
+}

+ 142 - 1
pages/cart/cart.js

@@ -1 +1,142 @@
-Page({})
+// 获取应用实例
+const {API} = require('../../service/api.js');
+Page({
+    data:{
+        cartList: [
+            { id: 1, name: "商品A商品A商品A商品A商品A", price: 100, checked: false, count: 1 },
+            { id: 2, name: "商品B商品B商品B商品B商品B", price: 200, checked: false, count: 2 },
+            { id: 3, name: "商品C", price: 300, checked: false, count: 1 }
+        ],
+        isAllChecked: false, // 全选状态
+        totalPrice:0,
+        checkedCount:0,
+        isManage:false, // 是否进入管理模式
+    },
+    // 获取购物车商品
+    getCartProds(){
+       API.getCartProds().then(res=>{
+           this.handleCartsFn(res);
+       })
+    },
+    // 处理商品函数
+    handleCartsFn(value){
+        let num = 0,checkIds=[];
+        value.carts.forEach(item=>{
+            if(item.checkFlag === "1"){
+                num+=1;
+                checkIds.push(item.id+'');
+            }
+        })
+        this.setData({
+             cartList:value.carts,
+             totalPrice:value.checkedSumAmount,
+             checkedIds:checkIds,
+             isAllChecked:num === value.carts.length
+        })
+    },
+    // 购物车选中/取消
+    handleCheckboxFn(prodId){
+        let {id} = this.data.cartList.filter(item=>item.id == prodId)[0];
+       API.checkedCartProds({id}).then(res=>{
+          this.handleCartsFn(res);
+       })
+    },
+    // 选中/取消选中所有
+    handleCheckedAll(){
+        API.handleCheckedAll().then(res=>{
+          
+        })
+    },
+    // 取消选中所有
+    handleUncheckedAll(){
+        API.handleUncheckedAll().then(res=>{
+            
+        })
+    },
+    // 删除选中的商品
+    deleteProd(){
+        let ids = this.data.checkedIds;
+        API.deleteCartProds({ids}).then(res=>{
+            this.handleCartsFn(res);
+        })
+    },
+    // 复选框变化事件
+    handleCheckboxChange(e) {
+        const oldCheckIds = this.data.checkedIds;
+        const checkedIds = e.detail.value; // 选中的商品id数组(如 ['1', '2'])
+        const cartList = this.data.cartList.map(item => {
+        item.checkFlag = checkedIds.includes(item.id.toString());
+            return item;
+        });
+        // 取消选中
+        if(oldCheckIds.length > checkedIds.length){
+           let id = oldCheckIds.filter(item=>!checkedIds.includes(item));
+           this.handleCheckboxFn(id[0]);
+        }else{
+           this.handleCheckboxFn(checkedIds.at(-1));
+        }
+        this.setData({ 
+            cartList,
+            checkedIds,
+            isAllChecked: checkedIds.length === this.data.cartList.length
+        });
+        this.calculateTotal(); // 计算总价
+    },
+    // 全选/取消全选
+    toggleAll() {
+        const isAllChecked = !this.data.isAllChecked;
+        const cartList = this.data.cartList.map(item => {
+            item.checkFlag = isAllChecked;
+            return item;
+        });
+        this.setData({ cartList, isAllChecked });
+        if(isAllChecked){
+            this.handleCheckedAll();
+        }else{
+            this.handleUncheckedAll();
+        }
+        this.calculateTotal();
+    },
+    // 增加数量
+    increaseCount(e) {
+        const id = e.currentTarget.dataset.id;
+        const cartList = this.data.cartList.map(item => {
+        if (item.id == id) item.quantity++;
+            return item;
+        });
+        this.setData({ cartList });
+        this.calculateTotal();
+    },
+  
+    // 减少数量
+    decreaseCount(e) {
+        const id = e.currentTarget.dataset.id;
+        const cartList = this.data.cartList.map(item => {
+        if (item.id == id && item.quantity > 1) item.quantity--;
+            return item;
+        });
+        this.setData({ cartList });
+        this.calculateTotal();
+    },
+    // 计算总价和选中数量
+    calculateTotal() {
+        let totalPrice = 0;
+        let checkedCount = 0;
+        this.data.cartList.forEach(item => {
+        if (item.checkFlag) {
+            totalPrice += item.price * item.quantity;
+            checkedCount++;
+        }
+        });
+        this.setData({ totalPrice, checkedCount });
+    },
+    // 管理按钮
+    manageBut(){
+        this.setData({
+            isManage:!this.data.isManage
+        })
+    },
+    onLoad(){
+        this.getCartProds();
+    }
+})

+ 4 - 2
pages/cart/cart.json

@@ -1,4 +1,6 @@
 {
-  "navigationStyle": "custom",
-  "usingComponents": {}
+  "navigationBarTitleText":"购物车",
+  "usingComponents": {
+    "product-list":"/components/product-list/product-list"
+  }
 }

+ 48 - 1
pages/cart/cart.wxml

@@ -1,3 +1,50 @@
 <view>
-  cart
+    <view class="manage">
+       <text bindtap="manageBut">{{isManage?"完 成":"管  理"}}</text>
+    </view>
+    <!-- 暂无可管理商品 -->
+    <view class="empty" wx:if="{{false}}">
+       <image class="emptyIcon" src="/images/cart/empty.png" alt=""/>
+       <text>暂无可管理商品</text>
+    </view>
+    <!-- 商品列表 -->
+    <view class="prodsList">
+        <checkbox-group bindchange="handleCheckboxChange">
+            <view class="itemProd" wx:for="{{cartList}}" wx:key="id">
+                <checkbox value="{{item.id}}" checked="{{item.checkFlag === '1'}}"></checkbox>
+                <view class="goods-info">
+                    <image src="/images/index/category-item.png" mode="aspectFill"></image>
+                    <view class="info">
+                        <text>{{item.prodName}}</text>
+                        <text>{{item.prodAttrName}}</text>
+                        <text>¥{{item.price}}</text>
+                    </view>
+                    <view class="count">
+                        <text class="reduceNum" bindtap="decreaseCount" data-id="{{item.id}}">-</text>
+                        <text class="num">{{item.quantity}}</text>
+                        <text class="addNum" bindtap="increaseCount" data-id="{{item.id}}">+</text>
+                    </view>
+                </view>
+            </view>
+        </checkbox-group>
+    
+    </view>
+    <!-- 推荐 -->
+    <view class="recommend">
+        <view class="divider">
+           <text class="line"></text>
+           <text class="text">更多个性化推荐</text>
+           <text class="line"></text>
+        </view>
+        <product-list position="hot"></product-list>
+    </view>
+    <!-- 底部全选和总价 -->
+    <view class="footer {{isManage && 'manageFooter'}}" >
+        <label class="checkBoxAll">
+            <checkbox value="all" checked="{{isAllChecked}}" bindtap="toggleAll">全 选</checkbox>
+        </label>
+        <text wx:if="{{!isManage}}">合计:¥{{totalPrice}}</text>
+        <text wx:if="{{!isManage}}">确认下单</text>
+        <view class="delete" wx:if="{{isManage}}" catchtap="deleteProd">删 除</view>
+    </view>
 </view>

+ 117 - 0
pages/cart/cart.wxss

@@ -0,0 +1,117 @@
+.manage{
+    width: 668rpx;
+    font-size: 25rpx;
+    text-align: right;
+    border-bottom: 2rpx solid #CFCFCF;
+    margin: 50rpx auto 0 auto;
+}
+/* 暂无可管理商品 */
+.empty{
+    text-align: center;
+    padding: 148rpx 0;
+}
+.emptyIcon{
+    width: 107rpx;
+    height: 107rpx;
+}
+.empty text{
+    font-size: 30rpx;
+    margin-top: 20rpx;
+    display: block;
+}
+/* 商品列表 */
+.prodsList{
+   width: 668rpx;
+   margin: auto;
+}
+.itemProd{
+    height: 224rpx;
+    border-bottom: 1rpx solid #EFEFEF;
+    display: flex;
+    align-items: center;
+}
+/* 商品信息 */
+.goods-info {
+    flex: 1;
+    display: flex;
+    margin-left: 10px;
+    position: relative;
+}
+.goods-info image {
+    width: 170rpx;
+    height: 170rpx;
+    border-radius: 10rpx;
+}
+.goods-info .info {
+    margin-left: 10px;
+    display: flex;
+    flex-direction: column;
+}
+  
+/* 数量加减按钮 */
+.count {
+    width: 144rpx;
+    height: 39rpx;
+    display: flex;
+    align-items: center;
+    border: 2rpx solid #CFCFCF;
+    border-radius: 50rpx;
+    position: absolute;
+    right: 10rpx;
+    bottom: 0;
+}
+.count .addNum,.count .reduceNum {
+    width: 39rpx;
+    line-height: 39rpx;
+    text-align: center;
+    font-size: 16px;
+    display: inline-block;
+}
+.count .num{
+    width: 66rpx;
+    text-align: center;
+    border-left: 2rpx solid #CFCFCF;
+    border-right: 2rpx solid #CFCFCF;
+    display: inline-block;
+}
+  
+/* 底部栏 */
+.footer {
+    position: fixed;
+    bottom: 0;
+    width: 100%;
+    color: #FFFFFF;
+    display: flex;
+    align-items: center;
+    justify-content: space-around;
+    padding: 10px 0;
+    background: #FED279;
+}
+.manageFooter{
+    background: #EA6087;
+    justify-content: space-between;
+}
+.manageFooter .checkBoxAll{
+    margin-left: 50rpx;
+}
+.footer .delete{
+    width: 125rpx;
+    text-align: right;
+    border-left: 2rpx solid #FFFFFF;
+    margin-right: 50rpx;
+}
+.divider{
+    margin: 30rpx 0;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+.divider .text{
+    margin: 0 20rpx;
+}
+.line{
+    width: 200rpx;
+    height: 2rpx;
+    background: #CFCFCF;
+    display: inline-block;
+}

+ 17 - 22
pages/index/index.js

@@ -1,10 +1,10 @@
 // index.js
-const { HomepageApi } = require('../../service/api.js');
+const { API } = require('../../service/api.js');
 
 const App = getApp();
 
 
-Component({
+Page({
   data: {
     brandList: [
       {
@@ -64,26 +64,21 @@ Component({
         name: "立绘",
       },
     ],
-    goodsList: [
-      {
-        name: "哪吒魔童闹海周边",
-        price: 49.5
-      },
-      {
-        name: "若来十二生肖盲盒 桌面手办",
-        price: 49.5
-      },
-      {
-        name: "官方正版姜子牙电影四不像",
-        price: 49.5
-      },
-      {
-        name: "若来十二生肖盲盒 十二节气祖国版",
-        price: 49.5
-      },
-    ],
+    showAddCartModal: false,
+    currentProduct: null
+  },
+  // 显示商品属性模态框
+  showAddCartModal(e) {
+    const product = e.detail;
+    this.setData({
+      showAddCartModal: true,
+      currentProduct:product
+    });
+  },
+  // 关闭商品属性模态框
+  handleCloseAddCartModal() {
+    this.setData({ showAddCartModal: false });
   },
-
   methods: {
     onLoad: async function (options) {
 
@@ -91,7 +86,7 @@ Component({
       console.log("onLoad");
       console.log('App.globalData', App.globalData);
 
-      const res = await HomepageApi.getBanners({});
+      const res = await API.getBanners({});
       console.log('res', res);
     },
   },

+ 6 - 1
pages/index/index.json

@@ -1,3 +1,8 @@
 {
-  "usingComponents": {}
+  "navigationStyle": "custom",
+  "usingComponents": {
+    "header":"/components/header/header",
+    "product-list":"/components/product-list/product-list",
+    "addCartModel":"/components/addCartModel/addCartModel"
+  }
 }

+ 11 - 34
pages/index/index.wxml

@@ -1,19 +1,9 @@
 <!--index.wxml-->
 <view class="container">
-  <view class="header">
-    <view class="header-bg"></view>
-    <view class="logo logo-at-left">
-      <image src="/images/index/logo.png" class="logo-image"></image>
-    </view>
-    <view class="search-and-cart">
-      <view class="search">
-        <image src="/images/index/search.png" class="search-icon"></image>
-      </view>
-      <view class="cart">
-        <image src="/images/index/cart.png" class="cart-icon"></image>
-      </view>
-    </view>
-  </view>
+  
+  <!-- 头部 -->
+  <header position="index"></header>
+
   <view class="banner">
     <view class="banner-item">
       banner
@@ -46,24 +36,11 @@
       <image src="/images/index/category-item.png" class="category-image"></image>
     </view>
   </view>
-  <view class="goods">
-    <view class="goods-row" wx:for="{{goodsList}}" wx:key="index" wx:for-item="row">
-      <view class="goods-item" wx:for="{{row}}" wx:key="itemIndex">
-        <view class="goods-image">
-          <image src="{{item.imageUrl}}" class="goods-image-inner"></image>
-        </view>
-        <view class="goods-info">
-          <text class="goods-name">{{item.name}}</text>
-          <text class="goods-price">¥{{item.price}}</text>
-        </view>
-        <view class="goods-action">
-          <view class="favorite">
-            <image src="/images/index/fav.png" class="favorite-icon"></image>
-          </view>
-          <button class="add-to-cart">加入购物车</button>
-          <button class="buy-now">立即购买</button>
-        </view>
-      </view>
-    </view>
-  </view>
+
+  <!-- 商品列表 -->
+  <product-list position="index" bindaddCart="showAddCartModal"></product-list>
+
+  <!-- 商品属性模态框 -->
+  <addCartModel visible="{{showAddCartModal}}" product="{{currentProduct}}" bindclose="handleCloseAddCartModal"></addCartModel>
+
 </view>

+ 0 - 137
pages/index/index.wxss

@@ -6,50 +6,6 @@ page {
   flex-direction: column;
 }
 
-.header {
-  height: 330rpx;
-  position: relative;
-}
-.header .header-bg {
-  z-index: 1;
-  position: absolute;
-  top: 0;
-  left: 0;
-  width: 100vw;
-  height: 295rpx;
-  background: #dfefec;
-}
-.header .logo {
-  width: 150rpx;
-  height: 150rpx;
-  z-index: 99;
-}
-.header .logo.logo-at-left {
-  position: absolute;
-  top: 96rpx;
-  left: 36rpx;
-}
-.header .logo-image {
-  width: 100%;
-  height: 100%;
-}
-.header .search-icon {
-  position: absolute;
-  z-index: 99;
-  top: 260rpx;
-  left: 30rpx;
-  height: 65rpx;
-  width: 530rpx;
-}
-.header .cart-icon {
-  position: absolute;
-  z-index: 99;
-  top: 260rpx;
-  right: 30rpx;
-  height: 65rpx;
-  width: 146rpx;
-}
-
 .banner {
   display: flex;
   justify-content: center;
@@ -126,96 +82,3 @@ page {
   width: 100%;
   height: 100%;
 }
-.goods {
-  display: flex;
-  flex-direction: column;
-  padding: 21rpx 21rpx 0 21rpx;
-}
-
-.goods-row {
-  display: flex;
-  flex-direction: row;
-  justify-content: space-evenly;
-  margin-bottom: 21rpx;
-}
-
-.goods-item {
-  width: 326rpx; /* 313*1.0417 */
-  background: #fff;
-  border-radius: 21rpx; /* 20*1.0417 */
-  box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.05);
-  overflow: hidden;
-  display: flex;
-  flex-direction: column;
-}
-
-.goods-image {
-  width: 326rpx;
-  height: 326rpx;
-  margin: 0;
-  border-top-left-radius: 21rpx;
-  border-top-right-radius: 21rpx;
-  border-bottom-left-radius: 0;
-  border-bottom-right-radius: 0;
-  overflow: hidden;
-  background: #f7f7f7;
-}
-.goods-image-inner {
-  width: 100%;
-  height: 100%;
-  object-fit: cover;
-}
-.goods-info {
-  padding: 16rpx 21rpx 0 21rpx;
-}
-.goods-name {
-  font-size: 18rpx;
-  color: #333;
-  display: block;
-  margin-bottom: 8rpx;
-  font-weight: bold;
-}
-.goods-price {
-  font-size: 20rpx;
-  color: #e4393c;
-  font-weight: bold;
-}
-.goods-action {
-  display: flex;
-  align-items: center;
-  justify-content: flex-end;
-  padding: 16rpx 21rpx 21rpx 21rpx;
-}
-.favorite {
-  width: 32rpx;
-  height: 32rpx;
-}
-.favorite-icon {
-  width: 100%;
-  height: 100%;
-}
-.add-to-cart,
-.buy-now {
-  width: 105rpx;
-  height: 36rpx;
-  line-height: 36rpx;
-  font-size: 16rpx;
-  border-radius: 6rpx;
-  margin-left: 8rpx;
-  padding: 0;
-  border: none;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  box-sizing: border-box;
-}
-.add-to-cart {
-  background: #fff;
-  color: #7AC7B5;
-  border: 2rpx solid #7AC7B5;
-}
-.buy-now {
-  background: #7AC7B5;
-  color: #fff;
-  border: none;
-}

+ 15 - 2
project.config.json

@@ -18,11 +18,24 @@
       "ignore": [],
       "disablePlugins": [],
       "outputPath": ""
-    }
+    },
+    "compileWorklet": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "packNpmManually": false,
+    "minifyWXSS": true,
+    "minifyWXML": true,
+    "localPlugins": false,
+    "disableUseStrict": false,
+    "useCompilerPlugins": false,
+    "condition": false,
+    "swc": false,
+    "disableSWC": true
   },
   "condition": {},
   "editorSetting": {
     "tabIndent": "insertSpaces",
     "tabSize": 2
-  }
+  },
+  "simulatorPluginLibVersion": {}
 }

+ 23 - 8
project.private.config.json

@@ -1,9 +1,24 @@
-{
-  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "projectname": "GululuQ-mp",
-  "setting": {
-    "compileHotReLoad": true,
-    "urlCheck": false
-  },
-  "libVersion": "3.8.0"
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "GululuQ-mp",
+  "setting": {
+    "compileHotReLoad": true,
+    "urlCheck": false,
+    "coverView": true,
+    "lazyloadPlaceholderEnable": false,
+    "skylineRenderEnable": false,
+    "preloadBackgroundData": false,
+    "autoAudits": false,
+    "useApiHook": true,
+    "useApiHostProcess": true,
+    "showShadowRootInWxmlPanel": true,
+    "useStaticServer": false,
+    "useLanDebug": false,
+    "showES6CompileOption": false,
+    "checkInvalidKey": true,
+    "ignoreDevUnusedFiles": true,
+    "bigPackageSizeSupport": false
+  },
+  "libVersion": "3.8.4",
+  "condition": {}
 }

+ 48 - 9
service/api.js

@@ -19,8 +19,8 @@ export const Qiniu = {
   },
 }
 
-// HomepageApiController
-export const HomepageApi = {
+// APIController
+export const API = {
   /** 
    * 返回示例:{
     "bannerList": [
@@ -72,7 +72,8 @@ export const HomepageApi = {
     ]
   }
   */
-  getIpInfos: function (payload) {
+  // 获取IP信息
+  getIpInfos: function (payload={}) {
     return http.get("/api/store/homepage/ipInfos", {
       ...payload,
     });
@@ -119,7 +120,8 @@ export const HomepageApi = {
     ]
   }
   */
-  getLeftProds: function (payload) {
+  // 获取热门商品
+  getLeftProds: function (payload = {}) {
     return http.get("/api/store/homepage/leftProds", {
       ...payload,
     });
@@ -214,9 +216,46 @@ export const HomepageApi = {
     ]
   }
   */
-  getProdClasses: function (payload) {
-    return http.get("/api/store/homepage/prodClasses", {
-      ...payload,
-    });
-  },
+    // 获取商品分类信息
+    getProdClasses: function (payload) {
+        return http.get("/api/store/homepage/prodClasses", {
+        ...payload,
+        });
+    },
+    // 获取商品列表
+    getProdsList: function(payload = {}){
+        return http.post("/api/store/homepage/prods",payload)
+    },
+    //  获取购物车商品
+    getCartProds: function(){
+        return http.get("/api/store/carts/list",{})
+    },
+    // 添加购物车
+    addCart: function(payload){
+        return http.post("/api/store/carts/add",payload)
+    },
+    // 获取商品详情
+    getProdDetail: function(payload){
+        return http.post("/api/store/homepage/prodDetail",payload)
+    },
+    // 添加购物车
+    addCarts: function(playload){
+        return http.post("/api/store/carts/add",playload)
+    },
+    // 选中/取消购物车商品
+    checkedCartProds: function(playload){
+        return http.post("/api/store/carts/checked",playload)
+    },
+    // 选中选中所有商品
+    handleCheckedAll: function(playload){
+        return http.post("/api/store/carts/checkedAll",playload)
+    },
+    // 取消选中所有商品
+    handleUncheckedAll: function(playload){
+        return http.post("/api/store/carts/uncheckedAll",playload)
+    },
+    // 删除购物车选中的商品
+    deleteCartProds: function(playload){
+        return http.post("/api/store/carts/delete",playload)
+    },
 }

+ 2 - 2
utils/http.js

@@ -74,8 +74,8 @@ function getPromise(url, data, method) {
         method: method,
         data: data,
         success: function (res) {
-          if (res.data.code === 200) {
-            resolve(res.data.data);
+          if (res.statusCode === 200) {
+            resolve(res.data);
           } else {
             if (res.statusCode === 401) {
               reject(401);