feat: 兑换添加手动价格、添加撤单功能

This commit is contained in:
2026-10-08 16:58:47 +08:00
parent 1c34e15f8a
commit 39100c71be
2 changed files with 311 additions and 113 deletions
+296 -112
View File
@@ -54,24 +54,28 @@
{{ formatAmount(v.packageAmount) }} 枚 {{ formatAmount(v.packageAmount) }} 枚
</view> </view>
</view> </view>
<view class="change-card"> <view class="change-card" :class="Number(v.status) === 0 ? 'change-card--pending' : ''">
<view class="change-card__left"> <view v-if="Number(v.status) === 0" class="change-card__pending-tag">
<view class="change-card__row"> <text class="record-item__status record-item__status--pending">
<view class="change-card__col"> {{ statusMap[Number(v.status)] || v.statusDesc || '' }}
<text class="change-card__label">变动前</text> </text>
<text class="change-card__value">{{ formatAmount(v.balanceBefore) }}</text> </view>
</view> <view class="change-card__left" :class="Number(v.status) === 0 ? 'change-card__left--pending' : ''">
<view class="change-card__arrow">→</view> <view class="change-card__price-label">兑换价格</view>
<view class="change-card__col change-card__col--right"> <view class="change-card__price-row" :class="Number(v.status) === 0 ? 'change-card__price-row--with-cancel' : ''">
<text class="change-card__label">变动后</text> <view class="change-card__price-main">
<text class="change-card__value">{{ formatAmount(v.balanceAfter) }}</text> <text class="change-card__price-symbol">¥</text>
<text class="change-card__price-value">{{ formatRecordPrice(v.price) }}</text>
</view> </view>
<view v-if="Number(v.status) === 0" class="cancel-btn cancel-btn--inline" @click="handleCancel(v)">撤单</view>
</view> </view>
</view> </view>
<view class="change-card__divider"></view> <view v-if="Number(v.status) !== 0" class="change-card__divider"></view>
<view class="change-card__right" :class="getStatusRightClass(v.status)"> <view v-if="Number(v.status) !== 0" class="change-card__right" :class="[getStatusRightClass(v.status)]">
<view class="record-item__status" :class="getStatusClass(v.status)"> <view class="change-card__right-top">
{{ v.statusDesc || statusMap[Number(v.status)] || '' }} <view class="record-item__status" :class="getStatusClass(v.status)">
{{ statusMap[Number(v.status)] || v.statusDesc || '' }}
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -125,6 +129,13 @@
</view> </view>
<view class="popup-fixed-tag">每笔固定 {{ exchangeAmount }} 金种子</view> <view class="popup-fixed-tag">每笔固定 {{ exchangeAmount }} 金种子</view>
</view> </view>
<view class="popup-input-box">
<view class="popup-input-label">兑换价格</view>
<view class="popup-input-row">
<text class="popup-input-symbol">¥</text>
<input class="popup-input" type="digit" :value="inputPrice" @input="onPriceInput" placeholder="请输入兑换价格" />
</view>
</view>
<view class="popup-tip"> <view class="popup-tip">
<uni-icons type="info" color="#C6C6C6" size="20" /> <uni-icons type="info" color="#C6C6C6" size="20" />
<text class="popup-tip-text">请慎重考虑,一经提交,不可撤销</text> <text class="popup-tip-text">请慎重考虑,一经提交,不可撤销</text>
@@ -149,6 +160,7 @@ const { proxy } = getCurrentInstance();
const PAGE_SIZE = 20; const PAGE_SIZE = 20;
const exchangeAmount = ref(100); const exchangeAmount = ref(100);
const inputPrice = ref('');
const popupVisible = ref(false); const popupVisible = ref(false);
const detailList = ref([]); const detailList = ref([]);
const dataObj = reactive({}); const dataObj = reactive({});
@@ -161,19 +173,20 @@ const statusMap = {
0: '待审核', 0: '待审核',
1: '审核通过', 1: '审核通过',
2: '审核拒绝', 2: '审核拒绝',
3: '已撤单',
}; };
const getStatusClass = (status) => { const getStatusClass = (status) => {
const s = Number(status); const s = Number(status);
if (s === 1) return 'record-item__status--pass'; 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'; return 'record-item__status--pending';
}; };
const getStatusRightClass = (status) => { const getStatusRightClass = (status) => {
const s = Number(status); const s = Number(status);
if (s === 1) return 'change-card__right--pass'; 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'; return 'change-card__right--pending';
}; };
@@ -212,6 +225,26 @@ const formatAmount = (val) => {
return n.toLocaleString(); 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) => { const formatDateTime = (val) => {
if (!val) return ''; if (!val) return '';
const d = new Date(Number(val)); const d = new Date(Number(val));
@@ -275,18 +308,29 @@ const refresh = async () => {
const openExchangePopup = async () => { const openExchangePopup = async () => {
await fetchExchangeConfig(); await fetchExchangeConfig();
inputPrice.value = '';
popupVisible.value = true; popupVisible.value = true;
}; };
const closeExchangePopup = () => { const closeExchangePopup = () => {
popupVisible.value = false; popupVisible.value = false;
inputPrice.value = '';
}; };
const submitExchange = async () => { 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 = ''; let errorMsg = '';
try { try {
const res = await homeApi.goldSeedExchangeCreate({ packageAmount: amount }); const res = await homeApi.goldSeedExchangeCreate({ price });
if (res?.code === 0) { if (res?.code === 0) {
closeExchangePopup(); closeExchangePopup();
fetchAsset(); fetchAsset();
@@ -299,7 +343,6 @@ const submitExchange = async () => {
errorMsg = (e && (e.msg || e.message)) ? (e.msg || e.message) : '请求异常,请稍后重试'; errorMsg = (e && (e.msg || e.message)) ? (e.msg || e.message) : '请求异常,请稍后重试';
} }
if (errorMsg) { if (errorMsg) {
// 先关闭弹窗,避免遮罩层级遮挡导致 toast 不显示
closeExchangePopup(); closeExchangePopup();
setTimeout(() => { setTimeout(() => {
uni.showToast({ 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(() => { onShow(() => {
refresh(); refresh();
}); });
@@ -535,105 +613,168 @@ onReachBottom(() => {
} }
.change-card { .change-card {
display: flex; display: flex;
align-items: stretch; align-items: stretch;
border-radius: 20rpx; border-radius: 16rpx;
overflow: hidden; overflow: hidden;
margin-bottom: 20rpx; margin-bottom: 16rpx;
} position: relative;
}
.change-card__left { .change-card--pending {
flex: 1; background: linear-gradient(135deg, rgba(107, 114, 128, 0.06) 0%, rgba(59, 130, 246, 0.05) 100%);
padding: 22rpx 24rpx; border: 1rpx solid rgba(107, 114, 128, 0.12);
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__row { .change-card__pending-tag {
display: flex; position: absolute;
align-items: center; top: 10rpx;
justify-content: space-between; right: 24rpx;
gap: 10rpx; z-index: 2;
} }
.change-card__col { .change-card__left {
flex: 1; flex: 1;
display: flex; padding: 22rpx 28rpx;
flex-direction: column; min-width: 0;
align-items: flex-start; display: flex;
gap: 10rpx; flex-direction: column;
min-width: 0; 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 { .change-card__left > view + view {
align-items: flex-end; margin-top: 10rpx;
} }
.change-card__label { .change-card__left--pending {
font-size: 22rpx; border: none;
color: #585654; border-radius: 16rpx;
opacity: 0.85; min-height: 120rpx;
} }
.change-card__value { .change-card__left--pending > view + view {
font-size: 30rpx; margin-top: 12rpx;
font-weight: 600; }
color: #111;
line-height: 1.1;
}
.change-card__arrow { .change-card__price-row--with-cancel {
flex-shrink: 0; display: flex;
padding: 0 12rpx; align-items: flex-end;
font-size: 28rpx; justify-content: flex-start;
color: #585654; }
opacity: 0.7;
}
.change-card__divider { .change-card__price-main {
width: 1rpx; display: inline-block;
background: rgba(0, 0, 0, 0.1); min-width: 0;
} flex-shrink: 1;
line-height: 44rpx;
height: 44rpx;
white-space: nowrap;
}
.change-card__right { .cancel-btn--inline {
width: 180rpx; margin-left: auto;
flex-shrink: 0; height: 40rpx;
display: flex; padding: 0 12rpx;
align-items: center; border-radius: 12rpx;
justify-content: center; border: none;
padding: 20rpx 16rpx; color: #ee0a24;
border-left: none; font-size: 20rpx;
border-radius: 0 20rpx 20rpx 0; display: flex;
} align-items: center;
justify-content: center;
box-sizing: border-box;
border: 1rpx solid #ee0a24;
}
.change-card__right--pending { .change-card__price-label {
background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.06) 100%); font-size: 22rpx;
border: 1rpx solid rgba(245, 158, 11, 0.2); color: #8b8b8b;
border-left: none; line-height: 30rpx;
} }
.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;
}
.record-item__status { .change-card__price-row {
font-size: 26rpx; line-height: 44rpx;
font-weight: 700; height: 44rpx;
line-height: 1.2; white-space: nowrap;
} }
.record-item__status--pending { color: #f59e0b; } .change-card__price-symbol {
.record-item__status--pass { color: #10b981; } display: inline-block;
.record-item__status--reject { color: #ef4444; } 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 { .record-item__meta-row {
display: flex; display: flex;
@@ -800,11 +941,54 @@ onReachBottom(() => {
} }
.popup-fixed-tag { .popup-fixed-tag {
margin-top: 10rpx; margin-top: 10rpx;
font-size: 22rpx; font-size: 22rpx;
color: #585654; color: #585654;
opacity: 0.85; 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 { .popup-tip {
margin-top: 8rpx; margin-top: 8rpx;
+15 -1
View File
@@ -96,7 +96,7 @@ export const goldSeedExchangeCreate = (params) => {
return request({ return request({
url: '/member/app/gold-seed-exchange/create', url: '/member/app/gold-seed-exchange/create',
method: 'POST', method: 'POST',
data: params, params: params,
custom: { custom: {
showSuccess: true, showSuccess: true,
showError: false, 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) => { export const getTeamStats = (params) => {
return request({ return request({