From 2c269700bae2a64da4906afd26633377702cb7a7 Mon Sep 17 00:00:00 2001 From: qiang Date: Sat, 10 Oct 2020 18:50:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20App=20=E7=AB=AF=20uni.scanCode=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=20autoDecodeCharSet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-app-plus/template/common/__uniappscan.js | 2 +- .../uni-app-plus/template/weex/__uniappscan.html | 7 ++++--- .../uni-cli-shared/template/common/__uniappscan.js | 2 +- .../uni-cli-shared/template/weex/__uniappscan.html | 7 ++++--- src/core/helpers/protocol/device/scan-code.js | 11 +++++++++++ .../service/api/device/scan-code-webview.js | 13 ++++++++----- .../app-plus/service/api/device/scan-code-weex.js | 4 +--- 7 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 src/core/helpers/protocol/device/scan-code.js diff --git a/packages/uni-app-plus/template/common/__uniappscan.js b/packages/uni-app-plus/template/common/__uniappscan.js index e4eaceccda..db7795b76a 100644 --- a/packages/uni-app-plus/template/common/__uniappscan.js +++ b/packages/uni-app-plus/template/common/__uniappscan.js @@ -1 +1 @@ -!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c&&(f.components=Object.assign(c,f.components||{})),u&&((u.beforeCreate||(u.beforeCreate=[])).unshift(function(){this[u.__module]=this}),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var d=f.render;f.render=function(e,t){return l.call(t),d(e,t)}}else{var p=f.beforeCreate;f.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:f}}n.d(t,"a",function(){return a})},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,n=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~n.indexOf(e))},r=function(t){return function(){for(var n=arguments.length,a=Array(n>1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{};return e(r.success)||e(r.fail)||e(r.complete)?t.apply(void 0,[r].concat(a)):new Promise(function(e,n){t.apply(void 0,[Object.assign({},r,{success:e,fail:n})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},i=[],s=void 0;function c(e){i.forEach(function(t){return t({origin:s,data:e})})}var u=o.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function f(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?l.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){i.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var r=e.__uniapp_mask,c=o.webview.getWebviewById(e.__uniapp_mask_id);c=c.parent()||c;var u=e.show,f=e.hide,d=e.close,p=function(){c.setStyle({mask:"none"})};e.show=function(){c.setStyle({mask:r});for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:R,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":x(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},F=weex.requireModule("plusstorage"),j="__TYPE",$=weex.requireModule("clipboard"),L=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function Q(e,t,n){return e[t].apply(e,n)}var J=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);N.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:D,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return i===R&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+V(a)),U.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:i!==R?V(a,i,g["Content-Type"]):""},function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)}),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.getItem(n+j,function(t){if("success"===t.result){var i=t.data;F.getItem(n,function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)})}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)})},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":x(a))&&(s="Object",a=JSON.stringify(a)),F.setItem(n,a,function(t){"success"===t.result?F.setItem(n+j,s,function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))}):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)})},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.removeItem(n,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)}),F.removeItem(n+j)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString(function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)})},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return Q(L(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return Q(L(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return Q(L(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return Q(L(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),q={os:{nvue:!0}},K={};return"undefined"!=typeof Proxy?K=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return I;if("onNavigationBarButtonTap"===t)return M;if("onNavigationBarSearchInputChanged"===t)return k;if("onNavigationBarSearchInputConfirmed"===t)return B;if("onNavigationBarSearchInputClicked"===t)return O;var n=J[t];return n||(n=b(t)),a(t)?r(n):n}}):(Object.keys(q).forEach(function(e){K[e]=q[e]}),K.postMessage=_,K.requireNativePlugin=I,K.onNavigationBarButtonTap=M,K.onNavigationBarSearchInputChanged=k,K.onNavigationBarSearchInputConfirmed=B,K.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=J[e];t||(t=b(e)),a(e)?K[e]=r(t):K[e]=t})),K};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},o=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else new BroadcastChannel(o).postMessage(a)}else{var r=e.webview.getWebviewById(o);r&&r.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"57707442",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg=="},onLoad:function(){var e=this,t=this.data.scanType,n=[];Array.isArray(t)&&t.length&&t.forEach(function(e){var t=c[e];t&&(n=n.concat(t))}),n.length||(n=n.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=n,this.onMessage(function(t){e.gallery()})},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,function(e,t,a){n.scanSuccess(e,t,a)},function(){e.nativeUI.toast("识别失败")},this.filters)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick(function(e){t.scan(e)},function(t){12!==t.code&&e.nativeUI.toast("选择失败")},{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file)},scanSuccess:function(e,t,n){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",function(){return a}),n.d(t,"c",function(){return o}),n.d(t,"a",function(){})},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c){f.components||(f.components={});var d=Object.prototype.hasOwnProperty;for(var p in c)d.call(c,p)&&!d.call(f.components,p)&&(f.components[p]=c[p])}if(u&&((u.beforeCreate||(u.beforeCreate=[])).unshift((function(){this[u.__module]=this})),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var g=f.render;f.render=function(e,t){return l.call(t),g(e,t)}}else{var v=f.beforeCreate;f.beforeCreate=v?[].concat(v,l):[l]}return{exports:e,options:f}}n.d(t,"a",(function(){return a}))},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},n=/^\$|^on|^create|Sync$|Manager$|^pause/,a=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],r=function(e){return(!n.test(e)||"createBLEConnection"===e)&&!~a.indexOf(e)},i=function(n){return function(){for(var a=arguments.length,o=Array(a>1?a-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{};return e(i.success)||e(i.fail)||e(i.complete)?n.apply(void 0,[i].concat(o)):t(new Promise((function(e,t){n.apply(void 0,[Object.assign({},i,{success:e,fail:t})].concat(o)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))}})))}},s=[],c=void 0;function u(e){s.forEach((function(t){return t({origin:c,data:e})}))}var l=o.webview.currentWebview().id,f=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){var t=o.webview.getWebviewById(e);return t&&!t.$processed&&function(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?f.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){s.push(e)},e.__uniapp_mask_id){c=e.__uniapp_host;var r=e.__uniapp_mask,i=o.webview.getWebviewById(e.__uniapp_mask_id);i=i.parent()||i;var u=e.show,l=e.hide,d=e.close,p=function(){i.setStyle({mask:r})},g=function(){i.setStyle({mask:"none"})};e.show=function(){p();for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":T(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&"):e},R=weex.requireModule("plusstorage"),V=weex.requireModule("clipboard"),F=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function j(e,t,n){return e[t].apply(e,n)}var $=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);I.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:N,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return"GET"===i&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+U(a)),x.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:"GET"!==i?U(a,i,g["Content-Type"]):""},(function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)})),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;R.getItem(n+"__TYPE",(function(t){if("success"===t.result){var i=t.data;R.getItem(n,(function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)}))}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)}))},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":T(a))&&(s="Object",a=JSON.stringify(a)),R.setItem(n,a,(function(t){"success"===t.result?R.setItem(n+"__TYPE",s,(function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))})):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)}))},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;R.removeItem(n,(function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)})),R.removeItem(n+"__TYPE")},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);V.getString((function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)}))},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};V.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:u,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return j(F(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return j(F(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return j(F(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return j(F(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),L={os:{nvue:!0}},J={};return"undefined"!=typeof Proxy?J=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return B;if("onNavigationBarButtonTap"===t)return E;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return k;if("onNavigationBarSearchInputClicked"===t)return O;var n=$[t];return n||(n=m(t)),r(t)?i(n):n}}):(Object.keys(L).forEach((function(e){J[e]=L[e]})),J.postMessage=_,J.requireNativePlugin=B,J.onNavigationBarButtonTap=E,J.onNavigationBarSearchInputChanged=M,J.onNavigationBarSearchInputConfirmed=k,J.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach((function(e){var t=$[e];t||(t=m(e)),r(e)?J[e]=i(t):J[e]=t}))),J};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,(function(){return a[e]}))}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",(function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")}));var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=JSON.parse(JSON.stringify({__message:{__page:this.__page,data:t,keep:n}})),o=this.__from;if("v8"===this.__runtime)if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else{var r=new BroadcastChannel(o);r.postMessage(a)}else{var i=e.webview.getWebviewById(o);i&&i.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"30087856",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg==",autoDecodeCharSet:!1},onLoad:function(){var e=this,t=this.data,n=t.scanType;this.autoDecodeCharSet=t.autoDecodeCharSet;var a=[];Array.isArray(n)&&n.length&&n.forEach((function(e){var t=c[e];t&&(a=a.concat(t))})),a.length||(a=a.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=a,this.onMessage((function(t){e.gallery()}))},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,(function(e,t,a,o){n.scanSuccess(e,t,a,o)}),(function(){e.nativeUI.toast("识别失败")}),this.filters,this.autoDecodeCharSet)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick((function(e){t.scan(e)}),(function(t){12!==t.code&&e.nativeUI.toast("选择失败")}),{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file,t.charSet)},scanSuccess:function(e,t,n,a){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:a||"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters,autoDecodeCharset:e.autoDecodeCharSet},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){}))},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,(function(){return a[e]}))}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file diff --git a/packages/uni-app-plus/template/weex/__uniappscan.html b/packages/uni-app-plus/template/weex/__uniappscan.html index 76db379747..e0f2505601 100644 --- a/packages/uni-app-plus/template/weex/__uniappscan.html +++ b/packages/uni-app-plus/template/weex/__uniappscan.html @@ -114,11 +114,12 @@ scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, { frameColor: '#118CE9', scanbarColor: '#118CE9' - }); - scan.onmarked = function(type, code, file) { + }, webview.__uniapp_auto_decode_char_set); + scan.onmarked = function(type, code, file, charSet) { var res = { type: type, - code: code + code: code, + charSet: charSet }; back() plus.webview.postMessageToUniNView({ diff --git a/packages/uni-cli-shared/template/common/__uniappscan.js b/packages/uni-cli-shared/template/common/__uniappscan.js index e4eaceccda..db7795b76a 100644 --- a/packages/uni-cli-shared/template/common/__uniappscan.js +++ b/packages/uni-cli-shared/template/common/__uniappscan.js @@ -1 +1 @@ -!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c&&(f.components=Object.assign(c,f.components||{})),u&&((u.beforeCreate||(u.beforeCreate=[])).unshift(function(){this[u.__module]=this}),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var d=f.render;f.render=function(e,t){return l.call(t),d(e,t)}}else{var p=f.beforeCreate;f.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:f}}n.d(t,"a",function(){return a})},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,n=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~n.indexOf(e))},r=function(t){return function(){for(var n=arguments.length,a=Array(n>1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{};return e(r.success)||e(r.fail)||e(r.complete)?t.apply(void 0,[r].concat(a)):new Promise(function(e,n){t.apply(void 0,[Object.assign({},r,{success:e,fail:n})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},i=[],s=void 0;function c(e){i.forEach(function(t){return t({origin:s,data:e})})}var u=o.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function f(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?l.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){i.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var r=e.__uniapp_mask,c=o.webview.getWebviewById(e.__uniapp_mask_id);c=c.parent()||c;var u=e.show,f=e.hide,d=e.close,p=function(){c.setStyle({mask:"none"})};e.show=function(){c.setStyle({mask:r});for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:R,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":x(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},F=weex.requireModule("plusstorage"),j="__TYPE",$=weex.requireModule("clipboard"),L=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function Q(e,t,n){return e[t].apply(e,n)}var J=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);N.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:D,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return i===R&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+V(a)),U.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:i!==R?V(a,i,g["Content-Type"]):""},function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)}),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.getItem(n+j,function(t){if("success"===t.result){var i=t.data;F.getItem(n,function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)})}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)})},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":x(a))&&(s="Object",a=JSON.stringify(a)),F.setItem(n,a,function(t){"success"===t.result?F.setItem(n+j,s,function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))}):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)})},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.removeItem(n,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)}),F.removeItem(n+j)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString(function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)})},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return Q(L(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return Q(L(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return Q(L(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return Q(L(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),q={os:{nvue:!0}},K={};return"undefined"!=typeof Proxy?K=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return I;if("onNavigationBarButtonTap"===t)return M;if("onNavigationBarSearchInputChanged"===t)return k;if("onNavigationBarSearchInputConfirmed"===t)return B;if("onNavigationBarSearchInputClicked"===t)return O;var n=J[t];return n||(n=b(t)),a(t)?r(n):n}}):(Object.keys(q).forEach(function(e){K[e]=q[e]}),K.postMessage=_,K.requireNativePlugin=I,K.onNavigationBarButtonTap=M,K.onNavigationBarSearchInputChanged=k,K.onNavigationBarSearchInputConfirmed=B,K.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=J[e];t||(t=b(e)),a(e)?K[e]=r(t):K[e]=t})),K};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},o=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else new BroadcastChannel(o).postMessage(a)}else{var r=e.webview.getWebviewById(o);r&&r.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"57707442",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg=="},onLoad:function(){var e=this,t=this.data.scanType,n=[];Array.isArray(t)&&t.length&&t.forEach(function(e){var t=c[e];t&&(n=n.concat(t))}),n.length||(n=n.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=n,this.onMessage(function(t){e.gallery()})},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,function(e,t,a){n.scanSuccess(e,t,a)},function(){e.nativeUI.toast("识别失败")},this.filters)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick(function(e){t.scan(e)},function(t){12!==t.code&&e.nativeUI.toast("选择失败")},{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file)},scanSuccess:function(e,t,n){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",function(){return a}),n.d(t,"c",function(){return o}),n.d(t,"a",function(){})},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c){f.components||(f.components={});var d=Object.prototype.hasOwnProperty;for(var p in c)d.call(c,p)&&!d.call(f.components,p)&&(f.components[p]=c[p])}if(u&&((u.beforeCreate||(u.beforeCreate=[])).unshift((function(){this[u.__module]=this})),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var g=f.render;f.render=function(e,t){return l.call(t),g(e,t)}}else{var v=f.beforeCreate;f.beforeCreate=v?[].concat(v,l):[l]}return{exports:e,options:f}}n.d(t,"a",(function(){return a}))},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},n=/^\$|^on|^create|Sync$|Manager$|^pause/,a=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],r=function(e){return(!n.test(e)||"createBLEConnection"===e)&&!~a.indexOf(e)},i=function(n){return function(){for(var a=arguments.length,o=Array(a>1?a-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{};return e(i.success)||e(i.fail)||e(i.complete)?n.apply(void 0,[i].concat(o)):t(new Promise((function(e,t){n.apply(void 0,[Object.assign({},i,{success:e,fail:t})].concat(o)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))}})))}},s=[],c=void 0;function u(e){s.forEach((function(t){return t({origin:c,data:e})}))}var l=o.webview.currentWebview().id,f=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){var t=o.webview.getWebviewById(e);return t&&!t.$processed&&function(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?f.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){s.push(e)},e.__uniapp_mask_id){c=e.__uniapp_host;var r=e.__uniapp_mask,i=o.webview.getWebviewById(e.__uniapp_mask_id);i=i.parent()||i;var u=e.show,l=e.hide,d=e.close,p=function(){i.setStyle({mask:r})},g=function(){i.setStyle({mask:"none"})};e.show=function(){p();for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":T(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&"):e},R=weex.requireModule("plusstorage"),V=weex.requireModule("clipboard"),F=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function j(e,t,n){return e[t].apply(e,n)}var $=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);I.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:N,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return"GET"===i&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+U(a)),x.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:"GET"!==i?U(a,i,g["Content-Type"]):""},(function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)})),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;R.getItem(n+"__TYPE",(function(t){if("success"===t.result){var i=t.data;R.getItem(n,(function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)}))}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)}))},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":T(a))&&(s="Object",a=JSON.stringify(a)),R.setItem(n,a,(function(t){"success"===t.result?R.setItem(n+"__TYPE",s,(function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))})):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)}))},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;R.removeItem(n,(function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)})),R.removeItem(n+"__TYPE")},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);V.getString((function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)}))},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};V.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:u,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return j(F(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return j(F(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return j(F(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return j(F(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),L={os:{nvue:!0}},J={};return"undefined"!=typeof Proxy?J=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return B;if("onNavigationBarButtonTap"===t)return E;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return k;if("onNavigationBarSearchInputClicked"===t)return O;var n=$[t];return n||(n=m(t)),r(t)?i(n):n}}):(Object.keys(L).forEach((function(e){J[e]=L[e]})),J.postMessage=_,J.requireNativePlugin=B,J.onNavigationBarButtonTap=E,J.onNavigationBarSearchInputChanged=M,J.onNavigationBarSearchInputConfirmed=k,J.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach((function(e){var t=$[e];t||(t=m(e)),r(e)?J[e]=i(t):J[e]=t}))),J};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,(function(){return a[e]}))}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",(function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")}));var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=JSON.parse(JSON.stringify({__message:{__page:this.__page,data:t,keep:n}})),o=this.__from;if("v8"===this.__runtime)if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else{var r=new BroadcastChannel(o);r.postMessage(a)}else{var i=e.webview.getWebviewById(o);i&&i.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"30087856",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg==",autoDecodeCharSet:!1},onLoad:function(){var e=this,t=this.data,n=t.scanType;this.autoDecodeCharSet=t.autoDecodeCharSet;var a=[];Array.isArray(n)&&n.length&&n.forEach((function(e){var t=c[e];t&&(a=a.concat(t))})),a.length||(a=a.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=a,this.onMessage((function(t){e.gallery()}))},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,(function(e,t,a,o){n.scanSuccess(e,t,a,o)}),(function(){e.nativeUI.toast("识别失败")}),this.filters,this.autoDecodeCharSet)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick((function(e){t.scan(e)}),(function(t){12!==t.code&&e.nativeUI.toast("选择失败")}),{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file,t.charSet)},scanSuccess:function(e,t,n,a){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:a||"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters,autoDecodeCharset:e.autoDecodeCharSet},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){}))},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,(function(){return a[e]}))}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file diff --git a/packages/uni-cli-shared/template/weex/__uniappscan.html b/packages/uni-cli-shared/template/weex/__uniappscan.html index 76db379747..e0f2505601 100644 --- a/packages/uni-cli-shared/template/weex/__uniappscan.html +++ b/packages/uni-cli-shared/template/weex/__uniappscan.html @@ -114,11 +114,12 @@ scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, { frameColor: '#118CE9', scanbarColor: '#118CE9' - }); - scan.onmarked = function(type, code, file) { + }, webview.__uniapp_auto_decode_char_set); + scan.onmarked = function(type, code, file, charSet) { var res = { type: type, - code: code + code: code, + charSet: charSet }; back() plus.webview.postMessageToUniNView({ diff --git a/src/core/helpers/protocol/device/scan-code.js b/src/core/helpers/protocol/device/scan-code.js new file mode 100644 index 0000000000..f76f9c8b5d --- /dev/null +++ b/src/core/helpers/protocol/device/scan-code.js @@ -0,0 +1,11 @@ +export const scanCode = { + onlyFromCamera: { + type: Boolean + }, + scanType: { + type: Array + }, + autoDecodeCharSet: { + type: Boolean + } +} diff --git a/src/platforms/app-plus/service/api/device/scan-code-webview.js b/src/platforms/app-plus/service/api/device/scan-code-webview.js index be6ffc67f7..0fd017dd96 100644 --- a/src/platforms/app-plus/service/api/device/scan-code-webview.js +++ b/src/platforms/app-plus/service/api/device/scan-code-webview.js @@ -23,7 +23,8 @@ const MESSAGE_TYPE = 'scanCode' export function scanCode ({ onlyFromCamera = false, - scanType + scanType, + autoDecodeCharSet }, callbackId) { const barcode = plus.barcode const SCAN_TYPES = { @@ -95,18 +96,19 @@ export function scanCode ({ width: '60px', onclick: function () { plus.gallery.pick(file => { - barcode.scan(file, (type, code) => { + barcode.scan(file, (type, code, path, charSet) => { if (isDark) { plus.navigator.setStatusBarStyle('isDark') } result = { type, - code + code, + charSet } webview.close('auto') }, () => { plus.nativeUI.toast('识别失败') - }, filters) + }, filters, autoDecodeCharSet) }, err => { if (err.code !== 12) { plus.nativeUI.toast('选择失败') @@ -135,6 +137,7 @@ export function scanCode ({ __uniapp_type: 'scan', __uniapp_dark: isDark, __uniapp_scan_type: filters, + __uniapp_auto_decode_char_set: autoDecodeCharSet, 'uni-app': 'none' }) const waiting = plus.nativeUI.showWaiting() @@ -148,7 +151,7 @@ export function scanCode ({ invoke(callbackId, { result: result.code, scanType: SCAN_MAPS[result.type] || '', - charSet: 'utf8', + charSet: result.charSet || 'utf8', path: '', errMsg: 'scanCode:ok' }) diff --git a/src/platforms/app-plus/service/api/device/scan-code-weex.js b/src/platforms/app-plus/service/api/device/scan-code-weex.js index e734efebf7..f850fbd3d2 100644 --- a/src/platforms/app-plus/service/api/device/scan-code-weex.js +++ b/src/platforms/app-plus/service/api/device/scan-code-weex.js @@ -23,9 +23,7 @@ export function scanCode (options, callbackId) { let result const page = showPage({ url: '__uniappscan', - data: { - scanType: options.scanType - }, + data: options, style: { animationType: options.animationType || 'pop-in', titleNView: { -- GitLab