@conecli/cone-render 0.8.24 → 0.8.25-beta.1

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/dist/api/index.ts CHANGED
@@ -1 +1 @@
1
- import { protocol, isBetaServer, isH5 } from '../config/env'
2
1
  mobileLogin: `${protocol}//conecli.com`,
2
+ import { protocol, isBetaServer, isH5 } from '../config/env'
3
3
  mobileLogin: `${protocol}//plogin.m.jd.com`,
@@ -0,0 +1 @@
1
+ export const TokenPlatform = {
2
  TYPE_JDAPP: '01',
1
3
  TYPE_WQ: '02',
2
4
  TYPE_M: '03',
3
5
  TYPE_OTHER: '-1',
4
6
  TYPE_ISVDEV: 'isvdev',
5
7
  TYPE_ISV_PACK_SAMPLE: 'isvPackSample',
6
8
  TYPE_ZXDESIGNER: 'zxdesigner',
7
9
  TYPE_JSHOPX: 'jshopx',
8
10
  TYPE_PAGES: 'pages',
@@ -0,0 +1 @@
1
+ import { isApp } from '../../utils/jm-common'
2
  return new Promise((resolve, reject) => {
1
3
  let platform: string = getPlatform()
2
4
  if (platform === TokenPlatform.TYPE_JDAPP) {
3
5
  import('./token.jd')
4
6
  .then((data) => {
5
7
  console.log('data:', data)
6
8
  resolve(data)
7
9
  })
8
10
  .catch((err) => {
9
11
  reject(err)
10
12
  })
11
13
  }
12
14
  else if (platform === TokenPlatform.TYPE_WQ) {
13
15
  import('./token.wxapp')
14
16
  .then((data) => {
15
17
  console.log('data:', data)
16
18
  resolve(data)
17
19
  })
18
20
  .catch((err) => {
19
21
  reject(err)
20
22
  })
21
23
  } else {
22
24
  import('./token')
23
25
  .then((data) => {
24
26
  console.log('data:', data)
25
27
  resolve(data)
26
28
  })
27
29
  .catch((err) => {
28
30
  reject(err)
29
31
  })
30
32
  }
31
33
  })
32
34
  return new Promise((resolve) => {
33
35
  loadTokenPromise.then((proxy: any) => {
34
36
  if (proxy?.isLogin) {
35
37
  proxy?.isLogin().then((data: boolean) => {
36
38
  resolve(data)
37
39
  })
38
40
  } else {
39
41
  resolve(false)
40
42
  }
41
43
  })
42
44
  })
43
45
  return new Promise((resolve) => {
44
46
  loadTokenPromise.then((proxy: any) => {
45
47
  if (proxy?.getIsvToken) {
46
48
  proxy?.getIsvToken().then((data: string) => {
47
49
  resolve(data)
48
50
  })
49
51
  } else {
50
52
  resolve('')
51
53
  }
52
54
  })
53
55
  })
54
56
  return new Promise((resolve) => {
55
57
  loadTokenPromise.then((proxy: any) => {
56
58
  if (proxy?.toLogin) {
57
59
  proxy?.toLogin(options)
58
60
  resolve(true)
59
61
  } else {
60
62
  resolve(false)
61
63
  }
62
64
  })
63
65
  })
64
66
  let platform = TokenPlatform.TYPE_M
65
67
  if (isApp('jd')) {
66
68
  platform = TokenPlatform.TYPE_JDAPP
67
69
  }
68
70
  else if (isApp('wx') && isApp('mp')) {
69
71
  platform = TokenPlatform.TYPE_WQ
70
72
  }
71
73
  return platform
72
74
  let platform = getPlatform()
73
75
  let source = platform
74
76
  if (platform === TokenPlatform.TYPE_M || platform === TokenPlatform.TYPE_WQ) {
75
77
  source = TokenPlatform.TYPE_JDAPP
76
78
  }
77
79
  return source
78
80
  return window?.page_data?.pageChannel || ''
@@ -0,0 +1 @@
1
+ import { TokenPlatform } from './const'
2
  return new Promise((resolve) => {
1
3
  console.log('isLogin暂未实现')
2
4
  resolve(false)
3
5
  })
4
6
  return new Promise((resolve) => {
5
7
  console.log('getIsvToken暂未实现')
6
8
  resolve('')
7
9
  })
8
10
  return new Promise((resolve) => {
9
11
  console.log('toLogin暂未实现')
10
12
  resolve(false)
11
13
  })
12
14
  return TokenPlatform.TYPE_OTHER
13
15
  return ''
14
16
  return ''
@@ -0,0 +1 @@
1
+ console.log('load token.jd')
2
  return new Promise((resolve) => {
1
3
  if (jmfe) {
2
4
  jmfe.isJDAppLogin().then(({ data }) => {
3
5
  if (data === '1') {
4
6
  resolve(true)
5
7
  } else if (data === '0') {
6
8
  resolve(false)
7
9
  }
8
10
  })
9
11
  } else {
10
12
  console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
11
13
  resolve(false)
12
14
  }
13
15
  })
14
16
  return requestIsvToken(window.location.href)
15
17
  if (jmfe) {
16
18
  jmfe.toLogin(options)
17
19
  } else {
18
20
  console.warn('jmfe对象不存在,可能没有提前动态引入jd-jssdk.js')
19
21
  }
20
22
  if (jmfe) {
21
23
  console.log('registerCode:', code)
22
24
  jmfe.registerCode(code)
23
25
  } else {
24
26
  console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
25
27
  }
26
28
  return new Promise((resolve) => {
27
29
  console.log('requestIsvToken:', url)
28
30
  if (jmfe) {
29
31
  jmfe
30
32
  .requestIsvToken(url)
31
33
  .then((result: any) => {
32
34
  console.log('requestIsvToken result:' + JSON.stringify(result))
33
35
  const { status, data, msg } = result
34
36
  if (status === '0') {
35
37
  resolve(data || '')
36
38
  } else {
37
39
  resolve('')
38
40
  }
39
41
  })
40
42
  .catch((e: any) => {
41
43
  console.log('requestIsvToken error:' + JSON.stringify(e))
42
44
  resolve('')
43
45
  })
44
46
  } else {
45
47
  console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
46
48
  resolve('')
47
49
  }
48
50
  })
@@ -0,0 +1 @@
1
+ import { domain } from '../../api'
2
  return window?.page_data?.pageChannel || ''
1
3
  return new Promise((resolve) => {
2
4
  const channel = getPageChannel()
3
5
  if (
4
6
  channel === PageChannel.TYPE_ISVDEV ||
5
7
  channel === PageChannel.TYPE_ISV_PACK_SAMPLE
6
8
  ) {
7
9
  getIsvToken().then((token) => {
8
10
  console.log('isLogin token:' + token)
9
11
  if (token) {
10
12
  resolve(true)
11
13
  } else {
12
14
  resolve(false)
13
15
  }
14
16
  })
15
17
  } else {
16
18
  const isLogin: string = `${domain.mobileLogin}/cgi-bin/ml/islogin`
17
19
  fetchJsonp(isLogin)
18
20
  .then((response: any) => {
19
21
  return response.json()
20
22
  })
21
23
  .then((data) => {
22
24
  console.log('data:', data)
23
25
  if (data?.islogin === '1') {
24
26
  resolve(true)
25
27
  } else {
26
28
  resolve(false)
27
29
  }
28
30
  })
29
31
  .catch((e) => {
30
32
  console.log('fetchJsonp cgi-bin/ml/islogin error:', e.message)
31
33
  resolve(false)
32
34
  })
33
35
  }
34
36
  })
35
37
  return new Promise((resolve) => {
36
38
  fetchGateway(
37
39
  'isvObfuscator',
38
40
  {
39
41
  url: window.location.href,
40
42
  id: 'shopisv',
41
43
  },
42
44
  {},
43
45
  )
44
46
  .then((data: any) => {
45
47
  console.log('fetchGateway isvObfuscator data:' + JSON.stringify(data))
46
48
  if (
47
49
  data?.statusCode == 200 &&
48
50
  data?.data?.errcode === 0 &&
49
51
  data?.data?.token
50
52
  ) {
51
53
  resolve(data?.data?.token)
52
54
  } else {
53
55
  resolve('')
54
56
  }
55
57
  })
56
58
  .catch((e: { message: any }) => {
57
59
  console.log('fetchGateway isvObfuscator error:' + e.message)
58
60
  resolve('')
59
61
  })
60
62
  })
61
63
  const defaultParams = {
62
64
  appid: '100',
63
65
  returnurl: window.location.href,
64
66
  }
65
67
  const params = Object.assign({}, defaultParams, options)
66
68
  params.returnurl = encodeURIComponent(params.returnurl)
67
69
  const loginUrl = `${domain.mobileLogin}/user/login.action?${serialize(
68
70
  params,
69
71
  )}`
70
72
  console.log('loginUrl:', loginUrl)
71
73
  window.location.href = loginUrl
@@ -0,0 +1 @@
1
+ import cookie from '../../utils/jm-cookie'
2
  return new Promise((resolve) => {
1
3
  const token = cookie.get('wq_auth_token')
2
4
  resolve(!!token)
3
5
  })
4
6
  return new Promise((resolve) => {
5
7
  const token = cookie.get('wq_auth_token') || ''
6
8
  resolve(token)
7
9
  })
8
10
  return new Promise((resolve) => {
9
11
  fetchGateway(
10
12
  'isvObfuscator',
11
13
  {
12
14
  url: window.location.href,
13
15
  id: 'shopisv',
14
16
  },
15
17
  { loginType: 1, loginWQBiz: WXAPP_BIZ_KEY },
16
18
  )
17
19
  .then((data: any) => {
18
20
  console.warn('fetchGateway isvObfuscator data:' + JSON.stringify(data))
19
21
  if (
20
22
  data?.statusCode == 200 &&
21
23
  data?.data?.errcode === 0 &&
22
24
  data?.data?.token
23
25
  ) {
24
26
  resolve(data?.data?.token)
25
27
  } else {
26
28
  resolve('')
27
29
  }
28
30
  })
29
31
  .catch((e: { message: any }) => {
30
32
  console.warn('fetchGateway isvObfuscator error:' + e.message)
31
33
  resolve('')
32
34
  })
33
35
  })
34
36
  const returnurl = options?.returnurl || window.location.href
35
37
  pinTokenRedirect(WXAPP_BIZ_KEY, returnurl)
36
38
  const url = `
37
39
  ${domain.wq}/pinbind/pintokenredirect?biz=${biz}&url=${encodeURIComponent(
38
40
  targetUrl,
39
41
  )}`
40
42
  console.log('pinTokenRedirect:', url)
41
43
  window.location.href = url