lazy-bee 1.0.8 → 1.1.0

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.
@@ -1,163 +1,54 @@
1
- import { Get as i } from "lazy-koala";
2
- import { inCMCC as T, SearchParams as k, HashParams as l, UrlParams as h } from "lazy-koala/leaf";
3
- import { addLeadeonScript as d } from "./addScript.js";
4
- const s = {
5
- urlToken: {
6
- // 来自url中的token, 需要转化为mcToken, 重庆本地和集团名称一样, 默认按重庆本地
7
- name: "token",
8
- // 名称
9
- position: "all",
10
- // 位置 search | hash | all
11
- type: "cq"
12
- // cq | jt
13
- },
14
- myToken: {
15
- // mytoken原商城token, 商城2.0以后需要转化为mctoken
16
- name: "mytoken",
17
- position: "all"
18
- // 位置 search | hash | all
19
- },
20
- appToken: {
21
- sourceId: ""
22
- },
23
- sessToken: {
24
- // 本地存储token, 也是登录判断标识, 各项目可能不一致
25
- name: "token",
26
- // 名称
27
- position: "session"
28
- // 位置 session | local
29
- },
30
- mcToken: {
31
- // 商城2.0以后的token, 等同sessToken, 可放url中
32
- name: "mctoken",
33
- position: "all"
34
- // 位置 search | hash | all
35
- },
36
- host: ""
37
- // 接口, 仅支持商城2.0及以上, 集团app内会自动转化
38
- };
39
- function g(n) {
40
- return new Promise((e, o) => {
41
- leadeon.checkSessionIsvalid({
42
- debug: !1,
43
- success: function(t) {
44
- String(t.status) === "1" && leadeon.getYDRZToken({
45
- debug: !1,
46
- sourceId: n,
47
- success: function(a) {
48
- e(a.token);
49
- },
50
- error: function(a) {
51
- o(a);
52
- }
53
- });
54
- },
55
- error: function(t) {
56
- o(t);
57
- }
58
- });
59
- });
1
+ import { Get as u } from "lazy-koala";
2
+ import { inCMCC as f, SearchParams as h, HashParams as v, UrlParams as g } from "lazy-koala/leaf";
3
+ import { addLeadeonScript as y } from "./addScript.js";
4
+ const i = { urlToken: { name: "token", position: "all", type: "cq" }, myToken: { name: "mytoken", position: "all" }, appToken: { sourceId: "" }, sessToken: { name: "token", position: "session" }, mcToken: { name: "mctoken", position: "all" }, host: "" };
5
+ function d(o, e) {
6
+ return e === "search" ? h(o) : e === "hash" ? v(o) : e === "all" ? g(o) : void 0;
60
7
  }
61
- function m(n, e) {
62
- if (e === "search")
63
- return k(n);
64
- if (e === "hash")
65
- return l(n);
66
- if (e === "all")
67
- return h(n);
68
- }
69
- function S(n = {}) {
70
- return Object.keys(s).forEach((e) => {
71
- s[e] instanceof Object ? n[e] = Object.assign(s[e], n[e]) : n[e] = n[e] || s[e];
72
- }), new Promise((e, o) => {
73
- if (!n.host) {
74
- o("缺少host");
75
- return;
76
- }
77
- const t = ((r) => {
78
- if (r.position === "local")
79
- return localStorage.getItem(r.name);
80
- if (r.position === "session")
81
- return sessionStorage.getItem(r.name);
82
- })(n.sessToken);
83
- if (t) {
84
- e({
85
- token: t,
86
- from: "sessToken"
87
- });
88
- return;
89
- }
90
- const a = m(n.mcToken.name, n.mcToken.position);
91
- if (a) {
92
- e({
93
- token: a,
94
- from: "mcToken"
95
- });
96
- return;
97
- }
98
- const u = m(n.urlToken.name, n.urlToken.position);
99
- if (u) {
100
- i(
101
- `${n.host}/api/user/loginReturnJsonToken`,
102
- {
103
- from: n.urlToken.type === "jt" ? "JT" : "CQAPP",
104
- data: n.urlToken.type === "jt" ? u : JSON.stringify({ ticket: u })
105
- }
106
- ).then((r) => {
107
- e({
108
- token: r.data,
109
- from: "urlToken"
110
- });
111
- }).catch((r) => {
112
- o(r);
113
- });
114
- return;
115
- }
116
- const f = m(n.myToken.name, n.myToken.position);
117
- if (f) {
118
- i(
119
- `${n.host}/api/user/entryFromThirdPartyJson`,
120
- {
121
- data: f
122
- }
123
- ).then((r) => {
124
- e({
125
- token: r.data,
126
- from: "urlToken"
8
+ function J(o = {}) {
9
+ return Object.keys(i).forEach((e) => {
10
+ o[e] = i[e] instanceof Object ? Object.assign(i[e], o[e]) : o[e] || i[e];
11
+ }), new Promise((e, t) => {
12
+ if (!o.host) return void t("缺少host");
13
+ const p = (a = o.sessToken).position === "local" ? localStorage.getItem(a.name) : a.position === "session" ? sessionStorage.getItem(a.name) : void 0;
14
+ var a;
15
+ if (p) return void e({ token: p, from: "sessToken" });
16
+ const T = d(o.mcToken.name, o.mcToken.position);
17
+ if (T) return void e({ token: T, from: "mcToken" });
18
+ const c = d(o.urlToken.name, o.urlToken.position);
19
+ if (c) return void u(`${o.host}/api/user/loginReturnJsonToken`, { from: o.urlToken.type === "jt" ? "JT" : "CQAPP", data: o.urlToken.type === "jt" ? c : JSON.stringify({ ticket: c }) }).then((n) => {
20
+ e({ token: n.data, from: "urlToken" });
21
+ }).catch((n) => {
22
+ t(n);
23
+ });
24
+ const l = d(o.myToken.name, o.myToken.position);
25
+ if (!l) return f() ? o.appToken.sourceId ? void y().then(() => {
26
+ var n;
27
+ (n = o.appToken.sourceId, new Promise((r, s) => {
28
+ leadeon.checkSessionIsvalid({ debug: !1, success: function(m) {
29
+ String(m.status) === "1" && leadeon.getYDRZToken({ debug: !1, sourceId: n, success: function(k) {
30
+ r(k.token);
31
+ }, error: function(k) {
32
+ s(k);
33
+ } });
34
+ }, error: function(m) {
35
+ s(m);
36
+ } });
37
+ })).then((r) => {
38
+ u(`${o.host}/api/user/loginReturnJsonToken`, { from: "JT", data: r }).then((s) => {
39
+ e({ token: s.data, from: "appToken" });
40
+ }).catch((s) => {
41
+ t(s);
127
42
  });
128
- }).catch((r) => {
129
- o(r);
130
- });
131
- return;
132
- }
133
- if (T()) {
134
- if (!n.appToken.sourceId) {
135
- o("缺少sourceId");
136
- return;
137
- }
138
- d().then(() => {
139
- g(n.appToken.sourceId).then((r) => {
140
- i(
141
- `${n.host}/api/user/loginReturnJsonToken`,
142
- {
143
- from: "JT",
144
- data: r
145
- }
146
- ).then((c) => {
147
- e({
148
- token: c.data,
149
- from: "appToken"
150
- });
151
- }).catch((c) => {
152
- o(c);
153
- });
154
- }).catch((r) => o(r));
155
- }).catch((r) => o(r));
156
- return;
157
- }
158
- o("未登录");
43
+ }).catch((r) => t(r));
44
+ }).catch((n) => t(n)) : void t("缺少sourceId") : void t("未登录");
45
+ u(`${o.host}/api/user/entryFromThirdPartyJson`, { data: l }).then((n) => {
46
+ e({ token: n.data, from: "urlToken" });
47
+ }).catch((n) => {
48
+ t(n);
49
+ });
159
50
  });
160
51
  }
161
52
  export {
162
- S as converToken
53
+ J as converToken
163
54
  };
@@ -1,9 +1,7 @@
1
- const e = {
2
- install() {
3
- localStorage.getItem("debug") !== "true" && (console.log = () => {
4
- });
5
- }
6
- };
1
+ const e = { install() {
2
+ localStorage.getItem("debug") !== "true" && (console.log = () => {
3
+ });
4
+ } };
7
5
  export {
8
6
  e as Debug
9
7
  };
@@ -1,30 +1,14 @@
1
- import { inCMCC as n } from "lazy-koala/leaf";
2
- import { addLeadeonScript as s, addShareScript as d } from "./addScript.js";
3
- function t({ title: e, content: r, link: o, imgUrl: a }) {
4
- n() ? s().then(() => {
5
- window.leadeon.shareMessage({
6
- debug: !1,
7
- shareChannelArray: ["0", "1", "2", "3", "4", "5", "6", "7"],
8
- title: e,
9
- content: r,
10
- link: o,
11
- imgUrl: a,
12
- success: function() {
13
- },
14
- error: function(h) {
15
- }
16
- });
17
- }) : d().then(() => {
18
- window.showCommonShareBox(
19
- [0, 1, 2, 3, 4, 5],
20
- e,
21
- r,
22
- o,
23
- a,
24
- !0
25
- );
1
+ import { inCMCC as t } from "lazy-koala/leaf";
2
+ import { addLeadeonScript as a, addShareScript as i } from "./addScript.js";
3
+ function h({ title: n, content: e, link: o, imgUrl: r }) {
4
+ t() ? a().then(() => {
5
+ window.leadeon.shareMessage({ debug: !1, shareChannelArray: ["0", "1", "2", "3", "4", "5", "6", "7"], title: n, content: e, link: o, imgUrl: r, success: function() {
6
+ }, error: function(s) {
7
+ } });
8
+ }) : i().then(() => {
9
+ window.showCommonShareBox([0, 1, 2, 3, 4, 5], n, e, o, r, !0);
26
10
  });
27
11
  }
28
12
  export {
29
- t as share
13
+ h as share
30
14
  };
@@ -1,63 +1,27 @@
1
- let n = null;
2
- class o {
3
- constructor(e = {}) {
4
- if (n)
5
- return n;
1
+ let e = null;
2
+ class s {
3
+ constructor(n = {}) {
4
+ if (e) return e;
6
5
  window.gdp = window.gdp || function() {
7
6
  (window.gdp.q = window.gdp.q || []).push(arguments);
8
- }, this.options = Object.assign({
9
- scriptName: "https://res.coc.10086.cn/res/res1/chama-h5sdk/gdp-full-3.8.6.js",
10
- generalProps: {}
11
- }, e), this.init(), n = this;
7
+ }, this.options = Object.assign({ scriptName: "https://res.coc.10086.cn/res/res1/chama-h5sdk/gdp-full-3.8.6.js", generalProps: {} }, n), this.init(), e = this;
12
8
  }
13
9
  init() {
14
10
  if (!this.options.generalProps.WT_cid) throw new Error("缺少WT_cid");
15
11
  if (!this.options.generalProps.WT_clientID) throw new Error("缺少WT_clientID");
16
12
  if (!this.options.generalProps.WT_channelid) throw new Error("WT_channelid");
17
- const e = document.createElement("script");
18
- e.src = this.options.scriptName, e.type = "text/javascript", e.async = !0, e.onload = function() {
19
- }, document.getElementsByTagName("head")[0].appendChild(e);
13
+ const n = document.createElement("script");
14
+ n.src = this.options.scriptName, n.type = "text/javascript", n.async = !0, n.onload = function() {
15
+ }, document.getElementsByTagName("head")[0].appendChild(n);
20
16
  const t = sessionStorage.getItem("debug") === "true";
21
- window._gr_ignore_local_rule = !!t, window.gdp("init", "9e4e5fa7244c6b6e", "b23efeab1461679b", {
22
- host: "jiguang.coc.10086.cn",
23
- autotrack: !!t,
24
- // 关闭无埋点事件发送,生产环境设置为关闭。
25
- compress: !t,
26
- // 开启数据压缩模式,整体报文加密,生产环境设置为开启。
27
- hashtag: !t,
28
- // 开启页面URL混淆采集,生产环境设置为开启。
29
- scheme: "https"
30
- });
31
- const s = Object.assign({
32
- WT_cid: this.options.channelid,
33
- WT_clientID: this.options.channelid,
34
- WT_loginProvince: "230",
35
- // 登录号码归属地省编码
36
- WT_loginCity: "023",
37
- // 登录号码归属地市编码
38
- WT_prov: "230",
39
- // 用户登陆省份和定位省份取最新值
40
- WT_city: "023",
41
- // 用户登陆地市和定位地市取最新值
42
- XY_member: "游客",
43
- // 超市会员等级
44
- XY_login_status: "0",
45
- // 登录状态
46
- WT_mc_ev: "210315_QYCS_230",
47
- // 营销活动码
48
- XY_environment: "production",
49
- // 环境
50
- WT_channelid: this.options.channelid
51
- // 事件编码
52
- }, this.options.generalProps);
53
- window.gdp("setGeneralProps", s);
17
+ window._gr_ignore_local_rule = !!t, window.gdp("init", "9e4e5fa7244c6b6e", "b23efeab1461679b", { host: "jiguang.coc.10086.cn", autotrack: !!t, compress: !t, hashtag: !t, scheme: "https" });
18
+ const o = Object.assign({ WT_cid: this.options.channelid, WT_clientID: this.options.channelid, WT_loginProvince: "230", WT_loginCity: "023", WT_prov: "230", WT_city: "023", XY_member: "游客", XY_login_status: "0", WT_mc_ev: "210315_QYCS_230", XY_environment: "production", WT_channelid: this.options.channelid }, this.options.generalProps);
19
+ window.gdp("setGeneralProps", o);
54
20
  }
55
21
  }
56
- const r = {
57
- init(i) {
58
- new o(i);
59
- }
60
- };
22
+ const r = { init(i) {
23
+ new s(i);
24
+ } };
61
25
  export {
62
26
  r as trackEvent
63
27
  };
package/src/index.js CHANGED
@@ -2,13 +2,15 @@ import { converToken as e } from "./components/converToken.js";
2
2
  import { share as f } from "./components/share.js";
3
3
  import { showLoginModal as p } from "./components/Login/LoginModal.js";
4
4
  import { LoginPage as a } from "./components/Login/LoginPage.js";
5
- import { PayModal as g } from "./components/PayModal/index.js";
5
+ import { Turntable as g } from "./components/Turntable/index.js";
6
+ import { PayModal as b } from "./components/PayModal/index.js";
6
7
  import { trackEvent as d } from "./components/trackEvent.js";
7
8
  import { Debug as i } from "./components/debug.js";
8
9
  export {
9
10
  i as Debug,
10
11
  a as LoginPage,
11
- g as PayModal,
12
+ b as PayModal,
13
+ g as Turntable,
12
14
  e as converToken,
13
15
  f as share,
14
16
  p as showLoginModal,