UNPKG

orcrist-wechat

Version:

for Orcrist Wechat sdk

11 lines (8 loc) 29.5 kB
/** * orcrist-wechat v2.6.7 * * Copyright (c) 2020, Boyang.Shang, yang8701@gmail.com * */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).wechat=t()}(this,function(){"use strict";var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function r(i,s,a,c){return new(a=a||Promise)(function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,r)}o((c=c.apply(i,s||[])).next())})}function m(n,r){var o,i,s,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&t[0]?i.return:t[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,t[1])).done)return s;switch(i=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=r.call(n,a)}catch(e){t=[6,e],i=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}var re="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(e,t){return e(t={exports:{}},t.exports),t.exports}function oe(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var t,n=e(function(e,t){e.exports=function(){function r(e){var t=typeof e;return e!==null&&(t==="object"||t==="function")}function c(e){return typeof e==="function"}var e=void 0;if(Array.isArray){e=Array.isArray}else{e=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}var n=e,o=0,t=void 0,i=void 0,s=function e(t,n){_[o]=t;_[o+1]=n;o+=2;if(o===2){if(i){i(S)}else{I()}}};function a(e){i=e}function u(e){s=e}var l=typeof window!=="undefined"?window:undefined,f=l||{},d=f.MutationObserver||f.WebKitMutationObserver,h=typeof self==="undefined"&&typeof process!=="undefined"&&{}.toString.call(process)==="[object process]",p=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function m(){return function(){return process.nextTick(S)}}function v(){if(typeof t!=="undefined"){return function(){t(S)}}return w()}function y(){var e=0;var t=new d(S);var n=document.createTextNode("");t.observe(n,{characterData:true});return function(){n.data=e=++e%2}}function g(){var e=new MessageChannel;e.port1.onmessage=S;return function(){return e.port2.postMessage(0)}}function w(){var e=setTimeout;return function(){return e(S,1)}}var _=new Array(1e3);function S(){for(var e=0;e<o;e+=2){var t=_[e];var n=_[e+1];t(n);_[e]=undefined;_[e+1]=undefined}o=0}function b(){try{var e=Function("return this")().require("vertx");t=e.runOnLoop||e.runOnContext;return v()}catch(e){return w()}}var I=void 0;if(h){I=m()}else if(d){I=y()}else if(p){I=g()}else if(l===undefined&&typeof oe==="function"){I=b()}else{I=w()}function E(e,t){var n=this;var r=new this.constructor(P);if(r[R]===undefined){Z(r)}var o=n._state;if(o){var i=arguments[o-1];s(function(){return J(o,r,i,n._result)})}else{L(n,r,e,t)}return r}function O(e){var t=this;if(e&&typeof e==="object"&&e.constructor===t){return e}var n=new t(P);W(n,e);return n}var R=Math.random().toString(36).substring(2);function P(){}var T=void 0,A=1,C=2;function x(){return new TypeError("You cannot resolve a promise with itself")}function D(){return new TypeError("A promises callback cannot return that same promise.")}function N(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}function j(e,r,o){s(function(t){var n=false;var e=N(o,r,function(e){if(n){return}n=true;if(r!==e){W(t,e)}else{q(t,e)}},function(e){if(n){return}n=true;F(t,e)},"Settle: "+(t._label||" unknown promise"));if(!n&&e){n=true;F(t,e)}},e)}function U(t,e){if(e._state===A){q(t,e._result)}else if(e._state===C){F(t,e._result)}else{L(e,undefined,function(e){return W(t,e)},function(e){return F(t,e)})}}function M(e,t,n){if(t.constructor===e.constructor&&n===E&&t.constructor.resolve===O){U(e,t)}else{if(n===undefined){q(e,t)}else if(c(n)){j(e,t,n)}else{q(e,t)}}}function W(t,e){if(t===e){F(t,x())}else if(r(e)){var n=void 0;try{n=e.then}catch(e){F(t,e);return}M(t,e,n)}else{q(t,e)}}function k(e){if(e._onerror){e._onerror(e._result)}H(e)}function q(e,t){if(e._state!==T){return}e._result=t;e._state=A;if(e._subscribers.length!==0){s(H,e)}}function F(e,t){if(e._state!==T){return}e._state=C;e._result=t;s(k,e)}function L(e,t,n,r){var o=e._subscribers;var i=o.length;e._onerror=null;o[i]=t;o[i+A]=n;o[i+C]=r;if(i===0&&e._state){s(H,e)}}function H(e){var t=e._subscribers;var n=e._state;if(t.length===0){return}var r=void 0,o=void 0,i=e._result;for(var s=0;s<t.length;s+=3){r=t[s];o=t[s+n];if(r){J(n,r,o,i)}else{o(i)}}e._subscribers.length=0}function J(e,t,n,r){var o=c(n),i=void 0,s=void 0,a=true;if(o){try{i=n(r)}catch(e){a=false;s=e}if(t===i){F(t,D());return}}else{i=r}if(t._state!==T);else if(o&&a){W(t,i)}else if(a===false){F(t,s)}else if(e===A){q(t,i)}else if(e===C){F(t,i)}}function B(n,e){try{e(function e(t){W(n,t)},function e(t){F(n,t)})}catch(e){F(n,e)}}var G=0;function X(){return G++}function Z(e){e[R]=G++;e._state=undefined;e._result=undefined;e._subscribers=[]}function K(){return new Error("Array Methods must be provided an Array")}var V=function(){function e(e,t){this._instanceConstructor=e;this.promise=new e(P);if(!this.promise[R]){Z(this.promise)}if(n(t)){this.length=t.length;this._remaining=t.length;this._result=new Array(this.length);if(this.length===0){q(this.promise,this._result)}else{this.length=this.length||0;this._enumerate(t);if(this._remaining===0){q(this.promise,this._result)}}}else{F(this.promise,K())}}e.prototype._enumerate=function e(t){for(var n=0;this._state===T&&n<t.length;n++){this._eachEntry(t[n],n)}};e.prototype._eachEntry=function e(t,n){var r=this._instanceConstructor;var o=r.resolve;if(o===O){var i=void 0;var s=void 0;var a=false;try{i=t.then}catch(e){a=true;s=e}if(i===E&&t._state!==T){this._settledAt(t._state,n,t._result)}else if(typeof i!=="function"){this._remaining--;this._result[n]=t}else if(r===te){var c=new r(P);if(a){F(c,s)}else{M(c,t,i)}this._willSettleAt(c,n)}else{this._willSettleAt(new r(function(e){return e(t)}),n)}}else{this._willSettleAt(o(t),n)}};e.prototype._settledAt=function e(t,n,r){var o=this.promise;if(o._state===T){this._remaining--;if(t===C){F(o,r)}else{this._result[n]=r}}if(this._remaining===0){q(o,this._result)}};e.prototype._willSettleAt=function e(t,n){var r=this;L(t,undefined,function(e){return r._settledAt(A,n,e)},function(e){return r._settledAt(C,n,e)})};return e}();function Y(e){return new V(this,e).promise}function z(o){var i=this;if(n(o))return new i(function(e,t){for(var n=o.length,r=0;r<n;r++)i.resolve(o[r]).then(e,t)});else return new i(function(e,t){return t(new TypeError("You must pass an array to race."))})}function Q(e){var t=new this(P);return F(t,e),t}function $(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function ee(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var te=function(){function t(e){this[R]=X();this._result=this._state=undefined;this._subscribers=[];if(P!==e){typeof e!=="function"&&$();this instanceof t?B(this,e):ee()}}t.prototype.catch=function e(t){return this.then(null,t)};t.prototype.finally=function e(t){var n=this;var r=n.constructor;if(c(t)){return n.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})}return n.then(t,t)};return t}();function ne(){var e=void 0;if(void 0!==re)e=re;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=te}return te.prototype.then=E,te.all=function(e){return new V(this,e).promise},te.race=function(o){var i=this;return n(o)?new i(function(e,t){for(var n=o.length,r=0;r<n;r++)i.resolve(o[r]).then(e,t)}):new i(function(e,t){return t(new TypeError("You must pass an array to race."))})},te.resolve=O,te.reject=function(e){var t=new this(P);return F(t,e),t},te._setScheduler=function(e){i=e},te._setAsap=function(e){s=e},te._asap=s,te.polyfill=function(){var e=void 0;if(void 0!==re)e=re;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=te},te.Promise=te}()}),o=e(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==re?re:"undefined"!=typeof self?self:{};var n,r=(function(e){e.exports=function(){function c(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=0,t=void 0,o=void 0,s=function(e,t){d[r]=e,d[r+1]=t,2===(r+=2)&&(o?o(h):g())},e="undefined"!=typeof window?window:void 0,i=e||{},a=i.MutationObserver||i.WebKitMutationObserver,u="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),l="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function f(){var e=setTimeout;return function(){return e(h,1)}}var d=new Array(1e3);function h(){for(var e=0;e<r;e+=2){(0,d[e])(d[e+1]),d[e]=void 0,d[e+1]=void 0}r=0}var p,m,v,y,g=void 0;function w(e,t){var n=this,r=new this.constructor(b);void 0===r[S]&&M(r);var o,i=n._state;return i?(o=arguments[i-1],s(function(){return j(i,r,o,n._result)})):D(n,r,e,t),r}function _(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(b);return T(t,e),t}g=u?function(){return process.nextTick(h)}:a?(m=0,v=new a(h),y=document.createTextNode(""),v.observe(y,{characterData:!0}),function(){y.data=m=++m%2}):l?((p=new MessageChannel).port1.onmessage=h,function(){return p.port2.postMessage(0)}):(void 0===e?function(){try{var e=Function("return this")().require("vertx");return void 0!==(t=e.runOnLoop||e.runOnContext)?function(){t(h)}:f()}catch(e){return f()}}:f)();var S=Math.random().toString(36).substring(2);function b(){}var I=void 0,E=1,O=2;function R(e,r,o){s(function(t){var n=!1,e=function(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}(o,r,function(e){n||(n=!0,(r!==e?T:C)(t,e))},function(e){n||(n=!0,x(t,e))},t._label);!n&&e&&(n=!0,x(t,e))},e)}function P(e,t,n){var r,o;t.constructor===e.constructor&&n===w&&t.constructor.resolve===_?(r=e,(o=t)._state===E?C(r,o._result):o._state===O?x(r,o._result):D(o,void 0,function(e){return T(r,e)},function(e){return x(r,e)})):void 0!==n&&c(n)?R(e,t,n):C(e,t)}function T(e,t){if(e===t)x(e,new TypeError("You cannot resolve a promise with itself"));else if(o=typeof(r=t),null===r||"object"!=o&&"function"!=o)C(e,t);else{var n=void 0;try{n=t.then}catch(t){return void x(e,t)}P(e,t,n)}var r,o}function A(e){e._onerror&&e._onerror(e._result),N(e)}function C(e,t){e._state===I&&(e._result=t,e._state=E,0!==e._subscribers.length&&s(N,e))}function x(e,t){e._state===I&&(e._state=O,e._result=t,s(A,e))}function D(e,t,n,r){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+E]=n,o[i+O]=r,0===i&&e._state&&s(N,e)}function N(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r,o=void 0,i=e._result,s=0;s<t.length;s+=3)r=t[s],o=t[s+n],r?j(n,r,o,i):o(i);e._subscribers.length=0}}function j(e,t,n,r){var o=c(n),i=void 0,s=void 0,a=!0;if(o){try{i=n(r)}catch(e){a=!1,s=e}if(t===i)return void x(t,new TypeError("A promises callback cannot return that same promise."))}else i=r;t._state!==I||(o&&a?T(t,i):!1===a?x(t,s):e===E?C(t,i):e===O&&x(t,i))}var U=0;function M(e){e[S]=U++,e._state=void 0,e._result=void 0,e._subscribers=[]}var W=(k.prototype._enumerate=function(e){for(var t=0;this._state===I&&t<e.length;t++)this._eachEntry(e[t],t)},k.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===_){var o,i=void 0,s=void 0,a=!1;try{i=t.then}catch(e){a=!0,s=e}i===w&&t._state!==I?this._settledAt(t._state,e,t._result):"function"!=typeof i?(this._remaining--,this._result[e]=t):n===q?(o=new n(b),a?x(o,s):P(o,t,i),this._willSettleAt(o,e)):this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},k.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===I&&(this._remaining--,e===O?x(r,n):this._result[t]=n),0===this._remaining&&C(r,this._result)},k.prototype._willSettleAt=function(e,t){var n=this;D(e,void 0,function(e){return n._settledAt(E,t,e)},function(e){return n._settledAt(O,t,e)})},k);function k(e,t){this._instanceConstructor=e,this.promise=new e(b),this.promise[S]||M(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?C(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&C(this.promise,this._result))):x(this.promise,new Error("Array Methods must be provided an Array"))}var q=(F.prototype.catch=function(e){return this.then(null,e)},F.prototype.finally=function(t){var n=this.constructor;return c(t)?this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){throw e})}):this.then(t,t)},F);function F(e){this[S]=U++,this._result=this._state=void 0,this._subscribers=[],b!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof F?function(t,e){try{e(function(e){T(t,e)},function(e){x(t,e)})}catch(e){x(t,e)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return q.prototype.then=w,q.all=function(e){return new W(this,e).promise},q.race=function(o){var i=this;return n(o)?new i(function(e,t){for(var n=o.length,r=0;r<n;r++)i.resolve(o[r]).then(e,t)}):new i(function(e,t){return t(new TypeError("You must pass an array to race."))})},q.resolve=_,q.reject=function(e){var t=new this(b);return x(t,e),t},q._setScheduler=function(e){o=e},q._setAsap=function(e){s=e},q._asap=s,q.polyfill=function(){var e=void 0,t=(e=L).Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=q},q.Promise=q}()}(n={exports:{}}),n.exports),v=["/api/trading-order/outer/wx/token/","/api/trading-order/outer/pagepoint/","/api/trading-order/outer/trace/"],o=["m.ytbxjj.com","ytbxjj.com","jkb.ytbxjj.com","www.ytbxjj.com"],y={401:"登录失效,请您重新登录",429:"当前下单人数较多,请您稍后再试"},i=window.location.protocol;r.polyfill();function s(c,u,e){var l=2<arguments.length&&void 0!==e?e:{timeout:0,break:!1};return function(e,t,n){if(!e||"string"!=typeof e)throw new TypeError("[RequestJS]: The parameter 'url' must be a string.");if(t&&!t.method.match(/^(get|post|put)$/gi))throw new TypeError("[RequestJS]: method '".concat(t.method,"' is not allowed."));if(n&&n.break){if("number"!=typeof n.timeout)throw new TypeError("[RequestJS]: 'handle.timeout' is ".concat(n.timeout,". For turn on the 'handle.break', the parameter 'handle.timeout' must be a valid number not a NaN."));(0===n.timeout||n.timeout<1)&&console.warn("[RequestJS]: 'handle.timeout' need set more than 0 sec, but the current timeout is only ".concat(n.timeout," sec"))}}(c,u,l),new Promise(function(e,t){var n=u.method,r=void 0===n?"GET":n,o=u.body,i=void 0===o?{}:o,s=u.headers,a=void 0===s?{}:s;c=f(c,r.toLocaleUpperCase(),i),d(e,t,{url:c,method:r.toLocaleUpperCase(),body:i,headers:a},l)}).then(function(e){if(!e||"-2"!==e.code&&"429"!=e.code)return e;throw new Error("The Server is busy")}).catch(function(e){if(console.info("[ Error Code ] ::: ".concat(e.code)),e.message.match(/busy/gi)||"429"===e.code){var t=document.querySelector(".ost_mask_default_popup")||{};throw t.parentNode&&t.parentNode.remove(),e}return console.error(e),e})}var a,c,u=(a=window.location.hostname,c=o.includes(a),"".concat(i,c?"//gateway.ytbxjj.com":"//spcare-api.medbanks-test.com")),f=function(e,t,n){switch(!0){case"GET"===t:var r="?";for(var o in n)n.hasOwnProperty(o)&&(r+=o+"="+n[o]+"&");r=r.slice(0,-1),e.match(/^http/g)?e+=r:e=u+e+r;break;case"PUT"===t||"POST"===t:e.match(/^http/g)||(e=u+e)}return e},d=function(n,r,e,t){var o=2<arguments.length&&void 0!==e?e:{url:"",method:"GET",body:{},headers:{}},i=3<arguments.length?t:void 0,s=o.url,a=o.method,c=o.body,u=o.headers;try{var l=new XMLHttpRequest,f=Date.now(),d=null,h=!1;if(l.open(a,s),l.onreadystatechange=function(){if(4===this.readyState&&!h)if(200<=this.status&&this.status<300){var e=this.response;n("string"==typeof e?JSON.parse(e):e)}else switch(!0){case!!y[this.status]:r({code:"".concat(this.status),data:null,message:"".concat(y[this.status])});break;case 500<=this.status:r({code:"O_90".concat(this.status),data:null,message:"Unexpect HTTP Request '".concat(s,"' Error Status: ").concat(this.status)});var t=!1;v.forEach(function(e){s.match(e)&&(t=!0)}),!location.origin.match(/m\.ytbxjj\.com/gi)&&t||(location.href="".concat(location.origin,"/spcare-products/products_hz/exception"));break;default:r({code:"O_90".concat(this.status),data:null,message:"Unexpect HTTP Request '".concat(s,"' Error Status: ").concat(this.status)})}},l.responseType="json",function(e,t){var n=e;for(var r in t)t[r]&&n.setRequestHeader(r,t[r]);t.hasOwnProperty("Accept")&&t.Accept||n.setRequestHeader("Accept","application/json"),t.hasOwnProperty("Content-Type")&&t["Content-Type"]||n.setRequestHeader("Content-Type","application/json;charset=utf-8"),n.setRequestHeader("requestId","REQUEST_ID_".concat(Date.now(),"_").concat(Number(1e4*Math.random()).toFixed(0))),t.token||(sessionStorage.getItem("SP_TOKEN")?n.setRequestHeader("token",sessionStorage.getItem("SP_TOKEN")):localStorage.getItem("SP_TOKEN")&&n.setRequestHeader("token",localStorage.getItem("SP_TOKEN")))}(l,u),"PUT"===a||"POST"===a)if(u["Content-Type"]&&u["Content-Type"].match(/form/gi)||u.contentType&&u.contentType.match(/form/gi)){var p=new FormData;for(var m in c)p.append(m,c[m]);l.send(p)}else c&&l.send(JSON.stringify(c));else l.send(null);i&&i.break&&i.timeout&&(d=setInterval(function(){Date.now()-f>i.timeout&&(l.abort(),h=!0,clearInterval(d))},200))}catch(e){throw new Error(e.message)}};t.default=s,t.request=s});(t=o)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")&&t.default;o.request;n.polyfill();function v(e){var t="";for(var n in e.requestId="traceLog"+Date.now(),e.scene=e.scene||a.BUZZ&&a.BUZZ.scene,e)e[n]&&String(e[n])&&(t+="&"+n+"="+e[n]);t=t&&"?"+t.slice(1);var r=new Image,o="localhost"===window.location.hostname||"spcare.medbanks-test.cn"===window.location.hostname||"spcare.medbanks-test.com"===window.location.hostname?"http://spcare-api.medbanks-test.com":"http://m.ytbxjj.com"===window.location.origin?"http://gateway.ytbxjj.com":"https://gateway.ytbxjj.com";r.src=o+"/api/trading-order/outer/trace/"+t}var s=o,a=window;function y(e){var t,n,r={},o=/[\?\&]([^=\?]+)=([^\?\&#]+)/;if(!(t=(e=e||window.location.href).match(/[\?\&][^\?\&]+=[^\?\&#]+/g)))return r;for(var i=0,s=t.length;i<s;i++)null!==(n=t[i].match(o))&&(r[n[1]]=n[2]);return r}function g(e,t){var n=document.createElement("div"),r=document.createElement("span");n.appendChild(r),n.style.opacity=0,n.style.transition="all 0.2s",n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.zIndex="9999",n.style.width="100%",n.style.height="100%",n.style.display="flex",n.style.justifyContent="center",n.style.alignItems="center",n.style.padding="50px",r.innerHTML=e,r.style.background="rgba(0, 0, 0, 0.7)",r.style.borderRadius="15px",r.style.padding="15px 15px",r.style.fontSize="26px",r.style.color="#fff",r.style.textAlign="center",setTimeout(function(){n.style.opacity=1},10),document.body.appendChild(n),setTimeout(function(){n.style.opacity=0,o(n)},1e3*t);var o=function(e){setTimeout(function(){e.parentNode.removeChild(e)},500)}}function w(e,t){return S.request("/api/wecahtmanagercenter/wechat/user/get_user_info",{method:"POST",body:{code:e,source:"1000000000"===t?"1100110101":t}}).then(function(e){var t=e.success,n=e.data;return sessionStorage.removeItem("SNSAPI_USERINFO"),t&&n?(sessionStorage.setItem("SP_WX_USERINFO",JSON.stringify(n)),sessionStorage.setItem("SP_WX_OPENID",n.openid),Promise.resolve({code:2e4,data:n,type:"userINFO"})):(sessionStorage.removeItem("SNSAPI_USERINFO"),g("系统异常,获取微信信息异常,可尝试重新进入 (CODE: 60005)",3),Promise.resolve({code:-1,data:"",type:"userINFO"}))}).catch(function(e){throw sessionStorage.removeItem("SNSAPI_USERINFO"),v({log:encodeURIComponent("[ GetOpenIDService ] Error Code: 500. "+e.message)}),g("网络异常,请重新进入页面",3),new Error(e.message)})}function _(){return r(void 0,void 0,void 0,function(){var n,r,o,i,s,a,c,u,l,f,d,h;return m(this,function(e){switch(e.label){case 0:n=y(),r=n.sources,o=void 0===r?"":r,n.code,i="";try{s=JSON.parse(sessionStorage.getItem("ORCRIST_WECHAT_APPMSG"))||{},i=s.APPID||""}catch(e){console.log(e)}if(i=i||sessionStorage.getItem("APPID")||"",!o&&!i)throw g("系统异常,URL未能正常获取渠道sources (CODE: 60000)",5),console.error("[ ORCRIST-WECHAT SERVICE ERROR ]: URL未能正常获取渠道sources (CODE: 60000)"),new Error("[ ORCRIST-WECHAT SERVICE ERROR ]: URL未能正常获取渠道sources (CODE: 60000)");return i?[2,{APPID:i}]:[3,1];case 1:return[4,(t=o,S.request("/api/trading-product/merchant/wechat/"+t,{method:"GET"}).then(function(e){return e}))];case 2:return"0"===(a=e.sent()||{}).code&&a.data?(u=(c=a.data).appId,l=c.logoImg,f=c.sources,d=c.accountName,h={APPID:u||"",SOURCE:f||"",LOGO_IMG:l||"",ACCOUNT_NAME:d||""},window.WeChat=window.WeChat||{},window.WeChat.APP_MSG=h,sessionStorage.setItem("ORCRIST_WECHAT_APPMSG",JSON.stringify(h)),sessionStorage.setItem("APPID",u||""),[2,{APPID:u||""}]):(g("系统异常,未能正确获取系统公众号配置 (CODE: 60003)",5),[2]);case 3:return[2]}var t})})}var S=s,b="https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE&connect_redirect=1#wechat_redirect",h=["chooseWXPay","hideMenuItems","hideAllNonBaseMenuItem","showMenuItems","showAllNonBaseMenuItem","updateAppMessageShareData","updateTimelineShareData","onMenuShareTimeline","onMenuShareAppMessage"],p=["menuItem:share:appMessage","menuItem:share:timeline","menuItem:share:qq","menuItem:share:weiboApp","menuItem:favorite","menuItem:share:facebook","menuItem:share:QZone","menuItem:share:email","menuItem:share:brand","menuItem:editTag","menuItem:delete","menuItem:copyUrl","menuItem:originPage","menuItem:readMode","menuItem:openWithQQBrowser","menuItem:openWithSafari"],c={authorize:function(e){var t=void 0===e?{redirectURL:location.href,isVisible:!1}:e,h=t.redirectURL,p=t.isVisible;return r(void 0,void 0,void 0,function(){var r,o,i,s,a,c,u,l,f,d;return m(this,function(e){switch(e.label){case 0:if(r=y(),o=r.sources,i=void 0===o?"":o,s=r.code,a=void 0===s?"":s,sessionStorage.getItem("SNSAPI_USERINFO"),c=JSON.parse(sessionStorage.getItem("SP_WX_USERINFO")||null),u=sessionStorage.getItem("SP_WX_OPENID"))return[2];if(!i&&!u)throw g("系统异常,URL未能正常获取渠道source (CODE: 60000)",5),console.error("[ ORCRIST-WECHAT SERVICE ERROR ]: URL未能正常获取渠道source (CODE: 60000)"),new Error("[ ORCRIST-WECHAT SERVICE ERROR ]: URL未能正常获取渠道source (CODE: 60000)");return[4,_()];case 1:if(l=(e.sent()||{}).APPID,!(f=void 0===l?"":l))throw g("系统异常,当前渠道"+i+"未能正确获取公众号ID (CODE: 60001)",5),console.error("[ ORCRIST-WECHAT SERVICE ERROR ]: 当前渠道"+i+"未能正确获取公众号ID (CODE: 60001)"),new Error("[ ORCRIST-WECHAT SERVICE ERROR ]: 当前渠道"+i+"未能正确获取公众号ID (CODE: 60001)");return a?(history.replaceState({},document.title||"",location.href.split("code")[0].slice(0,-1)),p?[2,c?Promise.resolve({code:2e4,data:c,type:"userINFO"}):w(a,i)]:[2,u?Promise.resolve({code:2e4,data:u,type:"openID"}):(t=a,void 0===(n=i)&&(n=""),S.request("/api/usercenter/wechat/get_openId",{method:"POST",body:{code:t,source:"1000000000"===n?"1100110101":n}}).then(function(e){var t=e.success,n=e.data;return t&&n?(sessionStorage.setItem("SP_WX_OPENID",n),Promise.resolve({code:2e4,data:n,type:"openID"})):(g("系统异常,获取微信信息异常,可尝试重新进入 (CODE: 60002)",3),Promise.resolve({code:-1,data:"",type:"openID"}))}).catch(function(e){throw v({log:encodeURIComponent("[ GetOpenIDService ] Error Code: 500. "+e.message)}),g("网络异常,请重新进入页面",3),new Error(e.message)}))]):(d=b.replace("APPID",f).replace("REDIRECT_URI",encodeURIComponent(h)).replace("SCOPE",p?"snsapi_userinfo":"snsapi_base").replace("STATE",""),console.info("[ ORCRIST-WECHAT SERVICE REDIRECT URL ] : "+d),p&&sessionStorage.setItem("SNSAPI_USERINFO","1"),window.location.replace(d),[2,Promise.resolve({code:-1,data:""})])}var t,n})})}},u=i(i({msg:_,pay:function(e){var s=e.payload,t=e.success,a=void 0===t?function(){}:t,n=e.error,c=void 0===n?function(e){}:n;return r(this,void 0,void 0,function(){var t,n,r,o,i;return m(this,function(e){return t=window,n=s.timestamp,r=s.nonceStr,o=s.prepayId,i=s.paySign,t.wx.chooseWXPay({timestamp:n,nonceStr:r,package:o,signType:"MD5",paySign:i,success:a,fail:function(e){throw c(e),new Error(e.message)}}),[2]})})},share:function(e,t){void 0===t&&(t=function(){});var n=window,r={title:e.title,link:e.link,imgUrl:e.imgUrl,success:t},o=i(i({},e),{type:"link",dataUrl:"",success:t});n.wx.onMenuShareTimeline(r),n.wx.onMenuShareAppMessage(o)},getUser:function(){return JSON.parse(sessionStorage.getItem("SP_WX_USERINFO")||null)}},{explicitAuth:function(f){return r(void 0,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l;return m(this,function(e){switch(e.label){case 0:return t=y(),n=t.sources,r=void 0===n?"":n,o=t.code,i=void 0===o?"":o,[4,_()];case 1:return s=(e.sent()||{}).APPID,a=void 0===s?"":s,c=sessionStorage.getItem("SNSAPI_USERINFO"),u=JSON.parse(sessionStorage.getItem("SP_WX_USERINFO")||null),i&&c?(history.replaceState({},document.title||"",location.href.split("code")[0].slice(0,-1)),[2,u?Promise.resolve({code:2e4,data:u,type:"userINFO"}):w(i,r)]):(l=b.replace("APPID",a).replace("REDIRECT_URI",encodeURIComponent(f)).replace("SCOPE","snsapi_userinfo").replace("STATE",""),sessionStorage.setItem("SNSAPI_USERINFO","1"),window.location.replace(l),[2,Promise.resolve({code:-1,data:""})])}})})}}),c),l=void 0,I=window,f=document,d=s;I.BUZZ&&(I.BUZZ.scene=I.BUZZ.scene+"_WECHAT");var E=function(e,t,n,r,o){var i=o.hideMenu,s=void 0!==i&&i,a=o.shareOpt,c=I.wx,u=c.config,l=void 0===u?function(){}:u,f=c.ready,d=c.error;l({appId:e,timestamp:t,nonceStr:n,signature:r,jsApiList:h}),f(function(){localStorage.setItem("WX_CONFIG",JSON.stringify({appId:e,nonceStr:n,signature:r,timestamp:t})),s?(O("hideOptionMenu"),I.wx.hideMenuItems({menuList:p}),I.wx.hideAllNonBaseMenuItem()):(O("showMenuItems"),a&&(I.wx.updateAppMessageShareData(a),I.wx.updateTimelineShareData(a),I.wx.onMenuShareTimeline(a),I.wx.onMenuShareAppMessage(a)),I.wx.showAllNonBaseMenuItem())}),d(function(e){v({log:encodeURIComponent(JSON.stringify(e||{}))})})},O=function(e){function t(){I.WeixinJSBridge.call(e)}e&&(void 0===I.WeixinJSBridge?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",t.bind(l),!1):f.attachEvent&&(f.attachEvent("WeixinJSBridgeReady",t.bind(l)),f.attachEvent("onWeixinJSBridgeReady",t.bind(l))):t())},R=i({register:function(l){void 0===l&&(l={});var e=encodeURIComponent(location.href.split("#")[0]);d.request("/api/trading-order/outer/wx/token/",{method:"POST",body:{url:e}}).then(function(e){var t=e.code,n=e.data;switch(t){case"0":var r=n.appid,o=void 0===r?"":r,i=n.nonceStr,s=void 0===i?"":i,a=n.sign,c=void 0===a?"":a,u=n.timestamp;E(o,u,s,c,l);break;default:v({log:encodeURIComponent("[ SignWechatSDKService ] Error Code: "+t)})}}).catch(function(e){throw v({log:encodeURIComponent("[ SignWechatSDKService ] Error Code: 500. "+e.message)}),new Error(e.message)})}},u);return!!window.navigator.userAgent.match(/MicroMessenger/gi)||console.warn("[Orcrist Wechat SDK] 请在微信环境下访问 "),window.WeChat=R}); //# sourceMappingURL=ost.wechat.umd.js.map