feat: 添加华夏变现、添加三方权限配置
This commit is contained in:
+217
-66
@@ -32,6 +32,7 @@
|
||||
</view>
|
||||
<view class="tip-text">{{ amountTipText }}</view>
|
||||
</view>
|
||||
|
||||
<view class="card code-card">
|
||||
<view class=" code-row--mobile">
|
||||
<view class="code-label size28">手机号</view>
|
||||
@@ -44,8 +45,18 @@
|
||||
:maxlength="11"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
v-if="isHuaxiaType && showHuaxiaMobileTip"
|
||||
:class="[
|
||||
'huaxia-mobile-tip',
|
||||
{ 'huaxia-mobile-tip--verified': isHuaxiaMobileVerified },
|
||||
]"
|
||||
>
|
||||
{{ isHuaxiaMobileVerified ? '账户核验完成' : '请正确输入华夏手机号' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="card code-card">
|
||||
|
||||
<view v-if="requireSmsCode" class="card code-card">
|
||||
<view class="code-row">
|
||||
<uni-easyinput
|
||||
v-model="smsCode"
|
||||
@@ -78,7 +89,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch, onBeforeUnmount } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import * as payApi from '@/sheep/api/home/pay';
|
||||
import * as incrementApi from '@/sheep/api/increment';
|
||||
@@ -94,10 +105,86 @@
|
||||
let smsTimer = null;
|
||||
const submitting = ref(false);
|
||||
const liquidationType = ref(1);
|
||||
const pageTitle = ref('去变现');
|
||||
const channelId = ref(null);
|
||||
const pageTitle = computed(
|
||||
() =>
|
||||
({
|
||||
1: '去变现',
|
||||
2: '无双变现',
|
||||
3: '华夏变现',
|
||||
}[Number(liquidationType.value)] || '去变现'),
|
||||
);
|
||||
const integerOnly = computed(() => Number(liquidationType.value) === 2);
|
||||
const isHuaxiaType = computed(() => Number(liquidationType.value) === 3);
|
||||
const requireSmsCode = computed(() => !isHuaxiaType.value);
|
||||
const amountPlaceholder = computed(() => (integerOnly.value ? '00' : '00.00'));
|
||||
const amountTipText = computed(() => (integerOnly.value ? '请输入整数变现金额' : '请输入去变现数量'));
|
||||
const amountTipText = computed(() =>
|
||||
integerOnly.value ? '请输入整数变现金额' : isHuaxiaType.value ? '请输入变现金额' : '请输入去变现数量'
|
||||
);
|
||||
|
||||
const huaxiaMobileRegistered = ref(null);
|
||||
const checkingHuaxiaMobile = ref(false);
|
||||
let huaxiaCheckTimer = null;
|
||||
const isHuaxiaMobileVerified = computed(
|
||||
() => huaxiaMobileRegistered.value === true,
|
||||
);
|
||||
const showHuaxiaMobileTip = computed(() => {
|
||||
if (!isHuaxiaType.value) return false;
|
||||
const mobile = String(smsMobile.value || '').trim();
|
||||
if (!isMobileValid(mobile)) return false;
|
||||
if (checkingHuaxiaMobile.value) return false;
|
||||
return (
|
||||
huaxiaMobileRegistered.value === false ||
|
||||
huaxiaMobileRegistered.value === true
|
||||
);
|
||||
});
|
||||
|
||||
const isMobileValid = (val) => /^1\d{10}$/.test(String(val ?? '').trim());
|
||||
|
||||
const checkHuaxiaMobile = async (mobile) => {
|
||||
if (!isHuaxiaType.value || !isMobileValid(mobile)) return;
|
||||
checkingHuaxiaMobile.value = true;
|
||||
try {
|
||||
const params = { mobile };
|
||||
if (channelId.value != null && channelId.value !== '') {
|
||||
params.channelId = Number(channelId.value);
|
||||
}
|
||||
const res = await incrementApi
|
||||
.checkHuaxiaMobile(params)
|
||||
.catch(() => ({ code: -1, data: false }));
|
||||
if (res?.code === 0) {
|
||||
huaxiaMobileRegistered.value = !!res?.data;
|
||||
} else {
|
||||
huaxiaMobileRegistered.value = null;
|
||||
}
|
||||
} finally {
|
||||
checkingHuaxiaMobile.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => smsMobile.value,
|
||||
(val) => {
|
||||
huaxiaMobileRegistered.value = null;
|
||||
if (huaxiaCheckTimer) {
|
||||
clearTimeout(huaxiaCheckTimer);
|
||||
huaxiaCheckTimer = null;
|
||||
}
|
||||
const mobile = String(val || '').trim();
|
||||
if (!isHuaxiaType.value) return;
|
||||
if (!isMobileValid(mobile)) return;
|
||||
huaxiaCheckTimer = setTimeout(() => {
|
||||
checkHuaxiaMobile(mobile);
|
||||
}, 300);
|
||||
},
|
||||
);
|
||||
|
||||
const stopCountdown = () => {
|
||||
if (smsTimer) {
|
||||
clearInterval(smsTimer);
|
||||
smsTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const sanitizeAmountInput = (val) => {
|
||||
let next = String(val ?? '').replace(integerOnly.value ? /[^\d]/g : /[^\d.]/g, '');
|
||||
@@ -149,66 +236,9 @@
|
||||
}
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (submitting.value) return;
|
||||
const amt = amountNumber.value;
|
||||
if (!amt) {
|
||||
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
|
||||
? integerOnly.value
|
||||
? String(Math.floor(availableYuan.value))
|
||||
: String(availableYuan.value.toFixed(2))
|
||||
: '0';
|
||||
return;
|
||||
}
|
||||
if (!String(smsCode.value || '').trim()) {
|
||||
sheep.$helper.toast('请输入验证码');
|
||||
return;
|
||||
}
|
||||
const mobile = resolveMobile();
|
||||
if (!mobile) return;
|
||||
const money = Math.round(amt * 100);
|
||||
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 }));
|
||||
if (res?.code === 0) {
|
||||
sheep.$helper.toast('变现成功,请等待审核');
|
||||
amount.value = '';
|
||||
smsCode.value = '';
|
||||
refreshWallet();
|
||||
return;
|
||||
}
|
||||
if (res?.code === 1006001000) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未实名认证,是否前往实名认证?',
|
||||
cancelText: '取消',
|
||||
confirmText: '去认证',
|
||||
success: (modalRes) => {
|
||||
if (!modalRes?.confirm) return;
|
||||
uni.navigateTo({
|
||||
url: '/pages/public/realname',
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveMobile = () => {
|
||||
const mobile = String(smsMobile.value || '').trim();
|
||||
if (!/^1\d{10}$/.test(mobile)) {
|
||||
if (!isMobileValid(mobile)) {
|
||||
sheep.$helper.toast('请输入正确手机号');
|
||||
return '';
|
||||
}
|
||||
@@ -216,6 +246,7 @@
|
||||
};
|
||||
|
||||
const sendSmsCode = async () => {
|
||||
if (isHuaxiaType.value) return;
|
||||
if (smsCountdown.value > 0) return;
|
||||
const amt = amountNumber.value;
|
||||
if (!amt) {
|
||||
@@ -246,6 +277,83 @@
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
if (submitting.value) return;
|
||||
const amt = amountNumber.value;
|
||||
if (!amt) {
|
||||
sheep.$helper.toast(integerOnly.value ? '请输入整数变现金额' : (isHuaxiaType.value ? '请输入变现金额' : '请输入去变现数量'));
|
||||
return;
|
||||
}
|
||||
if (integerOnly.value && !Number.isInteger(amt)) {
|
||||
sheep.$helper.toast('无双变现金额只能输入整数');
|
||||
return;
|
||||
}
|
||||
if (amt > availableYuan.value) {
|
||||
sheep.$helper.toast('变现金额不能大于钱包余额');
|
||||
amount.value = availableYuan.value > 0
|
||||
? integerOnly.value
|
||||
? String(Math.floor(availableYuan.value))
|
||||
: String(availableYuan.value.toFixed(2))
|
||||
: '0';
|
||||
return;
|
||||
}
|
||||
const mobile = resolveMobile();
|
||||
if (!mobile) return;
|
||||
if (isHuaxiaType.value) {
|
||||
if (huaxiaMobileRegistered.value === null || checkingHuaxiaMobile.value) {
|
||||
await checkHuaxiaMobile(mobile);
|
||||
}
|
||||
if (huaxiaMobileRegistered.value === false) {
|
||||
sheep.$helper.toast('请正确输入华夏手机号');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (requireSmsCode.value) {
|
||||
if (!String(smsCode.value || '').trim()) {
|
||||
sheep.$helper.toast('请输入验证码');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const money = Math.round(amt * 100);
|
||||
const payload = { money, mobile, type: liquidationType.value };
|
||||
if (requireSmsCode.value) {
|
||||
payload.scene = smsScene;
|
||||
payload.code = String(smsCode.value || '').trim();
|
||||
}
|
||||
if (channelId.value != null && channelId.value !== '') {
|
||||
payload.channelId = Number(channelId.value);
|
||||
}
|
||||
submitting.value = true;
|
||||
try {
|
||||
const res = await incrementApi.walletLiquidation(payload).catch(() => ({ code: -1 }));
|
||||
if (res?.code === 0) {
|
||||
sheep.$helper.toast('变现成功,请等待审核');
|
||||
amount.value = '';
|
||||
smsCode.value = '';
|
||||
refreshWallet();
|
||||
return;
|
||||
}
|
||||
if (res?.code === 1006001000) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您还未实名认证,是否前往实名认证?',
|
||||
cancelText: '取消',
|
||||
confirmText: '去认证',
|
||||
success: (modalRes) => {
|
||||
if (!modalRes?.confirm) return;
|
||||
uni.navigateTo({
|
||||
url: '/pages/public/realname',
|
||||
});
|
||||
},
|
||||
});
|
||||
} else if (res?.msg) {
|
||||
sheep.$helper.toast(res.msg);
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const goRecord = () => {
|
||||
uni.navigateTo({
|
||||
url: `/pages/home/liquidationRecord?type=${liquidationType.value}`,
|
||||
@@ -254,15 +362,46 @@
|
||||
|
||||
onLoad((options) => {
|
||||
const nextType = Number(options?.type || 1);
|
||||
liquidationType.value = nextType === 2 ? 2 : 1;
|
||||
pageTitle.value = liquidationType.value === 2 ? '无双变现' : String(options?.title || '去变现');
|
||||
liquidationType.value = [1, 2, 3].includes(nextType) ? nextType : 1;
|
||||
if (options?.channelId != null && options?.channelId !== '') {
|
||||
channelId.value = Number(options.channelId);
|
||||
}
|
||||
try {
|
||||
uni.setNavigationBarTitle({ title: pageTitle.value });
|
||||
} catch (e) {}
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
watch(
|
||||
() => liquidationType.value,
|
||||
() => {
|
||||
try {
|
||||
uni.setNavigationBarTitle({ title: pageTitle.value });
|
||||
} catch (e) {}
|
||||
},
|
||||
);
|
||||
|
||||
onShow(async () => {
|
||||
refreshWallet();
|
||||
const userStore = sheep.$store('user');
|
||||
try {
|
||||
await userStore.getInfo();
|
||||
} catch (e) {}
|
||||
const mobile = userStore?.userInfo?.mobile;
|
||||
if (!smsMobile.value && mobile) smsMobile.value = mobile;
|
||||
if (mobile && !smsMobile.value) smsMobile.value = mobile;
|
||||
if (isHuaxiaType.value) {
|
||||
const curMobile = String(smsMobile.value || '').trim();
|
||||
if (isMobileValid(curMobile)) {
|
||||
await checkHuaxiaMobile(curMobile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopCountdown();
|
||||
if (huaxiaCheckTimer) {
|
||||
clearTimeout(huaxiaCheckTimer);
|
||||
huaxiaCheckTimer = null;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -401,6 +540,18 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.huaxia-mobile-tip {
|
||||
margin-top: 8rpx;
|
||||
padding-left: 4rpx;
|
||||
color: #ff4d4f;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
|
||||
&.huaxia-mobile-tip--verified {
|
||||
color: #12b46b;
|
||||
}
|
||||
}
|
||||
|
||||
.tip-card {
|
||||
margin-top: 20rpx;
|
||||
padding: 28rpx;
|
||||
|
||||
+94
-23
@@ -10,9 +10,15 @@
|
||||
<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="goLiquidation">去变现</view>
|
||||
<view class="more-menu-item" @click.stop="goWushuangLiquidation">无双变现</view>
|
||||
<view v-if="showLiquidationMenu && enabledLiquidations.length" class="more-menu">
|
||||
<view
|
||||
v-for="item in enabledLiquidations"
|
||||
:key="item.type"
|
||||
class="more-menu-item"
|
||||
@click.stop="goLiquidationByType(item)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="num size68 m-y-8" @click="jumpPage('充值', '/pages/home/recharge')">
|
||||
@@ -43,15 +49,70 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import * as api from '@/sheep/api/home/pay';
|
||||
import * as apiIndex from '@/sheep/api/index/index';
|
||||
import * as incrementApi from '@/sheep/api/increment';
|
||||
import goods from '@/components/goods/goods.vue';
|
||||
|
||||
const money_obj = ref();
|
||||
const tagList = ref([]);
|
||||
const showLiquidationMenu = ref(false);
|
||||
const tradeChannelList = ref([]);
|
||||
|
||||
const LIQUIDATION_TYPE_META = {
|
||||
1: { type: 1, title: '去变现', keywords: ['千里马', '去变现', '变现'] },
|
||||
2: { type: 2, title: '无双变现', keywords: ['无双'] },
|
||||
3: { type: 3, title: '华夏变现', keywords: ['华夏'] },
|
||||
};
|
||||
|
||||
const matchLiquidationMeta = (channel) => {
|
||||
const lt = Number(channel?.liquidationType);
|
||||
if ([1, 2, 3].includes(lt) && LIQUIDATION_TYPE_META[lt]) {
|
||||
return { type: lt, meta: LIQUIDATION_TYPE_META[lt] };
|
||||
}
|
||||
const name = String(channel?.channelName || channel?.name || '').trim();
|
||||
if (!name) return null;
|
||||
for (const key of Object.keys(LIQUIDATION_TYPE_META)) {
|
||||
const m = LIQUIDATION_TYPE_META[key];
|
||||
const keywords = Array.isArray(m?.keywords) ? m.keywords : [];
|
||||
if (keywords.some((kw) => name.includes(kw))) {
|
||||
return { type: Number(key), meta: m };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const enabledLiquidations = computed(() => {
|
||||
const channels = Array.isArray(tradeChannelList.value) ? tradeChannelList.value : [];
|
||||
const list = [];
|
||||
const added = new Set();
|
||||
channels.forEach((it) => {
|
||||
if (Number(it?.status) !== 1) return;
|
||||
const matched = matchLiquidationMeta(it);
|
||||
if (!matched) return;
|
||||
const type = matched.type;
|
||||
const meta = matched.meta;
|
||||
if (added.has(type)) return;
|
||||
added.add(type);
|
||||
list.push({
|
||||
type,
|
||||
title: meta.title,
|
||||
channelId: it?.id ?? it?.channelId,
|
||||
});
|
||||
});
|
||||
return list;
|
||||
});
|
||||
|
||||
const fetchTradeChannels = async () => {
|
||||
try {
|
||||
const res = await incrementApi.getTradeChannelList();
|
||||
if (res?.code === 0 && Array.isArray(res?.data)) {
|
||||
tradeChannelList.value = res.data.filter((it) => Number(it?.status) === 1);
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
//获取钱包
|
||||
function getData() {
|
||||
@@ -72,19 +133,18 @@
|
||||
onLoad(() => {
|
||||
getData();
|
||||
});
|
||||
onMounted(() => {
|
||||
fetchTradeChannels();
|
||||
});
|
||||
//充值提现弹框提示去跳转
|
||||
function jumpPage(typeTxt, url) {
|
||||
showLiquidationMenu.value = false;
|
||||
uni.showModal({
|
||||
// title: '',
|
||||
content: '是否去' + typeTxt,
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
//用户点击确定
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
});
|
||||
uni.navigateTo({ url: url });
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -92,14 +152,26 @@
|
||||
function toggleLiquidationMenu() {
|
||||
showLiquidationMenu.value = !showLiquidationMenu.value;
|
||||
}
|
||||
function goLiquidation() {
|
||||
showLiquidationMenu.value = false;
|
||||
jumpPage('变现', '/pages/home/liquidation?type=1&title=去变现');
|
||||
}
|
||||
function goWushuangLiquidation() {
|
||||
function goLiquidationByType(item) {
|
||||
showLiquidationMenu.value = false;
|
||||
const type = Number(item?.type || 1);
|
||||
const title = item?.title || LIQUIDATION_TYPE_META[type]?.title || '去变现';
|
||||
const channelId = item?.channelId ? `&channelId=${item.channelId}` : '';
|
||||
if (type === 1) {
|
||||
uni.showModal({
|
||||
content: '是否去' + title,
|
||||
showCancel: true,
|
||||
success: (res) => {
|
||||
if (!res.confirm) return;
|
||||
uni.navigateTo({
|
||||
url: `/pages/home/liquidation?type=${type}${channelId}`,
|
||||
});
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/home/liquidation?type=2&title=无双变现',
|
||||
url: `/pages/home/liquidation?type=${type}${channelId}`,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -107,11 +179,10 @@
|
||||
<style lang="scss" scoped>
|
||||
.header {
|
||||
height: 318rpx;
|
||||
// background: linear-gradient(270deg, #75AFF6 0%, #366DEE 98.57%);
|
||||
margin: 32rpx;
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
.header-content {
|
||||
padding: 80rpx 32rpx 24rpx;
|
||||
@@ -144,18 +215,18 @@
|
||||
|
||||
.more-menu {
|
||||
position: absolute;
|
||||
top: 62rpx;
|
||||
top: 58rpx;
|
||||
right: 0;
|
||||
min-width: 176rpx;
|
||||
min-width: 200rpx;
|
||||
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;
|
||||
background: rgba(26, 45, 88, 0.98);
|
||||
box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.28);
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.more-menu-item {
|
||||
height: 68rpx;
|
||||
height: 64rpx;
|
||||
padding: 0 24rpx;
|
||||
border-radius: 14rpx;
|
||||
color: #ffffff;
|
||||
|
||||
Reference in New Issue
Block a user