Browse Source

✨ feat(cart): 添加购物车页面

陈雪 1 month ago
parent
commit
6a834d32fe

+ 7 - 1
src/locale/en.json

@@ -13,5 +13,11 @@
   "home.seeAll": "See All",
   "home.hotCategory": "Hot Category",
   "home.hotSelling": "Hot Selling",
-  "product.details": "Product Details"
+  "product.details": "Product Details",
+  "cart.homeName": "Home1",
+  "cart.manageCart": "Manage",
+  "cart.settlement": "Settlement",
+  "cart.priceUint": "$",
+  "cart.totalPrice": "Total Price",
+  "cart.selectAll": "Select All"
 }

+ 7 - 1
src/locale/zh-Hans.json

@@ -13,5 +13,11 @@
   "home.seeAll": "更多",
   "home.hotCategory": "热门分类",
   "home.hotSelling": "热销商品",
-  "product.details": "商品详情"
+  "product.details": "商品详情",
+  "cart.homeName": "地址1",
+  "cart.manageCart": "管理",
+  "cart.settlement": "支付",
+  "cart.priceUint": "¥",
+  "cart.totalPrice": "总价",
+  "cart.selectAll": "全选"
 }

+ 171 - 1
src/pages/cart/cart.vue

@@ -8,6 +8,7 @@
 }
 </route>
 <script setup lang="ts">
+  import { t } from '@/locale'
   const { safeAreaInsets } = uni.getSystemInfoSync()
 </script>
 <template>
@@ -15,6 +16,175 @@
     class="pb-tab bg-white overflow-hidden box-border"
     :style="{ marginTop: safeAreaInsets?.top + 'px' }"
   >
-    购物车
+    <wd-sticky>
+      <view class="nav-bar bg-white w-100vw">
+        <view class="cart-pos">
+          <view class="text">{{ t('tabbar.cart') }}</view>
+          <view class="pos">
+            <image class="w-36rpx" src="@/static/images/cart/pos.svg" mode="widthFix"></image>
+            <view class="address-name">{{ t('cart.homeName') }}</view>
+            <image class="w-36rpx" src="@/static/images/cart/right.svg" mode="widthFix"></image>
+          </view>
+        </view>
+        <view class="manage-cart">{{ t('cart.manageCart') }}</view>
+      </view>
+    </wd-sticky>
+
+    <view class="cart-list"></view>
+    <view class="cart-bottom-area pb-tab">
+      <view class="cart-control">
+        <view class="icon"></view>
+        <view class="text">{{ t('cart.selectAll') }}</view>
+        <view class="price">
+          {{ t('cart.totalPrice') }}
+          <view class="price-text flex">
+            {{ t('cart.priceUint') }}
+            <view v-format.price class="price-num">83.97</view>
+          </view>
+        </view>
+        <view class="button">{{ t('cart.settlement') }}</view>
+      </view>
+    </view>
   </view>
 </template>
+<style lang="scss" scoped>
+  :deep(.wd-sticky__container) {
+    top: 0 !important;
+  }
+
+  .cart-list {
+    height: 100vh;
+    margin-bottom: 130rpx;
+  }
+
+  .cart-bottom-area {
+    position: fixed;
+    bottom: 0;
+    box-sizing: border-box;
+    width: 750rpx;
+    background: $shop-white;
+
+    .cart-control {
+      box-sizing: border-box;
+      display: flex;
+      align-items: center;
+      width: 750rpx;
+      height: 120rpx;
+      padding: 16rpx 32rpx;
+      border-bottom: 2rpx solid var(--f-2-f-2-f-2, $shop-bg-line);
+
+      .icon {
+        box-sizing: border-box;
+        width: 42rpx;
+        height: 42rpx;
+        margin-right: 16rpx;
+        border: 4rpx solid $shop-bg-line;
+        border-radius: 50%;
+      }
+
+      .text {
+        margin-right: 96rpx;
+        font-family: 'PingFang SC';
+        font-size: 24rpx;
+        font-style: normal;
+        font-weight: 400;
+        line-height: 40rpx;
+        color: $shop-text-6;
+      }
+
+      .price {
+        width: 142rpx;
+        margin-right: 24rpx;
+        font-family: 'PingFang SC';
+        font-size: 28rpx;
+        font-style: normal;
+        font-weight: 400;
+        line-height: 44rpx;
+        color: var(--666, $shop-text-6);
+        text-align: center;
+
+        .price-text {
+          font-family: 'PingFang SC';
+          font-size: 28rpx;
+          font-style: normal;
+          font-weight: 500;
+          line-height: 44rpx; /* 157.143% */
+          color: var(--ff-4-c-1-b, $shop-primary);
+          text-align: center;
+        }
+      }
+
+      .button {
+        box-sizing: border-box;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        width: 260rpx;
+        height: 88rpx;
+        font-family: 'PingFang SC';
+        font-size: 32rpx;
+        font-style: normal;
+        font-weight: 600;
+        line-height: 48rpx; /* 150% */
+        color: #fff;
+        text-align: center;
+        text-transform: capitalize;
+        background: linear-gradient(270deg, $shop-primary 0%, $shop-help 100%);
+        border-radius: 42rpx;
+      }
+    }
+  }
+
+  .nav-bar {
+    box-sizing: border-box;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    height: 88rpx;
+    padding: 18rpx 32rpx;
+
+    .manage-cart {
+      font-family: 'PingFang SC';
+      font-size: 28rpx;
+      font-style: normal;
+      font-weight: 400;
+      line-height: 44rpx; /* 157.143% */
+      color: var(--666, $shop-text-6);
+      text-align: right;
+      text-transform: capitalize;
+    }
+
+    .cart-pos {
+      display: flex;
+      align-items: center;
+
+      .text {
+        font-family: 'PingFang SC';
+        font-size: 36rpx;
+        font-style: normal;
+        font-weight: 600;
+        line-height: 26rpx;
+        color: var($shop-text-3, #333333);
+      }
+
+      .pos {
+        box-sizing: border-box;
+        display: flex;
+        gap: 8rpx;
+        align-items: center;
+        align-self: stretch;
+        height: 52rpx;
+        padding: 10rpx 16rpx;
+        margin-left: 32rpx;
+        font-family: 'PingFang SC';
+        font-size: 24rpx;
+        font-style: normal;
+        font-weight: 400;
+        line-height: 40rpx; /* 166.667% */
+        color: var(--666, $shop-text-6);
+        background: var(--f-2-f-2-f-2, $shop-bg-line);
+        border-radius: 200rpx;
+      }
+    }
+  }
+</style>

+ 5 - 0
src/static/images/cart/pos.svg

@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
+  <path d="M3.6967 12.284C2.33947 12.6912 1.5 13.2537 1.5 13.875C1.5 15.1176 4.85786 16.125 9 16.125C13.1421 16.125 16.5 15.1176 16.5 13.875C16.5 13.2537 15.6605 12.6912 14.3033 12.284" stroke="#666666" stroke-linecap="round" stroke-linejoin="round"/>
+  <path d="M9 13.125C9 13.125 13.875 9.939 13.875 6.25568C13.875 3.62919 11.6924 1.5 9 1.5C6.30761 1.5 4.125 3.62919 4.125 6.25568C4.125 9.939 9 13.125 9 13.125Z" stroke="#666666" stroke-linejoin="round"/>
+  <path d="M9 8.25C10.0355 8.25 10.875 7.41052 10.875 6.375C10.875 5.33948 10.0355 4.5 9 4.5C7.96448 4.5 7.125 5.33948 7.125 6.375C7.125 7.41052 7.96448 8.25 9 8.25Z" stroke="#666666" stroke-linejoin="round"/>
+</svg>

+ 3 - 0
src/static/images/cart/right.svg

@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
+  <path d="M7.12471 4.5L11.6247 9L7.12471 13.5" stroke="#666666" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>