소스 검색

代码提交

Handy_Cao 3 년 전
부모
커밋
95515e4f14

+ 73 - 49
src/business/bank/index.ts

@@ -1,10 +1,10 @@
-import { reactive, shallowRef } from 'vue'
+import { reactive, shallowRef,computed } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
 import { useLoginStore, useUserStore } from '@/stores'
 import { queryHisAmountLog, t2bBankWithdraw, queryBankAccountSign, t2bBankDeposit, queryAccountInOutApply, queryCusBankSignBank, t2bBankSign, t2bBankCancelSign } from '@/services/api/bank'
-import { formatDate } from '@/filters'
-import { Model } from 'echarts'
 import { decryptAES } from '@/utils/websocket/crypto'
+import  moment  from "moment";
+import { da } from 'element-plus/es/locale'
 
 // 历史资金流水列表
 export function useBankStatementList() {
@@ -143,36 +143,48 @@ export function doWithdraw() {
     /// 获取当前是否已签约
     const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
 
+    const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
+        if (bankAccountSign.value.length) {
+            return bankAccountSign.value[0]
+        }
+        return {}
+    })
+
     /// 查询签约信息
     const request = queryBankAccountSign({
         data: {
             userid: getUserId()
         },
         success:(res)=>{
-            bankAccountSign.value=res.data,
-            ({
-                bankaccountname2:formData.BankAccoutName,
-                branchbankname: formData.BranchBankName,
-                accountcode: formData.AccountCode,
-                cusbankid: formData.CusBankID,
-                bankid: formData.OpenCardBankId
-            }=res.data[0])
+            if(res.data.length) {
+                bankAccountSign.value=res.data
+                const data=res.data[0]
+                formData.Currency=data.currency
+                formData.CusBankID=data.cusbankid
+                formData.BankAccoutName = data.bankaccountname
+                formData.OpenCardBankId=data.bankid
+                formData.AccountCode=data.accountcode
+                formData.BranchBankName=data.branchbankname
+                formData.BankAccoutName=data.bankaccountname2
+                formData.BankAccoutNum=data.bankaccountno2
+            }
         }
     })
 
     const formData = reactive<Partial<Proto.t2bBankWithdrawReq>>({
         AccountType: 0,
-        ExtOperatorID: new Date().getTime(),
-        AppDateTime: formatDate(Date(), 'yyyy-MM-dd HH:mm:ss'),
+        AppDateTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
         extend_info: JSON.stringify({"sex": 1})
     })
 
     const onSubmit = async () => {
         await request
         loading.value = true
+        
         return t2bBankWithdraw({
             data: {
                 ...formData,
+                ExtOperatorID: new Date().getTime()
             },
             complete: () => {
                 loading.value = false
@@ -184,37 +196,40 @@ export function doWithdraw() {
         loading, 
         onSubmit, 
         formData, 
-        bankAccountSign
+        sign
     }
 }
 
 // 充值请求
-export function doDeposit(url: string) {
+export function doDeposit() {
     /// 获取UserId
     const {getUserId} = useLoginStore()
     const loading = shallowRef(false)
     /// 获取当前是否已签约
     const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
 
-    const formData = reactive<Partial<Proto.t2bBankDepositReq>>({
-        ExtOperatorID: new Date().getTime(),
-        extend_info: JSON.stringify({'certificate_photo_url': url, "sex": 1})
-    })
+    const extendInfo={
+        certificate_photo_url: '',
+        sex: 1
+    }
+
+    const formData = reactive<Partial<Proto.t2bBankDepositReq>>({})
 
     const request = queryBankAccountSign({
         data: {
             userid: getUserId()
         },
         success:(res)=>{
-            bankAccountSign.value=res.data,
-            ({
-                amount: formData.Amount,
-                cusbankid: formData.CusBankID,
-                currency: formData.Currency,
-                bankaccountname2: formData.BankAccoutName,
-                bankaccountno2: formData.BankAccoutNum,
-                accountcode: formData.AccountCode
-            })
+            if(res.data.length) {
+                bankAccountSign.value=res.data
+                const data=res.data[0]
+                formData.Currency=data.currency
+                formData.CusBankID=data.cusbankid
+                formData.BankAccoutName = data.bankaccountname2
+                formData.OpenCardBankId=data.bankid
+                formData.AccountCode=data.accountcode
+                formData.BankAccoutNum=data.bankaccountno2
+            }
         }
     })
 
@@ -223,7 +238,9 @@ export function doDeposit(url: string) {
         loading.value = true
         return t2bBankDeposit({
             data: {
-                ...formData
+                ...formData,
+                ExtOperatorID: new Date().getTime(),
+                extend_info:JSON.stringify(extendInfo)
             },
             complete: () => {
                 loading.value = false
@@ -234,6 +251,7 @@ export function doDeposit(url: string) {
     return {
         loading, 
         onSubmit, 
+        extendInfo,
         formData,
         bankAccountSign
     }
@@ -255,9 +273,8 @@ export function doBankSign() {
         BankCardType: 0,
         BankAccountType: 1,
         extend_info: JSON.stringify({"sex": 1}),
-        ExtOperatorID: new Date().getTime(),
         AccountCode: getFirstAccountId().toString(),
-        CertID: getUserInfo()?.cardnum,
+        CertID: decryptAES(getUserInfo()?.cardnum ?? ''),
         CertType: getUserInfo()?.cardtypeid.toString(),
         
     })
@@ -281,10 +298,11 @@ export function doBankSign() {
     const onSubmit = async () => {
         await request
         loading.value = true
-        console.log(cusSignBank)
+
         return t2bBankSign({
             data: {
                 ...formData,
+                ExtOperatorID: new Date().getTime(),
                 AccountName: formData.BankAccountName,
                 ExBankName: cusSignBank.value?.Banklst.find(obj=> obj.bankid===formData.OpenBankAccId )?.bankname
             },
@@ -307,44 +325,50 @@ export function doCancelBankSign() {
     /// 获取UserId
     const {getUserId} = useLoginStore()
     const loading = shallowRef(false)
+
+    /// 表单信息
+    const formData = reactive<Partial<Proto.t2bBankCancelSignReq>>({ })
     /// 获取当前是否已签约
     const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
-    /// 表单信息
-    const formData = reactive<Partial<Proto.t2bBankCancelSignReq>>({})
-    
+    /// 当前已签约
+    const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
+        if (bankAccountSign.value.length) { return bankAccountSign.value[0] }
+        return {}
+    })
+
     /// 请求签约信息
     const request = queryBankAccountSign({
         data: {
             userid: getUserId()
         },
         success:(res)=>{
-            bankAccountSign.value=res.data,
-            ({
-                cusbankid: formData.CusBankID,
-                currency: formData.Currency,
-                tradedate: formData.TradeDate,
-                accountcode: formData.AccountCode,
-                bankaccountno: formData.BankChildAcc,
-                bankaccountname: formData.BankChildAccName
-            })
+            if (res.data.length) {
+                bankAccountSign.value=res.data
+                const data=res.data[0]
+                formData.CusBankID = data.cusbankid
+                formData.Currency = data.currency
+                formData.AccountCode = data.accountcode
+                formData.BankChildAccName=data.accountname2
+                formData.BankChildAcc=data.bankaccountno2
+            }
         }
     })
 
     const formSubmit = async () => {
         await request
-        const { cusbankid, currency, accountcode, bankaccountno, bankaccountname } = bankAccountSign.value[0]
+        const { cusbankid, currency, accountcode, bankaccountno2, bankaccountname2 } = bankAccountSign.value[0]
         loading.value = true
         /// 发起请求
         return t2bBankCancelSign({
             data: {
+                ...formData,
                 IsForce: 0,
                 ExtOperatorID: new Date().getTime(),
-                ...formData,
                 CusBankID: cusbankid,
                 Currency: currency,
                 AccountCode: accountcode,
-                BankChildAcc: bankaccountno,
-                BankChildAccName: bankaccountname
+                BankChildAcc: bankaccountno2,
+                BankChildAccName: bankaccountname2
             },
             complete: () => {
                 loading.value = false
@@ -356,6 +380,6 @@ export function doCancelBankSign() {
         loading, 
         formSubmit, 
         formData,
-        bankAccountSign
+        sign
     }
 }

+ 1 - 0
src/business/common/index.ts

@@ -3,6 +3,7 @@ import { useStore } from '@/stores'
 import { tokenCheck } from '@/services/api/account'
 import eventBus from '@/services/bus'
 import socket from '@/services/socket'
+import { uploadFile } from '@/services/api/common'
 
 /**
  * 退出登录

+ 4 - 0
src/constants/regex.ts

@@ -21,5 +21,9 @@ export const validateRules = {
     enname: {
         validate: (val: string) => /^[a-zA-Z0-9_]{1,}$/.test(val),
         message: '只能输入英文字母、数字、下划线',
+    },
+    cardno: {
+        validate: (val: string) => /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(val),
+        message: '身份证号码不合规',
     }
 }

+ 52 - 19
src/packages/mobile/views/account/certification/index.vue

@@ -8,14 +8,16 @@
                 <Field v-model="formData.username" name="username" label="姓名" placeholder="请输入用户姓名" :rules="formRules.username"/>
                 <app-select v-model="formData.cardtype" name="cardtype" label="证件类型" placeholder="请选择证件类型" :rules="formRules.cardtype" :options="enums" />
                 <Field v-model="formData.cardnum" name="cardnum" label="证件号码" placeholder="请输入证件号码" :rules="formRules.cardnum"/>
-                <Field v-model="formData.cardbackphotourl" name="cardbackphotourl" label="证件正面照片" :rules="formRules.cardbackphotourl">
+
+                <Field  name="cardbackphotourl" label="证件正面照片" :rules="formRules.cardbackphotourl">
                     <template #input>
-                        <Uploader v-model="backList" max-count="1" :after-read="afterRead" />
+                        <Uploader v-model="backList" max-count="1" :after-read="b_afterRead"/>
                     </template>
                 </Field>
-                <Field v-model="formData.cardfrontphotourl" name="cardfrontphotourl" label="证件反面照片" :rules="formRules.cardfrontphotourl">
+                
+                <Field name="cardfrontphotourl" label="证件反面照片" :rules="formRules.cardfrontphotourl">
                     <template #input>
-                        <Uploader v-model="frontList" max-count="1" :after-read="afterRead" />
+                        <Uploader v-model="frontList" max-count="1" :after-read="f_afterRead"/>
                     </template>
                 </Field>
             </CellGroup>
@@ -29,17 +31,19 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed } from 'vue'
+import { shallowRef, computed, ref } from 'vue'
 import { CellGroup, Button, Field, Form, FormInstance, Uploader, Toast, FieldRule } from 'vant'
 import { addAuthReq } from '@/business/user'
-import { Model } from 'echarts/core';
 import { fullloading, dialog } from '@/utils/vant';
-import { ref } from 'vue';
 import { getCertificateTypeList } from "@/constants/account";
 import AppSelect from '@mobile/components/base/select/index.vue'
+import { useNavigation } from '@/hooks/navigation'
+import axios from 'axios';
+import { getServiceUrl } from '@/services/http';
 
 const formRef = shallowRef<FormInstance>()
 const { formData, formSubmit } = addAuthReq()
+const { router }=useNavigation()
 
 /// 证件正面地址
 const backList = ref([]);
@@ -48,14 +52,47 @@ const frontList = ref([]);
 /// 获取对应的证件枚举类型
 const enums = computed(() => { return getCertificateTypeList().map(obj=>{ return {label: obj.label, value: obj.value} }) }) 
 
-const afterRead = (file: any) => {
+
+const b_afterRead = (file: any) => {
     file.status = 'uploading';
     file.message = '上传中...';
 
-    setTimeout(() => {
-    file.status = 'success';
-    file.message = '上传成功';
-    }, 1000);
+    var data = new FormData()
+    data.append('file', file.file)
+    let config = { headers: { "Content-type": "multipart/form-data" } }
+
+    /// 图片上传
+    axios.post(getServiceUrl('uploadUrl'), data, config).then(res => {
+        if (res.status == 200) {
+            file.status = 'success';
+            file.message = '上传成功';
+            formData.cardbackphotourl = res.data[0].filePath
+        } else {
+            file.status = 'failed';
+            file.message = '上传失败';
+        }
+    })
+};
+
+const f_afterRead = (file: any) => {
+    file.status = 'uploading';
+    file.message = '上传中...';
+
+    var data = new FormData()
+    data.append('file', file.file)
+    let config = { headers: { "Content-type": "multipart/form-data" } }
+
+    /// 图片上传
+    axios.post(getServiceUrl('uploadUrl'), data, config).then(res => {
+        if (res.status == 200) {
+            file.status = 'success';
+            file.message = '上传成功';
+            formData.cardfrontphotourl = res.data[0].filePath
+        } else {
+            file.status = 'failed';
+            file.message = '上传失败';
+        }
+    })
 };
 
 // 表单验证规则
@@ -64,12 +101,6 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         required: true,
         message: '请输入用户姓名',
     }],
-    cardtype: [{
-        message: '请选择证件类型',
-        validator: () => {
-            return !!formData.cardtype
-        }
-    }],
     cardnum: [{
         required: true,
         message: '请输入证件号码',
@@ -88,7 +119,9 @@ const onSubmit = () => {
     fullloading((hideLoading) => {
         formSubmit().then(() => {
             hideLoading()
-            dialog('实名认证提交请求成功')
+            dialog('实名认证提交请求成功').then(()=>{
+                router.back()
+            })
         }).catch((err) => {
             Toast.fail(err)
         })

+ 5 - 2
src/packages/mobile/views/bank/sign/components/edit/index.vue

@@ -26,7 +26,7 @@
 import { shallowRef, computed } from 'vue'
 import { CellGroup, Button, Field, Form, FormInstance, FieldRule, Toast } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { doBankSign } from '@/business/bank'
+import { doBankSign, } from '@/business/bank'
 import { useNavigation } from '@/hooks/navigation'
 import AppSelect from '@mobile/components/base/select/index.vue'
 
@@ -34,8 +34,11 @@ const {router}=useNavigation()
 const { formData, onSubmit, cusSignBank } = doBankSign()
 const formRef = shallowRef<FormInstance>()
 
+/// 银行列表
 const banklist=computed(()=> {
-    return (cusSignBank.value?.Banklst ?? []).map((e)=>({label:e.bankname,value:e.bankid}))
+    return (cusSignBank.value?.Banklst ?? []).filter(obj=>{
+        return obj.status == 0
+    }).map((e)=>({label:e.bankname, value:e.bankid}))
 })
 
 // 表单验证规则

+ 23 - 6
src/packages/mobile/views/bank/wallet/components/deposit/index.vue

@@ -5,7 +5,7 @@
                 <Field v-model="formData.Amount" label="充值金额" placeholder="请填写充值金额" :rules="formRules.Amount"/>
                 <Field label="凭证">
                     <template #input>
-                        <Uploader v-model="fileList" name="fileList" :max-size="50 * 1024 * 1024" @oversize="onOversize" max-count="1" :after-read="afterRead" :rules="formRules.fileList"/>
+                        <Uploader v-model="fileList" name="fileList" :max-size="5*1024*1024" @oversize="onOversize" max-count="1" :after-read="afterRead" :rules="formRules.fileList"/>
                     </template>
                 </Field>
             </CellGroup>
@@ -22,9 +22,11 @@ import { Form, Field, CellGroup, Button, Uploader, FieldRule, FormInstance, Toas
 import { doDeposit } from '@/business/bank'
 import { fullloading, dialog } from '@/utils/vant';
 import { useNavigation } from '@/hooks/navigation'
+import axios from 'axios';
+import { getServiceUrl } from '@/services/http';
 
 const formRef = ref<FormInstance>()
-const { formData, onSubmit } = doDeposit('xxx')
+const { formData, onSubmit, extendInfo } = doDeposit()
 const {router}=useNavigation()
 
 /// 证件正面地址
@@ -34,13 +36,28 @@ const afterRead = (file: any) => {
     file.status = 'uploading';
     file.message = '上传中...';
 
-    let params = new FormData()
-    params.append('file', file.file)
-    params.append('size', file.file.size)
+    var data = new FormData()
+    data.append('file', file.file)
+    const config = { headers: { "Content-type": "multipart/form-data" } }
+
+    /// 图片上传
+    axios.post(getServiceUrl('uploadUrl'), data, config).then(res => {
+        /// 上传成功
+        if (res.status == 200) {
+            file.status = 'success';
+            file.message = '上传成功';
+            /// 赋值
+            extendInfo.certificate_photo_url = res.data[0].filePath
+        } else {
+            file.status = 'failed';
+            file.message = '上传失败';
+        }
+    })
 };
 
+
 const onOversize = () => {
-    Toast('图片大小不能超过 50Mb')
+    Toast('图片大小不能超过 5Mb')
 };
 
 // 表单验证规则

+ 23 - 7
src/packages/mobile/views/bank/wallet/components/withdraw/index.vue

@@ -1,12 +1,28 @@
 <template>
     <app-view>
-        <Form class="g-form__container" @submit="formSubmit">
+        <Form ref="formRef"  class="g-form__container" @submit="formSubmit">
             <CellGroup inset>
                 <Field label="提现金额" v-model="formData.Amount" placeholder="请填写提现金额" :rules="formRules.Amount"/>
-                <Field label="开户银行" v-model="formData.BankAccoutName" readonly placeholder="请填写开户银行" />
-                <Field label="银行卡号" v-model="formData.BankAccoutNum" readonly placeholder="请填写银行卡号" />
-                <Field label="姓名" v-model="formData.BankChildAccountName" readonly placeholder="请填写姓名" />
-                <Field label="支行名称"  v-model="formData.BranchBankName" readonly placeholder="请填写支行名称" />
+                <Field label="开户银行" >
+                    <template #input>
+                        {{ sign.bankname }}
+                    </template>
+                </Field>
+                <Field label="银行卡号">
+                    <template #input>
+                        {{ sign.bankaccountno }}
+                    </template>
+                </Field>
+                <Field label="姓名">
+                    <template #input>
+                        {{ sign.bankaccountname }}
+                    </template>
+                </Field>
+                <Field label="支行名称">
+                    <template #input>
+                        {{ sign.branchbankname }}
+                    </template>
+                </Field>
             </CellGroup>
         </Form>
         <template #footer>
@@ -22,7 +38,7 @@ import { shallowRef } from 'vue'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@/hooks/navigation'
 
-const { formData, onSubmit } = doWithdraw()
+const { formData, onSubmit, sign } = doWithdraw()
 const {router}=useNavigation()
 const formRef = shallowRef<FormInstance>()
 
@@ -38,7 +54,7 @@ const formSubmit = () => {
     fullloading((hideLoading) => {
         onSubmit().then(() => {
             hideLoading()
-            dialog('出金成功。').then(() => {
+            dialog('出金提交申请成功,请耐心等待审核。').then(() => {
                 router.back()
             })
         }).catch((err) => {

+ 7 - 0
src/services/api/common/index.ts

@@ -44,6 +44,13 @@ export function sendResetVerifyCode(params: CommonParams<{ req: Model.SendResetV
 }
 
 /**
+ * 文件上传
+ */
+ export function uploadFile(params: CommonParams<{ req: Model.uploadFileReq, rsp: Model.uploadFileRsp }>) {
+    return commonRequest(getServiceUrl('uploadUrl'), 'post', params);
+}
+
+/**
  * 查询轮播图配置信息
  */
 export function queryImageConfigs(params: HttpParams<{ req: Model.ImageConfigsReq, rsp: Model.ImageConfigsRsp[] }>) {

+ 14 - 0
src/types/model/common.d.ts

@@ -128,5 +128,19 @@ declare global {
         interface MyRegisterMoneyRsp {
             amount: number; // 红包
         }
+
+        /** 文件上传请求 */
+        interface uploadFileReq {
+            /// 文件信息
+            data: FormData
+        }
+
+        /** 文件上传回应 */
+        interface uploadFileRsp {
+            /// 上传文件路径
+            filePath?: string,
+            /// 上传文件名
+            fileName?: string
+        }
     }
 }