gc_mobile 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/main.js CHANGED
@@ -1,84 +1,86 @@
1
- import l, { reject as p } from "lodash-es";
2
- import * as r from "dingtalk-jsapi";
1
+ import f from "lodash-es";
2
+ import * as o from "dingtalk-jsapi";
3
3
  import g from "qs";
4
4
  import h from "axios";
5
- const i = window.navigator.userAgent.toLowerCase();
5
+ const s = window.navigator.userAgent.toLowerCase();
6
6
  let a = {
7
7
  code: "",
8
8
  name: "未知"
9
9
  };
10
- function v() {
10
+ function w() {
11
11
  return typeof window < "u" && typeof document < "u" && typeof document.querySelector == "function" && typeof navigator < "u" && typeof XMLHttpRequest == "function";
12
12
  }
13
- const w = [
13
+ const v = [
14
14
  {
15
15
  code: "weixin",
16
16
  name: "微信",
17
- value: /MicroMessenger/i.test(i)
17
+ value: /MicroMessenger/i.test(s)
18
18
  },
19
19
  {
20
20
  code: "wxmp",
21
21
  name: "微信小程序",
22
- value: /miniProgram/i.test(i) || window.__wxjs_environment === "miniprogram"
22
+ value: /miniProgram/i.test(s) || window.__wxjs_environment === "miniprogram"
23
23
  },
24
24
  {
25
25
  code: "dd",
26
26
  name: "钉钉",
27
- value: /DingTalk/i.test(i)
27
+ value: /DingTalk/i.test(s)
28
28
  }
29
- ], y = (e) => e.value, u = l.find(w, y);
30
- u ? a = u : v() && (a = {
29
+ ], y = (e) => e.value, m = f.find(v, y);
30
+ m ? a = m : w() && (a = {
31
31
  code: "h5",
32
32
  name: "H5"
33
33
  });
34
- const I = a, x = (e) => e == "dev" ? "https://test.ihotel.cn/gw/v1/platform-gcding/" : e == "prod" ? "https://smart.ihotel.cn/gw/v1/platform-gcding" : e || "", q = g.parse(location.search, { ignoreQueryPrefix: !0 }), s = l.get(q, "corpId"), j = async ({ appCode: e, apiPrefix: t }) => {
35
- const o = x(t);
36
- return new Promise(async (f) => {
37
- var c, d;
38
- if (s) {
39
- const { code: m } = await r.getAuthCode({
40
- corpId: s
41
- }), n = await h.post(
42
- `${o}/api/auth/queryAuthNoExternalCompatible`,
34
+ const I = a, x = (e) => e == "dev" ? "https://test.ihotel.cn/gw/v1/platform-gcding/" : e == "prod" ? "https://smart.ihotel.cn/gw/v1/platform-gcding" : e || "", q = g.parse(location.search, { ignoreQueryPrefix: !0 }), r = f.get(q, "corpId"), C = async ({ appCode: e, apiPrefix: n }) => {
35
+ const i = x(n);
36
+ return new Promise(async (c) => {
37
+ var d, u, l;
38
+ if (r) {
39
+ const { code: p } = await o.getAuthCode({
40
+ corpId: r
41
+ }), t = await h.post(
42
+ `${i}/api/auth/queryAuthNoExternalCompatible`,
43
43
  {
44
44
  appCode: e,
45
- authCode: m,
46
- corpId: s
45
+ authCode: p,
46
+ corpId: r
47
47
  }
48
48
  );
49
- n.data && ((c = n.data) == null ? void 0 : c.result) === 0 ? f({ userInfo: (d = n == null ? void 0 : n.data) == null ? void 0 : d.retVal, res: n }) : p();
49
+ t.data && ((d = t.data) == null ? void 0 : d.result) === 0 ? c({ userInfo: (u = t == null ? void 0 : t.data) == null ? void 0 : u.retVal, res: t }) : (o.alert({
50
+ title: (l = t == null ? void 0 : t.data) == null ? void 0 : l.msg
51
+ }), c({ res: t }));
50
52
  } else
51
- r.alert({
53
+ o.alert({
52
54
  title: "未配置参数:corpId"
53
55
  });
54
56
  });
55
- }, C = {
56
- login: j,
57
- dd: r
58
- }, E = () => new Promise((e) => {
57
+ }, E = {
58
+ login: C,
59
+ dd: o
60
+ }, M = () => new Promise((e) => {
59
61
  e({
60
62
  userInfo: {
61
63
  ucToken: "When you see this,it means it's under development."
62
64
  }
63
65
  });
64
- }), M = {
65
- login: E
66
- }, P = {
67
- dd: C,
68
- h5: M
66
+ }), P = {
67
+ login: M
68
+ }, _ = {
69
+ dd: E,
70
+ h5: P
69
71
  };
70
- class _ {
71
- constructor(t) {
72
- this.config = t, this.env = I, this.js = P[this.env.code], this.userInfo = null;
72
+ class $ {
73
+ constructor(n) {
74
+ this.config = n, this.env = I, this.js = _[this.env.code], this.userInfo = null;
73
75
  }
74
76
  async init() {
75
- const t = await this.js.login(this.config), { userInfo: o } = t;
76
- this.userInfo = o;
77
+ const n = await this.js.login(this.config), { userInfo: i } = n;
78
+ this.userInfo = i;
77
79
  }
78
80
  }
79
81
  async function H(e) {
80
- const t = new _(e);
81
- return await t.init(), t;
82
+ const n = new $(e);
83
+ return await n.init(), n;
82
84
  }
83
85
  export {
84
86
  H as default
package/libs/main.umd.cjs CHANGED
@@ -1 +1 @@
1
- (function(t,s){typeof exports=="object"&&typeof module<"u"?module.exports=s(require("lodash-es"),require("dingtalk-jsapi"),require("qs"),require("axios")):typeof define=="function"&&define.amd?define(["lodash-es","dingtalk-jsapi","qs","axios"],s):(t=typeof globalThis<"u"?globalThis:t||self,t.Main=s(t._,t.dd$1,t.qs,t.axios))})(this,function(t,s,m,g){"use strict";function h(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return n.default=e,Object.freeze(n)}const c=h(s),a=window.navigator.userAgent.toLowerCase();let d={code:"",name:"未知"};function v(){return typeof window<"u"&&typeof document<"u"&&typeof document.querySelector=="function"&&typeof navigator<"u"&&typeof XMLHttpRequest=="function"}const w=[{code:"weixin",name:"微信",value:/MicroMessenger/i.test(a)},{code:"wxmp",name:"微信小程序",value:/miniProgram/i.test(a)||window.__wxjs_environment==="miniprogram"},{code:"dd",name:"钉钉",value:/DingTalk/i.test(a)}],y=e=>e.value,f=t.find(w,y);f?d=f:v()&&(d={code:"h5",name:"H5"});const j=d,q=e=>e=="dev"?"https://test.ihotel.cn/gw/v1/platform-gcding/":e=="prod"?"https://smart.ihotel.cn/gw/v1/platform-gcding":e||"",x=m.parse(location.search,{ignoreQueryPrefix:!0}),u=t.get(x,"corpId"),I={dd:{login:async({appCode:e,apiPrefix:n})=>{const o=q(n);return new Promise(async r=>{var l,p;if(u){const{code:P}=await c.getAuthCode({corpId:u}),i=await g.post(`${o}/api/auth/queryAuthNoExternalCompatible`,{appCode:e,authCode:P,corpId:u});i.data&&((l=i.data)==null?void 0:l.result)===0?r({userInfo:(p=i==null?void 0:i.data)==null?void 0:p.retVal,res:i}):t.reject()}else c.alert({title:"未配置参数:corpId"})})},dd:c},h5:{login:()=>new Promise(e=>{e({userInfo:{ucToken:"When you see this,it means it's under development."}})})}};class b{constructor(n){this.config=n,this.env=j,this.js=I[this.env.code],this.userInfo=null}async init(){const n=await this.js.login(this.config),{userInfo:o}=n;this.userInfo=o}}async function M(e){const n=new b(e);return await n.init(),n}return M});
1
+ (function(n,s){typeof exports=="object"&&typeof module<"u"?module.exports=s(require("lodash-es"),require("dingtalk-jsapi"),require("qs"),require("axios")):typeof define=="function"&&define.amd?define(["lodash-es","dingtalk-jsapi","qs","axios"],s):(n=typeof globalThis<"u"?globalThis:n||self,n.Main=s(n._,n.dd$1,n.qs,n.axios))})(this,function(n,s,g,h){"use strict";function w(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const a=w(s),c=window.navigator.userAgent.toLowerCase();let d={code:"",name:"未知"};function v(){return typeof window<"u"&&typeof document<"u"&&typeof document.querySelector=="function"&&typeof navigator<"u"&&typeof XMLHttpRequest=="function"}const y=[{code:"weixin",name:"微信",value:/MicroMessenger/i.test(c)},{code:"wxmp",name:"微信小程序",value:/miniProgram/i.test(c)||window.__wxjs_environment==="miniprogram"},{code:"dd",name:"钉钉",value:/DingTalk/i.test(c)}],q=e=>e.value,f=n.find(y,q);f?d=f:v()&&(d={code:"h5",name:"H5"});const j=d,x=e=>e=="dev"?"https://test.ihotel.cn/gw/v1/platform-gcding/":e=="prod"?"https://smart.ihotel.cn/gw/v1/platform-gcding":e||"",I=g.parse(location.search,{ignoreQueryPrefix:!0}),u=n.get(I,"corpId"),b={dd:{login:async({appCode:e,apiPrefix:t})=>{const i=x(t);return new Promise(async r=>{var l,p,m;if(u){const{code:_}=await a.getAuthCode({corpId:u}),o=await h.post(`${i}/api/auth/queryAuthNoExternalCompatible`,{appCode:e,authCode:_,corpId:u});o.data&&((l=o.data)==null?void 0:l.result)===0?r({userInfo:(p=o==null?void 0:o.data)==null?void 0:p.retVal,res:o}):(a.alert({title:(m=o==null?void 0:o.data)==null?void 0:m.msg}),r({res:o}))}else a.alert({title:"未配置参数:corpId"})})},dd:a},h5:{login:()=>new Promise(e=>{e({userInfo:{ucToken:"When you see this,it means it's under development."}})})}};class M{constructor(t){this.config=t,this.env=j,this.js=b[this.env.code],this.userInfo=null}async init(){const t=await this.js.login(this.config),{userInfo:i}=t;this.userInfo=i}}async function P(e){const t=new M(e);return await t.init(),t}return P});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gc_mobile",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "example",
package/src/modules/dd.js CHANGED
@@ -24,7 +24,10 @@ export const login = async ({ appCode, apiPrefix }) => {
24
24
  if (res.data && res.data?.result === 0) {
25
25
  resolve({ userInfo: res?.data?.retVal, res });
26
26
  } else {
27
- reject();
27
+ dd.alert({
28
+ title: res?.data?.msg
29
+ });
30
+ resolve({ res });
28
31
  }
29
32
  } else {
30
33
  dd.alert({