From 39100c71beede431e784bc502b48d9295226e77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E5=96=B5=E5=92=AA?= <15233722133@163.com> Date: Thu, 8 Oct 2026 16:58:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=91=E6=8D=A2=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E4=BB=B7=E6=A0=BC=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=92=A4=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/seedExchange.vue | 408 ++++++++++++++++++++++++++---------- sheep/api/home/index.js | 16 +- 2 files changed, 311 insertions(+), 113 deletions(-) diff --git a/pages/home/seedExchange.vue b/pages/home/seedExchange.vue index 8f8a817..1b75c7b 100644 --- a/pages/home/seedExchange.vue +++ b/pages/home/seedExchange.vue @@ -54,24 +54,28 @@ {{ formatAmount(v.packageAmount) }} 枚 - - - - - 变动前 - {{ formatAmount(v.balanceBefore) }} - - → - - 变动后 - {{ formatAmount(v.balanceAfter) }} + + + + {{ statusMap[Number(v.status)] || v.statusDesc || '' }} + + + + 兑换价格 + + + ¥ + {{ formatRecordPrice(v.price) }} + 撤单 - - - - {{ v.statusDesc || statusMap[Number(v.status)] || '' }} + + + + + {{ statusMap[Number(v.status)] || v.statusDesc || '' }} + @@ -125,6 +129,13 @@ 每笔固定 {{ exchangeAmount }} 金种子 + + 兑换价格 + + ¥ + + + 请慎重考虑,一经提交,不可撤销 @@ -149,6 +160,7 @@ const { proxy } = getCurrentInstance(); const PAGE_SIZE = 20; const exchangeAmount = ref(100); +const inputPrice = ref(''); const popupVisible = ref(false); const detailList = ref([]); const dataObj = reactive({}); @@ -161,19 +173,20 @@ const statusMap = { 0: '待审核', 1: '审核通过', 2: '审核拒绝', + 3: '已撤单', }; const getStatusClass = (status) => { const s = Number(status); if (s === 1) return 'record-item__status--pass'; - if (s === 2) return 'record-item__status--reject'; + if (s === 2 || s === 3) return 'record-item__status--reject'; return 'record-item__status--pending'; }; const getStatusRightClass = (status) => { const s = Number(status); if (s === 1) return 'change-card__right--pass'; - if (s === 2) return 'change-card__right--reject'; + if (s === 2 || s === 3) return 'change-card__right--reject'; return 'change-card__right--pending'; }; @@ -212,6 +225,26 @@ const formatAmount = (val) => { return n.toLocaleString(); }; +const formatRecordPrice = (val) => { + const n = Number(val); + if (!Number.isFinite(n)) return '0.0000'; + return n.toFixed(4); +}; + +const onPriceInput = (e) => { + let val = e?.detail?.value ?? ''; + val = val.replace(/[^\d.]/g, ''); + const firstDot = val.indexOf('.'); + if (firstDot !== -1) { + val = val.slice(0, firstDot + 1) + val.slice(firstDot + 1).replace(/\./g, ''); + } + const parts = val.split('.'); + if (parts.length > 1 && parts[1].length > 4) { + val = parts[0] + '.' + parts[1].slice(0, 4); + } + inputPrice.value = val; +}; + const formatDateTime = (val) => { if (!val) return ''; const d = new Date(Number(val)); @@ -275,18 +308,29 @@ const refresh = async () => { const openExchangePopup = async () => { await fetchExchangeConfig(); + inputPrice.value = ''; popupVisible.value = true; }; const closeExchangePopup = () => { popupVisible.value = false; + inputPrice.value = ''; }; const submitExchange = async () => { - const amount = Number(exchangeAmount.value) || 0; + const price = Number(inputPrice.value); + if (!Number.isFinite(price) || price <= 0) { + uni.showToast({ + title: '请输入兑换价格', + icon: 'none', + mask: true, + duration: 2000, + }); + return; + } let errorMsg = ''; try { - const res = await homeApi.goldSeedExchangeCreate({ packageAmount: amount }); + const res = await homeApi.goldSeedExchangeCreate({ price }); if (res?.code === 0) { closeExchangePopup(); fetchAsset(); @@ -299,7 +343,6 @@ const submitExchange = async () => { errorMsg = (e && (e.msg || e.message)) ? (e.msg || e.message) : '请求异常,请稍后重试'; } if (errorMsg) { - // 先关闭弹窗,避免遮罩层级遮挡导致 toast 不显示 closeExchangePopup(); setTimeout(() => { uni.showToast({ @@ -312,6 +355,41 @@ const submitExchange = async () => { } }; +const handleCancel = (item) => { + uni.showModal({ + title: '提示', + content: '确定要撤销该兑换申请吗?', + confirmColor: '#ee0a24', + success: async (res) => { + if (!res.confirm) return; + let errorMsg = ''; + try { + const cancelRes = await homeApi.goldSeedExchangeCancel({ + packageId: item.id, + }); + if (cancelRes?.code === 0) { + uni.showToast({ title: '撤销成功', icon: 'none', duration: 1500 }); + fetchAsset(); + setTimeout(() => getList(true), 300); + return; + } + errorMsg = cancelRes?.msg + || (cancelRes && typeof cancelRes.code === 'number' ? '操作失败' : '网络异常'); + } catch (e) { + errorMsg = (e && (e.msg || e.message)) ? (e.msg || e.message) : '请求异常,请稍后重试'; + } + if (errorMsg) { + uni.showToast({ + title: errorMsg, + icon: 'none', + mask: true, + duration: 2500, + }); + } + }, + }); +}; + onShow(() => { refresh(); }); @@ -535,105 +613,168 @@ onReachBottom(() => { } .change-card { - display: flex; - align-items: stretch; - border-radius: 20rpx; - overflow: hidden; - margin-bottom: 20rpx; -} + display: flex; + align-items: stretch; + border-radius: 16rpx; + overflow: hidden; + margin-bottom: 16rpx; + position: relative; + } -.change-card__left { - flex: 1; - padding: 22rpx 24rpx; - min-width: 0; - background: linear-gradient(135deg, rgba(107, 114, 128, 0.06) 0%, rgba(59, 130, 246, 0.05) 100%); - border: 1rpx solid rgba(107, 114, 128, 0.12); - border-right: none; - border-radius: 20rpx 0 0 20rpx; -} + .change-card--pending { + background: linear-gradient(135deg, rgba(107, 114, 128, 0.06) 0%, rgba(59, 130, 246, 0.05) 100%); + border: 1rpx solid rgba(107, 114, 128, 0.12); + } -.change-card__row { - display: flex; - align-items: center; - justify-content: space-between; - gap: 10rpx; -} + .change-card__pending-tag { + position: absolute; + top: 10rpx; + right: 24rpx; + z-index: 2; + } -.change-card__col { - flex: 1; - display: flex; - flex-direction: column; - align-items: flex-start; - gap: 10rpx; - min-width: 0; -} + .change-card__left { + flex: 1; + padding: 22rpx 28rpx; + min-width: 0; + display: flex; + flex-direction: column; + justify-content: center; + background: linear-gradient(135deg, rgba(107, 114, 128, 0.06) 0%, rgba(59, 130, 246, 0.05) 100%); + border: 1rpx solid rgba(107, 114, 128, 0.12); + border-right: none; + border-radius: 16rpx 0 0 16rpx; + } -.change-card__col--right { - align-items: flex-end; -} + .change-card__left > view + view { + margin-top: 10rpx; + } -.change-card__label { - font-size: 22rpx; - color: #585654; - opacity: 0.85; -} + .change-card__left--pending { + border: none; + border-radius: 16rpx; + min-height: 120rpx; + } -.change-card__value { - font-size: 30rpx; - font-weight: 600; - color: #111; - line-height: 1.1; -} + .change-card__left--pending > view + view { + margin-top: 12rpx; + } -.change-card__arrow { - flex-shrink: 0; - padding: 0 12rpx; - font-size: 28rpx; - color: #585654; - opacity: 0.7; -} + .change-card__price-row--with-cancel { + display: flex; + align-items: flex-end; + justify-content: flex-start; + } -.change-card__divider { - width: 1rpx; - background: rgba(0, 0, 0, 0.1); -} + .change-card__price-main { + display: inline-block; + min-width: 0; + flex-shrink: 1; + line-height: 44rpx; + height: 44rpx; + white-space: nowrap; + } -.change-card__right { - width: 180rpx; - flex-shrink: 0; - display: flex; - align-items: center; - justify-content: center; - padding: 20rpx 16rpx; - border-left: none; - border-radius: 0 20rpx 20rpx 0; -} + .cancel-btn--inline { + margin-left: auto; + height: 40rpx; + padding: 0 12rpx; + border-radius: 12rpx; + border: none; + color: #ee0a24; + font-size: 20rpx; + display: flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + border: 1rpx solid #ee0a24; + } -.change-card__right--pending { - background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.06) 100%); - border: 1rpx solid rgba(245, 158, 11, 0.2); - border-left: none; -} -.change-card__right--pass { - background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.06) 100%); - border: 1rpx solid rgba(16, 185, 129, 0.2); - border-left: none; -} -.change-card__right--reject { - background: linear-gradient(135deg, rgba(248, 113, 113, 0.08) 0%, rgba(239, 68, 68, 0.06) 100%); - border: 1rpx solid rgba(248, 113, 113, 0.2); - border-left: none; -} + .change-card__price-label { + font-size: 22rpx; + color: #8b8b8b; + line-height: 30rpx; + } -.record-item__status { - font-size: 26rpx; - font-weight: 700; - line-height: 1.2; -} + .change-card__price-row { + line-height: 44rpx; + height: 44rpx; + white-space: nowrap; + } -.record-item__status--pending { color: #f59e0b; } -.record-item__status--pass { color: #10b981; } -.record-item__status--reject { color: #ef4444; } + .change-card__price-symbol { + display: inline-block; + font-size: 26rpx; + font-weight: 700; + color: #f7772e; + line-height: 44rpx; + height: 44rpx; + vertical-align: top; + margin-right: 4rpx; + } + + .change-card__price-value { + display: inline-block; + font-size: 44rpx; + font-weight: 800; + color: #111; + line-height: 44rpx; + height: 44rpx; + vertical-align: top; + letter-spacing: 1rpx; + } + + .change-card__divider { + width: 1rpx; + border-left: 2rpx dashed rgba(0, 0, 0, 0.15); + flex-shrink: 0; + } + + .change-card__right { + width: 180rpx; + flex-shrink: 0; + display: flex; + flex-direction: column; + align-items: stretch; + justify-content: center; + padding: 22rpx 18rpx; + border-left: none; + border-radius: 0 16rpx 16rpx 0; + min-height: 120rpx; + } + + .change-card__right-top { + flex: 1; + display: flex; + align-items: center; + justify-content: center; + } + + .change-card__right--pending { + background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.06) 100%); + border: 1rpx solid rgba(245, 158, 11, 0.2); + border-left: none; + } + .change-card__right--pass { + background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.06) 100%); + border: 1rpx solid rgba(16, 185, 129, 0.2); + border-left: none; + } + .change-card__right--reject { + background: linear-gradient(135deg, rgba(156, 163, 175, 0.08) 0%, rgba(107, 114, 128, 0.06) 100%); + border: 1rpx solid rgba(156, 163, 175, 0.2); + border-left: none; + } + + .record-item__status { + font-size: 26rpx; + font-weight: 700; + line-height: 1.2; + } + + .record-item__status--pending { color: #f59e0b; } + .record-item__status--pass { color: #10b981; } + .record-item__status--reject { color: #9ca3af; } .record-item__meta-row { display: flex; @@ -800,11 +941,54 @@ onReachBottom(() => { } .popup-fixed-tag { - margin-top: 10rpx; - font-size: 22rpx; - color: #585654; - opacity: 0.85; -} + margin-top: 10rpx; + font-size: 22rpx; + color: #585654; + opacity: 0.85; + } + + .popup-input-box { + background: #f6f5f5; + border-radius: 16rpx; + padding: 24rpx 24rpx 20rpx; + margin-bottom: 8rpx; + } + + .popup-input-label { + font-size: 24rpx; + color: #585654; + font-weight: 600; + line-height: 34rpx; + } + + .popup-input-row { + margin-top: 14rpx; + display: flex; + align-items: center; + background: #fff; + border-radius: 12rpx; + padding: 0 20rpx; + height: 88rpx; + border: 1rpx solid rgba(0, 0, 0, 0.08); + } + + .popup-input-symbol { + font-size: 32rpx; + font-weight: 800; + color: #f7772e; + margin-right: 8rpx; + line-height: 1; + } + + .popup-input { + flex: 1; + min-width: 0; + font-size: 32rpx; + font-weight: 700; + color: #111; + height: 88rpx; + line-height: 88rpx; + } .popup-tip { margin-top: 8rpx; diff --git a/sheep/api/home/index.js b/sheep/api/home/index.js index 966f281..5938a68 100644 --- a/sheep/api/home/index.js +++ b/sheep/api/home/index.js @@ -96,7 +96,7 @@ export const goldSeedExchangeCreate = (params) => { return request({ url: '/member/app/gold-seed-exchange/create', method: 'POST', - data: params, + params: params, custom: { showSuccess: true, showError: false, @@ -105,6 +105,20 @@ export const goldSeedExchangeCreate = (params) => { }, }); }; +// 撤销金种子兑换 +export const goldSeedExchangeCancel = (params) => { + return request({ + url: '/member/app/gold-seed-exchange/cancel', + method: 'POST', + params: params, + custom: { + showSuccess: true, + showError: false, + loadingMsg: '撤销中', + successMsg: '撤销成功', + }, + }); +}; // 社员统计 export const getTeamStats = (params) => { return request({