Quellcode durchsuchen

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP20_WEB_GLOBAL

li.shaoyi vor 2 Jahren
Ursprung
Commit
abd1264a19

+ 1 - 1
public/config/appconfig.json

@@ -1,5 +1,5 @@
 {
   "version": "1.0.0",
   "versionCode": "100000",
-  "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204"
+  "apiUrl": "http://192.168.31.134:8080/cfg?key=test_134"
 }

+ 50 - 2
src/business/bank/index.ts

@@ -1,6 +1,14 @@
 import {ref, reactive, shallowRef, computed } from 'vue'
 import { useAccountStore, useUserStore, useLoginStore } from '@/stores'
-import { t2bBankWithdraw, queryBankAccountSign, t2bBankDeposit, queryCusBankSignBank, t2bBankSign, t2bBankCancelSign, accountFundInfoReq, queryBankCusBankExtendConfigs } from '@/services/api/bank'
+import { t2bBankWithdraw, 
+         queryBankAccountSign, 
+         t2bBankDeposit, 
+         queryCusBankSignBank, 
+         t2bBankSign, 
+         t2bBankCancelSign, 
+         accountFundInfoReq, 
+         queryBankCusBankExtendConfigs, 
+         t2bSMSVerificationCode } from '@/services/api/bank'
 import { SignStatus } from '@/constants/bank'
 import { decryptAES } from '@/services/websocket/package/crypto'
 import moment from "moment"
@@ -324,4 +332,44 @@ export function useQueryCusBankSignBank() {
     })
 
     return { cusBank, request }
-}
+}
+
+/// 银行获取手机验证码请求
+export function useT2bSMSVerificationCode() {
+    const loading = shallowRef(false)
+    /// 查询签约银行信息
+    const request = queryCusBankSignBank().then((res) => {
+        if (res.data.length) {
+            const data = res.data[0]
+            swsFormData.CusBankID = data.cusbankid
+            swsFormData.TradeDate = data.tradedate
+        }
+    })
+
+    /// 数据
+    const swsFormData = reactive<Partial<Proto.t2bSWSVerificationCodeReq>>({
+        Mobile: useStore.userInfo?.mobile2,
+        AccountCode: accountStore.currentAccountId.toString(),
+        extend_info: JSON.stringify({ "sex" : 1 })
+    })
+
+    const smsVerificationCode = async () => {
+        await request
+        loading.value = true
+
+        return t2bSMSVerificationCode({
+            data: {
+                ExtOperatorID: new Date().getTime(),
+                ...swsFormData,
+            }
+        }).finally(() => {
+            loading.value = false
+        })
+    }
+
+    return {
+        loading,
+        swsFormData,
+        smsVerificationCode
+    }
+}

+ 2 - 0
src/constants/funcode.ts

@@ -31,6 +31,8 @@ export enum FunCode {
     t2bBankDepositRsp = 589844,   //入金应答
     AccountFundInfoReq = 262150,   /// 账户资金信息请求(0, 4, 6)
     AccountFundInfoRsp = 262151,  /// 账户资金信息响应(0, 4, 7)
+    t2bSMSVerificationCodeReq = 589853,    // 银行获取手机验证码请求
+    t2bSMSVerificationCodeRsp = 589854,   // 银行获取手机验证码应答
 
     UserReceiveInfoReq = 1900545, // 新增修改收货地址请求
     UserReceiveInfoRsp = 1900546, // 新增修改收货地址请求响应

+ 55 - 3
src/packages/mobile/views/bank/sign/components/edit/Index.vue

@@ -18,7 +18,22 @@
                         :rules="formRules.BankAccountName" />
                     <Field name="MobilePhone" label="手机号码" readonly v-model="formData.MobilePhone" placeholder="请输入手机号码" />
                     <template v-for="(item, index) in configs" :key="index">
-                        <Field v-if="item.usabletype === 1 || item.usabletype === userStore.userInfo?.userinfotype"
+                        <Field v-if="(item.fieldcode === 'verify_code') && 
+                                     (item.usabletype === 1) || 
+                                     (item.usabletype === 2 && userStore.userInfo?.userinfotype === 2) || 
+                                     (item.usabletype === 3 && userStore.userInfo?.userinfotype === 1)" 
+                         v-model="item.value"  type="digit" name="vcode" :label="item.fieldname" placeholder="必填" autocomplete="off"
+                            :rules="item.fieldname">
+                            <template #button>
+                                <Button size="small" type="danger" :disabled="isCountdown" @click="sendVerifyCode">
+                                    <span v-if="isCountdown">重新发送({{ currentTime.seconds }})</span>
+                                    <span v-else>获取验证码</span>
+                                </Button>
+                            </template>
+                        </Field>
+                        <Field v-else-if="(item.usabletype === 1) || 
+                         (item.usabletype === 2 && userStore.userInfo?.userinfotype === 2) || 
+                         (item.usabletype === 3 && userStore.userInfo?.userinfotype === 1)"
                             :name="item.fieldcode" :label="item.fieldname" v-model="item.value"
                             :placeholder="`请输入${item.fieldname}`" />
                     </template>
@@ -35,12 +50,13 @@
 
 <script lang="ts" setup>
 
-import { shallowRef } from 'vue'
+import { shallowRef, ref, computed } from 'vue'
 import { CellGroup, Button, Field, Form, FormInstance, FieldRule, showFailToast } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { useDoBankSign, useDoCusBankExtendConfigs } from '@/business/bank'
+import { useDoBankSign, useDoCusBankExtendConfigs, useT2bSMSVerificationCode } from '@/business/bank'
 import { validateRules } from '@/constants/regex'
 import { useErrorInfoStore } from '@/stores'
+import { useCountDown } from '@vant/use'
 import { useUserStore } from '@/stores'
 import AppModal from '@/components/base/modal/index.vue'
 import AppSelect from '@mobile/components/base/select/index.vue'
@@ -51,6 +67,21 @@ const refresh = shallowRef(false) // 是否刷新父组件数据
 const formRef = shallowRef<FormInstance>()
 const { configs } = useDoCusBankExtendConfigs(1)
 const userStore = useUserStore()
+const { smsVerificationCode } = useT2bSMSVerificationCode()
+
+/// 短信验证码交易中心信息
+const CenterErrMsg = shallowRef('')
+// 倒计时函数
+const countdown = useCountDown({
+    time: 60 * 1000,
+    onFinish: () => {
+        countdown.reset()
+        isCountdown.value = false
+    }
+})
+const isCountdown = ref(false) // 是否正在倒计时
+// 倒计时剩余时间
+const currentTime = computed(() => countdown.current.value)
 
 const props = defineProps({
     isedit: {
@@ -59,6 +90,22 @@ const props = defineProps({
     }
 })
 
+
+// 发送手机验证码
+const sendVerifyCode = () => {
+    formRef.value?.validate('MobilePhone').then(() => {
+        smsVerificationCode().then((res) => {
+            if (res.CenterErrMsg != '') {
+                CenterErrMsg.value = res.CenterErrMsg ?? ''
+            }
+            isCountdown.value = true
+            countdown.start()
+        }).catch(() => {
+            showFailToast('发送失败')
+        })
+    })
+}
+
 // 表单验证规则
 const formRules: { [key in keyof Proto.t2bBankSignReq]?: FieldRule[] } = {
     OpenBankAccId: [{
@@ -107,7 +154,12 @@ const formSubmit = () => {
                 formData.BankCity = e.value
             }
         })
+        /// 如果需要短信验证码
+        if (CenterErrMsg.value != '') {
+                obj['smsSerialNo'] = CenterErrMsg.value
+            }
         formData.extend_info = JSON.stringify(obj)
+
         onSubmit().then(() => {
             hideLoading()
             dialog(props.isedit ? '签约信息修改提交成功' : '签约提交成功,请耐心等待审核。').then(() => {

+ 59 - 4
src/packages/pc/views/account/sign/components/sign/index.vue

@@ -1,8 +1,8 @@
 <!-- 账户管理-签约账号管理-签约 -->
 <template>
-    <app-drawer :title="bankInfo ? '修改签约账户' : '添加签约账户'" :width="400" v-model:show="show" :loading="loading"
+    <app-drawer :title="bankInfo ? '修改签约账户' : '添加签约账户'" :width="800" v-model:show="show" :loading="loading"
         :refresh="refresh">
-        <el-form ref="formRef" class="el-form--vertical" label-width="90px" :model="formData" :rules="formRules">
+        <el-form ref="formRef" class="el-form--horizontal" label-width="120px" :model="formData" :rules="formRules">
             <el-form-item label="开户银行" prop="OpenBankAccId">
                 <el-select v-model="formData.OpenBankAccId">
                     <el-option :label="item.bankname" :value="item.bankid" v-for="(item, index) in banklist" :key="index" />
@@ -20,8 +20,24 @@
                 <el-input name="MobilePhone" readonly placeholder="请输入手机号码" v-model="formData.MobilePhone" />
             </el-form-item>
             <template v-for="(item, index) in configs" :key="index">
+                <el-form-item :label="item.fieldname" :prop="item.fieldcode" 
+                   v-if="(item.fieldcode === 'verify_code') && 
+                         (item.usabletype === 1) || 
+                         (item.usabletype === 2 && userStore.userInfo?.userinfotype === 2) || 
+                         (item.usabletype === 3 && userStore.userInfo?.userinfotype === 1)">
+                    <el-input placeholder="请输入短信验证码" type="number" v-model="item.value" :rules="formRules.vcode">
+                        <template #append>
+                            <el-button size="small" type="primary" :disabled="isCountdown" @click="sendVerifyCode">
+                                <span v-if="isCountdown">重新发送({{ seconds }})</span>
+                                <span v-else>获取验证码</span>
+                            </el-button>
+                        </template>
+                    </el-input>
+                </el-form-item>
                 <el-form-item :label="item.fieldname" :prop="item.fieldcode"
-                    v-if="item.usabletype === 1 || item.usabletype === userStore.userInfo?.userinfotype">
+                    v-else-if="(item.usabletype === 1) || 
+                         (item.usabletype === 2 && userStore.userInfo?.userinfotype === 2) || 
+                         (item.usabletype === 3 && userStore.userInfo?.userinfotype === 1)">
                     <el-input :name="item.fieldcode" placeholder="请必须输入" v-model="item.value" />
                 </el-form-item>
             </template>
@@ -37,11 +53,13 @@
 import { ref } from 'vue'
 import { ElMessage } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
-import { useDoBankSign, useDoCusBankExtendConfigs } from '@/business/bank'
+import { useDoBankSign, useDoCusBankExtendConfigs, useT2bSMSVerificationCode } from '@/business/bank'
 import { useErrorInfoStore } from '@/stores'
 import { validateRules } from '@/constants/regex'
 import { useUserStore } from '@/stores'
+import service from '@/services'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
+import { shallowRef } from 'vue'
 
 const formRules: FormRules = {
     OpenBankAccId: [{
@@ -69,17 +87,50 @@ const formRules: FormRules = {
 
 const { formData, onSubmit, banklist, bankInfo, loading } = useDoBankSign()
 const { configs } = useDoCusBankExtendConfigs(1)
+const { smsVerificationCode } = useT2bSMSVerificationCode()
 
 const userStore = useUserStore()
 const show = ref(true)
 const refresh = ref(false)
 const formRef = ref<FormInstance>()
+const seconds = ref(60) //倒计时剩余时间
+const isCountdown = ref(false) // 是否正在倒计时
+/// 短信验证码交易中心信息
+const CenterErrMsg = shallowRef('')
 
 const onCancel = (isRefresh = false) => {
     show.value = false
     refresh.value = isRefresh
 }
 
+// 发送手机验证码
+const sendVerifyCode = () => {
+    formRef.value?.validateField('MobilePhone', (valid) => {
+        if (valid) {
+            service.onReady().then(() => {
+                smsVerificationCode().then((res) => {
+                    if (res.CenterErrMsg != '') {
+                        CenterErrMsg.value = res.CenterErrMsg ?? ''
+                    }
+                    isCountdown.value = true
+                    // 开始倒计时
+                    const countDown = window.setInterval(() => {
+                        seconds.value--
+                        if (seconds.value <= 0) {
+                            clearInterval(countDown)
+                            isCountdown.value = false
+                        }
+                    }, 1000)
+                }).catch(() => {
+                    ElMessage.error('发送失败')
+                })
+            }).catch((err) => {
+                ElMessage.error(err)
+            })
+        }
+    })
+}
+
 const formSubmit = () => {
     formRef.value?.validate((valid) => {
         if (valid) {
@@ -102,6 +153,10 @@ const formSubmit = () => {
                         formData.BankCity = e.value
                     }
                 })
+                /// 如果需要短信验证码
+                if (CenterErrMsg.value != '') {
+                    obj['smsSerialNo'] = CenterErrMsg.value
+                }
                 formData.extend_info = JSON.stringify(obj)
 
                 onSubmit().then(() => {

+ 11 - 0
src/services/api/bank/index.ts

@@ -28,6 +28,17 @@ export function t2bBankSign(config: RequestConfig<Partial<Proto.t2bBankSignReq>>
 }
 
 /**
+ * 短信验证码请求
+ */
+export function t2bSMSVerificationCode(config: RequestConfig<Partial<Proto.t2bSWSVerificationCodeReq>>) {
+    return http.mqRequest<Proto.t2bSWSVerificationCodeRsp>({
+        data: config.data,
+        requestCode: 't2bSMSVerificationCodeReq',
+        responseCode: 't2bSMSVerificationCodeRsp',
+    })
+}
+
+/**
  * 银行解约
  */
 export function t2bBankCancelSign(config: RequestConfig<Partial<Proto.t2bBankCancelSignReq>>) {

+ 27 - 0
src/types/proto/bank.d.ts

@@ -194,5 +194,32 @@ declare global {
             AvailableOutMoney: number; // double 可出资金,查询位掩码: 2
             IsCleanAccount: number; // int32 是否是干净账户,查询位掩码: 4
         }
+
+        /** 短信验证码请求请求 */
+        interface t2bSWSVerificationCodeReq {
+            Header?: IMessageHead;
+            ExtOperatorID?: number; // 外部操作流水号
+            CusBankID?: string; // 托管银行编号
+            ExchId?: string; // 交易所编号
+            TradeDate?: string; // 交易日
+            ExchTicket?: string; // 交易所流水号
+            AccountCode?: string; // 资金账户
+            BusinessNo?: string; // 银行业务编号
+            Mobile?: string; // 手机号码
+            extend_info?: string; // 扩展信息(JSON串,参考配置要求进行填充〉
+        }
+
+        /** 短信验证码应答应答 */
+        interface t2bSWSVerificationCodeRsp {
+            Header?: IMessageHead;
+            ExtOperatorID?: number; // 外部操作流水号
+            Status?: number; // 状态(0成功,其他数值参考银行服务的错误码)
+            ExchTicket?: string; // 交易所流水号
+            ExchId?: string; // 交易所编号
+            TradeDate?: string; // 交易日
+            CenterTicket?: number; // 中心流水号
+            CenterErrCode?: string; // 中心返回码
+            CenterErrMsg?: string; // 中心返回结果说明
+        }
     }
 }