|
|
@@ -1,4 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
+import { InputFormatUtil } from '../../utils/index'
|
|
|
import { StaticUrl } from '@/config'
|
|
|
import router from '@/router'
|
|
|
|
|
|
@@ -36,9 +37,38 @@ function selectAccountType(type: number) {
|
|
|
submitFrom.value.accountType = type
|
|
|
}
|
|
|
|
|
|
+function validateRechargeAccount(formData: Api.videoRightsubmitOrder): {
|
|
|
+ isValid: boolean
|
|
|
+ errorMessage: string | null
|
|
|
+} {
|
|
|
+ if (formData.rechargeAccount === '') {
|
|
|
+ return {
|
|
|
+ isValid: false,
|
|
|
+ errorMessage: '请输入充值账号',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (formData.accountType === 1 && !InputFormatUtil.isPhone(formData.rechargeAccount || '')) {
|
|
|
+ return {
|
|
|
+ isValid: false,
|
|
|
+ errorMessage: '请输入正确的手机号',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (formData.accountType === 2 && !InputFormatUtil.isQQ(formData.rechargeAccount || '')) {
|
|
|
+ return {
|
|
|
+ isValid: false,
|
|
|
+ errorMessage: '请输入正确的QQ号',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ isValid: true,
|
|
|
+ errorMessage: null,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function submitPay() {
|
|
|
- if (submitFrom.value.rechargeAccount === '') {
|
|
|
- useGlobalToast().show({ msg: '请输入充值账号' })
|
|
|
+ const validation = validateRechargeAccount(submitFrom.value)
|
|
|
+ if (!validation.isValid) {
|
|
|
+ useGlobalToast().show({ msg: validation.errorMessage! })
|
|
|
return
|
|
|
}
|
|
|
submitFrom.value.productId = previewGoods.value.id
|