feat: 去变现添加 获取验证码
This commit is contained in:
+103
-2
@@ -33,6 +33,22 @@
|
||||
<view class="tip-text">请输入去变现数量</view>
|
||||
</view>
|
||||
|
||||
<view class="card code-card">
|
||||
<view class="code-row">
|
||||
<uni-easyinput
|
||||
v-model="smsCode"
|
||||
type="number"
|
||||
placeholder="请输入验证码"
|
||||
placeholder-style="font-size: 28rpx;color:#C6C6C6;"
|
||||
:inputBorder="false"
|
||||
:maxlength="6"
|
||||
/>
|
||||
<view class="code-btn" :class="{ disabled: smsCountdown > 0 }" @click="sendSmsCode">
|
||||
{{ smsCountdown > 0 ? `${smsCountdown}s` : '获取验证码' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card tip-card">
|
||||
<view class="tip-header">
|
||||
<view class="tip-title">兑换提示</view>
|
||||
@@ -54,10 +70,15 @@
|
||||
import { 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';
|
||||
import sheep from '@/sheep';
|
||||
|
||||
const walletBalanceCents = ref(0);
|
||||
const amount = ref('');
|
||||
const smsCode = ref('');
|
||||
const smsCountdown = ref(0);
|
||||
const smsScene = 7;
|
||||
let smsTimer = null;
|
||||
|
||||
const sanitizeAmountInput = (val) => {
|
||||
let next = String(val ?? '').replace(/[^\d.]/g, '');
|
||||
@@ -112,15 +133,64 @@
|
||||
amount.value = availableYuan.value > 0 ? String(availableYuan.value.toFixed(2)) : '0';
|
||||
return;
|
||||
}
|
||||
if (!String(smsCode.value || '').trim()) {
|
||||
sheep.$helper.toast('请输入验证码');
|
||||
return;
|
||||
}
|
||||
const userStore = sheep.$store('user');
|
||||
if (!userStore?.userInfo?.mobile) {
|
||||
await userStore?.getInfo?.().catch(() => {});
|
||||
}
|
||||
const mobile = userStore?.userInfo?.mobile;
|
||||
if (!mobile) {
|
||||
sheep.$helper.toast('未绑定手机号');
|
||||
return;
|
||||
}
|
||||
const money = Math.round(amt * 100);
|
||||
const res = await incrementApi.walletLiquidation({ money }).catch(() => ({ code: -1 }));
|
||||
const payload = { money, mobile, scene: smsScene, code: smsCode.value };
|
||||
const res = await incrementApi.walletLiquidation(payload).catch(() => ({ code: -1 }));
|
||||
if (res?.code === 0) {
|
||||
sheep.$helper.toast('提交成功');
|
||||
amount.value = '';
|
||||
smsCode.value = '';
|
||||
refreshWallet();
|
||||
}
|
||||
};
|
||||
|
||||
const sendSmsCode = async () => {
|
||||
if (smsCountdown.value > 0) return;
|
||||
const amt = amountNumber.value;
|
||||
if (!amt) {
|
||||
sheep.$helper.toast('请输入去变现数量');
|
||||
return;
|
||||
}
|
||||
if (amt > availableYuan.value) {
|
||||
sheep.$helper.toast('变现金额不能大于钱包余额');
|
||||
return;
|
||||
}
|
||||
const userStore = sheep.$store('user');
|
||||
if (!userStore?.userInfo?.mobile) {
|
||||
await userStore?.getInfo?.().catch(() => {});
|
||||
}
|
||||
const mobile = userStore?.userInfo?.mobile;
|
||||
if (!mobile) {
|
||||
sheep.$helper.toast('未绑定手机号');
|
||||
return;
|
||||
}
|
||||
const res = await AuthUtil.sendSmsCode({ mobile, scene: smsScene }).catch(() => ({ code: -1 }));
|
||||
if (res?.code !== 0) return;
|
||||
smsCountdown.value = 60;
|
||||
if (smsTimer) clearInterval(smsTimer);
|
||||
smsTimer = setInterval(() => {
|
||||
smsCountdown.value -= 1;
|
||||
if (smsCountdown.value <= 0) {
|
||||
clearInterval(smsTimer);
|
||||
smsTimer = null;
|
||||
smsCountdown.value = 0;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const goRecord = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/liquidationRecord',
|
||||
@@ -165,6 +235,7 @@
|
||||
background: #f4f8f2;
|
||||
border-radius: 24rpx;
|
||||
padding: 28rpx;
|
||||
box-shadow: 0 10rpx 26rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.balance-card {
|
||||
@@ -202,6 +273,37 @@
|
||||
padding: 24rpx 28rpx;
|
||||
}
|
||||
|
||||
.code-card {
|
||||
padding: 18rpx 22rpx;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
|
||||
.code-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.code-btn {
|
||||
margin-left: 18rpx;
|
||||
min-width: 168rpx;
|
||||
height: 68rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(54, 110, 238, 0.12);
|
||||
color: #366eee;
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.code-btn.disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.amount-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -276,4 +378,3 @@
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@
|
||||
sendCode();
|
||||
};
|
||||
const sendCode = async () => {
|
||||
AuthUtil.sendSmsCode(formData.value.mobile, 3).then((res) => {
|
||||
AuthUtil.sendSmsCode({ mobile: formData.value.mobile, scene: 3 }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num.value = 60;
|
||||
timer.value = setInterval(() => {
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
sendCode();
|
||||
};
|
||||
const sendCode = async () => {
|
||||
AuthUtil.sendSmsCode(formData.value.mobile, 3).then((res) => {
|
||||
AuthUtil.sendSmsCode({ mobile: formData.value.mobile, scene: 3 }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num.value = 60;
|
||||
timer.value = setInterval(() => {
|
||||
@@ -125,7 +125,7 @@
|
||||
});
|
||||
};
|
||||
const sendCode1 = async () => {
|
||||
AuthUtil.sendSmsCode(formData.value.mobile1, 3).then((res) => {
|
||||
AuthUtil.sendSmsCode({ mobile: formData.value.mobile1, scene: 3 }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num1.value = 60;
|
||||
timer1.value = setInterval(() => {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<view class="title-right" />
|
||||
</view>
|
||||
<!-- 商品 -->
|
||||
<su-sticky top="100rpx">
|
||||
<su-sticky top="0">
|
||||
<view class="goodsIndex">
|
||||
<goods :list="tagList" v-if="tagList?.length"></goods>
|
||||
</view>
|
||||
|
||||
@@ -313,7 +313,7 @@
|
||||
numType = 4;
|
||||
break;
|
||||
}
|
||||
AuthUtil.sendSmsCode(formData.mobile, numType).then((res) => {
|
||||
AuthUtil.sendSmsCode({ mobile: formData.mobile, scene: numType }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num.value = 60;
|
||||
timer.value = setInterval(() => {
|
||||
|
||||
Reference in New Issue
Block a user