ソースを参照

水贝亿爵增加合同签署以及合同签署成功后才能进行交易

Handy_Cao 2 年 前
コミット
5882b712c3

+ 5 - 0
src/packages/sbyj/router/index.ts

@@ -120,6 +120,11 @@ const routes: Array<RouteRecordRaw> = [
         name: 'account-certification',
         component: () => import('@mobile/views/account/certification/Index.vue'),
       },
+      {
+        path: 'protocol',
+        name: 'account-protocol',
+        component: () => import('../views/account/protocol/Index.vue'),
+      }
     ],
   },
   {

+ 146 - 0
src/packages/sbyj/views/account/certification/Index.vue

@@ -0,0 +1,146 @@
+<template>
+    <app-view class="g-form account-certification">
+        <template #header>
+            <app-navbar title="实名认证" />
+        </template>
+        <Form ref="formRef" class="g-form__container" @submit="onCheckCardNum" :loading="loading">
+            <CellGroup inset>
+                <Field v-model="formData.username" name="username" label="姓名" placeholder="请输入用户姓名" :rules="formRules.username"
+                    :readonly="isReadonly" />
+                <Field v-model="formData.mobile" name="mobile" readonly label="手机号码" />
+                <Field name="idCardType" label="证件类型" :rules="formRules.cardtype" is-link>
+                    <template #input>
+                        <app-select v-model="formData.cardtype" placeholder="请选择证件类型"
+                            :options="getCerTypePersonList()" :readonly="isReadonly" />
+                    </template>
+                </Field>
+                <Field v-model="formData.cardnum" name="cardnum" label="证件号码" placeholder="请输入证件号码" :rules="formRules.cardnum"
+                    :readonly="isReadonly" />
+                <Field name="cardfrontphotourl" label="证件正面照片" :rules="formRules.cardfrontphotourl">
+                    <template #input>
+                        <Image fit="contain" :src="getFileUrl(formData.cardfrontphotourl)" width="100" height="100"
+                            v-if="isReadonly" />
+                        <app-uploader @success="f_afterRead" v-else />
+                    </template>
+                </Field>
+                <Field name="cardbackphotourl" label="证件反面照片" :rules="formRules.cardbackphotourl">
+                    <template #input>
+                        <Image fit="contain" :src="getFileUrl(formData.cardbackphotourl)" width="100" height="100"
+                            v-if="isReadonly" />
+                        <app-uploader @success="b_afterRead" v-else />
+                    </template>
+                </Field>
+            </CellGroup>
+        </Form>
+        <img src="../../../assets/images/certification.png" />
+        <template #footer>
+            <div class="g-form__footer inset">
+                <Button type="danger" :loading="buttonLoading" @click="formRef?.submit" round block>提交实名认证</Button>
+            </div>
+        </template>
+    </app-view>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, onMounted } from 'vue'
+import { CellGroup, Button, Field, Form, FormInstance, showFailToast, FieldRule, Image } from 'vant'
+import { fullloading, dialog } from '@/utils/vant';
+import { getFileUrl } from '@/filters';
+import { getCerTypePersonList } from "@/constants/account";
+import { useRequest } from '@/hooks/request'
+import { queryTencentUsereSignRecords, requestCheckCardNum } from '@/services/api/account';
+import { addAuthReq } from '@/business/user/account';
+import { validateRules } from '@/constants/regex';
+import { useUserStore } from '@/stores'
+import AppSelect from '@mobile/components/base/select/index.vue'
+import AppUploader from '@mobile/components/base/uploader/index.vue'
+import { useNavigation } from '@mobile/router/navigation'
+import { getUserId, getMemberUserId } from '@/services/methods/user'
+
+const { router } = useNavigation()
+const userStore = useUserStore()
+const formRef = shallowRef<FormInstance>()
+const { formData, formSubmit, loading } = addAuthReq()
+
+const isReadonly = false//computed(() => userESignRecords.value.some((e) => e.recordstatus === 3))
+
+/// 查询记录
+const { loading: buttonLoading } = useRequest(queryTencentUsereSignRecords, {
+    params: {
+        userId: getUserId(),
+        memberUserId: getMemberUserId()
+    },
+    onError: (err) => {
+        showFailToast(err)
+    }
+})
+
+const b_afterRead = (filePath: string) => {
+    formData.cardbackphotourl = filePath
+}
+
+const f_afterRead = (filePath: string) => {
+    formData.cardfrontphotourl = filePath
+}
+
+// 表单验证规则
+const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
+    username: [{
+        required: true,
+        message: '请输入用户姓名',
+    }],
+    mobile: [{
+        required: true,
+        message: '请输入手机号码',
+        validator: (val) => {
+            if (validateRules.phone.validate(val)) {
+                return true
+            }
+            return validateRules.phone.message
+        }
+    }],
+    cardnum: [{
+        required: true,
+        message: '请输入证件号码',
+        validator: (val) => {
+            if (validateRules.cardno.validate(val)) {
+                return true
+            }
+            return validateRules.cardno.message
+        }
+    }],
+    cardbackphotourl: [{
+        required: true,
+        message: '请上传证件背面照片',
+    }],
+    cardfrontphotourl: [{
+        required: true,
+        message: '请上传证件正面照片',
+    }],
+}
+
+const onCheckCardNum = () => {
+    fullloading((hideLoading) => {
+        requestCheckCardNum({
+            data: {
+                cardnum: formData.cardnum
+            }
+        }).then(() => {
+            formSubmit().then(() => {
+                hideLoading()
+                dialog('提交请求成功,请耐心等待审核!').then(() => {
+                    router.back()
+                })
+            }).catch((err) => {
+                hideLoading(err, 'fail')
+            })
+        }).catch((err) => {
+            hideLoading(err, 'fail')
+        })
+    })
+}
+
+onMounted(() => {
+    formData.mobile = userStore.userInfo?.mobile2 ?? ''
+})
+</script>

+ 135 - 0
src/packages/sbyj/views/account/protocol/Index.vue

@@ -0,0 +1,135 @@
+<template>
+    <app-view class="g-form">
+        <template #header>
+            <app-navbar title="合同签署" />
+        </template>
+        <div class="g-form__container">
+            <CellGroup inset>
+                <Cell title="姓名" :value="customername" />
+                <Cell title="手机号码" :value="mobile2" />
+                <Cell title="证件号码" :value="decryptAES(cardnum)" />
+                <Cell title="签署机构" :value="memberUserId" />
+            </CellGroup>
+            <CellGroup inset>
+                <template v-for="(item, index) in dataList" :key="index">
+                    <Cell :title="item.templatename" :icon="iconName(item.recordstatus)" @click="signer(item)"
+                        is-link />
+                </template>
+            </CellGroup>
+        </div>
+    </app-view>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef } from 'vue'
+import { CellGroup, Cell, showFailToast, showToast } from 'vant'
+import { fullloading } from '@/utils/vant';
+import { useNavigation } from '@mobile/router/navigation'
+import { useRequest } from '@/hooks/request'
+import { queryTencentUsereSignRecords, requestInitTencentESS } from '@/services/api/account';
+import { useRequestCreateFlowByTemplateDirectly } from '@/business/user/account';
+import plus from '@/utils/h5plus'
+import { getUserId } from '@/services/methods/user'
+import { useUserStore } from '@/stores'
+import { decryptAES } from '@/services/websocket/package/crypto'
+
+const { getQueryStringToNumber } = useNavigation()
+/// 所属机构
+const memberUserId = getQueryStringToNumber('memberUserId')
+/// userStore
+const userStore = useUserStore()
+/// 创建电子签合同
+const { createTemplate, templateFormData } = useRequestCreateFlowByTemplateDirectly()
+/// 电子签合同信息
+const dataList = shallowRef<Model.TencentUsereSignRecordsRsq[]>([])
+/// 用户信息
+const { customername, cardnum, mobile2 } =  userStore.userInfo
+/// 查询
+const { run } = useRequest(queryTencentUsereSignRecords, {
+    params: {
+        userId: getUserId(),
+        memberUserId: memberUserId
+    },
+    onSuccess: (res) => {
+        if (res.data != null && res.data.length != 0) {
+            dataList.value = res.data
+        }  else {
+            /// 创建电子签合同
+            initTencentESS()
+        }
+    }
+})
+
+/// 创建电子签合同
+const { run: initTencentESS } = useRequest(requestInitTencentESS, {
+    manual: true,
+    params: {
+        userId: getUserId(),
+        memberUserId: memberUserId
+    },
+    onSuccess: () => {
+        /// 重新请求
+        run()
+    }
+})
+
+const iconName = (type: number) => {
+    switch (type) {
+        case 2: return 'info-o'
+        case 4: return 'close'
+        case 3: return 'passed'
+        default: return 'circle'
+    }
+}
+
+const openWebview = (url: string) => {
+    const ua = window.navigator.userAgent.toLowerCase()
+    if (ua.indexOf('micromessenger') !== -1) {
+        showToast({
+            type: 'fail',
+            message: '请使用浏览器打开此页面'
+        })
+    } else {
+        plus.openWebview({
+            url,
+            titleText: '实名认证',
+            onClose: () => run()
+        })
+    }
+}
+
+const signer = (item: Model.TencentUsereSignRecordsRsq) => {
+    ///  如果是已签署
+    if (item.recordstatus === 2) {
+        item.signurl ? openWebview(item.signurl) : showFailToast('合同地址错误')
+    } else if (item.recordstatus === 3) {
+        showFailToast('合同已签署,请前往腾讯电子签小程序查看!')
+    } else {
+        fullloading((hideLoading) => {
+            const userinfotype = useUserStore().userInfo.userinfotype
+            templateFormData.userESignRecordID = item.recordid
+            templateFormData.userType = userinfotype
+            /// 个人信息
+            if (userinfotype === 1) {
+                templateFormData.personInfo = {
+                    idCardNumber: decryptAES(cardnum),
+                    mobile: mobile2,
+                    name: customername
+                }
+            } else {
+                templateFormData.organizationInfo = {
+                    name: customername
+                }
+            }
+            /// 创建合同
+            createTemplate().then((res) => {
+                hideLoading()
+                openWebview(res.data.signUrl)
+            }).catch((err) => {
+                hideLoading(err, 'fail')
+            })
+        })
+    }
+}
+
+</script>

+ 31 - 6
src/packages/sbyj/views/market/detail/index.vue

@@ -113,10 +113,10 @@
 <script lang="ts" setup>
 
 import { useOrder } from '@/business/trade'
-import { shallowRef, onMounted, onUnmounted, computed, defineAsyncComponent } from 'vue'
-import { Form, Field, Stepper, Button, FieldRule, FormInstance, Radio, RadioGroup } from 'vant'
+import { shallowRef, onMounted, onUnmounted, computed, onActivated, defineAsyncComponent } from 'vue'
+import { Form, Field, Stepper, Button, FieldRule, FormInstance, Radio, RadioGroup, showToast } from 'vant'
 import { useNavigation } from '@mobile/router/navigation'
-import { useFuturesStore } from '@/stores'
+import { useFuturesStore, useUserStore } from '@/stores'
 import { getGoodsUnitName } from '@/constants/unit'
 import { formatDecimal, parsePercent, handleNumberValue } from '@/filters'
 import { useComponent } from '@/hooks/component'
@@ -126,10 +126,13 @@ import { BuyOrSell } from '@/constants/order'
 import { useSBYJOrder } from '@/business/order'
 import quoteSocket from '@/services/websocket/quote'
 import eventBus from '@/services/bus'
+import { queryMdUserSwapProtocol } from '@/services/api/swap'
+import { getUserId } from '@/services/methods/user'
 
 const { getQueryString } = useNavigation()
 const { formData, formSubmit } = useOrder()
 const futuresStore = useFuturesStore()
+const userStore = useUserStore()
 const formRef = shallowRef<FormInstance>()
 const goodscode = getQueryString('goodscode')
 const quote = futuresStore.getGoodsQuote(goodscode)
@@ -137,6 +140,8 @@ const qtyStep = shallowRef(1) // 数量步长
 const subscribe = quoteSocket.createSubscribe()
 const selectedRow = shallowRef<Model.SBYJMyOrderRsp>()
 const orderQty = shallowRef(1) // 数量
+/// 能否下单交易
+const canBankSign = shallowRef(false)
 
 const componentMap = new Map<string, unknown>([
     ['detail', defineAsyncComponent(() => import('../../order/detail/index.vue'))], // 详情
@@ -174,9 +179,18 @@ const getOrderList = () => {
 }
 
 const commit = (buyOrSell: BuyOrSell) => {
-    formData.BuyOrSell = buyOrSell
-    formData.OrderPrice = buyOrSell === BuyOrSell.Buy ? quote.value?.ask : quote.value?.bid
-    formRef.value?.submit()
+    /// 这里要去判断是否已经实名认证
+    if (userStore.hasAuth) {
+        if (userStore.userInfo.usertype != 2 && !canBankSign.value) {
+            showToast('请先通过“我的”-“合同签署”功能菜单签署相应的合同!')
+        } else {
+            formData.BuyOrSell = buyOrSell
+            formData.OrderPrice = buyOrSell === BuyOrSell.Buy ? quote.value?.ask : quote.value?.bid
+            formRef.value?.submit()
+        }
+    } else {
+        showToast('未实名认证,请先去实名认证,如果已提交实名认证,请耐心等待审核通过!')
+    }
 }
 
 // 下单
@@ -233,6 +247,17 @@ const showComponent = (componentName: string, row: Model.SBYJMyOrderRsp) => {
 // 接收委托单成交通知
 const orderDealedNtf = eventBus.$on('OrderDealedNtf', () => getOrderList())
 
+onActivated(() => {
+    /// 查询是否已签署合同
+    queryMdUserSwapProtocol({
+        data: {
+            userId: getUserId()
+        }
+    }).then((res) => {
+        canBankSign.value = res.data.some(e => e.protocolstatus === 4)
+    })
+})
+
 onMounted(() => {
     subscribe.start(goodscode)
     orderQty.value = agreeunit.value

+ 31 - 2
src/packages/sbyj/views/mine/index.vue

@@ -70,11 +70,16 @@
                         <Iconfont icon="g-icon-certification">实名认证</Iconfont>
                     </template>
                 </Cell>
-                <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
+                <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && canBankSign">
                     <template #title>
                         <Iconfont icon="g-icon-sign">签约账户</Iconfont>
                     </template>
                 </Cell>
+                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
+                    <template #title>
+                        <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
+                    </template>
+                </Cell>
                 <Cell is-link :to="{ name: 'mine-profile' }">
                     <template #title>
                         <Iconfont icon="g-icon-profile">个人信息</Iconfont>
@@ -123,13 +128,16 @@ import { queryBankAccountSign } from '@/services/api/bank'
 import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
+import { getMemberUserId } from '@/services/methods/user'
+import { queryMdUserSwapProtocol } from '@/services/api/swap'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
-
+/// 判断是否能签约
+const canBankSign = shallowRef(false) 
 const headerRef = shallowRef<HTMLDivElement>()
 const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
 
@@ -141,6 +149,17 @@ const onReady = (el: HTMLDivElement) => {
 /// 进行出入金操作判断
 const doInOutMoney = (tab: string) => {
     if (authStatus.value === AuthStatus.Certified) {
+        /// 当前未签署合同
+        if (!canBankSign.value) {
+            dialog({
+                message: '请先去签署合同条例!',
+                showCancelButton: true,
+                confirmButtonText: '去签署合同'
+            }).then(() => {
+                router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
+            })
+            return
+        }
         fullloading((hideLoading) => {
             queryBankAccountSign().then((res) => {
                 hideLoading()
@@ -187,6 +206,16 @@ onActivated(() => {
         userStore.getUserData()
     }
     accountStore.getAccountList()
+
+    /// 查询数据
+    queryMdUserSwapProtocol({
+        data: {
+            userId: loginStore.userId
+        }
+    }).then((res) => {
+        /// 判断是否能签约
+        canBankSign.value = res.data.some(e => e.protocolstatus === 4 )
+    })
 })
 </script>