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 +41 -39
- package/libs/main.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/modules/dd.js +4 -1
package/libs/main.js
CHANGED
|
@@ -1,84 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
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
|
|
5
|
+
const s = window.navigator.userAgent.toLowerCase();
|
|
6
6
|
let a = {
|
|
7
7
|
code: "",
|
|
8
8
|
name: "未知"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
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
|
|
13
|
+
const v = [
|
|
14
14
|
{
|
|
15
15
|
code: "weixin",
|
|
16
16
|
name: "微信",
|
|
17
|
-
value: /MicroMessenger/i.test(
|
|
17
|
+
value: /MicroMessenger/i.test(s)
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
code: "wxmp",
|
|
21
21
|
name: "微信小程序",
|
|
22
|
-
value: /miniProgram/i.test(
|
|
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(
|
|
27
|
+
value: /DingTalk/i.test(s)
|
|
28
28
|
}
|
|
29
|
-
], y = (e) => e.value,
|
|
30
|
-
|
|
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 }),
|
|
35
|
-
const
|
|
36
|
-
return new Promise(async (
|
|
37
|
-
var
|
|
38
|
-
if (
|
|
39
|
-
const { code:
|
|
40
|
-
corpId:
|
|
41
|
-
}),
|
|
42
|
-
`${
|
|
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:
|
|
46
|
-
corpId:
|
|
45
|
+
authCode: p,
|
|
46
|
+
corpId: r
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
|
-
|
|
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
|
-
|
|
53
|
+
o.alert({
|
|
52
54
|
title: "未配置参数:corpId"
|
|
53
55
|
});
|
|
54
56
|
});
|
|
55
|
-
},
|
|
56
|
-
login:
|
|
57
|
-
dd:
|
|
58
|
-
},
|
|
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
|
-
}),
|
|
65
|
-
login:
|
|
66
|
-
},
|
|
67
|
-
dd:
|
|
68
|
-
h5:
|
|
66
|
+
}), P = {
|
|
67
|
+
login: M
|
|
68
|
+
}, _ = {
|
|
69
|
+
dd: E,
|
|
70
|
+
h5: P
|
|
69
71
|
};
|
|
70
|
-
class
|
|
71
|
-
constructor(
|
|
72
|
-
this.config =
|
|
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
|
|
76
|
-
this.userInfo =
|
|
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
|
|
81
|
-
return await
|
|
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(
|
|
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
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
|
-
|
|
27
|
+
dd.alert({
|
|
28
|
+
title: res?.data?.msg
|
|
29
|
+
});
|
|
30
|
+
resolve({ res });
|
|
28
31
|
}
|
|
29
32
|
} else {
|
|
30
33
|
dd.alert({
|