From f4427bc094a6b7091cc25d58598f8490fc2e8932 Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Wed, 19 Feb 2025 21:03:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(payment):=20=E5=AE=9E=E7=8E=B0=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 payment 存储对象,用于保存支付相关信息 - 实现全款和部分款项支付逻辑 - 优化直播室、艺术品详情、个人中心等页面的支付相关展示和功能 - 添加千分位格式化函数,提升用户体验 --- app/pages/artDetail/index.vue | 15 ++++- .../collectCode/signature/protocol/index.vue | 1 - .../liveRoom/components/Broadcast/index.vue | 6 +- .../liveRoom/components/SideButton/index.vue | 7 +- .../components/SideButton/tangPopup.vue | 7 +- app/pages/liveRoom/index.client.vue | 6 +- app/pages/payment/index.vue | 65 ++++++++++++------- app/pages/profile/index.vue | 13 ++-- app/stores/auth/index.js | 6 ++ app/stores/live/index.js | 2 +- 10 files changed, 86 insertions(+), 42 deletions(-) diff --git a/app/pages/artDetail/index.vue b/app/pages/artDetail/index.vue index 8576f79..219db6f 100644 --- a/app/pages/artDetail/index.vue +++ b/app/pages/artDetail/index.vue @@ -1,6 +1,7 @@ @@ -64,8 +73,8 @@ initData()
- - {{ $t('art_detail_page.button') }} RMB10,000 + + {{ $t('art_detail_page.button') }} {{detail.leftCurrency}}{{formatThousands(detail.leftPrice)}}
{ }else { router.push('/collectCode/signature/panel') } - } diff --git a/app/pages/liveRoom/components/Broadcast/index.vue b/app/pages/liveRoom/components/Broadcast/index.vue index a6cf92a..ef889d3 100644 --- a/app/pages/liveRoom/components/Broadcast/index.vue +++ b/app/pages/liveRoom/components/Broadcast/index.vue @@ -4,6 +4,10 @@ import {authStore} from "~/stores/auth/index.js"; import {useI18n} from 'vue-i18n' const {auctionData} = liveStore() const {userInfo}= authStore() +function formatThousands(num) { + + return Number(num).toLocaleString(); +} const headList=[ { label:useI18n().t('live_room.head'), @@ -40,7 +44,7 @@ const headItem=(statusCode)=>{
{{ headItem(item.statusCode).label }}
{{ item.auctionType==='local'? $t('live_room.spot'):$t('live_room.network') }}
{{ item.createdAt }}
-
{{item.baseCurrency}}{{ item.baseMoney }}
+
{{item.baseCurrency}}{{ formatThousands(item.baseMoney) }}
{{ item.userId===userInfo.ID?$t('live_room.me'):'' }}
diff --git a/app/pages/liveRoom/components/SideButton/index.vue b/app/pages/liveRoom/components/SideButton/index.vue index 7ea0e32..00b3505 100644 --- a/app/pages/liveRoom/components/SideButton/index.vue +++ b/app/pages/liveRoom/components/SideButton/index.vue @@ -11,7 +11,7 @@ import {showMinWindow} from "~/components/liveMinWindow/createMinWindow.js"; const { quoteStatus, changeStatus, show, auctionData, getSocketData ,lastSnapshot,fullLive} = liveStore() const { pageRef } = goodStore() -const { userInfo } = authStore() +const { userInfo ,payment} = authStore() const showTang = ref(false) const router = useRouter() // 拖动相关状态 @@ -168,7 +168,7 @@ const openOne = () => { const paySide = computed(() => { //当前是否已成交,以及成交人是当前登录用户 - if (auctionData.value.artwork?.isSoled && auctionData.value.artwork?.buyInfo.userID === userInfo.value.ID) { + if (auctionData.value.artwork?.isSoled && auctionData.value.artwork?.buyInfo?.userID === userInfo.value.ID) { return true } else { return false @@ -176,6 +176,9 @@ const paySide = computed(() => { }) const goPay = () => { + payment.value.leftCurrency=auctionData.value?.nowAuctionPrice?.currency + payment.value.leftPrice=auctionData.value?.nowAuctionPrice?.successPrice + payment.value.buyUid=auctionData.value?.nowAuctionPrice?.successBuyUuid handleCapture() router.push('/signature/protocol') } diff --git a/app/pages/liveRoom/components/SideButton/tangPopup.vue b/app/pages/liveRoom/components/SideButton/tangPopup.vue index 01a1385..676a500 100644 --- a/app/pages/liveRoom/components/SideButton/tangPopup.vue +++ b/app/pages/liveRoom/components/SideButton/tangPopup.vue @@ -63,6 +63,11 @@ const loadMore = async () => { const { finished } = await getArtworkList() localState.value.finished = finished } +watch(()=>{ + return auctionData.value?.artwork?.index +},(newValue)=>{ + console.log('newValue',newValue) +}) watch(()=>props.show,(newValue)=>{ if (newValue){ nextTick(()=>{ @@ -113,7 +118,7 @@ watch(()=>props.show,(newValue)=>{ loading="lazy" />
LOT{{item.index}}
- +
diff --git a/app/pages/liveRoom/index.client.vue b/app/pages/liveRoom/index.client.vue index d3c0c1a..d652c08 100644 --- a/app/pages/liveRoom/index.client.vue +++ b/app/pages/liveRoom/index.client.vue @@ -181,15 +181,15 @@ const tipOpen = () => {
{{ t('live_room.lower_price') }}:{{ auctionData?.nowAuctionPrice?.currency }}
-
+
{{ - `${t('live_room.confirm')} ${auctionData?.nowAuctionPrice?.currency} ${auctionData?.nowAuctionPrice?.nextPrice ?? 0}` + `${t('live_room.confirm')} ${auctionData?.nowAuctionPrice?.currency} ${auctionData?.nowAuctionPrice?.nowPrice ?? 0}` }}
-
+
{{ t('live_room.button') }}
diff --git a/app/pages/payment/index.vue b/app/pages/payment/index.vue index c2ffe17..9feaffc 100644 --- a/app/pages/payment/index.vue +++ b/app/pages/payment/index.vue @@ -4,45 +4,60 @@ import {createBuyOrder} from "~/api/goods/index.js"; import {goodStore} from "~/stores/goods/index.js"; import { showLoadingToast ,closeToast} from 'vant'; import {authStore} from "~/stores/auth/index.js"; -const {checkoutSessionUrl}= authStore() +import {message} from "~/components/x-message/useMessage.js"; +const {checkoutSessionUrl,payment}= authStore() const payStatus=ref(0) +definePageMeta({ + title: '支付' +}) const changePayStatus=()=>{ payStatus.value=payStatus.value===0?1:0 } const { auctionData} = liveStore() -const validateInput = (e) => { - const value = e.target.value - const char = String.fromCharCode(e.charCode) - - if (!/[\d.]/.test(char)) { - e.preventDefault() - return - } - - if (char === '.' && (value.includes('.') || !value)) { - e.preventDefault() - return - } - - if (value.includes('.') && value.split('.')[1]?.length >= 2) { - e.preventDefault() - return - } -} +const amount=ref('') const confirmPay=async ()=>{ + if (payStatus.value===1&&!amount.value){ + message.warning('请输入金额') + return + } + if (Number(payment.value.leftPrice) { + // 只允许数字和小数点,且只保留两位小数 + const value = e.target.value + // 清除非数字和小数点 + let newValue = value.replace(/[^\d.]/g, '') + // 确保只有一个小数点 + newValue = newValue.replace(/\.{2,}/g, '.') + // 只保留第一个小数点 + newValue = newValue.replace(/^(\d*\.\d*)\./, '$1') + // 保留两位小数 + if (newValue.indexOf('.') > 0) { + newValue = newValue.slice(0, newValue.indexOf('.') + 3) + } + // 禁止输入以0开头的多位整数 + newValue = newValue.replace(/^0+(\d)/, '$1') + + amount.value = newValue +}