摸大红支持购物车多选一起结账
下单支持多商品行快照与一次支付;支付后整单复制文案,前台提供购物车加购与结账。
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
startMohongPayment,
|
||||
type MohongProduct,
|
||||
} from '@/features/mohong/api/mohong'
|
||||
import MohongCartPanel from '@/features/mohong/components/MohongCartPanel.vue'
|
||||
import { useMohongCart } from '@/features/mohong/composables/useMohongCart'
|
||||
import type { PaymentPayWay } from '@/features/orders/api/orders'
|
||||
import { useOrderPaymentCashier } from '@/features/orders/composables/useOrderPaymentCashier'
|
||||
import { useSessionStore } from '@/stores/session'
|
||||
@@ -18,6 +20,7 @@ import { readError } from '@/shared/utils/error'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const session = useSessionStore()
|
||||
const { addProduct, openCart, totalCount: cartCount } = useMohongCart()
|
||||
const product = ref<MohongProduct | null>(null)
|
||||
const loading = ref(true)
|
||||
const quantity = ref(1)
|
||||
@@ -112,6 +115,20 @@ async function ensureAuthReady() {
|
||||
return true
|
||||
}
|
||||
|
||||
function handleAddCart() {
|
||||
if (!product.value) return
|
||||
if (!canBuy.value) {
|
||||
ElMessage.warning('库存不足')
|
||||
return
|
||||
}
|
||||
const result = addProduct(product.value, quantity.value)
|
||||
if (result.ok) {
|
||||
ElMessage.success(result.message)
|
||||
} else {
|
||||
ElMessage.warning(result.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBuy() {
|
||||
if (!product.value || submitting.value) return
|
||||
if (!(await ensureAuthReady())) return
|
||||
@@ -204,6 +221,9 @@ async function handleBuy() {
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<el-button size="large" class="btn-outline" :disabled="!canBuy" @click="handleAddCart">
|
||||
加入购物车
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
@@ -214,6 +234,9 @@ async function handleBuy() {
|
||||
>
|
||||
{{ canBuy ? '立即购买' : '暂时缺货' }}
|
||||
</el-button>
|
||||
<el-button size="large" class="btn-outline" @click="openCart">
|
||||
购物车{{ cartCount > 0 ? `(${cartCount})` : '' }}
|
||||
</el-button>
|
||||
<el-button size="large" class="btn-outline" @click="router.push('/mohong')">
|
||||
返回列表
|
||||
</el-button>
|
||||
@@ -223,8 +246,8 @@ async function handleBuy() {
|
||||
<p>购买须知</p>
|
||||
<ul>
|
||||
<li>下单需登录并完成实名认证</li>
|
||||
<li>可加入购物车多选,一起结账;支付后一键复制整单信息</li>
|
||||
<li>支付成功后可在订单详情扫码联系客服</li>
|
||||
<li>订单详情支持一键复制订单信息发给客服</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -232,6 +255,11 @@ async function handleBuy() {
|
||||
</template>
|
||||
<el-empty v-else-if="!loading" description="商品不存在" />
|
||||
|
||||
<MohongCartPanel
|
||||
:select-pay-way="selectPayWay"
|
||||
:start-cashier="(payment, onPaid) => cashier.openPaymentCashier(payment, onPaid)"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
v-model="payWayDialogVisible"
|
||||
title="选择支付方式"
|
||||
|
||||
Reference in New Issue
Block a user