unify-external-plugin-platform 0.0.3-85 → 0.0.3-86

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.
@@ -83178,8 +83178,8 @@ var scanner_cameravue_type_template_id_00e9072f_scoped_true_render = function re
83178
83178
  };
83179
83179
  var scanner_cameravue_type_template_id_00e9072f_scoped_true_staticRenderFns = [];
83180
83180
 
83181
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[4]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=template&id=3fc2d979&
83182
- var scanner_camera_componentvue_type_template_id_3fc2d979_render = function render() {
83181
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[4]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=template&id=efc69384&scoped=true&
83182
+ var scanner_camera_componentvue_type_template_id_efc69384_scoped_true_render = function render() {
83183
83183
  var _vm = this,
83184
83184
  _c = _vm._self._c;
83185
83185
  return _c('div', {
@@ -83192,12 +83192,7 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83192
83192
  staticClass: "load-success"
83193
83193
  }, [_vm.machineType === 9 ? _c('video', {
83194
83194
  ref: "monitor",
83195
- staticStyle: {
83196
- "max-width": "800px",
83197
- "max-height": "600px",
83198
- "width": "100%",
83199
- "height": "100%"
83200
- },
83195
+ staticClass: "camera-video",
83201
83196
  attrs: {
83202
83197
  "id": "monitor",
83203
83198
  "autoplay": "",
@@ -83207,18 +83202,13 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83207
83202
  domProps: {
83208
83203
  "muted": true
83209
83204
  }
83210
- }) : _c('div', {
83205
+ }) : _vm.scannerVideoSrc ? _c('div', {
83211
83206
  staticClass: "camera-container",
83212
83207
  class: {
83213
83208
  'select-mode': _vm.isSelectAreaMode && _vm.machineType === 5
83214
83209
  }
83215
83210
  }, [_c('img', {
83216
- staticStyle: {
83217
- "max-width": "800px",
83218
- "max-height": "600px",
83219
- "width": "100%",
83220
- "height": "100%"
83221
- },
83211
+ staticClass: "camera-preview",
83222
83212
  attrs: {
83223
83213
  "id": "photo",
83224
83214
  "src": _vm.scannerVideoSrc
@@ -83235,7 +83225,11 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83235
83225
  attrs: {
83236
83226
  "id": "selection-box"
83237
83227
  }
83238
- }) : _vm._e()])]) : _c('div', {
83228
+ }) : _vm._e()]) : _c('div', {
83229
+ staticClass: "camera-empty"
83230
+ }, [_c('i', {
83231
+ staticClass: "el-icon-camera camera-empty-icon"
83232
+ }), _c('p', [_vm._v("正在连接摄像头,请稍候…")])])]) : _c('div', {
83239
83233
  staticClass: "load-error"
83240
83234
  }, [_c('i', {
83241
83235
  staticClass: "el-icon-s-cooperation"
@@ -83264,12 +83258,13 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83264
83258
  "value": item.value
83265
83259
  }
83266
83260
  });
83267
- }), 1), [_vm._l(_vm.buttonList, function (item) {
83261
+ }), 1), _vm._l(_vm.buttonList, function (item) {
83268
83262
  return [_vm._isShowButton(item.name) ? _c('el-button', {
83269
83263
  key: item.name,
83270
83264
  attrs: {
83271
83265
  "type": "primary",
83272
- "size": "small"
83266
+ "size": "small",
83267
+ "loading": item.name === 'take-pictures' && _vm.takingPhoto
83273
83268
  },
83274
83269
  on: {
83275
83270
  "click": function ($event) {
@@ -83277,7 +83272,7 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83277
83272
  }
83278
83273
  }
83279
83274
  }, [_vm._v(_vm._s(item.label))]) : _vm._e()];
83280
- }), _vm.machineType === 5 ? _c('el-dropdown', {
83275
+ }), _vm.machineType === 5 || _vm.machineType === 6 ? _c('el-dropdown', {
83281
83276
  attrs: {
83282
83277
  "size": "small"
83283
83278
  },
@@ -83285,9 +83280,6 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83285
83280
  "command": _vm.handleRotateCommand
83286
83281
  }
83287
83282
  }, [_c('el-button', {
83288
- staticStyle: {
83289
- "margin-left": "10px"
83290
- },
83291
83283
  attrs: {
83292
83284
  "type": "primary",
83293
83285
  "size": "small"
@@ -83311,9 +83303,9 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83311
83303
  attrs: {
83312
83304
  "command": "rotate-180"
83313
83305
  }
83314
- }, [_vm._v("旋转180°")])], 1)], 1) : _vm._e(), _vm._t("action")]], 2)])]);
83306
+ }, [_vm._v("旋转180°")])], 1)], 1) : _vm._e(), _vm._t("action")], 2)])]);
83315
83307
  };
83316
- var scanner_camera_componentvue_type_template_id_3fc2d979_staticRenderFns = [];
83308
+ var scanner_camera_componentvue_type_template_id_efc69384_scoped_true_staticRenderFns = [];
83317
83309
 
83318
83310
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
83319
83311
  function _typeof(obj) {
@@ -84720,144 +84712,248 @@ var WEIRONGMethodCode;
84720
84712
  WEIRONGMethodCode["ScannerCamera"] = "ScannerCamera";
84721
84713
  /** 结束预览*/
84722
84714
  WEIRONGMethodCode["StopCamera"] = "StopCamera";
84715
+ /** 旋转画面(1-右转 90°,2-左转 90°)*/
84716
+ WEIRONGMethodCode["Transpose"] = "Transpose";
84723
84717
  })(WEIRONGMethodCode || (WEIRONGMethodCode = {}));
84724
84718
  class WeiRongPluginService {
84725
- static startConnect(method) {
84719
+ /** 正在建立的连接,防止并发重复建连 */
84720
+
84721
+ /** 在途请求按 method 分组,响应只唤醒等待同一 method 的请求 */
84722
+
84723
+ /** 单次请求响应超时,需大于设备端 outTimes(30 秒) */
84724
+
84725
+ static startConnect() {
84726
84726
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
84727
- return this;
84727
+ return Promise.resolve(this.ws);
84728
84728
  }
84729
- const ws = new WebSocket(this.webSocketUrl);
84730
- let resolved;
84731
- const onConnect = new Promise(resolve => {
84732
- resolved = resolve;
84733
- });
84734
- ws.onopen = () => {
84735
- resolved(true);
84736
- };
84737
- ws.onmessage = event => {
84738
- this.handleMessage(event);
84739
- };
84740
- ws.onclose = () => this.handleClose();
84741
- ws.onerror = () => this.handleError();
84742
- this.ws = ws;
84743
- return onConnect;
84744
- }
84745
- static handleError() {
84746
- for (const type in this.requestStore) {
84747
- this.requestStore.forEach(({
84748
- reject
84749
- }) => {
84750
- reject('handleError');
84751
- });
84729
+ if (!this.connecting) {
84730
+ this.connecting = this.openSocket();
84752
84731
  }
84753
- throw Error('统一插件平台设备功能加载失败');
84732
+ return this.connecting;
84754
84733
  }
84755
- static handleClose() {
84756
- for (const type in this.requestStore) {
84757
- this.requestStore.forEach(({
84758
- reject
84759
- }) => {
84760
- reject('close');
84761
- });
84762
- }
84734
+ static openSocket() {
84735
+ return new Promise((resolve, reject) => {
84736
+ const ws = new WebSocket(this.webSocketUrl);
84737
+ let settled = false;
84738
+ const connectTimeout = setTimeout(() => {
84739
+ if (settled) return;
84740
+ settled = true;
84741
+ this.connecting = null;
84742
+ try {
84743
+ ws.close();
84744
+ } catch (e) {/* 忽略关闭异常 */}
84745
+ reject(new Error('统一插件平台设备连接超时'));
84746
+ }, 5000);
84747
+ const settleError = message => {
84748
+ if (settled) return;
84749
+ settled = true;
84750
+ clearTimeout(connectTimeout);
84751
+ this.connecting = null;
84752
+ reject(new Error(message));
84753
+ };
84754
+ ws.onopen = () => {
84755
+ if (settled) return;
84756
+ settled = true;
84757
+ clearTimeout(connectTimeout);
84758
+ this.connecting = null;
84759
+ this.ws = ws;
84760
+ resolve(ws);
84761
+ };
84762
+ ws.onmessage = event => this.handleMessage(event);
84763
+ ws.onerror = () => settleError('统一插件平台设备连接失败');
84764
+ ws.onclose = () => {
84765
+ if (!settled) {
84766
+ settleError('统一插件平台设备连接失败');
84767
+ return;
84768
+ }
84769
+ // 只有断开的是当前连接时才清空引用并让在途请求失败,下次 read 会自动重连
84770
+ if (this.ws === ws) {
84771
+ this.ws = null;
84772
+ this.rejectAllPending('统一插件平台设备连接已断开');
84773
+ }
84774
+ };
84775
+ });
84763
84776
  }
84764
84777
  static handleMessage(msg) {
84765
- let data = '';
84778
+ let data = null;
84766
84779
  try {
84767
84780
  data = JSON.parse(msg.data);
84768
84781
  } catch (e) {
84769
- data = '';
84782
+ return;
84783
+ }
84784
+ if (!data || !data.method) {
84785
+ return;
84770
84786
  }
84771
84787
  if (data.method === 'FaceScreenStream' || data.method === 'VideoStream') {
84772
84788
  const event = new ScannerCameraRefreshPhotoEvent(data.imgBase64);
84773
84789
  return window.dispatchEvent(event);
84774
84790
  } else {
84775
- this.requestStore.forEach(({
84776
- resolve
84777
- }) => {
84778
- resolve(data);
84779
- });
84780
- this.requestStore = [];
84791
+ this.resolvePending(data.method, data);
84781
84792
  }
84782
84793
  }
84783
- static async read(method) {
84784
- await this.startConnect(method);
84785
- if (this.ws.readyState === 1) {
84786
- let jsonString;
84787
- switch (method) {
84788
- case WEIRONGMethodCode.ReadCard_Base64:
84789
- jsonString = JSON.stringify({
84790
- method: 'ReadIDCard_Base64',
84791
- args: {
84792
- outTimes: 30,
84793
- cardReader: 0
84794
- }
84795
- });
84796
- break;
84797
- case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84798
- jsonString = JSON.stringify({
84799
- method: 'FaceValidateWithIdCard_Base64',
84800
- args: {
84801
- outTimes: 30,
84802
- score: 75
84803
- }
84804
- });
84805
- break;
84806
- case WEIRONGMethodCode.StartSignName:
84807
- jsonString = JSON.stringify({
84808
- method: 'SignNameScreen_Start',
84809
- args: {
84810
- outTimes: 30
84811
- }
84812
- });
84813
- break;
84814
- case WEIRONGMethodCode.GetSignNameStatus:
84815
- jsonString = JSON.stringify({
84816
- method: 'SignNameScreen_Status',
84817
- args: {}
84818
- });
84819
- break;
84820
- case WEIRONGMethodCode.GetSignName_Base64:
84821
- jsonString = JSON.stringify({
84822
- method: 'SignNameScreen_Get',
84823
- args: {}
84824
- });
84825
- break;
84826
- case WEIRONGMethodCode.TurnOnTheCamera:
84827
- jsonString = JSON.stringify({
84828
- method: 'VideoStart',
84829
- args: {}
84830
- });
84831
- break;
84832
- case WEIRONGMethodCode.ScannerCamera:
84833
- jsonString = JSON.stringify({
84834
- method: 'GetCameraImage',
84835
- args: {
84836
- imagePath: ''
84837
- }
84838
- });
84839
- break;
84840
- case WEIRONGMethodCode.StopCamera:
84841
- jsonString = JSON.stringify({
84842
- method: 'VideoStop',
84843
- args: {}
84844
- });
84845
- break;
84846
- }
84847
- this.ws.send(jsonString);
84848
- return new Promise((resolve, reject) => {
84849
- if (!this.requestStore) {
84850
- this.requestStore = [];
84851
- }
84852
- this.requestStore.push({
84853
- resolve,
84854
- reject
84794
+ static getPendingStore(method) {
84795
+ let store = this.pendingStore.get(method);
84796
+ if (!store) {
84797
+ store = [];
84798
+ this.pendingStore.set(method, store);
84799
+ }
84800
+ return store;
84801
+ }
84802
+ /** 响应与请求按 method 先进先出配对,一条响应只唤醒一个请求 */
84803
+ static resolvePending(method, data) {
84804
+ const store = this.pendingStore.get(method);
84805
+ const entry = store && store.shift();
84806
+ if (store && store.length === 0) {
84807
+ this.pendingStore.delete(method);
84808
+ }
84809
+ if (entry) {
84810
+ entry.resolve(data);
84811
+ }
84812
+ }
84813
+ static rejectAllPending(reason) {
84814
+ this.pendingStore.forEach(store => {
84815
+ store.splice(0).forEach(({
84816
+ reject
84817
+ }) => reject(reason));
84818
+ });
84819
+ this.pendingStore.clear();
84820
+ }
84821
+ static removePending(method, entry) {
84822
+ const store = this.pendingStore.get(method);
84823
+ if (!store) return;
84824
+ const index = store.indexOf(entry);
84825
+ if (index > -1) store.splice(index, 1);
84826
+ if (store.length === 0) this.pendingStore.delete(method);
84827
+ }
84828
+ static buildRequest(method) {
84829
+ switch (method) {
84830
+ case WEIRONGMethodCode.ReadCard_Base64:
84831
+ return JSON.stringify({
84832
+ method: 'ReadIDCard_Base64',
84833
+ args: {
84834
+ outTimes: 30,
84835
+ cardReader: 0
84836
+ }
84855
84837
  });
84856
- });
84857
- } else {
84858
- throw Error('统一插件平台设备未准备完成');
84838
+ case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84839
+ return JSON.stringify({
84840
+ method: 'FaceValidateWithIdCard_Base64',
84841
+ args: {
84842
+ outTimes: 30,
84843
+ score: 75
84844
+ }
84845
+ });
84846
+ case WEIRONGMethodCode.StartSignName:
84847
+ return JSON.stringify({
84848
+ method: 'SignNameScreen_Start',
84849
+ args: {
84850
+ outTimes: 30
84851
+ }
84852
+ });
84853
+ case WEIRONGMethodCode.GetSignNameStatus:
84854
+ return JSON.stringify({
84855
+ method: 'SignNameScreen_Status',
84856
+ args: {}
84857
+ });
84858
+ case WEIRONGMethodCode.GetSignName_Base64:
84859
+ return JSON.stringify({
84860
+ method: 'SignNameScreen_Get',
84861
+ args: {}
84862
+ });
84863
+ case WEIRONGMethodCode.TurnOnTheCamera:
84864
+ return JSON.stringify({
84865
+ method: 'VideoStart',
84866
+ args: {}
84867
+ });
84868
+ case WEIRONGMethodCode.ScannerCamera:
84869
+ return JSON.stringify({
84870
+ method: 'GetCameraImage',
84871
+ args: {
84872
+ imagePath: ''
84873
+ }
84874
+ });
84875
+ case WEIRONGMethodCode.StopCamera:
84876
+ return JSON.stringify({
84877
+ method: 'VideoStop',
84878
+ args: {}
84879
+ });
84880
+ case WEIRONGMethodCode.Transpose:
84881
+ return JSON.stringify({
84882
+ method: 'Transpose',
84883
+ args: {
84884
+ rotationAngle: 0
84885
+ }
84886
+ });
84887
+ default:
84888
+ return null;
84889
+ }
84890
+ }
84891
+ /** 设备端响应的 method 名与请求枚举名不同,配对前需要先映射成响应名 */
84892
+ static responseMethodOf(method) {
84893
+ switch (method) {
84894
+ case WEIRONGMethodCode.ReadCard_Base64:
84895
+ return 'ReadIDCard_Base64';
84896
+ case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84897
+ return 'FaceValidateWithIdCard_Base64';
84898
+ case WEIRONGMethodCode.StartSignName:
84899
+ return 'SignNameScreen_Start';
84900
+ case WEIRONGMethodCode.GetSignNameStatus:
84901
+ return 'SignNameScreen_Status';
84902
+ case WEIRONGMethodCode.GetSignName_Base64:
84903
+ return 'SignNameScreen_Get';
84904
+ case WEIRONGMethodCode.TurnOnTheCamera:
84905
+ return 'VideoStart';
84906
+ case WEIRONGMethodCode.ScannerCamera:
84907
+ return 'GetCameraImage';
84908
+ case WEIRONGMethodCode.StopCamera:
84909
+ return 'VideoStop';
84910
+ case WEIRONGMethodCode.Transpose:
84911
+ return 'Transpose';
84912
+ default:
84913
+ return null;
84859
84914
  }
84860
84915
  }
84916
+ static async read(method, argsOverride) {
84917
+ const ws = await this.startConnect();
84918
+ const jsonString = this.buildRequest(method);
84919
+ const responseMethod = this.responseMethodOf(method);
84920
+ if (!jsonString || !responseMethod) {
84921
+ throw Error(`统一插件平台不支持的操作:${method}`);
84922
+ }
84923
+ // 旋转等指令的参数随调用变化,允许覆盖默认 args
84924
+ let requestJson = jsonString;
84925
+ if (argsOverride) {
84926
+ const request = JSON.parse(jsonString);
84927
+ request.args = argsOverride;
84928
+ requestJson = JSON.stringify(request);
84929
+ }
84930
+ return new Promise((resolve, reject) => {
84931
+ const store = this.getPendingStore(responseMethod);
84932
+ let timeoutTimer = null;
84933
+ const entry = {
84934
+ resolve: value => {
84935
+ if (timeoutTimer) clearTimeout(timeoutTimer);
84936
+ resolve(value);
84937
+ },
84938
+ reject: reason => {
84939
+ if (timeoutTimer) clearTimeout(timeoutTimer);
84940
+ reject(reason);
84941
+ }
84942
+ };
84943
+ timeoutTimer = setTimeout(() => {
84944
+ this.removePending(responseMethod, entry);
84945
+ reject(Error('统一插件平台设备响应超时'));
84946
+ }, this.requestTimeout);
84947
+ store.push(entry);
84948
+ try {
84949
+ ws.send(requestJson);
84950
+ } catch (e) {
84951
+ this.removePending(responseMethod, entry);
84952
+ this.ws = null;
84953
+ reject(Error('统一插件平台设备未准备完成'));
84954
+ }
84955
+ });
84956
+ }
84861
84957
  /** 读取身份证和永居证*/
84862
84958
  static async idCardRead() {
84863
84959
  const readData = await WeiRongPluginService.read(WEIRONGMethodCode.ReadCard_Base64);
@@ -84865,7 +84961,6 @@ class WeiRongPluginService {
84865
84961
  throw Error('未匹配到可用的读取设备');
84866
84962
  }
84867
84963
  if (readData.retVal !== 0) {
84868
- if (this.ws) this.ws.close();
84869
84964
  throw Error("读取二代身份证失败,返回值:" + readData.retVal + ",错误信息:" + readData.errMsg);
84870
84965
  }
84871
84966
  let idInfo = readData.idInfo;
@@ -84917,7 +85012,6 @@ class WeiRongPluginService {
84917
85012
  },
84918
85013
  headImage: readData.idPhotoBase64
84919
85014
  };
84920
- if (this.ws) this.ws.close();
84921
85015
  return IDCardData;
84922
85016
  }
84923
85017
  /** 读取社保卡 */
@@ -84927,7 +85021,6 @@ class WeiRongPluginService {
84927
85021
  throw Error('未匹配可用的读取设备');
84928
85022
  }
84929
85023
  if (readData.retVal !== 0) {
84930
- if (this.ws) this.ws.close();
84931
85024
  throw Error("读取社保卡基本信息失败,返回值:" + readData.retVal + ",错误信息:" + readData.idInfo);
84932
85025
  }
84933
85026
  // 返回数据:cardType 3 社保卡
@@ -84951,7 +85044,6 @@ class WeiRongPluginService {
84951
85044
  },
84952
85045
  headImage: ''
84953
85046
  };
84954
- if (this.ws) this.ws.close();
84955
85047
  return IDCardData;
84956
85048
  }
84957
85049
  /**
@@ -84959,7 +85051,7 @@ class WeiRongPluginService {
84959
85051
  */
84960
85052
  static async faceValidateWithIdCardRead() {
84961
85053
  const readData = await WeiRongPluginService.read(WEIRONGMethodCode.FaceValidateWithIdCard_Base64);
84962
- if (readData.method === 'FaceValidateWithIdCard_Base64' && readData.retVal == '0') {
85054
+ if (readData.retVal == '0') {
84963
85055
  const idInfo = readData.idInfo;
84964
85056
  let {
84965
85057
  name,
@@ -85012,63 +85104,87 @@ class WeiRongPluginService {
85012
85104
  faceimg: readData.scenceBase64,
85013
85105
  score: readData.score
85014
85106
  };
85015
- if (this.ws) this.ws.close();
85016
85107
  return IDCardData;
85017
85108
  } else {
85018
- if (this.ws) this.ws.close();
85109
+ return undefined;
85019
85110
  }
85020
85111
  }
85021
85112
  /** 签字*/
85022
85113
  static async signNameRead() {
85023
- return new Promise(async (resolve, reject) => {
85024
- const readData = await WeiRongPluginService.read(WEIRONGMethodCode.StartSignName);
85025
- if (readData.method === 'SignNameScreen_Start') {
85026
- if (readData.retVal !== 0) {
85027
- if (this.ws) this.ws.close();
85028
- reject(`开始签名失败,返回值:${readData.retVal},错误信息:${readData.errMsg}`);
85029
- } else {
85030
- if (!this.timer) {
85031
- this.timer = setInterval(async () => {
85032
- let status = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignNameStatus);
85033
- if (status.signScreenStatus == 2) {
85034
- clearInterval(this.timer);
85035
- this.timer = null;
85036
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignName_Base64);
85037
- if (this.ws) this.ws.close();
85038
- resolve(res.signPicBase64);
85039
- } else if (status.retVal == 3) {
85040
- clearInterval(this.timer);
85041
- this.timer = null;
85042
- if (this.ws) this.ws.close();
85043
- reject('签字结果=>签字失败,或意外中断!');
85044
- }
85045
- }, 2000);
85114
+ const readData = await WeiRongPluginService.read(WEIRONGMethodCode.StartSignName);
85115
+ if (readData.method !== 'SignNameScreen_Start') {
85116
+ throw Error('开始签名失败:设备无响应');
85117
+ }
85118
+ if (readData.retVal !== 0) {
85119
+ throw Error(`开始签名失败,返回值:${readData.retVal},错误信息:${readData.errMsg}`);
85120
+ }
85121
+ return new Promise((resolve, reject) => {
85122
+ if (this.timer) {
85123
+ clearInterval(this.timer);
85124
+ }
85125
+ this.timer = setInterval(async () => {
85126
+ let status;
85127
+ try {
85128
+ status = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignNameStatus);
85129
+ } catch (e) {
85130
+ clearInterval(this.timer);
85131
+ this.timer = null;
85132
+ reject('签字结果=>获取签名状态失败:' + (e?.message || e));
85133
+ return;
85134
+ }
85135
+ if (status.signScreenStatus == 2) {
85136
+ clearInterval(this.timer);
85137
+ this.timer = null;
85138
+ try {
85139
+ let res = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignName_Base64);
85140
+ resolve(res.signPicBase64);
85141
+ } catch (e) {
85142
+ reject('签字结果=>获取签名失败:' + (e?.message || e));
85046
85143
  }
85144
+ } else if (status.retVal == 3) {
85145
+ clearInterval(this.timer);
85146
+ this.timer = null;
85147
+ reject('签字结果=>签字失败,或意外中断!');
85047
85148
  }
85048
- }
85149
+ }, 2000);
85049
85150
  });
85050
85151
  }
85051
85152
  // 开启主摄像头/副摄像头
85052
85153
  static async turnOnTheCamera() {
85053
- await WeiRongPluginService.read(WEIRONGMethodCode.TurnOnTheCamera);
85154
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.TurnOnTheCamera);
85155
+ if (res.retVal !== 0) {
85156
+ throw Error('高拍仪摄像头打开失败,返回值:' + res.retVal);
85157
+ }
85054
85158
  }
85055
85159
  // 拍照
85056
85160
  static async scanByCamera() {
85057
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.ScannerCamera);
85058
- if (res.method === 'GetCameraImage' && res.retVal == 0) {
85059
- // if (this.ws) this.ws.close();
85161
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.ScannerCamera);
85162
+ if (res.retVal == 0) {
85060
85163
  return res.cameraImgBase64;
85061
85164
  }
85165
+ return undefined;
85062
85166
  }
85063
85167
  static async stopCamera() {
85064
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.StopCamera);
85065
- if (this.ws) this.ws.close();
85168
+ // 等待设备确认停止预览后再返回;连接保持复用,不再主动关闭
85169
+ return WeiRongPluginService.read(WEIRONGMethodCode.StopCamera);
85170
+ }
85171
+ /** 旋转画面:1-右转 90°,2-左转 90°(设备端旋转预览流和拍照画面) */
85172
+ static async transpose(rotationAngle) {
85173
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.Transpose, {
85174
+ rotationAngle: rotationAngle
85175
+ });
85176
+ if (res.retVal !== 0) {
85177
+ throw Error('旋转失败,返回值:' + res.retVal);
85178
+ }
85179
+ return res;
85066
85180
  }
85067
85181
  }
85068
85182
  _defineProperty(WeiRongPluginService, "webSocketUrl", 'ws://127.0.0.1:5847');
85069
- _defineProperty(WeiRongPluginService, "ws", void 0);
85070
- _defineProperty(WeiRongPluginService, "requestStore", []);
85183
+ _defineProperty(WeiRongPluginService, "ws", null);
85184
+ _defineProperty(WeiRongPluginService, "connecting", null);
85185
+ _defineProperty(WeiRongPluginService, "pendingStore", new Map());
85071
85186
  _defineProperty(WeiRongPluginService, "timer", null);
85187
+ _defineProperty(WeiRongPluginService, "requestTimeout", 35000);
85072
85188
  ;// CONCATENATED MODULE: ./packages/service/external-plugins/han-wang-plugin.service.ts
85073
85189
 
85074
85190
 
@@ -86799,7 +86915,9 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
86799
86915
  // X轴缩放比例
86800
86916
  zoomScaleY: 1,
86801
86917
  // Y轴缩放比例
86802
- isSelectAreaMode: false
86918
+ isSelectAreaMode: false,
86919
+ // 拍照进行中(防止连点重复发起)
86920
+ takingPhoto: false
86803
86921
  };
86804
86922
  },
86805
86923
  watch: {
@@ -86904,85 +87022,99 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
86904
87022
  * 拍照
86905
87023
  */
86906
87024
  async takePictures() {
86907
- switch (this.machineType) {
86908
- case 0:
86909
- // 捷宇
86910
- let res = await JieYueService.scanByCamera();
86911
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86912
- break;
86913
- case 3:
86914
- {
86915
- // 方正
86916
- this.$emit('send-scanner-result', this.scannerVideoSrc);
86917
- break;
86918
- }
86919
- case 4:
86920
- {
86921
- // 紫图速拍仪
86922
- // 按当前选择的摄像头拍照:0-主头(文档),1-副头(照片)
86923
- let res = this.camera === 1 ? await UdsPluginSocketService.scanBySubCamera() : await UdsPluginSocketService.scanByCamera();
86924
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86925
- break;
86926
- }
86927
- case 5:
86928
- {
86929
- // 良田
86930
- let type = this.camera === 0 ? 'main' : 'vice';
86931
- console.log('this.deskewStatus', this.deskewStatus);
86932
- const res = await ELoamPassService.scanByCamera(type, this.deskewStatus);
86933
- if (res) {
86934
- let path = res;
86935
- this.$emit('send-scanner-result', `${BEGIN_DATA}${path}`);
86936
- } else {
86937
- this.$message.error('拍照出错,请检查设备是否连接成功');
87025
+ if (this.takingPhoto) return;
87026
+ this.takingPhoto = true;
87027
+ try {
87028
+ switch (this.machineType) {
87029
+ case 0:
87030
+ {
87031
+ // 捷宇
87032
+ let res = await JieYueService.scanByCamera();
87033
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87034
+ break;
86938
87035
  }
86939
- break;
86940
- }
86941
- case 6:
86942
- {
86943
- // 国产客户端一体机
86944
- let res = await WeiRongPluginService.scanByCamera();
86945
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86946
- break;
86947
- }
86948
- case 9:
86949
- {
86950
- // 本机摄像头
86951
- this.takeDefaultCameraPicture();
86952
- break;
86953
- }
86954
- case 8:
86955
- {
86956
- // 汉王高拍仪 拍照
86957
- let res = await HanWangPluginService.scanByCamera();
86958
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86959
- break;
86960
- }
86961
- case 10:
86962
- {
86963
- // 维山高拍仪
86964
- let type = this.camera === 0 ? 'main' : 'vice';
86965
- // 帧消息已通过 callback 路由,不会干扰拍照响应,无需停止预览
86966
- let res = await ViisanPluginService.scanByCamera(type);
86967
- if (res) {
87036
+ case 3:
87037
+ {
87038
+ // 方正
87039
+ this.$emit('send-scanner-result', this.scannerVideoSrc);
87040
+ break;
87041
+ }
87042
+ case 4:
87043
+ {
87044
+ // 紫图速拍仪
87045
+ // 按当前选择的摄像头拍照:0-主头(文档),1-副头(照片)
87046
+ let res = this.camera === 1 ? await UdsPluginSocketService.scanBySubCamera() : await UdsPluginSocketService.scanByCamera();
86968
87047
  this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86969
- } else {
86970
- this.$message.error('拍照出错,请检查设备是否连接成功');
87048
+ break;
86971
87049
  }
86972
- break;
86973
- }
86974
- case 11:
86975
- {
86976
- // 沃斯德人证交互终端(拍照作用于当前预览画面,预览保持可连续拍)
86977
- let type = this.camera === 0 ? 'main' : 'vice';
86978
- let res = await EWindowPassService.scanByCamera(type);
86979
- if (res) {
87050
+ case 5:
87051
+ {
87052
+ // 良田
87053
+ let type = this.camera === 0 ? 'main' : 'vice';
87054
+ const res = await ELoamPassService.scanByCamera(type, this.deskewStatus);
87055
+ if (res) {
87056
+ let path = res;
87057
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${path}`);
87058
+ } else {
87059
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87060
+ }
87061
+ break;
87062
+ }
87063
+ case 6:
87064
+ {
87065
+ // 国产客户端一体机
87066
+ let res = await WeiRongPluginService.scanByCamera();
87067
+ if (res) {
87068
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87069
+ } else {
87070
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87071
+ }
87072
+ break;
87073
+ }
87074
+ case 9:
87075
+ {
87076
+ // 本机摄像头
87077
+ this.takeDefaultCameraPicture();
87078
+ break;
87079
+ }
87080
+ case 8:
87081
+ {
87082
+ // 汉王高拍仪 拍照
87083
+ let res = await HanWangPluginService.scanByCamera();
86980
87084
  this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86981
- } else {
86982
- this.$message.error('拍照出错,请检查设备是否连接成功');
87085
+ break;
86983
87086
  }
86984
- break;
86985
- }
87087
+ case 10:
87088
+ {
87089
+ // 维山高拍仪
87090
+ let type = this.camera === 0 ? 'main' : 'vice';
87091
+ // 帧消息已通过 callback 路由,不会干扰拍照响应,无需停止预览
87092
+ let res = await ViisanPluginService.scanByCamera(type);
87093
+ if (res) {
87094
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87095
+ } else {
87096
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87097
+ }
87098
+ break;
87099
+ }
87100
+ case 11:
87101
+ {
87102
+ // 沃斯德人证交互终端(拍照作用于当前预览画面,预览保持可连续拍)
87103
+ let type = this.camera === 0 ? 'main' : 'vice';
87104
+ let res = await EWindowPassService.scanByCamera(type);
87105
+ if (res) {
87106
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87107
+ } else {
87108
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87109
+ }
87110
+ break;
87111
+ }
87112
+ }
87113
+ } catch (e) {
87114
+ console.error('拍照失败:', e);
87115
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87116
+ } finally {
87117
+ this.takingPhoto = false;
86986
87118
  }
86987
87119
  },
86988
87120
  /**
@@ -87016,7 +87148,20 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87016
87148
  break;
87017
87149
  case 6:
87018
87150
  // 国产客户端一体机
87019
- await WeiRongPluginService.turnOnTheCamera();
87151
+ this.loadSuccess = true;
87152
+ try {
87153
+ await WeiRongPluginService.turnOnTheCamera();
87154
+ // 默认右旋 90°(设备端 Transpose:1-右转,2-左转)
87155
+ try {
87156
+ await WeiRongPluginService.transpose(1);
87157
+ } catch (e) {
87158
+ console.error('默认旋转失败:', e);
87159
+ }
87160
+ } catch (e) {
87161
+ console.error('打开摄像头失败:', e);
87162
+ this.loadSuccess = false;
87163
+ this.$message.error('打开摄像头失败,请确认维荣插件服务已启动');
87164
+ }
87020
87165
  break;
87021
87166
  case 9:
87022
87167
  // 本机摄像头
@@ -87175,7 +87320,20 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87175
87320
  break;
87176
87321
  case 6:
87177
87322
  // 国产客户端一体机
87178
- await WeiRongPluginService.turnOnTheCamera();
87323
+ this.loadSuccess = true;
87324
+ try {
87325
+ await WeiRongPluginService.turnOnTheCamera();
87326
+ // 默认右旋 90°(设备端 Transpose:1-右转,2-左转)
87327
+ try {
87328
+ await WeiRongPluginService.transpose(1);
87329
+ } catch (e) {
87330
+ console.error('默认旋转失败:', e);
87331
+ }
87332
+ } catch (e) {
87333
+ console.error('打开摄像头失败:', e);
87334
+ this.loadSuccess = false;
87335
+ this.$message.error('打开摄像头失败,请确认维荣插件服务已启动');
87336
+ }
87179
87337
  break;
87180
87338
  case 9:
87181
87339
  // 本机摄像头
@@ -87280,7 +87438,27 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87280
87438
  * 处理旋转命令
87281
87439
  * @param command 旋转命令:rotate-left(左旋90°), rotate-right(右旋90°), rotate-180(旋转180°)
87282
87440
  */
87283
- handleRotateCommand(command) {
87441
+ async handleRotateCommand(command) {
87442
+ // 维荣(国产一体机):设备端 Transpose 指令,1-右转 90°,2-左转 90°
87443
+ if (this.machineType === 6) {
87444
+ try {
87445
+ if (command === 'rotate-left') {
87446
+ await WeiRongPluginService.transpose(2);
87447
+ } else if (command === 'rotate-right') {
87448
+ await WeiRongPluginService.transpose(1);
87449
+ } else if (command === 'rotate-180') {
87450
+ await WeiRongPluginService.transpose(1);
87451
+ await WeiRongPluginService.transpose(1);
87452
+ } else {
87453
+ return;
87454
+ }
87455
+ this.$message.success('旋转成功');
87456
+ } catch (e) {
87457
+ console.error('旋转失败:', e);
87458
+ this.$message.error('旋转失败,请检查设备连接');
87459
+ }
87460
+ return;
87461
+ }
87284
87462
  if (this.machineType !== 5) return; // 仅良田支持旋转
87285
87463
 
87286
87464
  const isLinux = String(navigator.platform).indexOf("Linux") > -1;
@@ -87511,10 +87689,10 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87511
87689
  });
87512
87690
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=script&lang=js&
87513
87691
  /* harmony default export */ var component_scanner_camera_componentvue_type_script_lang_js_ = (scanner_camera_componentvue_type_script_lang_js_);
87514
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=3fc2d979&prod&lang=scss&
87692
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=efc69384&prod&lang=scss&scoped=true&
87515
87693
  // extracted by mini-css-extract-plugin
87516
87694
 
87517
- ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=3fc2d979&prod&lang=scss&
87695
+ ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=efc69384&prod&lang=scss&scoped=true&
87518
87696
 
87519
87697
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue
87520
87698
 
@@ -87527,11 +87705,11 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87527
87705
 
87528
87706
  var scanner_camera_component_component = normalizeComponent(
87529
87707
  component_scanner_camera_componentvue_type_script_lang_js_,
87530
- scanner_camera_componentvue_type_template_id_3fc2d979_render,
87531
- scanner_camera_componentvue_type_template_id_3fc2d979_staticRenderFns,
87708
+ scanner_camera_componentvue_type_template_id_efc69384_scoped_true_render,
87709
+ scanner_camera_componentvue_type_template_id_efc69384_scoped_true_staticRenderFns,
87532
87710
  false,
87533
87711
  null,
87534
- null,
87712
+ "efc69384",
87535
87713
  null
87536
87714
 
87537
87715
  )