feat: 添加无双相关

This commit is contained in:
2026-07-25 16:30:57 +08:00
parent 3569ff6b5a
commit d168e38305
4 changed files with 133 additions and 15 deletions
+41 -10
View File
@@ -1,5 +1,5 @@
<template>
<s-pages title="去变现" :pink_bg="true">
<s-pages :title="pageTitle" :pink_bg="true">
<view class="liquidation">
<view class="top_bar">
<view class="record_link" @click="goRecord">变现记录</view>
@@ -21,7 +21,7 @@
<uni-easyinput
v-model="amountInput"
type="digit"
placeholder="00.00"
:placeholder="amountPlaceholder"
placeholder-style="font-size: 64rpx;color:#C6C6C6;"
:inputBorder="false"
:min="0"
@@ -30,7 +30,7 @@
@confirm="submit"
/>
</view>
<view class="tip-text">请输入去变现数量</view>
<view class="tip-text">{{ amountTipText }}</view>
</view>
<view class="card code-card">
<view class=" code-row--mobile">
@@ -79,7 +79,7 @@
<script setup>
import { computed, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import { onLoad, onShow } from '@dcloudio/uni-app';
import * as payApi from '@/sheep/api/home/pay';
import * as incrementApi from '@/sheep/api/increment';
import AuthUtil from '@/sheep/api/member/auth';
@@ -93,9 +93,15 @@
const smsScene = 7;
let smsTimer = null;
const submitting = ref(false);
const liquidationType = ref(1);
const pageTitle = ref('去变现');
const integerOnly = computed(() => Number(liquidationType.value) === 2);
const amountPlaceholder = computed(() => (integerOnly.value ? '00' : '00.00'));
const amountTipText = computed(() => (integerOnly.value ? '请输入整数变现金额' : '请输入去变现数量'));
const sanitizeAmountInput = (val) => {
let next = String(val ?? '').replace(/[^\d.]/g, '');
let next = String(val ?? '').replace(integerOnly.value ? /[^\d]/g : /[^\d.]/g, '');
if (integerOnly.value) return next.replace(/^0+(\d)/, '$1');
const firstDot = next.indexOf('.');
if (firstDot !== -1) {
next = next.slice(0, firstDot + 1) + next.slice(firstDot + 1).replace(/\./g, '');
@@ -130,9 +136,16 @@
amount.value = '0';
return;
}
if (integerOnly.value && String(amount.value || '').includes('.')) {
amount.value = String(Math.floor(amountNumber.value || 0));
}
if (amountNumber.value > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0 ? String(availableYuan.value.toFixed(2)) : '0';
amount.value = availableYuan.value > 0
? integerOnly.value
? String(Math.floor(availableYuan.value))
: String(availableYuan.value.toFixed(2))
: '0';
}
};
@@ -140,12 +153,20 @@
if (submitting.value) return;
const amt = amountNumber.value;
if (!amt) {
sheep.$helper.toast('请输入去变现数量');
sheep.$helper.toast(integerOnly.value ? '请输入整数变现金额' : '请输入去变现数量');
return;
}
if (integerOnly.value && !Number.isInteger(amt)) {
sheep.$helper.toast('无双变现金额只能输入整数');
return;
}
if (amt > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0 ? String(availableYuan.value.toFixed(2)) : '0';
amount.value = availableYuan.value > 0
? integerOnly.value
? String(Math.floor(availableYuan.value))
: String(availableYuan.value.toFixed(2))
: '0';
return;
}
if (!String(smsCode.value || '').trim()) {
@@ -155,7 +176,7 @@
const mobile = resolveMobile();
if (!mobile) return;
const money = Math.round(amt * 100);
const payload = { money, mobile, scene: smsScene, code: smsCode.value };
const payload = { money, mobile, scene: smsScene, code: smsCode.value, type: liquidationType.value };
submitting.value = true;
try {
const res = await incrementApi.walletLiquidation(payload).catch(() => ({ code: -1 }));
@@ -198,7 +219,11 @@
if (smsCountdown.value > 0) return;
const amt = amountNumber.value;
if (!amt) {
sheep.$helper.toast('请输入去变现数量');
sheep.$helper.toast(integerOnly.value ? '请输入整数变现金额' : '请输入去变现数量');
return;
}
if (integerOnly.value && !Number.isInteger(amt)) {
sheep.$helper.toast('无双变现金额只能输入整数');
return;
}
if (amt > availableYuan.value) {
@@ -227,6 +252,12 @@
});
};
onLoad((options) => {
const nextType = Number(options?.type || 1);
liquidationType.value = nextType === 2 ? 2 : 1;
pageTitle.value = liquidationType.value === 2 ? '无双变现' : String(options?.title || '去变现');
});
onShow(() => {
refreshWallet();
const userStore = sheep.$store('user');