@toolspack/ttd-common 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,327 +1,328 @@
1
- <!--无纸化 签署-->
2
- <template>
3
- <div class="CryptoAgent-wrapper">
4
- <object v-if="isIE" ref="CryptoAgent" :codebase="publicPath + codebase" :classid="classid"></object>
5
- <embed v-else ref="CryptoAgent" type="application/npCryptoKit.ToToDi.x86" style="height: 0px; width: 0px" />
6
- </div>
7
- </template>
8
- <script>
9
- import { getUrl } from '../utils'
10
-
11
- export default {
12
- name: 'wzh-sing',
13
- data() {
14
- let codebase = ''
15
- let classid = ''
16
- if (window.navigator.cpuClass === 'x86') {
17
- codebase = 'wzh/CryptoKit.Paperless.x86.cab'
18
- classid = 'clsid:B64B695B-348D-400D-8D58-9AAB1DA5851A'
19
- // classid = '5635B01D-C661-4ACE-B997-EECFA63BD388'
20
- } else {
21
- codebase = 'wzh/CryptoKit.Paperless.x64.cab'
22
- classid = 'clsid:8BF7E683-630E-4B59-9E61-C996B671EBDF'
23
- // classid = 'clsid:63F9892E-D854-476E-A839-C8BA79254EC1'
24
- }
25
-
26
- const { userAgent } = navigator
27
- const isIE = userAgent.indexOf('Trident') >= 0
28
- return {
29
- isIE,
30
- publicPath: 'https://wsp.totodi.com/jz/', // 为了获取public下的静态文件
31
- codebase,
32
- classid,
33
- sourceData: '', // 签名原文, 动态随机字符串
34
- certType: 'RSA', // 签名算法
35
- CryptoAgent: null,
36
- }
37
- },
38
- props: {
39
- api: {
40
- type: Object,
41
- required: true,
42
- },
43
- },
44
- mounted() {
45
- this.onLoad()
46
- },
47
- methods: {
48
- /**
49
- * 初始化验签工具包,加载 验签空间(object)
50
- */
51
- onLoad() {
52
- if (this.CryptoAgent) {
53
- return false
54
- }
55
- this.CryptoAgent = this.$refs.CryptoAgent
56
- if (!this.CryptoAgent) {
57
- alert('验签插件加载失败!')
58
- }
59
- console.log('加载this.CryptoAgent ', this.CryptoAgent)
60
- },
61
-
62
- getUkeyImage() {
63
- let image = ''
64
- try {
65
- image = this.CryptoAgent.GetSealImage('CFCA_UKEY_P11.dll')
66
- console.log('CFCA_UKEY_P11', image)
67
- } catch (e) {
68
- console.log('CFCA_UKEY_P11 error', e)
69
- }
70
- if (!image) {
71
- try {
72
- image = this.CryptoAgent.GetSealImage('UyeePKCS11.Enterprise.dll')
73
- console.log('UyeePKCS11', image)
74
- } catch (e) {
75
- console.log('UyeePKCS11 error', e)
76
- }
77
- }
78
- if (!image) {
79
- try {
80
- image = this.CryptoAgent.GetSealImage('UlanPKCS11.Enterprise.dll')
81
- console.log('UlanPKCS11.Enterprise', image)
82
- } catch (e) {
83
- console.log('UlanPKCS11.Enterprise error', e)
84
- }
85
- }
86
- if (!image) {
87
- try {
88
- image = this.CryptoAgent.GetSealImage('UlanPKCS11.dll')
89
- console.log('UlanPKCS11', image)
90
- } catch (e) {
91
- console.log('error', e)
92
- }
93
- }
94
- if (!image) {
95
- alert('读取Ukey印章图片失败!')
96
- }
97
- return image
98
- },
99
- // 消息签名, 生成Base64 编码的 PKCS#7 签名结果
100
- SignOnClick() {
101
- this.sourceData = `${new Date().getTime()}`
102
- try {
103
- const source = this.sourceData
104
- let signature = ''
105
- const signType = 'Attach' // 签名类型
106
- const selectedAlg = 'SHA-1' // 哈希算法(仅对RSA算法有效,SM2默认使用SM3哈希算法):
107
-
108
- if (signType === 'Attach') {
109
- // PKCS#7 Attach
110
- signature = this.CryptoAgent.SignMsgPKCS7(source, selectedAlg, true)
111
- } else if (signType === 'Detach') {
112
- // PKCS#7 Detach
113
- signature = this.CryptoAgent.SignMsgPKCS7(source, selectedAlg, false)
114
- } else {
115
- // PKCS#1
116
- signature = this.CryptoAgent.SignMsgPKCS1(source, selectedAlg)
117
- }
118
- if (!signature) {
119
- this.ShowErrorInfo()
120
- return ''
121
- }
122
- console.log('SignOnClick 签名结果:', signature)
123
- return signature
124
- } catch (e) {
125
- console.log('SignOnClick error=', e)
126
- this.ShowErrorInfo()
127
- return ''
128
- }
129
- },
130
- GetCertInfoOnClick(InfoTypeID) {
131
- InfoTypeID = InfoTypeID || 'SubjectDN'
132
- console.log('GetCertInfoOnClick:InfoTypeID ', InfoTypeID)
133
- try {
134
- const InfoContent = this.CryptoAgent.GetSignCertInfo(InfoTypeID)
135
- // Opera浏览器,NPAPI函数执行结果为false时,不能触发异常,需要自己判断返回值。
136
- if (!InfoContent) {
137
- this.ShowErrorInfo()
138
- return false
139
- }
140
- return InfoContent
141
- } catch (e) {
142
- console.log('GetCertInfoOnClick-WzhSign: ', e)
143
- this.ShowErrorInfo(e)
144
- return false
145
- }
146
- },
147
- SelectCertificateOnClick(serialNo = '') {
148
- // if (!this.isIE) {
149
- // alert('请使用IE浏览器!')
150
- // }
151
- try {
152
- const subjectDNFilter = '';
153
- const issuerDNFilter = 'CFCA ACS';// CFCA ACS OCA31 ,CFCA ACS OCA32, CFCA ACS TEST OCA31
154
- const serialNumFilter = serialNo;
155
- const bstrSM2CSPNameList = 'Uyee CSP v6.0 (Enterprise)||CFCA FOR UKEY CSP v1.1.0'
156
- let bSelectCertResult = '';
157
- console.log('无纸化 选证书 selectSignCert, serialNo(非传)=', serialNo)
158
- bSelectCertResult = this.CryptoAgent.SelectCertificate(subjectDNFilter, issuerDNFilter, serialNumFilter, bstrSM2CSPNameList);
159
- // Opera浏览器,NPAPI函数执行结果为false时,不能触发异常,需要自己判断返回值。
160
- if (!bSelectCertResult) {
161
- console.log('wzh SelectCertResult 不存在')
162
- this.ShowErrorInfo()
163
- return false;
164
- }
165
- console.log('wzh SelectCertResult', bSelectCertResult)
166
- return true
167
- } catch (e) {
168
- console.log('wzh SelectCertResult error: ', e)
169
- this.ShowErrorInfo(e)
170
- return false
171
- }
172
- },
173
- getHashValue(label, fileOss, params) {
174
- const CertContent = this.CryptoAgent.GetSignCertInfo('CertContent');
175
- this.$emit('getImg', params)
176
- if (!CertContent) {
177
- alert('获取证书公钥失败!')
178
- return Promise.reject()
179
- }
180
- if (fileOss.bucketName && fileOss.objectKey) {
181
- return this.api.getSignHash({
182
- jsonData: {
183
- source: 'TTDFUND',
184
- timestamp: new Date().getTime(),
185
- msgBody: {
186
- // 合同地址, 相对路径--合同文件全路径。网络地址:http://xxxxxx.pdf;阿里云地址:oss:bucketxx:key
187
- attachfile: `oss:${fileOss.bucketName}:${fileOss.objectKey}`,
188
- reason: '', // 签署原因
189
- location: '', // 签署地点
190
- signImgfileName: '', // 图片名称
191
- signImgfile: params.image, // 图片路径,格式同文件字段类似
192
- signImgMd5: params.md5, // 印章图片的md5
193
- sealId: params.sealId, // 印章图片的id
194
- serialNo: params.serialNo, // 证书序列号
195
- ukeyType: params.ukeyType, // 证书类型(ttd配置)
196
- userId: params.userId, // 用户id
197
- pageNo: label.pageIndex, // 签章页
198
- pageX: Number(label.X), // 签章页签章位置X坐标
199
- pageY: Number(label.Y), // 签章页签章位置Y坐标
200
- certBase64: CertContent, // 证书公钥
201
- },
202
- },
203
- })
204
- }
205
- alert('文件对象不合规!')
206
- return Promise.reject()
207
- },
208
- async getSignHashValue(item, fileItem, params) {
209
- let sourceHashData = ''
210
- const { code, data } = await this.getHashValue(item, fileItem, params);
211
- if (code === 0) {
212
- if (`${data.bean.code}` === '200') { sourceHashData = data.bean.pdfHash }
213
- }
214
- if (!sourceHashData) {
215
- alert(`CFCA计算HASH值失败!( ${data.bean.msg || ''})`)
216
- return false
217
- }
218
- // 将原文Hash值的Base64编码解码后,对其进行PKCS#7分离式签名
219
- let signature = ''
220
- try {
221
- signature = this.CryptoAgent.SignHashMsgPKCS7Detached(sourceHashData, 'SHA-1');
222
- } catch (e) {
223
- this.ShowErrorInfo()
224
- }
225
- if (signature) {
226
- return {
227
- signature,
228
- id: data.bean.id,
229
- }
230
- }
231
- alert('获取PKCS#7分离式签名失败!')
232
- return false
233
- },
234
- async signFileKeyImage(item, fileItem, params) {
235
- const res = await this.getSignHashValue(item, fileItem, params)
236
- let errorMsg = '计算Hash 失败!'
237
- if (res) {
238
- const { data, code } = await this.api.mergeHash({
239
- jsonData: {
240
- source: 'TTDFUND',
241
- timestamp: new Date().getTime(),
242
- msgBody: {
243
- sigString: res.signature, // 签名后的hash值
244
- id: res.id, // 计算接口返回的ID
245
- },
246
- },
247
- })
248
- // 此方法 code 不能完全说明正确,调用失败code 也是0
249
- if (code === 0) {
250
- if (data.bean.url) {
251
- return data.bean
252
- }
253
- errorMsg = data.bean.msg
254
- } else {
255
- errorMsg = data.msg
256
- }
257
- }
258
- this.$message.error(errorMsg || 'error计算Hash失败!')
259
- return false
260
- },
261
- // fileOss: 为文件对象 {obje}
262
- // isOffset: 修正印章的位置,印章加时间后需要向下修正
263
- // parama: 其他参数:ukeyType, image, md5, isOffset
264
- async multipleSign(labels, fileOss, params) {
265
- let result = ''
266
- const localParams = { ...params }
267
- const { isOffset = 18 } = localParams
268
- if (!localParams.image) {
269
- alert('印章图片缺失!')
270
- return false
271
- }
272
-
273
- for (let index = 0; index < labels.length; index++) {
274
- const item = getUrl(labels[index])
275
- // 此处for循环多个文件时候以前签署,所以提示无意义
276
- // const message = `签署 [${text}] 位于第${label.pageIndex}页的位置,[总共:${index + 1}/${labels.length}个位置]`
277
- if (typeof isOffset === 'number') {
278
- // 印章统一向下偏移
279
- item.Y -= isOffset
280
- }
281
- if (index > 0) {
282
- const serialNoAgain = this.CryptoAgent.GetSignCertInfo('SerialNumber');
283
- if (localParams.serialNo !== serialNoAgain) {
284
- console.log(`params.serialNo:${ localParams.serialNo}`, `serialNoAgain${ serialNoAgain}`)
285
- alert('签署过程中,请不要更换ukey!')
286
- return false
287
- }
288
- // 这里签署第二个章,需要在第一个签好的文件上签署 所以用result中是文件
289
- if (result) {
290
- // eslint-disable-next-line
291
- result = await this.signFileKeyImage((item), result, {...localParams})
292
- }
293
- console.log(`iterateSign 签章结果${index}---result----`, result)
294
- } else {
295
- // eslint-disable-next-line
296
- result = await this.signFileKeyImage((item), fileOss, {...localParams})
297
- console.log('第一个章 签章结果', result)
298
- }
299
- }
300
- console.log('multipleSign 签章的结果', result)
301
- return result
302
- },
303
- ShowErrorInfo(response = '') {
304
- if (!this.CryptoAgent) {
305
- alert('不支持该功能!');
306
- } else if (!this.CryptoAgent.GetLastErrorDesc) {
307
- alert('签署异常!');
308
- } else { // host error
309
- let errorDesc = this.CryptoAgent.GetLastErrorDesc()
310
- if (response) {
311
- errorDesc = `${errorDesc}[${response}]`
312
- }
313
- alert(errorDesc)
314
- }
315
- },
316
- },
317
- }
318
-
319
- </script>
320
- <style lang="less" scoped>
321
- .CryptoAgent-wrapper {
322
- height: 0;
323
- width: 0;
324
- position: absolute;
325
- left: -5000px;
326
- }
327
- </style>
1
+ <!--无纸化 签署-->
2
+ <template>
3
+ <div class="CryptoAgent-wrapper">
4
+ <object v-if="isIE" ref="CryptoAgent" :codebase="publicPath + codebase" :classid="classid"></object>
5
+ <embed v-else ref="CryptoAgent" type="application/npCryptoKit.ToToDi.x86" style="height: 0px; width: 0px" />
6
+ </div>
7
+ </template>
8
+ <script>
9
+ import { getUrl } from '../utils'
10
+
11
+ export default {
12
+ name: 'wzh-sing',
13
+ data() {
14
+ let codebase = ''
15
+ let classid = ''
16
+ if (window.navigator.cpuClass === 'x86') {
17
+ codebase = 'wzh/CryptoKit.Paperless.x86.cab'
18
+ classid = 'clsid:B64B695B-348D-400D-8D58-9AAB1DA5851A'
19
+ // classid = '5635B01D-C661-4ACE-B997-EECFA63BD388'
20
+ } else {
21
+ codebase = 'wzh/CryptoKit.Paperless.x64.cab'
22
+ classid = 'clsid:8BF7E683-630E-4B59-9E61-C996B671EBDF'
23
+ // classid = 'clsid:63F9892E-D854-476E-A839-C8BA79254EC1'
24
+ }
25
+
26
+ const { userAgent } = navigator
27
+ const isIE = userAgent.indexOf('Trident') >= 0
28
+ return {
29
+ isIE,
30
+ publicPath: 'https://wsp.totodi.com/jz/', // 为了获取public下的静态文件
31
+ codebase,
32
+ classid,
33
+ sourceData: '', // 签名原文, 动态随机字符串
34
+ certType: 'RSA', // 签名算法
35
+ CryptoAgent: null,
36
+ }
37
+ },
38
+ props: {
39
+ api: {
40
+ type: Object,
41
+ required: true,
42
+ },
43
+ },
44
+ mounted() {
45
+ this.onLoad()
46
+ },
47
+ methods: {
48
+ /**
49
+ * 初始化验签工具包,加载 验签空间(object)
50
+ */
51
+ onLoad() {
52
+ if (this.CryptoAgent) {
53
+ return false
54
+ }
55
+ this.CryptoAgent = this.$refs.CryptoAgent
56
+ if (!this.CryptoAgent) {
57
+ alert('验签插件加载失败!')
58
+ }
59
+ console.log('加载this.CryptoAgent ', this.CryptoAgent)
60
+ },
61
+
62
+ getUkeyImage() {
63
+ let image = ''
64
+ try {
65
+ image = this.CryptoAgent.GetSealImage('CFCA_UKEY_P11.dll')
66
+ console.log('CFCA_UKEY_P11', image)
67
+ } catch (e) {
68
+ console.log('CFCA_UKEY_P11 error', e)
69
+ }
70
+ if (!image) {
71
+ try {
72
+ image = this.CryptoAgent.GetSealImage('UyeePKCS11.Enterprise.dll')
73
+ console.log('UyeePKCS11', image)
74
+ } catch (e) {
75
+ console.log('UyeePKCS11 error', e)
76
+ }
77
+ }
78
+ if (!image) {
79
+ try {
80
+ image = this.CryptoAgent.GetSealImage('UlanPKCS11.Enterprise.dll')
81
+ console.log('UlanPKCS11.Enterprise', image)
82
+ } catch (e) {
83
+ console.log('UlanPKCS11.Enterprise error', e)
84
+ }
85
+ }
86
+ if (!image) {
87
+ try {
88
+ image = this.CryptoAgent.GetSealImage('UlanPKCS11.dll')
89
+ console.log('UlanPKCS11', image)
90
+ } catch (e) {
91
+ console.log('error', e)
92
+ }
93
+ }
94
+ if (!image) {
95
+ alert('读取Ukey印章图片失败!')
96
+ }
97
+ return image
98
+ },
99
+ // 消息签名, 生成Base64 编码的 PKCS#7 签名结果
100
+ SignOnClick() {
101
+ this.sourceData = `${new Date().getTime()}`
102
+ try {
103
+ const source = this.sourceData
104
+ let signature = ''
105
+ const signType = 'Attach' // 签名类型
106
+ const selectedAlg = 'SHA-1' // 哈希算法(仅对RSA算法有效,SM2默认使用SM3哈希算法):
107
+
108
+ if (signType === 'Attach') {
109
+ // PKCS#7 Attach
110
+ signature = this.CryptoAgent.SignMsgPKCS7(source, selectedAlg, true)
111
+ } else if (signType === 'Detach') {
112
+ // PKCS#7 Detach
113
+ signature = this.CryptoAgent.SignMsgPKCS7(source, selectedAlg, false)
114
+ } else {
115
+ // PKCS#1
116
+ signature = this.CryptoAgent.SignMsgPKCS1(source, selectedAlg)
117
+ }
118
+ if (!signature) {
119
+ this.ShowErrorInfo()
120
+ return ''
121
+ }
122
+ console.log('SignOnClick 签名结果:', signature)
123
+ return signature
124
+ } catch (e) {
125
+ console.log('SignOnClick error=', e)
126
+ this.ShowErrorInfo()
127
+ return ''
128
+ }
129
+ },
130
+ GetCertInfoOnClick(InfoTypeID) {
131
+ InfoTypeID = InfoTypeID || 'SubjectDN'
132
+ console.log('GetCertInfoOnClick:InfoTypeID ', InfoTypeID)
133
+ try {
134
+ const InfoContent = this.CryptoAgent.GetSignCertInfo(InfoTypeID)
135
+ // Opera浏览器,NPAPI函数执行结果为false时,不能触发异常,需要自己判断返回值。
136
+ if (!InfoContent) {
137
+ this.ShowErrorInfo()
138
+ return false
139
+ }
140
+ return InfoContent
141
+ } catch (e) {
142
+ console.log('GetCertInfoOnClick-WzhSign: ', e)
143
+ this.ShowErrorInfo(e)
144
+ return false
145
+ }
146
+ },
147
+ SelectCertificateOnClick(serialNo = '') {
148
+ // if (!this.isIE) {
149
+ // alert('请使用IE浏览器!')
150
+ // }
151
+ try {
152
+ const subjectDNFilter = '';
153
+ const issuerDNFilter = 'CFCA ACS';// CFCA ACS OCA31 ,CFCA ACS OCA32, CFCA ACS TEST OCA31
154
+ const serialNumFilter = serialNo;
155
+ const bstrSM2CSPNameList = 'Uyee CSP v6.0 (Enterprise)||CFCA FOR UKEY CSP v1.1.0'
156
+ let bSelectCertResult = '';
157
+ console.log('无纸化 选证书 selectSignCert, serialNo(非传)=', serialNo)
158
+ bSelectCertResult = this.CryptoAgent.SelectCertificate(subjectDNFilter, issuerDNFilter, serialNumFilter, bstrSM2CSPNameList);
159
+ // Opera浏览器,NPAPI函数执行结果为false时,不能触发异常,需要自己判断返回值。
160
+ if (!bSelectCertResult) {
161
+ console.log('wzh SelectCertResult 不存在')
162
+ this.ShowErrorInfo()
163
+ return false;
164
+ }
165
+ console.log('wzh SelectCertResult', bSelectCertResult)
166
+ return true
167
+ } catch (e) {
168
+ console.log('wzh SelectCertResult error: ', e)
169
+ this.ShowErrorInfo(e)
170
+ return false
171
+ }
172
+ },
173
+ getHashValue(label, fileOss, params) {
174
+ const CertContent = this.CryptoAgent.GetSignCertInfo('CertContent');
175
+ this.$emit('getImg', params)
176
+ if (!CertContent) {
177
+ alert('获取证书公钥失败!')
178
+ return Promise.reject()
179
+ }
180
+ if (fileOss.bucketName && fileOss.objectKey) {
181
+ return this.api.getSignHash({
182
+ jsonData: {
183
+ source: 'TTDFUND',
184
+ timestamp: new Date().getTime(),
185
+ msgBody: {
186
+ // 合同地址, 相对路径--合同文件全路径。网络地址:http://xxxxxx.pdf;阿里云地址:oss:bucketxx:key
187
+ attachfile: `oss:${fileOss.bucketName}:${fileOss.objectKey}`,
188
+ reason: '', // 签署原因
189
+ location: '', // 签署地点
190
+ signImgfileName: '', // 图片名称
191
+ signImgfile: params.image, // 图片路径,格式同文件字段类似
192
+ signImgMd5: params.md5, // 印章图片的md5
193
+ sealId: params.sealId, // 印章图片的id
194
+ serialNo: params.serialNo, // 证书序列号
195
+ ukeyType: params.ukeyType, // 证书类型(ttd配置)
196
+ userId: params.userId, // 用户id
197
+ pageNo: label.pageIndex, // 签章页
198
+ pageX: Number(label.X), // 签章页签章位置X坐标
199
+ pageY: Number(label.Y), // 签章页签章位置Y坐标
200
+ certBase64: CertContent, // 证书公钥
201
+ },
202
+ },
203
+ })
204
+ }
205
+ alert('文件对象不合规!')
206
+ return Promise.reject()
207
+ },
208
+ async getSignHashValue(item, fileItem, params) {
209
+ let sourceHashData = ''
210
+ const { code, data, msg } = await this.getHashValue(item, fileItem, params);
211
+ if (code === 0) {
212
+ if (`${data.bean.code}` === '200') { sourceHashData = data.bean.pdfHash }
213
+ }
214
+ if (!sourceHashData) {
215
+ const errorMsg = msg|| data?.msg || data?.bean?.msg || 'CFCA计算HASH值失败!'
216
+ alert(errorMsg)
217
+ return false
218
+ }
219
+ // 将原文Hash值的Base64编码解码后,对其进行PKCS#7分离式签名
220
+ let signature = ''
221
+ try {
222
+ signature = this.CryptoAgent.SignHashMsgPKCS7Detached(sourceHashData, 'SHA-1');
223
+ } catch (e) {
224
+ this.ShowErrorInfo()
225
+ }
226
+ if (signature) {
227
+ return {
228
+ signature,
229
+ id: data.bean.id,
230
+ }
231
+ }
232
+ alert('获取PKCS#7分离式签名失败!')
233
+ return false
234
+ },
235
+ async signFileKeyImage(item, fileItem, params) {
236
+ const res = await this.getSignHashValue(item, fileItem, params)
237
+ let errorMsg = '计算Hash 失败!'
238
+ if (res) {
239
+ const { data, code } = await this.api.mergeHash({
240
+ jsonData: {
241
+ source: 'TTDFUND',
242
+ timestamp: new Date().getTime(),
243
+ msgBody: {
244
+ sigString: res.signature, // 签名后的hash值
245
+ id: res.id, // 计算接口返回的ID
246
+ },
247
+ },
248
+ })
249
+ // 此方法 code 不能完全说明正确,调用失败code 也是0
250
+ if (code === 0) {
251
+ if (data.bean.url) {
252
+ return data.bean
253
+ }
254
+ errorMsg = data.bean.msg
255
+ } else {
256
+ errorMsg = data.msg
257
+ }
258
+ }
259
+ this.$message.error(errorMsg || 'error计算Hash失败!')
260
+ return false
261
+ },
262
+ // fileOss: 为文件对象 {obje}
263
+ // isOffset: 修正印章的位置,印章加时间后需要向下修正
264
+ // parama: 其他参数:ukeyType, image, md5, isOffset
265
+ async multipleSign(labels, fileOss, params) {
266
+ let result = ''
267
+ const localParams = { ...params }
268
+ const { isOffset = 18 } = localParams
269
+ if (!localParams.image) {
270
+ alert('印章图片缺失!')
271
+ return false
272
+ }
273
+
274
+ for (let index = 0; index < labels.length; index++) {
275
+ const item = getUrl(labels[index])
276
+ // 此处for循环多个文件时候以前签署,所以提示无意义
277
+ // const message = `签署 [${text}] 位于第${label.pageIndex}页的位置,[总共:${index + 1}/${labels.length}个位置]`
278
+ if (typeof isOffset === 'number') {
279
+ // 印章统一向下偏移
280
+ item.Y -= isOffset
281
+ }
282
+ if (index > 0) {
283
+ const serialNoAgain = this.CryptoAgent.GetSignCertInfo('SerialNumber');
284
+ if (localParams.serialNo !== serialNoAgain) {
285
+ console.log(`params.serialNo:${ localParams.serialNo}`, `serialNoAgain${ serialNoAgain}`)
286
+ alert('签署过程中,请不要更换ukey!')
287
+ return false
288
+ }
289
+ // 这里签署第二个章,需要在第一个签好的文件上签署 所以用result中是文件
290
+ if (result) {
291
+ // eslint-disable-next-line
292
+ result = await this.signFileKeyImage((item), result, {...localParams})
293
+ }
294
+ console.log(`iterateSign 签章结果${index}---result----`, result)
295
+ } else {
296
+ // eslint-disable-next-line
297
+ result = await this.signFileKeyImage((item), fileOss, {...localParams})
298
+ console.log('第一个章 签章结果', result)
299
+ }
300
+ }
301
+ console.log('multipleSign 签章的结果', result)
302
+ return result
303
+ },
304
+ ShowErrorInfo(response = '') {
305
+ if (!this.CryptoAgent) {
306
+ alert('不支持该功能!');
307
+ } else if (!this.CryptoAgent.GetLastErrorDesc) {
308
+ alert('签署异常!');
309
+ } else { // host error
310
+ let errorDesc = this.CryptoAgent.GetLastErrorDesc()
311
+ if (response) {
312
+ errorDesc = `${errorDesc}[${response}]`
313
+ }
314
+ alert(errorDesc)
315
+ }
316
+ },
317
+ },
318
+ }
319
+
320
+ </script>
321
+ <style lang="less" scoped>
322
+ .CryptoAgent-wrapper {
323
+ height: 0;
324
+ width: 0;
325
+ position: absolute;
326
+ left: -5000px;
327
+ }
328
+ </style>