zhb 2 месяцев назад
Родитель
Сommit
5cd567f277

+ 9 - 4
pages/customer/components/TerminalChangePasswordDialog.vue

@@ -1,6 +1,6 @@
 <template>
-    <cwg-popup :title="props.pwdType == 1 ? t('vu.item3') : t('vu.item4')"
-        :visible="props.visible" :showFooters="false" @update:visible="$emit('update:visible', $event)">
+    <cwg-popup :title="props.pwdType == 1 ? t('vu.item3') : t('vu.item4')" :visible="props.visible" :showFooters="false"
+        @update:visible="$emit('update:visible', $event)">
         <view class="popup-content">
             <text class="account-number">{{ accountLabel }} {{ account.login }}</text>
 
@@ -67,15 +67,20 @@ const rule3 = computed(() => {
         passwordInfo.value.newPassword
     );
 });
+const rule4 = computed(() => {
+    return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test(
+        formData.password
+    );
+});
 
 const noticeItems = computed(() => [
     { label: t('signup.form.rules.1st'), valid: rule1.value },
     { label: t('signup.form.rules.2nd'), valid: rule2.value },
-    { label: t('signup.form.rules.3rd'), valid: rule3.value }
+    { label: t('signup.form.rules.4rd'), valid: rule4.value }
 ]);
 
 const isFormValid = computed(() => {
-    return rule1.value && rule2.value && rule3.value && passwordInfo.value.oldPassword && passwordInfo.value.newPassword;
+    return rule1.value && rule2.value && rule4.value && passwordInfo.value.oldPassword && passwordInfo.value.newPassword;
 });
 
 const flag = ref(false); // 防止重复提交

+ 141 - 97
pages/customer/create-account.vue

@@ -8,19 +8,19 @@
                     <cwg-tabs v-model:cativeIndex="cativeIndex" :tabs="tabs" />
 
                 </view>
-                <uni-forms ref="baseForm" :model="formData" labelWidth="200" label-position="top" :rules="rules"
-                    class="base-info-form">
+                <uni-forms ref="formRef" :model="formData" :rules="rules" label-width="200" label-position="top"
+                    class="base-info-form" validate-trigger="submit">
                     <uni-row class="demo-uni-row uni-row1 uni-row2">
                         <!-- MT4/MT5 -->
                         <uni-col :xs="24">
-                            <uni-forms-item :label="t('Custom.NewAccount.Platform')">
+                            <uni-forms-item :label="t('Custom.NewAccount.Platform')" name="platform">
                                 <cwg-combox :clearable="false" v-model:value="formData.platform"
                                     :options="platformColumns" :placeholder="t('placeholder.choose')" />
                             </uni-forms-item>
                         </uni-col>
                         <!-- 货币类型 -->
                         <uni-col :xs="24">
-                            <uni-forms-item :label="t('Custom.NewAccount.Currency')">
+                            <uni-forms-item :label="t('Custom.NewAccount.Currency')" name="currency">
                                 <cwg-combox :clearable="false" v-model:value="formData.currency"
                                     :options="currencyColumns" :placeholder="t('placeholder.choose')" />
                             </uni-forms-item>
@@ -28,7 +28,7 @@
 
                         <!-- 杠杆 -->
                         <uni-col :xs="24">
-                            <uni-forms-item :label="t('Custom.NewAccount.Lever')">
+                            <uni-forms-item :label="t('Custom.NewAccount.Lever')" name="leverage">
                                 <cwg-combox :clearable="false" :disabled="hidden" v-model:value="formData.leverage"
                                     :options="leverageColumns" :placeholder="t('placeholder.choose')" />
                             </uni-forms-item>
@@ -36,14 +36,14 @@
 
                         <!-- 账户余额 -->
                         <uni-col :xs="24" v-if="dome">
-                            <uni-forms-item :label="t('Custom.NewAccount.Balance')">
+                            <uni-forms-item :label="t('Custom.NewAccount.Balance')" name="balance">
                                 <uni-easyinput type="digit" :clearable="false" v-model="formData.balance"
                                     :placeholder="t('Custom.NewAccount.BalancePlaceholder')" />
                             </uni-forms-item>
                         </uni-col>
                         <!-- 交易密码 -->
                         <uni-col :xs="24">
-                            <uni-forms-item :label="t('Custom.NewAccount.Password')">
+                            <uni-forms-item :label="t('Custom.NewAccount.Password')" name="password">
                                 <uni-easyinput :clearable="false" v-model="formData.password"
                                     :placeholder="t('Custom.NewAccount.Password')" />
                             </uni-forms-item>
@@ -252,6 +252,21 @@ const formData = reactive({
     platform: '',
     balance: null,
 });
+const resetForm = async () => {
+    await nextTick();
+    formRef.value?.clearValidate();
+    formData.password = ""
+    formData.currency = ""
+    formData.leverage = ""
+    formData.platform = ""
+    formData.balance = ""
+    amountErrorMessage.value = ""
+    submitting.value = false
+    flag.value = false
+    loginValue.value = ""
+    dialogCheck.value = false
+    dialogVisible.value = false
+}
 
 
 // 计算属性
@@ -269,70 +284,91 @@ const rule3 = computed(() => {
         formData.password
     );
 });
+const rule4 = computed(() => {
+    return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test(
+        formData.password
+    );
+});
 const noticeItems = computed(() => [
     { label: t('signup.form.rules.1st'), valid: rule1.value },
     { label: t('signup.form.rules.2nd'), valid: rule2.value },
-    { label: t('signup.form.rules.3rd'), valid: rule3.value }
+    { label: t('signup.form.rules.4rd'), valid: rule4.value }
 ])
+const rules = computed(() => ({
+    platform: {
+        rules: [
+            {
+                required: true,
+                errorMessage: t('vaildate.select.empty'),
+                trigger: 'change',
+            },
+        ],
+    },
+    currency: {
+        rules: [
+            {
+                required: true,
+                errorMessage: t('vaildate.select.empty'),
+                trigger: 'change',
+            },
+        ],
+    },
+    leverage: {
+        rules: [
+            {
+                required: true,
+                errorMessage: t('vaildate.select.empty'),
+                trigger: 'change',
+            },
+        ],
+    },
 
-// 验证规则
-const rules = {
-    password: [
-        {
-            validator: (rule, value, callback) => {
-                if (/^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test(value)) {
-                    callback();
-                } else {
-                    callback(new Error(t('vaildate.password.format')));
-                }
+    password: {
+        rules: [
+            {
+                required: true,
+                errorMessage: t('vaildate.password.format'),
+                trigger: 'blur',
             },
-            trigger: 'blur',
-            required: true
-        }
-    ],
-    platform: [
-        {
-            required: true,
-            message: t('vaildate.select.empty'),
-            trigger: 'change'
-        }
-    ],
-    currency: [
-        {
-            required: true,
-            message: t('vaildate.select.empty'),
-            trigger: 'change'
-        }
-    ],
-    leverage: [
-        {
-            required: true,
-            message: t('vaildate.select.empty'),
-            trigger: 'change'
-        }
-    ],
-    balance: [
-        {
-            validator: (rule, value, callback) => {
-                if (value === null || value === undefined || value === '') {
-                    callback();
-                    return;
-                }
-                const numValue = Number(value);
-                if (isNaN(numValue)) {
-                    callback(new Error(t('vaildate.amount.format')));
-                    return;
-                }
-                if (numValue < 0 || numValue > 100000) {
-                    callback(new Error(t('vaildate.amount.amount') + '0-100000'));
-                    return;
+            {
+                validateFunction: (rule, value, data, callback) => {
+                    if (/^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test(value)) {
+                        return true;
+                    } else {
+                        callback(t('vaildate.password.format')); return false;
+                    }
+                },
+                trigger: 'blur',
+            },
+        ],
+    },
+    balance: {
+        rules: [
+            {
+                required: true,
+                errorMessage: t('vaildate.amount.format'),
+            },
+            {
+                validateFunction: (rule, value, data, callback) => {
+                    if (value === null || value === undefined || value === '') {
+                        return true;
+                    }
+                    const numValue = Number(value);
+                    if (isNaN(numValue)) {
+                        callback(t('vaildate.amount.format'));
+                        return false;
+                    }
+                    if (numValue < 0 || numValue > 100000) {
+                        callback(t('vaildate.amount.amount') + '0-100000');
+                        return false;
+                    }
                 }
-                callback();
             },
-            trigger: ['blur', 'change']
-        }
-    ]
-};
+        ],
+    },
+
+}));
+
 // 平台选项
 const platformColumns = computed(() => {
     const columns = [];
@@ -363,11 +399,7 @@ const leverageColumns = computed(() => {
 
 // 方法
 const closeDia = () => {
-    if (formRef.value) {
-        formRef.value.resetFields();
-    }
-    dialogCheck.value = false;
-    dialogVisible.value = false;
+    resetForm()
 };
 
 const closeAccountLimitDialog = () => {
@@ -416,37 +448,51 @@ const getExcludeShowLogin = async () => {
 // 提交开户
 const newAccount = async () => {
 
-    if (flag.value) return;
-    flag.value = true;
-    const api = dome.value ? customApi.AccountApplyAddDome : customApi.AccountApplyAdd;
-    const res = await api({
-        type: Number(isOpenAccount.value),
-        ...formData
-    });
 
-    if (res.code === 200) {
-        if (dome.value) {
-            uni.showToast({
-                title: t('Msg.Success'),
-                icon: 'success'
+    try {
+        if (formRef.value) {
+            const valid = await formRef.value.validate()
+            if (flag.value) return;
+            flag.value = true;
+            const api = dome.value ? customApi.AccountApplyAddDome : customApi.AccountApplyAdd;
+            const res = await api({
+                type: Number(isOpenAccount.value),
+                ...formData
             });
+
+            if (res.code === 200) {
+                if (dome.value) {
+                    uni.showToast({
+                        title: t('Msg.Success'),
+                        icon: 'success'
+                    });
+                }
+                router.push('/pages/customer/index')
+                isOpenAccount.value = 0;
+                dialogCheck.value = true;
+                dialogVisible.value = true;
+                if (formRef.value) {
+                    formRef.value.resetFields();
+                }
+                flag.value = false;
+            } else if (res.code === 407) {
+                showAccountLimitDialog(formData.platform);
+                flag.value = false;
+            } else {
+                RES.value = res.msg;
+                dialogCheck.value = true;
+                dialogVisible.value = false;
+                flag.value = false;
+                resetForm()
+            }
         }
-        router.push('/pages/customer/index')
-        isOpenAccount.value = 0;
-        dialogCheck.value = true;
-        dialogVisible.value = true;
-        if (formRef.value) {
-            formRef.value.resetFields();
+    } catch (error) {
+        if (error instanceof Array) {
+            // showToast(error[0].errorMessage);
+            return
+        } else {
+            RES.value = error.msg;
         }
-        flag.value = false;
-    } else if (res.code === 407) {
-        showAccountLimitDialog(formData.platform);
-        flag.value = false;
-    } else {
-        RES.value = res.msg;
-        dialogCheck.value = true;
-        dialogVisible.value = false;
-        flag.value = false;
     }
 };
 
@@ -458,8 +504,6 @@ const checkPlatform = (pla) => {
     } else {
         hidden.value = true;
     }
-    formData.currency = '';
-    formData.leverage = '';
     optionsLev.value = [];
     optionsCur.value = [];
     const Cur = [];

+ 12 - 5
pages/mine/components/SecurityCenterTab.vue

@@ -34,7 +34,8 @@
                             </view>
                         </uni-col>
                         <uni-col :xs="24">
-                            <view class="btn btn-confirm" @click="passwordUpdate">{{ locale == 'es' ? 'Actualizar contraseña' : t('Btn.Application') }}</view>
+                            <view class="btn btn-confirm" @click="passwordUpdate">{{ locale == 'es' ? 'Actualizar
+                                contraseña' : t('Btn.Application') }}</view>
                         </uni-col>
                     </uni-row>
                 </uni-forms>
@@ -68,7 +69,8 @@
                             </view>
                         </uni-col>
                         <uni-col :xs="24">
-                            <view class="btn btn-confirm" @click="emailUpdate">{{ locale == 'es' ? 'Actualizar contraseña' : t('Btn.Application') }}</view>
+                            <view class="btn btn-confirm" @click="emailUpdate">{{ locale == 'es' ? 'Actualizar
+                                contraseña' : t('Btn.Application') }}</view>
                         </uni-col>
                     </uni-row>
                 </uni-forms>
@@ -119,10 +121,15 @@ const rule3 = computed(() => {
         passwordInfo.value.newPassword
     );
 });
+const rule4 = computed(() => {
+    return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@&%$^*./\\(\\)\\+\\=#_-])[A-Za-z0-9~!@&%$^*./\\(\\)\\+\\=#_-]{8,16}$/.test(
+        passwordInfo.value.newPassword
+    );
+});
 const noticeItems = computed(() => [
     { label: t('signup.form.rules.1st'), valid: rule1.value },
     { label: t('signup.form.rules.2nd'), valid: rule2.value },
-    { label: t('signup.form.rules.3rd'), valid: rule3.value }
+    { label: t('signup.form.rules.4rd'), valid: rule4.value }
 ])
 // 发送邮箱验证码
 async function sendEmailCode() {
@@ -185,8 +192,8 @@ async function passwordUpdate() {
             showToast(t("signup.form.rules.2nd"));
             return;
         }
-        if (!rule3.value) {
-            showToast(t("signup.form.rules.3rd"));
+        if (!rule4.value) {
+            showToast(t("signup.form.rules.4rd"));
             return;
         }
         const res = await personalApi.customUpdatePassword({