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');
+63 -3
View File
@@ -1,10 +1,18 @@
<template>
<s-pages title="钱包" :pink_bg="true">
<!-- 头部 -->
<view class="header" :style="{ backgroundImage: 'url(' + $url + 'home/wallet2.png' + ')' }">
<view class="header" :style="{ backgroundImage: 'url(' + $url + 'home/wallet2.png' + ')' }" @click.stop>
<view class="header-content">
<view class="title" @click="jumpPage('充值', '/pages/home/recharge')">
钱包余额 <uni-icons type="right" color="#fff" size="28rpx" />
<view class="header-top">
<view class="title" @click="jumpPage('充值', '/pages/home/recharge')">
钱包余额 <uni-icons type="right" color="#fff" size="28rpx" />
</view>
<view class="more-trigger" @click.stop="toggleLiquidationMenu">
<uni-icons type="more-filled" color="#fff" size="34rpx" />
</view>
<view v-if="showLiquidationMenu" class="more-menu">
<view class="more-menu-item" @click.stop="goWushuangLiquidation">无双变现</view>
</view>
</view>
<view class="num size68 m-y-8" @click="jumpPage('充值', '/pages/home/recharge')">
{{ $fen2yuan(money_obj?.balance || 0) }}
@@ -43,6 +51,7 @@
const money_obj = ref();
const tagList = ref([]);
const showLiquidationMenu = ref(false);
//获取钱包
function getData() {
@@ -65,6 +74,7 @@
});
//充值提现弹框提示去跳转
function jumpPage(typeTxt, url) {
showLiquidationMenu.value = false;
uni.showModal({
// title: '',
content: '是否去' + typeTxt,
@@ -79,6 +89,15 @@
},
});
}
function toggleLiquidationMenu() {
showLiquidationMenu.value = !showLiquidationMenu.value;
}
function goWushuangLiquidation() {
showLiquidationMenu.value = false;
uni.navigateTo({
url: '/pages/home/liquidation?type=2&title=无双变现',
});
}
</script>
<style lang="scss" scoped>
@@ -93,6 +112,13 @@
.header-content {
padding: 80rpx 32rpx 24rpx;
.header-top {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
}
.title {
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
@@ -101,6 +127,40 @@
line-height: 40rpx;
}
.more-trigger {
width: 52rpx;
height: 52rpx;
border-radius: 26rpx;
background: rgba(255, 255, 255, 0.14);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.more-menu {
position: absolute;
top: 62rpx;
right: 0;
min-width: 176rpx;
padding: 10rpx;
border-radius: 18rpx;
background: rgba(26, 45, 88, 0.96);
box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.18);
z-index: 10;
}
.more-menu-item {
height: 68rpx;
padding: 0 24rpx;
border-radius: 14rpx;
color: #ffffff;
font-size: 26rpx;
display: flex;
align-items: center;
white-space: nowrap;
}
.num {
font-family: Avenir, Avenir;
font-weight: 900;
+15 -1
View File
@@ -307,8 +307,22 @@
};
const openThirdPartyService = (item) => {
if (!item?.url) return;
const title = encodeURIComponent(item.title || item.name || '第三方服务');
const targetUrl = encodeURIComponent(item.url);
if (typeof plus !== 'undefined' && plus?.runtime) {
uni.navigateTo({
url: `/pages/public/webview?title=${title}&url=${targetUrl}`,
});
return;
}
if (typeof window !== 'undefined' && typeof window.open === 'function') {
const opened = window.open(item.url, '_blank');
if (opened) return;
window.location.href = item.url;
return;
}
uni.navigateTo({
url: `/pages/public/webview?title=${encodeURIComponent(item.title || item.name || '第三方服务')}&url=${encodeURIComponent(item.url)}`,
url: `/pages/public/webview?title=${title}&url=${targetUrl}`,
});
};
const updateAvatar = async (avatar) => {
+14 -1
View File
@@ -1,7 +1,14 @@
<!-- 网页加载 -->
<template>
<s-layout :title="title" />
<iframe :src="url" frameborder="0" class="iframe" />
<view class="container">
<!-- #ifdef APP-PLUS || MP -->
<web-view :src="url" class="webview" />
<!-- #endif -->
<!-- #ifdef H5 -->
<iframe :src="url" frameborder="0" class="iframe" />
<!-- #endif -->
</view>
</template>
<script setup>
@@ -19,6 +26,12 @@
</script>
<style lang="scss" scoped>
.container {
width: 100%;
height: 100vh;
}
.webview,
.iframe {
width: 100%;
height: 100%;