feat:购物车
This commit is contained in:
1 parent
ff759ff83b
commit
27fec438f6
5 files changed
+20
-16
No files matched your search
@@ -1,16 +1,17 @@
|
||||
<template>
|
||||
<crud-layout title="购物车" mainIsScroll tabBarType="just-flot-back" bg="/static/page/blue-bg.png">
|
||||
<view v-if="cartStore.totCount > 0" class="flex-row card p-x-15rpx p-y-25rpx m-t-20rpx" v-for="(v, i) in cartStore.cart" :key="i">
|
||||
<image class="size-160rpx rounded-12rpx" :src="filePath(v.picUrl)" mode="aspectFill" />
|
||||
<view class="flex-1 m-l-20rpx">
|
||||
<view class="sub-text-28 show-line">{{ v.productName }}</view>
|
||||
<view class="second-text-26 show-line">单位:{{ v.unit }}</view>
|
||||
<crud-layout title="购物车" mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<view class="h-20rpx"></view>
|
||||
<view v-if="cartStore.totalCount > 0" class="flex-row card px-15rpx py-25rpx mb-20rpx" v-for="(v, i) in cartStore.cart" :key="i">
|
||||
<image class="size-160rpx rounded-12rpx mr-20rpx bg-#eeeeee" :src="filePath(v.picUrl)" mode="aspectFill" />
|
||||
<view class="flex-1 overflow-hidden">
|
||||
<view class="sub-text-30 truncate">{{ v.productName }}</view>
|
||||
<view class="second-text-26 show-line">单位 {{ v.unit }}</view>
|
||||
<view class="flex-row justify-between items-center">
|
||||
<view class="second-text-30"> ¥{{ hooks.useMoney(v.productPrice) }} </view>
|
||||
<view class="second-text-30">x {{ v.productCount }}</view>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center">
|
||||
<view class="second-text-32 c-red!"> ¥{{ hooks.useMoney(v.totalPrice) }} </view>
|
||||
<view class="second-text-32 c-red!">¥{{ hooks.useMoney(v.totalPrice) }}</view>
|
||||
<view class="flex-row justify-between items-center">
|
||||
<view
|
||||
class="flex-row-center size-40rpx rounded-full border-1px border-solid border-color-#0094ff"
|
||||
@@ -27,14 +28,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="flex-col justify-center items-center pt-300rpx" v-else>
|
||||
<view v-else class="flex-col justify-center items-center pt-300rpx">
|
||||
<image src="@/static/page/cart_empty.png" class="w-350rpx h-350rpx" />
|
||||
<text class="sub-text-32 font-bold">购物车空空如也</text>
|
||||
</view>
|
||||
|
||||
<template #main-bottom>
|
||||
<view class="z-200 p-x-30rpx p-y-30rpx bg-white">
|
||||
<product-total :totPrice="cartStore.totPrice" :totCount="cartStore.totCount" @doContainer="" @submit="doBuy" />
|
||||
<product-total :totPrice="cartStore.totPrice" :totCount="cartStore.totalCount" @doContainer="" @submit="doBuy" />
|
||||
</view>
|
||||
</template>
|
||||
</crud-layout>
|
||||
@@ -69,12 +70,12 @@ const submitPay = async () => {
|
||||
if (isEmpty(cartStore.cart)) return uni.showToast({ title: "请至少购买一件商品", icon: "none" })
|
||||
|
||||
uni.showLoading({ title: "支付中...", mask: false })
|
||||
const { data, code }: any = await payApi.createSupermarketOrder({ carParentId: cartStore.cart[0].parentCarId, hardType: "SUPERMARKET" })
|
||||
if (code != 0) throw new Error()
|
||||
const { code, msg }: any = await payApi.createSupermarketOrder({ carParentId: cartStore.cart[0].parentCarId, hardType: "SUPERMARKET" })
|
||||
if (code != 0) throw new Error(msg)
|
||||
uni.showToast({ title: "支付成功", icon: "none" })
|
||||
router.jump("/pages/tabbar/order")
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} catch (error: any) {
|
||||
uni.showToast({ title: error.message, icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -6,6 +6,7 @@ import { filePath } from "@/sheep/utils/file"
|
||||
import ProductSku from "./components/product-sku.vue"
|
||||
import { useCartStore } from "@/sheep/stores/cart"
|
||||
import { hooks, router } from "@/sheep"
|
||||
import { displayPrice } from "@/sheep/utils/formatMoney"
|
||||
|
||||
const cartStore = useCartStore()
|
||||
|
||||
@@ -89,8 +90,10 @@ const goCart = async () => {
|
||||
<text>{{ item?.stock || 0 }}</text>
|
||||
</view>
|
||||
<view class="flex items-end mt-1">
|
||||
<text class="c-red! second-text-32 mr-2">¥{{ item.promotionPrice.toFixed(2) || item.retailPrice.toFixed(2) || 0 }}</text>
|
||||
<text class="line-through">¥{{ item.retailPrice.toFixed(2) || 0 }}</text>
|
||||
<text class="c-red! second-text-32 mr-2">
|
||||
¥{{ displayPrice(item.promotionPrice, "") || displayPrice(item.retailPrice, "") || 0 }}
|
||||
</text>
|
||||
<text class="line-through">¥{{ displayPrice(item.retailPrice, "") || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<view>已售 {{ item.salesCount || 0 }}</view>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center">
|
||||
<view class="second-text-32 c-red!">¥{{ displayPrice(item.minPrice, "") }}</view>
|
||||
<view class="second-text-32 c-red!">¥{{ item.minPrice.toFixed(2) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in new issue
Block a user