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.
@@ -83188,8 +83188,8 @@ var scanner_cameravue_type_template_id_00e9072f_scoped_true_render = function re
83188
83188
  };
83189
83189
  var scanner_cameravue_type_template_id_00e9072f_scoped_true_staticRenderFns = [];
83190
83190
 
83191
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-85.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&
83192
- var scanner_camera_componentvue_type_template_id_3fc2d979_render = function render() {
83191
+ ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-85.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&
83192
+ var scanner_camera_componentvue_type_template_id_efc69384_scoped_true_render = function render() {
83193
83193
  var _vm = this,
83194
83194
  _c = _vm._self._c;
83195
83195
  return _c('div', {
@@ -83202,12 +83202,7 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83202
83202
  staticClass: "load-success"
83203
83203
  }, [_vm.machineType === 9 ? _c('video', {
83204
83204
  ref: "monitor",
83205
- staticStyle: {
83206
- "max-width": "800px",
83207
- "max-height": "600px",
83208
- "width": "100%",
83209
- "height": "100%"
83210
- },
83205
+ staticClass: "camera-video",
83211
83206
  attrs: {
83212
83207
  "id": "monitor",
83213
83208
  "autoplay": "",
@@ -83217,18 +83212,13 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83217
83212
  domProps: {
83218
83213
  "muted": true
83219
83214
  }
83220
- }) : _c('div', {
83215
+ }) : _vm.scannerVideoSrc ? _c('div', {
83221
83216
  staticClass: "camera-container",
83222
83217
  class: {
83223
83218
  'select-mode': _vm.isSelectAreaMode && _vm.machineType === 5
83224
83219
  }
83225
83220
  }, [_c('img', {
83226
- staticStyle: {
83227
- "max-width": "800px",
83228
- "max-height": "600px",
83229
- "width": "100%",
83230
- "height": "100%"
83231
- },
83221
+ staticClass: "camera-preview",
83232
83222
  attrs: {
83233
83223
  "id": "photo",
83234
83224
  "src": _vm.scannerVideoSrc
@@ -83245,7 +83235,11 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83245
83235
  attrs: {
83246
83236
  "id": "selection-box"
83247
83237
  }
83248
- }) : _vm._e()])]) : _c('div', {
83238
+ }) : _vm._e()]) : _c('div', {
83239
+ staticClass: "camera-empty"
83240
+ }, [_c('i', {
83241
+ staticClass: "el-icon-camera camera-empty-icon"
83242
+ }), _c('p', [_vm._v("正在连接摄像头,请稍候…")])])]) : _c('div', {
83249
83243
  staticClass: "load-error"
83250
83244
  }, [_c('i', {
83251
83245
  staticClass: "el-icon-s-cooperation"
@@ -83274,12 +83268,13 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83274
83268
  "value": item.value
83275
83269
  }
83276
83270
  });
83277
- }), 1), [_vm._l(_vm.buttonList, function (item) {
83271
+ }), 1), _vm._l(_vm.buttonList, function (item) {
83278
83272
  return [_vm._isShowButton(item.name) ? _c('el-button', {
83279
83273
  key: item.name,
83280
83274
  attrs: {
83281
83275
  "type": "primary",
83282
- "size": "small"
83276
+ "size": "small",
83277
+ "loading": item.name === 'take-pictures' && _vm.takingPhoto
83283
83278
  },
83284
83279
  on: {
83285
83280
  "click": function ($event) {
@@ -83287,7 +83282,7 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83287
83282
  }
83288
83283
  }
83289
83284
  }, [_vm._v(_vm._s(item.label))]) : _vm._e()];
83290
- }), _vm.machineType === 5 ? _c('el-dropdown', {
83285
+ }), _vm.machineType === 5 || _vm.machineType === 6 ? _c('el-dropdown', {
83291
83286
  attrs: {
83292
83287
  "size": "small"
83293
83288
  },
@@ -83295,9 +83290,6 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83295
83290
  "command": _vm.handleRotateCommand
83296
83291
  }
83297
83292
  }, [_c('el-button', {
83298
- staticStyle: {
83299
- "margin-left": "10px"
83300
- },
83301
83293
  attrs: {
83302
83294
  "type": "primary",
83303
83295
  "size": "small"
@@ -83321,9 +83313,9 @@ var scanner_camera_componentvue_type_template_id_3fc2d979_render = function rend
83321
83313
  attrs: {
83322
83314
  "command": "rotate-180"
83323
83315
  }
83324
- }, [_vm._v("旋转180°")])], 1)], 1) : _vm._e(), _vm._t("action")]], 2)])]);
83316
+ }, [_vm._v("旋转180°")])], 1)], 1) : _vm._e(), _vm._t("action")], 2)])]);
83325
83317
  };
83326
- var scanner_camera_componentvue_type_template_id_3fc2d979_staticRenderFns = [];
83318
+ var scanner_camera_componentvue_type_template_id_efc69384_scoped_true_staticRenderFns = [];
83327
83319
 
83328
83320
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
83329
83321
  function _typeof(obj) {
@@ -84730,144 +84722,248 @@ var WEIRONGMethodCode;
84730
84722
  WEIRONGMethodCode["ScannerCamera"] = "ScannerCamera";
84731
84723
  /** 结束预览*/
84732
84724
  WEIRONGMethodCode["StopCamera"] = "StopCamera";
84725
+ /** 旋转画面(1-右转 90°,2-左转 90°)*/
84726
+ WEIRONGMethodCode["Transpose"] = "Transpose";
84733
84727
  })(WEIRONGMethodCode || (WEIRONGMethodCode = {}));
84734
84728
  class WeiRongPluginService {
84735
- static startConnect(method) {
84729
+ /** 正在建立的连接,防止并发重复建连 */
84730
+
84731
+ /** 在途请求按 method 分组,响应只唤醒等待同一 method 的请求 */
84732
+
84733
+ /** 单次请求响应超时,需大于设备端 outTimes(30 秒) */
84734
+
84735
+ static startConnect() {
84736
84736
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
84737
- return this;
84737
+ return Promise.resolve(this.ws);
84738
84738
  }
84739
- const ws = new WebSocket(this.webSocketUrl);
84740
- let resolved;
84741
- const onConnect = new Promise(resolve => {
84742
- resolved = resolve;
84743
- });
84744
- ws.onopen = () => {
84745
- resolved(true);
84746
- };
84747
- ws.onmessage = event => {
84748
- this.handleMessage(event);
84749
- };
84750
- ws.onclose = () => this.handleClose();
84751
- ws.onerror = () => this.handleError();
84752
- this.ws = ws;
84753
- return onConnect;
84754
- }
84755
- static handleError() {
84756
- for (const type in this.requestStore) {
84757
- this.requestStore.forEach(({
84758
- reject
84759
- }) => {
84760
- reject('handleError');
84761
- });
84739
+ if (!this.connecting) {
84740
+ this.connecting = this.openSocket();
84762
84741
  }
84763
- throw Error('统一插件平台设备功能加载失败');
84742
+ return this.connecting;
84764
84743
  }
84765
- static handleClose() {
84766
- for (const type in this.requestStore) {
84767
- this.requestStore.forEach(({
84768
- reject
84769
- }) => {
84770
- reject('close');
84771
- });
84772
- }
84744
+ static openSocket() {
84745
+ return new Promise((resolve, reject) => {
84746
+ const ws = new WebSocket(this.webSocketUrl);
84747
+ let settled = false;
84748
+ const connectTimeout = setTimeout(() => {
84749
+ if (settled) return;
84750
+ settled = true;
84751
+ this.connecting = null;
84752
+ try {
84753
+ ws.close();
84754
+ } catch (e) {/* 忽略关闭异常 */}
84755
+ reject(new Error('统一插件平台设备连接超时'));
84756
+ }, 5000);
84757
+ const settleError = message => {
84758
+ if (settled) return;
84759
+ settled = true;
84760
+ clearTimeout(connectTimeout);
84761
+ this.connecting = null;
84762
+ reject(new Error(message));
84763
+ };
84764
+ ws.onopen = () => {
84765
+ if (settled) return;
84766
+ settled = true;
84767
+ clearTimeout(connectTimeout);
84768
+ this.connecting = null;
84769
+ this.ws = ws;
84770
+ resolve(ws);
84771
+ };
84772
+ ws.onmessage = event => this.handleMessage(event);
84773
+ ws.onerror = () => settleError('统一插件平台设备连接失败');
84774
+ ws.onclose = () => {
84775
+ if (!settled) {
84776
+ settleError('统一插件平台设备连接失败');
84777
+ return;
84778
+ }
84779
+ // 只有断开的是当前连接时才清空引用并让在途请求失败,下次 read 会自动重连
84780
+ if (this.ws === ws) {
84781
+ this.ws = null;
84782
+ this.rejectAllPending('统一插件平台设备连接已断开');
84783
+ }
84784
+ };
84785
+ });
84773
84786
  }
84774
84787
  static handleMessage(msg) {
84775
- let data = '';
84788
+ let data = null;
84776
84789
  try {
84777
84790
  data = JSON.parse(msg.data);
84778
84791
  } catch (e) {
84779
- data = '';
84792
+ return;
84793
+ }
84794
+ if (!data || !data.method) {
84795
+ return;
84780
84796
  }
84781
84797
  if (data.method === 'FaceScreenStream' || data.method === 'VideoStream') {
84782
84798
  const event = new ScannerCameraRefreshPhotoEvent(data.imgBase64);
84783
84799
  return window.dispatchEvent(event);
84784
84800
  } else {
84785
- this.requestStore.forEach(({
84786
- resolve
84787
- }) => {
84788
- resolve(data);
84789
- });
84790
- this.requestStore = [];
84801
+ this.resolvePending(data.method, data);
84791
84802
  }
84792
84803
  }
84793
- static async read(method) {
84794
- await this.startConnect(method);
84795
- if (this.ws.readyState === 1) {
84796
- let jsonString;
84797
- switch (method) {
84798
- case WEIRONGMethodCode.ReadCard_Base64:
84799
- jsonString = JSON.stringify({
84800
- method: 'ReadIDCard_Base64',
84801
- args: {
84802
- outTimes: 30,
84803
- cardReader: 0
84804
- }
84805
- });
84806
- break;
84807
- case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84808
- jsonString = JSON.stringify({
84809
- method: 'FaceValidateWithIdCard_Base64',
84810
- args: {
84811
- outTimes: 30,
84812
- score: 75
84813
- }
84814
- });
84815
- break;
84816
- case WEIRONGMethodCode.StartSignName:
84817
- jsonString = JSON.stringify({
84818
- method: 'SignNameScreen_Start',
84819
- args: {
84820
- outTimes: 30
84821
- }
84822
- });
84823
- break;
84824
- case WEIRONGMethodCode.GetSignNameStatus:
84825
- jsonString = JSON.stringify({
84826
- method: 'SignNameScreen_Status',
84827
- args: {}
84828
- });
84829
- break;
84830
- case WEIRONGMethodCode.GetSignName_Base64:
84831
- jsonString = JSON.stringify({
84832
- method: 'SignNameScreen_Get',
84833
- args: {}
84834
- });
84835
- break;
84836
- case WEIRONGMethodCode.TurnOnTheCamera:
84837
- jsonString = JSON.stringify({
84838
- method: 'VideoStart',
84839
- args: {}
84840
- });
84841
- break;
84842
- case WEIRONGMethodCode.ScannerCamera:
84843
- jsonString = JSON.stringify({
84844
- method: 'GetCameraImage',
84845
- args: {
84846
- imagePath: ''
84847
- }
84848
- });
84849
- break;
84850
- case WEIRONGMethodCode.StopCamera:
84851
- jsonString = JSON.stringify({
84852
- method: 'VideoStop',
84853
- args: {}
84854
- });
84855
- break;
84856
- }
84857
- this.ws.send(jsonString);
84858
- return new Promise((resolve, reject) => {
84859
- if (!this.requestStore) {
84860
- this.requestStore = [];
84861
- }
84862
- this.requestStore.push({
84863
- resolve,
84864
- reject
84804
+ static getPendingStore(method) {
84805
+ let store = this.pendingStore.get(method);
84806
+ if (!store) {
84807
+ store = [];
84808
+ this.pendingStore.set(method, store);
84809
+ }
84810
+ return store;
84811
+ }
84812
+ /** 响应与请求按 method 先进先出配对,一条响应只唤醒一个请求 */
84813
+ static resolvePending(method, data) {
84814
+ const store = this.pendingStore.get(method);
84815
+ const entry = store && store.shift();
84816
+ if (store && store.length === 0) {
84817
+ this.pendingStore.delete(method);
84818
+ }
84819
+ if (entry) {
84820
+ entry.resolve(data);
84821
+ }
84822
+ }
84823
+ static rejectAllPending(reason) {
84824
+ this.pendingStore.forEach(store => {
84825
+ store.splice(0).forEach(({
84826
+ reject
84827
+ }) => reject(reason));
84828
+ });
84829
+ this.pendingStore.clear();
84830
+ }
84831
+ static removePending(method, entry) {
84832
+ const store = this.pendingStore.get(method);
84833
+ if (!store) return;
84834
+ const index = store.indexOf(entry);
84835
+ if (index > -1) store.splice(index, 1);
84836
+ if (store.length === 0) this.pendingStore.delete(method);
84837
+ }
84838
+ static buildRequest(method) {
84839
+ switch (method) {
84840
+ case WEIRONGMethodCode.ReadCard_Base64:
84841
+ return JSON.stringify({
84842
+ method: 'ReadIDCard_Base64',
84843
+ args: {
84844
+ outTimes: 30,
84845
+ cardReader: 0
84846
+ }
84865
84847
  });
84866
- });
84867
- } else {
84868
- throw Error('统一插件平台设备未准备完成');
84848
+ case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84849
+ return JSON.stringify({
84850
+ method: 'FaceValidateWithIdCard_Base64',
84851
+ args: {
84852
+ outTimes: 30,
84853
+ score: 75
84854
+ }
84855
+ });
84856
+ case WEIRONGMethodCode.StartSignName:
84857
+ return JSON.stringify({
84858
+ method: 'SignNameScreen_Start',
84859
+ args: {
84860
+ outTimes: 30
84861
+ }
84862
+ });
84863
+ case WEIRONGMethodCode.GetSignNameStatus:
84864
+ return JSON.stringify({
84865
+ method: 'SignNameScreen_Status',
84866
+ args: {}
84867
+ });
84868
+ case WEIRONGMethodCode.GetSignName_Base64:
84869
+ return JSON.stringify({
84870
+ method: 'SignNameScreen_Get',
84871
+ args: {}
84872
+ });
84873
+ case WEIRONGMethodCode.TurnOnTheCamera:
84874
+ return JSON.stringify({
84875
+ method: 'VideoStart',
84876
+ args: {}
84877
+ });
84878
+ case WEIRONGMethodCode.ScannerCamera:
84879
+ return JSON.stringify({
84880
+ method: 'GetCameraImage',
84881
+ args: {
84882
+ imagePath: ''
84883
+ }
84884
+ });
84885
+ case WEIRONGMethodCode.StopCamera:
84886
+ return JSON.stringify({
84887
+ method: 'VideoStop',
84888
+ args: {}
84889
+ });
84890
+ case WEIRONGMethodCode.Transpose:
84891
+ return JSON.stringify({
84892
+ method: 'Transpose',
84893
+ args: {
84894
+ rotationAngle: 0
84895
+ }
84896
+ });
84897
+ default:
84898
+ return null;
84899
+ }
84900
+ }
84901
+ /** 设备端响应的 method 名与请求枚举名不同,配对前需要先映射成响应名 */
84902
+ static responseMethodOf(method) {
84903
+ switch (method) {
84904
+ case WEIRONGMethodCode.ReadCard_Base64:
84905
+ return 'ReadIDCard_Base64';
84906
+ case WEIRONGMethodCode.FaceValidateWithIdCard_Base64:
84907
+ return 'FaceValidateWithIdCard_Base64';
84908
+ case WEIRONGMethodCode.StartSignName:
84909
+ return 'SignNameScreen_Start';
84910
+ case WEIRONGMethodCode.GetSignNameStatus:
84911
+ return 'SignNameScreen_Status';
84912
+ case WEIRONGMethodCode.GetSignName_Base64:
84913
+ return 'SignNameScreen_Get';
84914
+ case WEIRONGMethodCode.TurnOnTheCamera:
84915
+ return 'VideoStart';
84916
+ case WEIRONGMethodCode.ScannerCamera:
84917
+ return 'GetCameraImage';
84918
+ case WEIRONGMethodCode.StopCamera:
84919
+ return 'VideoStop';
84920
+ case WEIRONGMethodCode.Transpose:
84921
+ return 'Transpose';
84922
+ default:
84923
+ return null;
84869
84924
  }
84870
84925
  }
84926
+ static async read(method, argsOverride) {
84927
+ const ws = await this.startConnect();
84928
+ const jsonString = this.buildRequest(method);
84929
+ const responseMethod = this.responseMethodOf(method);
84930
+ if (!jsonString || !responseMethod) {
84931
+ throw Error(`统一插件平台不支持的操作:${method}`);
84932
+ }
84933
+ // 旋转等指令的参数随调用变化,允许覆盖默认 args
84934
+ let requestJson = jsonString;
84935
+ if (argsOverride) {
84936
+ const request = JSON.parse(jsonString);
84937
+ request.args = argsOverride;
84938
+ requestJson = JSON.stringify(request);
84939
+ }
84940
+ return new Promise((resolve, reject) => {
84941
+ const store = this.getPendingStore(responseMethod);
84942
+ let timeoutTimer = null;
84943
+ const entry = {
84944
+ resolve: value => {
84945
+ if (timeoutTimer) clearTimeout(timeoutTimer);
84946
+ resolve(value);
84947
+ },
84948
+ reject: reason => {
84949
+ if (timeoutTimer) clearTimeout(timeoutTimer);
84950
+ reject(reason);
84951
+ }
84952
+ };
84953
+ timeoutTimer = setTimeout(() => {
84954
+ this.removePending(responseMethod, entry);
84955
+ reject(Error('统一插件平台设备响应超时'));
84956
+ }, this.requestTimeout);
84957
+ store.push(entry);
84958
+ try {
84959
+ ws.send(requestJson);
84960
+ } catch (e) {
84961
+ this.removePending(responseMethod, entry);
84962
+ this.ws = null;
84963
+ reject(Error('统一插件平台设备未准备完成'));
84964
+ }
84965
+ });
84966
+ }
84871
84967
  /** 读取身份证和永居证*/
84872
84968
  static async idCardRead() {
84873
84969
  const readData = await WeiRongPluginService.read(WEIRONGMethodCode.ReadCard_Base64);
@@ -84875,7 +84971,6 @@ class WeiRongPluginService {
84875
84971
  throw Error('未匹配到可用的读取设备');
84876
84972
  }
84877
84973
  if (readData.retVal !== 0) {
84878
- if (this.ws) this.ws.close();
84879
84974
  throw Error("读取二代身份证失败,返回值:" + readData.retVal + ",错误信息:" + readData.errMsg);
84880
84975
  }
84881
84976
  let idInfo = readData.idInfo;
@@ -84927,7 +85022,6 @@ class WeiRongPluginService {
84927
85022
  },
84928
85023
  headImage: readData.idPhotoBase64
84929
85024
  };
84930
- if (this.ws) this.ws.close();
84931
85025
  return IDCardData;
84932
85026
  }
84933
85027
  /** 读取社保卡 */
@@ -84937,7 +85031,6 @@ class WeiRongPluginService {
84937
85031
  throw Error('未匹配可用的读取设备');
84938
85032
  }
84939
85033
  if (readData.retVal !== 0) {
84940
- if (this.ws) this.ws.close();
84941
85034
  throw Error("读取社保卡基本信息失败,返回值:" + readData.retVal + ",错误信息:" + readData.idInfo);
84942
85035
  }
84943
85036
  // 返回数据:cardType 3 社保卡
@@ -84961,7 +85054,6 @@ class WeiRongPluginService {
84961
85054
  },
84962
85055
  headImage: ''
84963
85056
  };
84964
- if (this.ws) this.ws.close();
84965
85057
  return IDCardData;
84966
85058
  }
84967
85059
  /**
@@ -84969,7 +85061,7 @@ class WeiRongPluginService {
84969
85061
  */
84970
85062
  static async faceValidateWithIdCardRead() {
84971
85063
  const readData = await WeiRongPluginService.read(WEIRONGMethodCode.FaceValidateWithIdCard_Base64);
84972
- if (readData.method === 'FaceValidateWithIdCard_Base64' && readData.retVal == '0') {
85064
+ if (readData.retVal == '0') {
84973
85065
  const idInfo = readData.idInfo;
84974
85066
  let {
84975
85067
  name,
@@ -85022,63 +85114,87 @@ class WeiRongPluginService {
85022
85114
  faceimg: readData.scenceBase64,
85023
85115
  score: readData.score
85024
85116
  };
85025
- if (this.ws) this.ws.close();
85026
85117
  return IDCardData;
85027
85118
  } else {
85028
- if (this.ws) this.ws.close();
85119
+ return undefined;
85029
85120
  }
85030
85121
  }
85031
85122
  /** 签字*/
85032
85123
  static async signNameRead() {
85033
- return new Promise(async (resolve, reject) => {
85034
- const readData = await WeiRongPluginService.read(WEIRONGMethodCode.StartSignName);
85035
- if (readData.method === 'SignNameScreen_Start') {
85036
- if (readData.retVal !== 0) {
85037
- if (this.ws) this.ws.close();
85038
- reject(`开始签名失败,返回值:${readData.retVal},错误信息:${readData.errMsg}`);
85039
- } else {
85040
- if (!this.timer) {
85041
- this.timer = setInterval(async () => {
85042
- let status = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignNameStatus);
85043
- if (status.signScreenStatus == 2) {
85044
- clearInterval(this.timer);
85045
- this.timer = null;
85046
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignName_Base64);
85047
- if (this.ws) this.ws.close();
85048
- resolve(res.signPicBase64);
85049
- } else if (status.retVal == 3) {
85050
- clearInterval(this.timer);
85051
- this.timer = null;
85052
- if (this.ws) this.ws.close();
85053
- reject('签字结果=>签字失败,或意外中断!');
85054
- }
85055
- }, 2000);
85124
+ const readData = await WeiRongPluginService.read(WEIRONGMethodCode.StartSignName);
85125
+ if (readData.method !== 'SignNameScreen_Start') {
85126
+ throw Error('开始签名失败:设备无响应');
85127
+ }
85128
+ if (readData.retVal !== 0) {
85129
+ throw Error(`开始签名失败,返回值:${readData.retVal},错误信息:${readData.errMsg}`);
85130
+ }
85131
+ return new Promise((resolve, reject) => {
85132
+ if (this.timer) {
85133
+ clearInterval(this.timer);
85134
+ }
85135
+ this.timer = setInterval(async () => {
85136
+ let status;
85137
+ try {
85138
+ status = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignNameStatus);
85139
+ } catch (e) {
85140
+ clearInterval(this.timer);
85141
+ this.timer = null;
85142
+ reject('签字结果=>获取签名状态失败:' + (e?.message || e));
85143
+ return;
85144
+ }
85145
+ if (status.signScreenStatus == 2) {
85146
+ clearInterval(this.timer);
85147
+ this.timer = null;
85148
+ try {
85149
+ let res = await WeiRongPluginService.read(WEIRONGMethodCode.GetSignName_Base64);
85150
+ resolve(res.signPicBase64);
85151
+ } catch (e) {
85152
+ reject('签字结果=>获取签名失败:' + (e?.message || e));
85056
85153
  }
85154
+ } else if (status.retVal == 3) {
85155
+ clearInterval(this.timer);
85156
+ this.timer = null;
85157
+ reject('签字结果=>签字失败,或意外中断!');
85057
85158
  }
85058
- }
85159
+ }, 2000);
85059
85160
  });
85060
85161
  }
85061
85162
  // 开启主摄像头/副摄像头
85062
85163
  static async turnOnTheCamera() {
85063
- await WeiRongPluginService.read(WEIRONGMethodCode.TurnOnTheCamera);
85164
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.TurnOnTheCamera);
85165
+ if (res.retVal !== 0) {
85166
+ throw Error('高拍仪摄像头打开失败,返回值:' + res.retVal);
85167
+ }
85064
85168
  }
85065
85169
  // 拍照
85066
85170
  static async scanByCamera() {
85067
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.ScannerCamera);
85068
- if (res.method === 'GetCameraImage' && res.retVal == 0) {
85069
- // if (this.ws) this.ws.close();
85171
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.ScannerCamera);
85172
+ if (res.retVal == 0) {
85070
85173
  return res.cameraImgBase64;
85071
85174
  }
85175
+ return undefined;
85072
85176
  }
85073
85177
  static async stopCamera() {
85074
- let res = await WeiRongPluginService.read(WEIRONGMethodCode.StopCamera);
85075
- if (this.ws) this.ws.close();
85178
+ // 等待设备确认停止预览后再返回;连接保持复用,不再主动关闭
85179
+ return WeiRongPluginService.read(WEIRONGMethodCode.StopCamera);
85180
+ }
85181
+ /** 旋转画面:1-右转 90°,2-左转 90°(设备端旋转预览流和拍照画面) */
85182
+ static async transpose(rotationAngle) {
85183
+ const res = await WeiRongPluginService.read(WEIRONGMethodCode.Transpose, {
85184
+ rotationAngle: rotationAngle
85185
+ });
85186
+ if (res.retVal !== 0) {
85187
+ throw Error('旋转失败,返回值:' + res.retVal);
85188
+ }
85189
+ return res;
85076
85190
  }
85077
85191
  }
85078
85192
  _defineProperty(WeiRongPluginService, "webSocketUrl", 'ws://127.0.0.1:5847');
85079
- _defineProperty(WeiRongPluginService, "ws", void 0);
85080
- _defineProperty(WeiRongPluginService, "requestStore", []);
85193
+ _defineProperty(WeiRongPluginService, "ws", null);
85194
+ _defineProperty(WeiRongPluginService, "connecting", null);
85195
+ _defineProperty(WeiRongPluginService, "pendingStore", new Map());
85081
85196
  _defineProperty(WeiRongPluginService, "timer", null);
85197
+ _defineProperty(WeiRongPluginService, "requestTimeout", 35000);
85082
85198
  ;// CONCATENATED MODULE: ./packages/service/external-plugins/han-wang-plugin.service.ts
85083
85199
 
85084
85200
 
@@ -86809,7 +86925,9 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
86809
86925
  // X轴缩放比例
86810
86926
  zoomScaleY: 1,
86811
86927
  // Y轴缩放比例
86812
- isSelectAreaMode: false
86928
+ isSelectAreaMode: false,
86929
+ // 拍照进行中(防止连点重复发起)
86930
+ takingPhoto: false
86813
86931
  };
86814
86932
  },
86815
86933
  watch: {
@@ -86914,85 +87032,99 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
86914
87032
  * 拍照
86915
87033
  */
86916
87034
  async takePictures() {
86917
- switch (this.machineType) {
86918
- case 0:
86919
- // 捷宇
86920
- let res = await JieYueService.scanByCamera();
86921
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86922
- break;
86923
- case 3:
86924
- {
86925
- // 方正
86926
- this.$emit('send-scanner-result', this.scannerVideoSrc);
86927
- break;
86928
- }
86929
- case 4:
86930
- {
86931
- // 紫图速拍仪
86932
- // 按当前选择的摄像头拍照:0-主头(文档),1-副头(照片)
86933
- let res = this.camera === 1 ? await UdsPluginSocketService.scanBySubCamera() : await UdsPluginSocketService.scanByCamera();
86934
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86935
- break;
86936
- }
86937
- case 5:
86938
- {
86939
- // 良田
86940
- let type = this.camera === 0 ? 'main' : 'vice';
86941
- console.log('this.deskewStatus', this.deskewStatus);
86942
- const res = await ELoamPassService.scanByCamera(type, this.deskewStatus);
86943
- if (res) {
86944
- let path = res;
86945
- this.$emit('send-scanner-result', `${BEGIN_DATA}${path}`);
86946
- } else {
86947
- this.$message.error('拍照出错,请检查设备是否连接成功');
87035
+ if (this.takingPhoto) return;
87036
+ this.takingPhoto = true;
87037
+ try {
87038
+ switch (this.machineType) {
87039
+ case 0:
87040
+ {
87041
+ // 捷宇
87042
+ let res = await JieYueService.scanByCamera();
87043
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87044
+ break;
86948
87045
  }
86949
- break;
86950
- }
86951
- case 6:
86952
- {
86953
- // 国产客户端一体机
86954
- let res = await WeiRongPluginService.scanByCamera();
86955
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86956
- break;
86957
- }
86958
- case 9:
86959
- {
86960
- // 本机摄像头
86961
- this.takeDefaultCameraPicture();
86962
- break;
86963
- }
86964
- case 8:
86965
- {
86966
- // 汉王高拍仪 拍照
86967
- let res = await HanWangPluginService.scanByCamera();
86968
- this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86969
- break;
86970
- }
86971
- case 10:
86972
- {
86973
- // 维山高拍仪
86974
- let type = this.camera === 0 ? 'main' : 'vice';
86975
- // 帧消息已通过 callback 路由,不会干扰拍照响应,无需停止预览
86976
- let res = await ViisanPluginService.scanByCamera(type);
86977
- if (res) {
87046
+ case 3:
87047
+ {
87048
+ // 方正
87049
+ this.$emit('send-scanner-result', this.scannerVideoSrc);
87050
+ break;
87051
+ }
87052
+ case 4:
87053
+ {
87054
+ // 紫图速拍仪
87055
+ // 按当前选择的摄像头拍照:0-主头(文档),1-副头(照片)
87056
+ let res = this.camera === 1 ? await UdsPluginSocketService.scanBySubCamera() : await UdsPluginSocketService.scanByCamera();
86978
87057
  this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86979
- } else {
86980
- this.$message.error('拍照出错,请检查设备是否连接成功');
87058
+ break;
86981
87059
  }
86982
- break;
86983
- }
86984
- case 11:
86985
- {
86986
- // 沃斯德人证交互终端(拍照作用于当前预览画面,预览保持可连续拍)
86987
- let type = this.camera === 0 ? 'main' : 'vice';
86988
- let res = await EWindowPassService.scanByCamera(type);
86989
- if (res) {
87060
+ case 5:
87061
+ {
87062
+ // 良田
87063
+ let type = this.camera === 0 ? 'main' : 'vice';
87064
+ const res = await ELoamPassService.scanByCamera(type, this.deskewStatus);
87065
+ if (res) {
87066
+ let path = res;
87067
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${path}`);
87068
+ } else {
87069
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87070
+ }
87071
+ break;
87072
+ }
87073
+ case 6:
87074
+ {
87075
+ // 国产客户端一体机
87076
+ let res = await WeiRongPluginService.scanByCamera();
87077
+ if (res) {
87078
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87079
+ } else {
87080
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87081
+ }
87082
+ break;
87083
+ }
87084
+ case 9:
87085
+ {
87086
+ // 本机摄像头
87087
+ this.takeDefaultCameraPicture();
87088
+ break;
87089
+ }
87090
+ case 8:
87091
+ {
87092
+ // 汉王高拍仪 拍照
87093
+ let res = await HanWangPluginService.scanByCamera();
86990
87094
  this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
86991
- } else {
86992
- this.$message.error('拍照出错,请检查设备是否连接成功');
87095
+ break;
86993
87096
  }
86994
- break;
86995
- }
87097
+ case 10:
87098
+ {
87099
+ // 维山高拍仪
87100
+ let type = this.camera === 0 ? 'main' : 'vice';
87101
+ // 帧消息已通过 callback 路由,不会干扰拍照响应,无需停止预览
87102
+ let res = await ViisanPluginService.scanByCamera(type);
87103
+ if (res) {
87104
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87105
+ } else {
87106
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87107
+ }
87108
+ break;
87109
+ }
87110
+ case 11:
87111
+ {
87112
+ // 沃斯德人证交互终端(拍照作用于当前预览画面,预览保持可连续拍)
87113
+ let type = this.camera === 0 ? 'main' : 'vice';
87114
+ let res = await EWindowPassService.scanByCamera(type);
87115
+ if (res) {
87116
+ this.$emit('send-scanner-result', `${BEGIN_DATA}${res}`);
87117
+ } else {
87118
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87119
+ }
87120
+ break;
87121
+ }
87122
+ }
87123
+ } catch (e) {
87124
+ console.error('拍照失败:', e);
87125
+ this.$message.error('拍照出错,请检查设备是否连接成功');
87126
+ } finally {
87127
+ this.takingPhoto = false;
86996
87128
  }
86997
87129
  },
86998
87130
  /**
@@ -87026,7 +87158,20 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87026
87158
  break;
87027
87159
  case 6:
87028
87160
  // 国产客户端一体机
87029
- await WeiRongPluginService.turnOnTheCamera();
87161
+ this.loadSuccess = true;
87162
+ try {
87163
+ await WeiRongPluginService.turnOnTheCamera();
87164
+ // 默认右旋 90°(设备端 Transpose:1-右转,2-左转)
87165
+ try {
87166
+ await WeiRongPluginService.transpose(1);
87167
+ } catch (e) {
87168
+ console.error('默认旋转失败:', e);
87169
+ }
87170
+ } catch (e) {
87171
+ console.error('打开摄像头失败:', e);
87172
+ this.loadSuccess = false;
87173
+ this.$message.error('打开摄像头失败,请确认维荣插件服务已启动');
87174
+ }
87030
87175
  break;
87031
87176
  case 9:
87032
87177
  // 本机摄像头
@@ -87185,7 +87330,20 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87185
87330
  break;
87186
87331
  case 6:
87187
87332
  // 国产客户端一体机
87188
- await WeiRongPluginService.turnOnTheCamera();
87333
+ this.loadSuccess = true;
87334
+ try {
87335
+ await WeiRongPluginService.turnOnTheCamera();
87336
+ // 默认右旋 90°(设备端 Transpose:1-右转,2-左转)
87337
+ try {
87338
+ await WeiRongPluginService.transpose(1);
87339
+ } catch (e) {
87340
+ console.error('默认旋转失败:', e);
87341
+ }
87342
+ } catch (e) {
87343
+ console.error('打开摄像头失败:', e);
87344
+ this.loadSuccess = false;
87345
+ this.$message.error('打开摄像头失败,请确认维荣插件服务已启动');
87346
+ }
87189
87347
  break;
87190
87348
  case 9:
87191
87349
  // 本机摄像头
@@ -87290,7 +87448,27 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87290
87448
  * 处理旋转命令
87291
87449
  * @param command 旋转命令:rotate-left(左旋90°), rotate-right(右旋90°), rotate-180(旋转180°)
87292
87450
  */
87293
- handleRotateCommand(command) {
87451
+ async handleRotateCommand(command) {
87452
+ // 维荣(国产一体机):设备端 Transpose 指令,1-右转 90°,2-左转 90°
87453
+ if (this.machineType === 6) {
87454
+ try {
87455
+ if (command === 'rotate-left') {
87456
+ await WeiRongPluginService.transpose(2);
87457
+ } else if (command === 'rotate-right') {
87458
+ await WeiRongPluginService.transpose(1);
87459
+ } else if (command === 'rotate-180') {
87460
+ await WeiRongPluginService.transpose(1);
87461
+ await WeiRongPluginService.transpose(1);
87462
+ } else {
87463
+ return;
87464
+ }
87465
+ this.$message.success('旋转成功');
87466
+ } catch (e) {
87467
+ console.error('旋转失败:', e);
87468
+ this.$message.error('旋转失败,请检查设备连接');
87469
+ }
87470
+ return;
87471
+ }
87294
87472
  if (this.machineType !== 5) return; // 仅良田支持旋转
87295
87473
 
87296
87474
  const isLinux = String(navigator.platform).indexOf("Linux") > -1;
@@ -87521,10 +87699,10 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87521
87699
  });
87522
87700
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=script&lang=js&
87523
87701
  /* harmony default export */ var component_scanner_camera_componentvue_type_script_lang_js_ = (scanner_camera_componentvue_type_script_lang_js_);
87524
- ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.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-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.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&
87702
+ ;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-67.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-67.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-67.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-67.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&
87525
87703
  // extracted by mini-css-extract-plugin
87526
87704
 
87527
- ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=3fc2d979&prod&lang=scss&
87705
+ ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue?vue&type=style&index=0&id=efc69384&prod&lang=scss&scoped=true&
87528
87706
 
87529
87707
  ;// CONCATENATED MODULE: ./packages/scanner/scanner-camera/src/component/scanner-camera-component.vue
87530
87708
 
@@ -87537,11 +87715,11 @@ const BEGIN_DATA = 'data:image/jpg;base64,';
87537
87715
 
87538
87716
  var scanner_camera_component_component = normalizeComponent(
87539
87717
  component_scanner_camera_componentvue_type_script_lang_js_,
87540
- scanner_camera_componentvue_type_template_id_3fc2d979_render,
87541
- scanner_camera_componentvue_type_template_id_3fc2d979_staticRenderFns,
87718
+ scanner_camera_componentvue_type_template_id_efc69384_scoped_true_render,
87719
+ scanner_camera_componentvue_type_template_id_efc69384_scoped_true_staticRenderFns,
87542
87720
  false,
87543
87721
  null,
87544
- null,
87722
+ "efc69384",
87545
87723
  null
87546
87724
 
87547
87725
  )