UNPKG

orcrist-wechat

Version:

for Orcrist Wechat sdk

11 lines (8 loc) 30.8 kB
/** * orcrist-wechat v2.6.7 * * Copyright (c) 2020, Boyang.Shang, yang8701@gmail.com * */ "use strict";var __assign=function(){return(__assign=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 __awaiter(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 __generator(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 commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var es6Promise=createCommonjsModule(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){w[o]=t;w[o+1]=n;o+=2;if(o===2){if(i){i(S)}else{b()}}};function a(e){i=e}function u(e){s=e}var l=typeof window!=="undefined"?window:undefined,f=l||{},h=f.MutationObserver||f.WebKitMutationObserver,d=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 g()}function _(){var e=0;var t=new h(S);var n=document.createTextNode("");t.observe(n,{characterData:true});return function(){n.data=e=++e%2}}function y(){var e=new MessageChannel;e.port1.onmessage=S;return function(){return e.port2.postMessage(0)}}function g(){var e=setTimeout;return function(){return e(S,1)}}var w=new Array(1e3);function S(){for(var e=0;e<o;e+=2){var t=w[e];var n=w[e+1];t(n);w[e]=undefined;w[e+1]=undefined}o=0}function E(){try{var e=Function("return this")().require("vertx");t=e.runOnLoop||e.runOnContext;return v()}catch(e){return g()}}var b=void 0;if(d){b=m()}else if(h){b=_()}else if(p){b=y()}else if(l===undefined&&typeof commonjsRequire==="function"){b=E()}else{b=g()}function I(e,t){var n=this;var r=new this.constructor(A);if(r[T]===undefined){Q(r)}var o=n._state;if(o){var i=arguments[o-1];s(function(){return G(o,r,i,n._result)})}else{H(n,r,e,t)}return r}function R(e){var t=this;if(e&&typeof e==="object"&&e.constructor===t){return e}var n=new t(A);W(n,e);return n}var T=Math.random().toString(36).substring(2);function A(){}var O=void 0,C=1,P=2;function j(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function M(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}function U(e,r,o){s(function(t){var n=false;var e=M(o,r,function(e){if(n){return}n=true;if(r!==e){W(t,e)}else{k(t,e)}},function(e){if(n){return}n=true;L(t,e)},"Settle: "+(t._label||" unknown promise"));if(!n&&e){n=true;L(t,e)}},e)}function D(t,e){if(e._state===C){k(t,e._result)}else if(e._state===P){L(t,e._result)}else{H(e,undefined,function(e){return W(t,e)},function(e){return L(t,e)})}}function N(e,t,n){if(t.constructor===e.constructor&&n===I&&t.constructor.resolve===R){D(e,t)}else{if(n===undefined){k(e,t)}else if(c(n)){U(e,t,n)}else{k(e,t)}}}function W(t,e){if(t===e){L(t,j())}else if(r(e)){var n=void 0;try{n=e.then}catch(e){L(t,e);return}N(t,e,n)}else{k(t,e)}}function q(e){if(e._onerror){e._onerror(e._result)}F(e)}function k(e,t){if(e._state!==O){return}e._result=t;e._state=C;if(e._subscribers.length!==0){s(F,e)}}function L(e,t){if(e._state!==O){return}e._state=P;e._result=t;s(q,e)}function H(e,t,n,r){var o=e._subscribers;var i=o.length;e._onerror=null;o[i]=t;o[i+C]=n;o[i+P]=r;if(i===0&&e._state){s(F,e)}}function F(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){G(n,r,o,i)}else{o(i)}}e._subscribers.length=0}function G(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){L(t,x());return}}else{i=r}if(t._state!==O);else if(o&&a){W(t,i)}else if(a===false){L(t,s)}else if(e===C){k(t,i)}else if(e===P){L(t,i)}}function J(n,e){try{e(function e(t){W(n,t)},function e(t){L(n,t)})}catch(e){L(n,e)}}var $=0;function B(){return $++}function Q(e){e[T]=$++;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(A);if(!this.promise[T]){Q(this.promise)}if(n(t)){this.length=t.length;this._remaining=t.length;this._result=new Array(this.length);if(this.length===0){k(this.promise,this._result)}else{this.length=this.length||0;this._enumerate(t);if(this._remaining===0){k(this.promise,this._result)}}}else{L(this.promise,K())}}e.prototype._enumerate=function e(t){for(var n=0;this._state===O&&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===R){var i=void 0;var s=void 0;var a=false;try{i=t.then}catch(e){a=true;s=e}if(i===I&&t._state!==O){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(A);if(a){L(c,s)}else{N(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===O){this._remaining--;if(t===P){L(o,r)}else{this._result[n]=r}}if(this._remaining===0){k(o,this._result)}};e.prototype._willSettleAt=function e(t,n){var r=this;H(t,undefined,function(e){return r._settledAt(C,n,e)},function(e){return r._settledAt(P,n,e)})};return e}();function X(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 z(e){var t=new this(A);return L(t,e),t}function Y(){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[T]=B();this._result=this._state=undefined;this._subscribers=[];if(A!==e){typeof e!=="function"&&Y();this instanceof t?J(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!==commonjsGlobal)e=commonjsGlobal;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=I,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=R,te.reject=function(e){var t=new this(A);return L(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!==commonjsGlobal)e=commonjsGlobal;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}()}),request_cjs=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var H="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==commonjsGlobal?commonjsGlobal:"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){h[r]=e,h[r+1]=t,2===(r+=2)&&(o?o(d):y())},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(d,1)}}var h=new Array(1e3);function d(){for(var e=0;e<r;e+=2){(0,h[e])(h[e+1]),h[e]=void 0,h[e+1]=void 0}r=0}var p,m,v,_,y=void 0;function g(e,t){var n=this,r=new this.constructor(E);void 0===r[S]&&N(r);var o,i=n._state;return i?(o=arguments[i-1],s(function(){return U(i,r,o,n._result)})):x(n,r,e,t),r}function w(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(E);return O(t,e),t}y=u?function(){return process.nextTick(d)}:a?(m=0,v=new a(d),_=document.createTextNode(""),v.observe(_,{characterData:!0}),function(){_.data=m=++m%2}):l?((p=new MessageChannel).port1.onmessage=d,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(d)}:f()}catch(e){return f()}}:f)();var S=Math.random().toString(36).substring(2);function E(){}var b=void 0,I=1,R=2;function T(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?O:P)(t,e))},function(e){n||(n=!0,j(t,e))},t._label);!n&&e&&(n=!0,j(t,e))},e)}function A(e,t,n){var r,o;t.constructor===e.constructor&&n===g&&t.constructor.resolve===w?(r=e,(o=t)._state===I?P(r,o._result):o._state===R?j(r,o._result):x(o,void 0,function(e){return O(r,e)},function(e){return j(r,e)})):void 0!==n&&c(n)?T(e,t,n):P(e,t)}function O(e,t){if(e===t)j(e,new TypeError("You cannot resolve a promise with itself"));else if(o=typeof(r=t),null===r||"object"!=o&&"function"!=o)P(e,t);else{var n=void 0;try{n=t.then}catch(t){return void j(e,t)}A(e,t,n)}var r,o}function C(e){e._onerror&&e._onerror(e._result),M(e)}function P(e,t){e._state===b&&(e._result=t,e._state=I,0!==e._subscribers.length&&s(M,e))}function j(e,t){e._state===b&&(e._state=R,e._result=t,s(C,e))}function x(e,t,n,r){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+I]=n,o[i+R]=r,0===i&&e._state&&s(M,e)}function M(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?U(n,r,o,i):o(i);e._subscribers.length=0}}function U(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 j(t,new TypeError("A promises callback cannot return that same promise."))}else i=r;t._state!==b||(o&&a?O(t,i):!1===a?j(t,s):e===I?P(t,i):e===R&&j(t,i))}var D=0;function N(e){e[S]=D++,e._state=void 0,e._result=void 0,e._subscribers=[]}var W=(q.prototype._enumerate=function(e){for(var t=0;this._state===b&&t<e.length;t++)this._eachEntry(e[t],t)},q.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===w){var o,i=void 0,s=void 0,a=!1;try{i=t.then}catch(e){a=!0,s=e}i===g&&t._state!==b?this._settledAt(t._state,e,t._result):"function"!=typeof i?(this._remaining--,this._result[e]=t):n===k?(o=new n(E),a?j(o,s):A(o,t,i),this._willSettleAt(o,e)):this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},q.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===b&&(this._remaining--,e===R?j(r,n):this._result[t]=n),0===this._remaining&&P(r,this._result)},q.prototype._willSettleAt=function(e,t){var n=this;x(e,void 0,function(e){return n._settledAt(I,t,e)},function(e){return n._settledAt(R,t,e)})},q);function q(e,t){this._instanceConstructor=e,this.promise=new e(E),this.promise[S]||N(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?P(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&P(this.promise,this._result))):j(this.promise,new Error("Array Methods must be provided an Array"))}var k=(L.prototype.catch=function(e){return this.then(null,e)},L.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)},L);function L(e){this[S]=D++,this._result=this._state=void 0,this._subscribers=[],E!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof L?function(t,e){try{e(function(e){O(t,e)},function(e){j(t,e)})}catch(e){j(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 k.prototype.then=g,k.all=function(e){return new W(this,e).promise},k.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."))})},k.resolve=w,k.reject=function(e){var t=new this(E);return j(t,e),t},k._setScheduler=function(e){o=e},k._setAsap=function(e){s=e},k._asap=s,k.polyfill=function(){var e=void 0;if(void 0!==H)e=H;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=k},k.Promise=k}()}(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"],_={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),h(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},h=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(),h=null,d=!1;if(l.open(a,s),l.onreadystatechange=function(){if(4===this.readyState&&!d)if(200<=this.status&&this.status<300){var e=this.response;n("string"==typeof e?JSON.parse(e):e)}else switch(!0){case!!_[this.status]:r({code:"".concat(this.status),data:null,message:"".concat(_[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&&(h=setInterval(function(){Date.now()-f>i.timeout&&(l.abort(),d=!0,clearInterval(h))},200))}catch(e){throw new Error(e.message)}};t.default=s,t.request=s});unwrapExports(request_cjs);var request_cjs_1=request_cjs.request;es6Promise.polyfill();var _orcristRequest_1_6_1_orcristRequest=request_cjs,w=window,reqHostName=function(){var e="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";return e},traceLog=function(e){var t="";for(var n in e.requestId="traceLog"+Date.now(),e.scene=e.scene||w.BUZZ&&w.BUZZ.scene,e)e[n]&&String(e[n])&&(t+="&"+n+"="+e[n]);t=t&&"?"+t.slice(1);var r=new Image,o=reqHostName();r.src=o+"/api/trading-order/outer/trace/"+t};function pay(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 __awaiter(this,void 0,void 0,function(){var t,n,r,o,i;return __generator(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]})})}var 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=__assign(__assign({},e),{type:"link",dataUrl:"",success:t});n.wx.onMenuShareTimeline(r),n.wx.onMenuShareAppMessage(o)},getQueryMap=function(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},Toast=function(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)}},OST_REQ=_orcristRequest_1_6_1_orcristRequest,queryWechatAppMSG=function(e){return OST_REQ.request("/api/trading-product/merchant/wechat/"+e,{method:"GET"})},queryOpenID=function(e,t){return void 0===t&&(t=""),OST_REQ.request("/api/usercenter/wechat/get_openId",{method:"POST",body:{code:e,source:"1000000000"===t?"1100110101":t}}).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"})):(Toast("系统异常,获取微信信息异常,可尝试重新进入 (CODE: 60002)",3),Promise.resolve({code:-1,data:"",type:"openID"}))}).catch(function(e){throw traceLog({log:encodeURIComponent("[ GetOpenIDService ] Error Code: 500. "+e.message)}),Toast("网络异常,请重新进入页面",3),new Error(e.message)})},queryUserInfo=function(e,t){return OST_REQ.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"),Toast("系统异常,获取微信信息异常,可尝试重新进入 (CODE: 60005)",3),Promise.resolve({code:-1,data:"",type:"userINFO"}))}).catch(function(e){throw sessionStorage.removeItem("SNSAPI_USERINFO"),traceLog({log:encodeURIComponent("[ GetOpenIDService ] Error Code: 500. "+e.message)}),Toast("网络异常,请重新进入页面",3),new Error(e.message)})},msg=function(){return __awaiter(void 0,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l,f,h;return __generator(this,function(e){switch(e.label){case 0:t=getQueryMap(),n=t.sources,r=void 0===n?"":n,t.code,o="";try{i=JSON.parse(sessionStorage.getItem("ORCRIST_WECHAT_APPMSG"))||{},o=i.APPID||""}catch(e){console.log(e)}if(o=o||sessionStorage.getItem("APPID")||"",!r&&!o)throw Toast("系统异常,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 o?[2,{APPID:o}]:[3,1];case 1:return[4,queryWechatAppMSG(r).then(function(e){return e})];case 2:return"0"===(s=e.sent()||{}).code&&s.data?(c=(a=s.data).appId,u=a.logoImg,l=a.sources,f=a.accountName,h={APPID:c||"",SOURCE:l||"",LOGO_IMG:u||"",ACCOUNT_NAME:f||""},window.WeChat=window.WeChat||{},window.WeChat.APP_MSG=h,sessionStorage.setItem("ORCRIST_WECHAT_APPMSG",JSON.stringify(h)),sessionStorage.setItem("APPID",c||""),[2,{APPID:c||""}]):(Toast("系统异常,未能正确获取系统公众号配置 (CODE: 60003)",5),[2]);case 3:return[2]}})})},WECHAT_REDIRECT_URL="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",WECHAT_REGISTER_APIS=["chooseWXPay","hideMenuItems","hideAllNonBaseMenuItem","showMenuItems","showAllNonBaseMenuItem","updateAppMessageShareData","updateTimelineShareData","onMenuShareTimeline","onMenuShareAppMessage"],WECHAT_MENU_ITEMS=["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"],REGISTER_SERVICE_URL="/api/trading-order/outer/wx/token/",authorize=function(e){var t=void 0===e?{redirectURL:location.href,isVisible:!1}:e,f=t.redirectURL,h=t.isVisible;return __awaiter(void 0,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l;return __generator(this,function(e){switch(e.label){case 0:if(t=getQueryMap(),n=t.sources,r=void 0===n?"":n,o=t.code,i=void 0===o?"":o,sessionStorage.getItem("SNSAPI_USERINFO"),s=JSON.parse(sessionStorage.getItem("SP_WX_USERINFO")||null),a=sessionStorage.getItem("SP_WX_OPENID"))return[2];if(!r&&!a)throw Toast("系统异常,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,msg()];case 1:if(c=(e.sent()||{}).APPID,!(u=void 0===c?"":c))throw Toast("系统异常,当前渠道"+r+"未能正确获取公众号ID (CODE: 60001)",5),console.error("[ ORCRIST-WECHAT SERVICE ERROR ]: 当前渠道"+r+"未能正确获取公众号ID (CODE: 60001)"),new Error("[ ORCRIST-WECHAT SERVICE ERROR ]: 当前渠道"+r+"未能正确获取公众号ID (CODE: 60001)");return i?(history.replaceState({},document.title||"",location.href.split("code")[0].slice(0,-1)),h?[2,s?Promise.resolve({code:2e4,data:s,type:"userINFO"}):queryUserInfo(i,r)]:[2,a?Promise.resolve({code:2e4,data:a,type:"openID"}):queryOpenID(i,r)]):(l=WECHAT_REDIRECT_URL.replace("APPID",u).replace("REDIRECT_URI",encodeURIComponent(f)).replace("SCOPE",h?"snsapi_userinfo":"snsapi_base").replace("STATE",""),console.info("[ ORCRIST-WECHAT SERVICE REDIRECT URL ] : "+l),h&&sessionStorage.setItem("SNSAPI_USERINFO","1"),window.location.replace(l),[2,Promise.resolve({code:-1,data:""})])}})})},authorize$1={authorize:authorize},getUser=function(){return JSON.parse(sessionStorage.getItem("SP_WX_USERINFO")||null)},explicitAuth=function(f){return __awaiter(void 0,void 0,void 0,function(){var t,n,r,o,i,s,a,c,u,l;return __generator(this,function(e){switch(e.label){case 0:return t=getQueryMap(),n=t.sources,r=void 0===n?"":n,o=t.code,i=void 0===o?"":o,[4,msg()];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"}):queryUserInfo(i,r)]):(l=WECHAT_REDIRECT_URL.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:""})])}})})},explicitAuth$1={explicitAuth:explicitAuth},API=__assign(__assign({msg:msg,pay:pay,share:share,getUser:getUser},explicitAuth$1),authorize$1),_this=void 0,w$1=window,d=document,r=_orcristRequest_1_6_1_orcristRequest;w$1.BUZZ&&(w$1.BUZZ.scene=w$1.BUZZ.scene+"_WECHAT");var register=function(l){void 0===l&&(l={});var e=encodeURIComponent(location.href.split("#")[0]);r.request(REGISTER_SERVICE_URL,{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;configWechatJSSDK(o,u,s,c,l);break;default:traceLog({log:encodeURIComponent("[ SignWechatSDKService ] Error Code: "+t)})}}).catch(function(e){throw traceLog({log:encodeURIComponent("[ SignWechatSDKService ] Error Code: 500. "+e.message)}),new Error(e.message)})},configWechatJSSDK=function(e,t,n,r,o){var i=o.hideMenu,s=void 0!==i&&i,a=o.shareOpt,c=w$1.wx,u=c.config,l=void 0===u?function(){}:u,f=c.ready,h=c.error;l({appId:e,timestamp:t,nonceStr:n,signature:r,jsApiList:WECHAT_REGISTER_APIS}),f(function(){localStorage.setItem("WX_CONFIG",JSON.stringify({appId:e,nonceStr:n,signature:r,timestamp:t})),s?(setOptionMenu("hideOptionMenu"),w$1.wx.hideMenuItems({menuList:WECHAT_MENU_ITEMS}),w$1.wx.hideAllNonBaseMenuItem()):(setOptionMenu("showMenuItems"),a&&(w$1.wx.updateAppMessageShareData(a),w$1.wx.updateTimelineShareData(a),w$1.wx.onMenuShareTimeline(a),w$1.wx.onMenuShareAppMessage(a)),w$1.wx.showAllNonBaseMenuItem())}),h(function(e){traceLog({log:encodeURIComponent(JSON.stringify(e||{}))})})},setOptionMenu=function(e){function t(){w$1.WeixinJSBridge.call(e)}e&&(void 0===w$1.WeixinJSBridge?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",t.bind(_this),!1):d.attachEvent&&(d.attachEvent("WeixinJSBridgeReady",t.bind(_this)),d.attachEvent("onWeixinJSBridgeReady",t.bind(_this))):t())},WeChat=__assign({register:register},API),isWechat=!!window.navigator.userAgent.match(/MicroMessenger/gi);isWechat||console.warn("[Orcrist Wechat SDK] 请在微信环境下访问 "),window.WeChat=WeChat,module.exports=WeChat; //# sourceMappingURL=ost.wechat.cjs.js.map