zhengyiming
2025-02-20 703c46d17731d1b437509f326c050d1d36838f74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<template>
  <PageLayout title="在线签约" has-border>
    <LoadingLayout :loading="isLoading">
      <ContentScrollView>
        <ProForm :model="form" ref="formRef" label-width="auto">
          <ProFormItemV2
            label="身份证正面照片:"
            prop="idFrontUrl"
            :check-rules="[{ message: '请上传身份证正面照片', type: 'upload' }]"
          >
            <ProFormImageUpload
              v-model:file-url="form.idFrontUrl"
              :limitFileSize="10"
              :showTip="false"
              :on-success="handleFrontUrlChange"
            >
            </ProFormImageUpload>
          </ProFormItemV2>
          <ProFormItemV2
            label="身份证反面照片:"
            prop="idBackUrl"
            :check-rules="[{ message: '请上传身份证反面照片', type: 'upload' }]"
          >
            <ProFormImageUpload
              v-model:file-url="form.idBackUrl"
              :limitFileSize="10"
              :showTip="false"
            >
            </ProFormImageUpload>
          </ProFormItemV2>
          <ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入您的姓名' }]">
            <ProFormText placeholder="请输入您的姓名" v-model.trim="form.name"></ProFormText>
          </ProFormItemV2>
          <ProFormItemV2
            label="身份证号:"
            prop="idNumber"
            :check-rules="[{ message: '请输入您的身份证号', type: 'idCard' }]"
          >
            <ProFormText
              placeholder="请输入您的身份证号"
              v-model.trim="form.idNumber"
            ></ProFormText>
          </ProFormItemV2>
 
          <ProFormItemV2
            label="手机号:"
            prop="phone"
            :check-rules="[{ type: 'phone', message: '请输入您的手机号' }]"
          >
            <ProFormText v-model.trim="form.phone" placeholder="请输入您的手机号">
              <template #suffix v-if="signChannel === SignChannelEnum.BestSign">
                <ProFormCaptcha
                  :onGetCaptcha="onGetCaptcha"
                  :phonePropName="['phone', 'name', 'idNumber', 'idFrontUrl', 'idBackUrl']"
                  class="code-btn"
                  link
                ></ProFormCaptcha>
              </template>
            </ProFormText>
          </ProFormItemV2>
          <ProFormItemV2
            label="验证码:"
            prop="vcode"
            :check-rules="[{ trigger: 'blur', message: '请输入验证码' }]"
            v-if="signChannel === SignChannelEnum.BestSign"
          >
            <ProFormText v-model.trim="form.vcode" class="code-input" placeholder="请输入验证码">
            </ProFormText>
          </ProFormItemV2>
          <ProFormItemV2 class="pro-form-item-label-hidden pro-form-item-center" prop="isAgree">
            <el-checkbox v-model="form.isAgree">
              <span class="text">我已阅读并同意&nbsp;</span>
              <span class="primary-text" @click.stop.prevent="goFaq"
                >《818平台数字证书使用协议》</span
              >
            </el-checkbox>
            <div class="tip-text">
              数字证书申请中,该证书存储在上上签电子签约平台。仅在您同意的情况下,您的证书方可被调用签署相关的电子合同等法律文件。
            </div>
          </ProFormItemV2>
          <PageFooterBtn @click="handleConfirm" style="width: 100%" :hasMargin="false"
            >确认提交</PageFooterBtn
          >
        </ProForm>
      </ContentScrollView>
      <!-- <PageFooter>
      <PageFooterBtn @click="handleConfirm">确认提交</PageFooterBtn>
    </PageFooter> -->
    </LoadingLayout>
  </PageLayout>
</template>
 
<script setup lang="ts">
import { FormInstance } from 'element-plus';
import {
  ProForm,
  ProFormItemV2,
  ProFormText,
  UploadUserFile,
  ProFormImageUpload,
  ProFormCaptcha,
  bolePreview,
  LoadingLayout,
} from '@bole-core/components';
import * as lgGigWorkerServices from '@/services/api/LgGigWorker';
import { DigitalProtocolTempPath, SignChannelEnum } from '@/constants';
import { Message } from '@bole-core/core';
import { getPreviewOfficeUrl } from '@/utils';
import {
  useCheckUserRealVerifyStatus,
  userCredentialVerifyOcrIDCard,
  useSignChannelByBussinessCode,
} from '@/hooks';
 
defineOptions({
  name: 'OnlineSign',
});
 
const route = useRoute();
const customerId = (route.query.customerId as string) ?? '';
const templateId = (route.query.templateId as string) ?? '';
const companyId = (route.query.companyId as string) ?? '';
const name = (route.query.name as string) ?? '';
const phoneNumber = (route.query.phoneNumber as string) ?? '';
const action = Number(route.query.action as string);
const bussinessCode = (route.query.bussinessCode as string) ?? '';
console.log('bussinessCode: ', bussinessCode);
 
const { isLoading } = useCheckUserRealVerifyStatus({
  customerId,
  templateId,
  companyId,
  action,
  phoneNumber,
  bussinessCode,
});
 
const { signChannel } = useSignChannelByBussinessCode({ bussinessCode });
 
const form = reactive({
  name: decodeURI(name),
  idNumber: '',
  idFrontUrl: [] as UploadUserFile[],
  idBackUrl: [] as UploadUserFile[],
  phone: decodeURI(phoneNumber),
  vcode: '',
  isAgree: false,
});
 
const onGetCaptcha = async (phoneNumber: string) => {
  let res = await userGoToContactSignVerify();
  personalIdentity3Key.value = res.data;
  if (!!res?.data2) {
    goContractPreview(res);
  }
};
 
function userGoToContactSignVerify() {
  return lgGigWorkerServices.userGoToContactSignVerify(
    {
      name: form.name,
      idNumber: form.idNumber,
      idFrontUrl: form.idFrontUrl?.[0]?.path ?? '',
      idBackUrl: form.idBackUrl?.[0]?.path ?? '',
      phone: form.phone,
      companyId: companyId,
      bussinessCode: bussinessCode,
    },
    { showLoading: false }
  );
}
 
function handleFrontUrlChange(response: UploadUserFile) {
  userCredentialVerifyOcrIDCard(response, {
    onSuccess(res) {
      if (res.realName) form.name = res.realName;
      if (res.idcardNum) form.idNumber = res.idcardNum;
    },
  });
}
 
const formRef = ref<FormInstance>();
 
async function handleConfirm() {
  // showFailToast({
  //   message: '请勾选数字证书使用协议',
  //   icon: 'close',
  // });
  // showSuccessToast('请勾选数字证书使用协议');
  if (!formRef.value) return;
  if (!form.isAgree) {
    Message.errorMessage('请勾选数字证书使用协议');
    return;
  }
  await formRef.value?.validate?.();
  userPersonalRegAndRealNameAndApplyCert();
}
 
const router = useRouter();
 
const personalIdentity3Key = ref('');
 
async function userPersonalRegAndRealNameAndApplyCert() {
  try {
    if (signChannel.value === SignChannelEnum.Alipay) {
      await userGoToContactSignVerify();
    }
    let params: API.UserPersonRealVerifyInput = {
      name: form.name,
      idNumber: form.idNumber,
      idFrontUrl: form.idFrontUrl?.[0]?.path ?? '',
      idBackUrl: form.idBackUrl?.[0]?.path ?? '',
      phone: form.phone,
      vcode: form.vcode,
      companyId: companyId,
      personalIdentity3Key: personalIdentity3Key.value,
      bussinessCode: bussinessCode,
    };
    let res = await lgGigWorkerServices.userPersonalRegAndRealNameAndApplyCert(params);
    goContractPreview(res);
  } catch (error) {}
}
 
function goContractPreview(res: API.BestSignRequestResultDto) {
  /**原先上上签逻辑 */
  // if (res && res.success && res.data && res.data2) {
  if (res && res.success && res.data2) {
    router.replace({
      name: 'ContractPreview',
      query: {
        url: res.data,
        lgGigSignId: res.data2,
      },
    });
  } else {
    router.push({
      name: 'OnlineAuthFail',
    });
  }
}
 
function goFaq() {
  // bolePreview({
  //   fileUrl: DigitalProtocolTempPath,
  // });
  location.href = getPreviewOfficeUrl(DigitalProtocolTempPath);
}
</script>
 
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
 
.text {
  color: getCssVar('text-color', 'regular') !important;
}
 
.primary-text {
  color: boleGetCssVar('color', 'primary') !important;
}
 
.tip-text {
  color: getCssVar('text-color', 'secondary');
  line-height: 1.5;
}
 
.pro-form-item-center {
  :deep(.el-form-item__content) {
    justify-content: center;
  }
}
</style>