@gm-mobile/mp-request 3.11.2-beta.0 → 3.11.3-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gm-mobile/mp-request",
3
- "version": "3.11.2-beta.0",
3
+ "version": "3.11.3-beta.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "zhongsink <zhongink@gmail.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-mobile#readme",
@@ -20,9 +20,9 @@
20
20
  "url": "https://github.com/gmfe/gm-mobile/issues"
21
21
  },
22
22
  "dependencies": {
23
- "@gm-mobile/c-tool": "^3.11.2-beta.0",
24
- "@gm-mobile/locales": "^3.11.2-beta.0",
25
- "@gm-mobile/mp": "^3.11.2-beta.0",
23
+ "@gm-mobile/c-tool": "^3.11.3-beta.0",
24
+ "@gm-mobile/locales": "^3.11.3-beta.0",
25
+ "@gm-mobile/mp": "^3.11.3-beta.0",
26
26
  "js-base64": "^3.6.0"
27
27
  },
28
28
  "peerDependencies": {
@@ -30,5 +30,5 @@
30
30
  "taro-axios": "^1.1.1",
31
31
  "weapp-cookie": "^1.4.6"
32
32
  },
33
- "gitHead": "0703860dd8377767874403df5236d56c00446c54"
33
+ "gitHead": "135f8d4d5caae0cfb013c1c0fdd72255f9704921"
34
34
  }
@@ -16,23 +16,57 @@ async function configPrivateDomain(defaultBaseUrl: string) {
16
16
  const form: any = /^\{/.test(data) ? JSON.parse(data) : {}
17
17
  switch (apiName) {
18
18
  case 'Token': {
19
- const group_id = form.group_id
20
- const group_customized_code = form.group_customized_code
21
- const {
22
- data: { groups },
23
- status,
24
- } = await axios.post(
25
- '/ceres/enterprise/EnterpriseService/ListLoginGroup',
26
- {
27
- group_id,
28
- customized_code: group_customized_code,
29
- },
30
- { baseURL: defaultBaseUrl }
31
- )
32
- if (status !== 200)
33
- return Promise.reject(new Error('ListLoginGroup 请求失败'))
34
- privateBaseUrl = get(groups, '0.private_domain_name') || ''
35
- LocalStorage.set('privateBaseUrl', privateBaseUrl)
19
+ // #region 已知目前三种登录方式:
20
+ // 1、group_id 使用企业id登录,如轻巧版
21
+ // 2、group_customized_code 使用自定义编码登录,如采购助手
22
+ // 3、wechat_app_id 使用绑定了企业的应用id登录,通过GetApplicationRelation取得group_id,如eshop
23
+ // 故以下三个一定存在一个
24
+ const group_id: string | undefined = form.group_id
25
+ const group_customized_code: string | undefined =
26
+ form.group_customized_code
27
+ const wechat_app_id: string | undefined = form.wechat_app_id
28
+ // #endregion
29
+ const getPrivateBaseUrl = async ({
30
+ group_id,
31
+ customized_code,
32
+ }: {
33
+ group_id?: string
34
+ customized_code?: string
35
+ }) => {
36
+ const {
37
+ data: { groups },
38
+ } = await axios.post(
39
+ '/ceres/enterprise/EnterpriseService/ListLoginGroup',
40
+ { group_id, customized_code },
41
+ { baseURL: defaultBaseUrl }
42
+ )
43
+ return get(groups, '0.private_domain_name') || ''
44
+ }
45
+ // 登录1和登录2
46
+ if (group_id || group_customized_code) {
47
+ privateBaseUrl =
48
+ (await getPrivateBaseUrl({
49
+ group_id,
50
+ customized_code: group_customized_code,
51
+ })) || ''
52
+ LocalStorage.set('privateBaseUrl', privateBaseUrl)
53
+ } else if (wechat_app_id) {
54
+ // 登录3
55
+ const {
56
+ data: { group_id },
57
+ } = await axios.post(
58
+ '/ceres/preference/PreferenceService/GetApplicationRelation',
59
+ {
60
+ application_key: wechat_app_id,
61
+ application_type: 1,
62
+ },
63
+ { baseURL: defaultBaseUrl }
64
+ )
65
+ privateBaseUrl = (await getPrivateBaseUrl({ group_id })) || ''
66
+ LocalStorage.set('privateBaseUrl', privateBaseUrl)
67
+ } else {
68
+ console.warn('不该来到这里')
69
+ }
36
70
  break
37
71
  }
38
72
  default: