@mpxjs/api-proxy 2.9.6 → 2.9.11-test.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.
Files changed (110) hide show
  1. package/package.json +2 -2
  2. package/src/common/js/index.js +0 -1
  3. package/src/{mini → common/js}/promisify.js +4 -2
  4. package/src/common/js/utils.js +32 -1
  5. package/src/common/js/web.js +25 -15
  6. package/src/index.js +4 -75
  7. package/src/install.js +62 -0
  8. package/src/{web → platform}/api/action-sheet/ActionSheet.js +6 -6
  9. package/src/platform/api/action-sheet/index.ali.js +28 -0
  10. package/src/platform/api/action-sheet/index.js +9 -0
  11. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  12. package/src/platform/api/add-phone-contact/index.js +9 -0
  13. package/src/platform/api/animation/index.js +9 -0
  14. package/src/platform/api/app/index.js +24 -0
  15. package/src/platform/api/audio/index.js +9 -0
  16. package/src/platform/api/base/index.js +12 -0
  17. package/src/platform/api/ble-connection/index.ali.js +17 -0
  18. package/src/platform/api/ble-connection/index.js +15 -0
  19. package/src/platform/api/canvas/index.ali.js +16 -0
  20. package/src/platform/api/canvas/index.js +15 -0
  21. package/src/platform/api/check-session/index.js +9 -0
  22. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  23. package/src/platform/api/clipboard-data/index.js +12 -0
  24. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  25. package/src/platform/api/create-intersection-observer/index.js +9 -0
  26. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  27. package/src/platform/api/create-selector-query/index.js +9 -0
  28. package/src/platform/api/device/network/index.js +15 -0
  29. package/src/platform/api/file/index.ali.js +35 -0
  30. package/src/platform/api/file/index.js +12 -0
  31. package/src/platform/api/get-user-info/index.ali.js +18 -0
  32. package/src/platform/api/get-user-info/index.js +9 -0
  33. package/src/platform/api/image/index.ali.js +36 -0
  34. package/src/platform/api/image/index.js +12 -0
  35. package/src/platform/api/login/index.ali.js +15 -0
  36. package/src/platform/api/login/index.js +9 -0
  37. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  38. package/src/platform/api/make-phone-call/index.js +9 -0
  39. package/src/{web → platform}/api/modal/Modal.js +2 -7
  40. package/src/platform/api/modal/index.ali.js +32 -0
  41. package/src/platform/api/modal/index.js +9 -0
  42. package/src/platform/api/next-tick/index.ali.js +7 -0
  43. package/src/platform/api/next-tick/index.js +9 -0
  44. package/src/platform/api/next-tick/index.tt.js +7 -0
  45. package/src/platform/api/page-scroll-to/index.js +9 -0
  46. package/src/platform/api/pull-down/index.js +12 -0
  47. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  48. package/src/platform/api/request/index.ali.js +26 -0
  49. package/src/platform/api/request/index.js +9 -0
  50. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +2 -5
  51. package/src/platform/api/request-payment/index.ali.js +45 -0
  52. package/src/platform/api/request-payment/index.js +9 -0
  53. package/src/platform/api/route/index.js +21 -0
  54. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +59 -80
  55. package/src/platform/api/scan-code/index.ali.js +17 -0
  56. package/src/platform/api/scan-code/index.js +9 -0
  57. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  58. package/src/platform/api/screen-brightness/index.js +12 -0
  59. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  60. package/src/platform/api/set-navigation-bar/index.js +12 -0
  61. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  62. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  63. package/src/platform/api/socket/index.js +9 -0
  64. package/src/platform/api/storage/index.ali.js +59 -0
  65. package/src/platform/api/storage/index.js +36 -0
  66. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  67. package/src/platform/api/system/index.ali.js +38 -0
  68. package/src/platform/api/system/index.js +12 -0
  69. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  70. package/src/platform/api/tab-bar/index.js +18 -0
  71. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  72. package/src/{web → platform}/api/toast/Toast.js +1 -3
  73. package/src/platform/api/toast/index.ali.js +39 -0
  74. package/src/platform/api/toast/index.js +18 -0
  75. package/src/platform/api/video/index.js +9 -0
  76. package/src/platform/api/window/index.js +12 -0
  77. package/src/platform/index.js +106 -0
  78. package/src/common/js/ToPromise.js +0 -25
  79. package/src/index.web.js +0 -24
  80. package/src/mini/platform/wxToAli.js +0 -667
  81. package/src/mini/platform/wxToQq.js +0 -20
  82. package/src/mini/platform/wxToTt.js +0 -9
  83. package/src/mini/transform.js +0 -71
  84. package/src/web/api/index.js +0 -68
  85. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  86. /package/src/{web → platform}/api/animation/animation.js +0 -0
  87. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  88. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  89. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  90. /package/src/{web → platform}/api/base/base64.js +0 -0
  91. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  92. /package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +0 -0
  93. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  94. /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
  95. /package/src/{web → platform}/api/create-selector-query/SelectQuery.js +0 -0
  96. /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
  97. /package/src/{web → platform}/api/device/network/getNetworkType.js +0 -0
  98. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  99. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  100. /package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +0 -0
  101. /package/src/{web/api/preview-image → platform/api/image}/Preview.js +0 -0
  102. /package/src/{web/api/preview-image/index.js → platform/api/image/index.web.js} +0 -0
  103. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  104. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  105. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  106. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  107. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  108. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  109. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  110. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
@@ -15,30 +15,24 @@ function redirectTo (options = {}) {
15
15
  webHandleFail(res, options.fail, options.complete)
16
16
  return Promise.reject(res)
17
17
  }
18
- router.__mpxAction = {
19
- type: 'redirect'
20
- }
18
+ router.__mpxAction = { type: 'redirect' }
21
19
  if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
22
- return new Promise((resolve, reject) => {
23
- router.replace(
24
- {
25
- path: options.url,
26
- query: {
27
- routeCount: ++routeCount
28
- }
29
- },
30
- () => {
31
- const res = { errMsg: 'redirectTo:ok' }
32
- webHandleSuccess(res, options.success, options.complete)
33
- resolve(res)
34
- },
35
- err => {
36
- const res = { errMsg: `redirectTo:fail ${err}` }
37
- webHandleFail(res, options.fail, options.complete)
38
- reject(res)
20
+ router.replace(
21
+ {
22
+ path: options.url,
23
+ query: {
24
+ routeCount: ++routeCount
39
25
  }
40
- )
41
- })
26
+ },
27
+ () => {
28
+ const res = { errMsg: 'redirectTo:ok' }
29
+ webHandleSuccess(res, options.success, options.complete)
30
+ },
31
+ err => {
32
+ const res = { errMsg: `redirectTo:fail ${err}` }
33
+ webHandleFail(res, options.fail, options.complete)
34
+ }
35
+ )
42
36
  }
43
37
  }
44
38
 
@@ -63,26 +57,22 @@ function navigateTo (options = {}) {
63
57
  eventChannel._addListeners(options.events)
64
58
  }
65
59
  if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
66
- return new Promise((resolve, reject) => {
67
- router.push(
68
- {
69
- path: options.url,
70
- query: {
71
- routeCount: ++routeCount
72
- }
73
- },
74
- () => {
75
- const res = { errMsg: 'navigateTo:ok', eventChannel }
76
- webHandleSuccess(res, options.success, options.complete)
77
- resolve(res)
78
- },
79
- err => {
80
- const res = { errMsg: err }
81
- webHandleFail(res, options.fail, options.complete)
82
- reject(res)
60
+ router.push(
61
+ {
62
+ path: options.url,
63
+ query: {
64
+ routeCount: ++routeCount
83
65
  }
84
- )
85
- })
66
+ },
67
+ () => {
68
+ const res = { errMsg: 'navigateTo:ok', eventChannel }
69
+ webHandleSuccess(res, options.success, options.complete)
70
+ },
71
+ err => {
72
+ const res = { errMsg: err }
73
+ webHandleFail(res, options.fail, options.complete)
74
+ }
75
+ )
86
76
  }
87
77
  }
88
78
 
@@ -105,7 +95,6 @@ function navigateBack (options = {}) {
105
95
  router.go(-delta)
106
96
  const res = { errMsg: 'navigateBack:ok' }
107
97
  webHandleSuccess(res, options.success, options.complete)
108
- return Promise.resolve(res)
109
98
  }
110
99
  }
111
100
 
@@ -129,30 +118,25 @@ function reLaunch (options = {}) {
129
118
  router.go(-delta)
130
119
  } else {
131
120
  router.__mpxAction.replaced = true
132
- return new Promise((resolve, reject) => {
133
- router.replace(
134
- {
135
- path: options.url,
136
- query: {
137
- routeCount
138
- }
139
- },
140
- () => {
141
- const res = { errMsg: 'reLaunch:ok' }
142
- webHandleSuccess(res, options.success, options.complete)
143
- resolve(res)
144
- },
145
- err => {
146
- const res = { errMsg: err }
147
- webHandleFail(res, options.fail, options.complete)
148
- !options.fail && reject(res)
121
+ router.replace(
122
+ {
123
+ path: options.url,
124
+ query: {
125
+ routeCount
149
126
  }
150
- )
151
- })
127
+ },
128
+ () => {
129
+ const res = { errMsg: 'reLaunch:ok' }
130
+ webHandleSuccess(res, options.success, options.complete)
131
+ },
132
+ err => {
133
+ const res = { errMsg: err }
134
+ webHandleFail(res, options.fail, options.complete)
135
+ }
136
+ )
152
137
  }
153
138
  const res = { errMsg: 'reLaunch:ok' }
154
139
  webHandleSuccess(res, options.success, options.complete)
155
- return Promise.resolve(res)
156
140
  }
157
141
  }
158
142
 
@@ -181,28 +165,23 @@ function switchTab (options = {}) {
181
165
  router.go(-delta)
182
166
  } else {
183
167
  router.__mpxAction.replaced = true
184
- return new Promise((resolve, reject) => {
185
- router.replace(
186
- {
187
- path: options.url
188
- },
189
- () => {
190
- const res = { errMsg: 'switchTab:ok' }
191
- webHandleSuccess(res, options.success, options.complete)
192
- resolve(res)
193
- },
194
- err => {
195
- const res = { errMsg: err }
196
- webHandleFail(res, options.fail, options.complete)
197
- !options.fail && reject(res)
198
- }
199
- )
200
- })
168
+ router.replace(
169
+ {
170
+ path: options.url
171
+ },
172
+ () => {
173
+ const res = { errMsg: 'switchTab:ok' }
174
+ webHandleSuccess(res, options.success, options.complete)
175
+ },
176
+ err => {
177
+ const res = { errMsg: err }
178
+ webHandleFail(res, options.fail, options.complete)
179
+ }
180
+ )
201
181
  }
202
182
  }
203
183
  const res = { errMsg: 'switchTab:ok' }
204
184
  webHandleSuccess(res, options.success, options.complete)
205
- return Promise.resolve(res)
206
185
  }
207
186
  }
208
187
 
@@ -0,0 +1,17 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function scanCode (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ onlyFromCamera: 'hideAlbum'
6
+ })
7
+
8
+ handleSuccess(opts, res => {
9
+ return changeOpts(res, { code: 'result' })
10
+ })
11
+
12
+ my.scan(opts)
13
+ }
14
+
15
+ export {
16
+ scanCode
17
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const scanCode = ENV_OBJ.scanCode || envError('scanCode')
6
+
7
+ export {
8
+ scanCode
9
+ }
@@ -0,0 +1,26 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function setScreenBrightness (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ value: 'brightness'
6
+ })
7
+ handleSuccess(opts, res => {
8
+ return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
9
+ })
10
+ my.setScreenBrightness(opts)
11
+ }
12
+
13
+ function getScreenBrightness (options = {}) {
14
+ const opts = changeOpts(options)
15
+
16
+ handleSuccess(opts, res => {
17
+ return changeOpts(res, { brightness: 'value' }, { errMsg: 'getScreenBrightness:ok' })
18
+ })
19
+
20
+ my.getScreenBrightness(opts)
21
+ }
22
+
23
+ export {
24
+ setScreenBrightness,
25
+ getScreenBrightness
26
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setScreenBrightness = ENV_OBJ.setScreenBrightness || envError('setScreenBrightness')
6
+
7
+ const getScreenBrightness = ENV_OBJ.getScreenBrightness || envError('getScreenBrightness')
8
+
9
+ export {
10
+ setScreenBrightness,
11
+ getScreenBrightness
12
+ }
@@ -0,0 +1,25 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function setNavigationBarTitle (options = {}) {
4
+ handleSuccess(options, res => {
5
+ return changeOpts(res, {}, { errMsg: 'setScreenBrightness:ok' })
6
+ })
7
+ if (my.canIUse('setNavigationBarTitle')) {
8
+ my.setNavigationBarTitle(options)
9
+ return
10
+ }
11
+ my.setNavigationBar(options)
12
+ }
13
+
14
+ function setNavigationBarColor (options = {}) {
15
+ if (my.canIUse('setNavigationBarColor')) {
16
+ my.setNavigationBarColor(options)
17
+ return
18
+ }
19
+ my.setNavigationBar(options)
20
+ }
21
+
22
+ export {
23
+ setNavigationBarTitle,
24
+ setNavigationBarColor
25
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavigationBarTitle')
6
+
7
+ const setNavigationBarColor = ENV_OBJ.setNavigationBarColor || envError('setNavigationBarColor')
8
+
9
+ export {
10
+ setNavigationBarTitle,
11
+ setNavigationBarColor
12
+ }
@@ -6,7 +6,6 @@ function setNavigationBarTitle (options = {}) {
6
6
  return
7
7
  }
8
8
  const { title, success, complete } = options
9
-
10
9
  if (document.title !== title) {
11
10
  document.title = title
12
11
  }
@@ -56,7 +56,7 @@ class SocketTask {
56
56
  }
57
57
  }
58
58
 
59
- close (options) {
59
+ close (options = {}) {
60
60
  const { code = 1000, reason = '', success, fail, complete } = options
61
61
  this._closeData = {
62
62
  code,
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const connectSocket = ENV_OBJ.connectSocket || envError('connectSocket')
6
+
7
+ export {
8
+ connectSocket
9
+ }
@@ -0,0 +1,59 @@
1
+ function setStorage (options) {
2
+ my.setStorage(options)
3
+ }
4
+
5
+ function setStorageSync (key, data) {
6
+ my.setStorageSync({
7
+ key,
8
+ data
9
+ })
10
+ }
11
+
12
+ function getStorage (options) {
13
+ my.getStorage(options)
14
+ }
15
+
16
+ function getStorageSync (key) {
17
+ return my.getStorageSync({
18
+ key
19
+ }).data
20
+ }
21
+
22
+ function getStorageInfo (options) {
23
+ return my.getStorageInfo(options)
24
+ }
25
+
26
+ function getStorageInfoSync () {
27
+ return my.getStorageInfoSync()
28
+ }
29
+
30
+ function removeStorage (options) {
31
+ return my.removeStorage(options)
32
+ }
33
+
34
+ function removeStorageSync (key) {
35
+ my.removeStorageSync({
36
+ key
37
+ })
38
+ }
39
+
40
+ function clearStorage (options) {
41
+ my.clearStorage(options)
42
+ }
43
+
44
+ function clearStorageSync (options) {
45
+ my.clearStorageSync(options)
46
+ }
47
+
48
+ export {
49
+ setStorage,
50
+ setStorageSync,
51
+ getStorage,
52
+ getStorageSync,
53
+ getStorageInfo,
54
+ getStorageInfoSync,
55
+ removeStorage,
56
+ removeStorageSync,
57
+ clearStorage,
58
+ clearStorageSync
59
+ }
@@ -0,0 +1,36 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setStorage = ENV_OBJ.setStorage || envError('setStorage')
6
+
7
+ const setStorageSync = ENV_OBJ.setStorageSync || envError('setStorageSync')
8
+
9
+ const getStorage = ENV_OBJ.getStorage || envError('getStorage')
10
+
11
+ const getStorageSync = ENV_OBJ.getStorageSync || envError('getStorageSync')
12
+
13
+ const getStorageInfo = ENV_OBJ.getStorageInfo || envError('getStorageInfo')
14
+
15
+ const getStorageInfoSync = ENV_OBJ.getStorageInfoSync || envError('getStorageInfoSync')
16
+
17
+ const removeStorage = ENV_OBJ.removeStorage || envError('removeStorage')
18
+
19
+ const removeStorageSync = ENV_OBJ.removeStorageSync || envError('removeStorageSync')
20
+
21
+ const clearStorage = ENV_OBJ.clearStorage || envError('clearStorage')
22
+
23
+ const clearStorageSync = ENV_OBJ.clearStorageSync || envError('clearStorageSync')
24
+
25
+ export {
26
+ setStorage,
27
+ setStorageSync,
28
+ getStorage,
29
+ getStorageSync,
30
+ getStorageInfo,
31
+ getStorageInfoSync,
32
+ removeStorage,
33
+ removeStorageSync,
34
+ clearStorage,
35
+ clearStorageSync
36
+ }
@@ -12,11 +12,9 @@ function setStorage (options = {}) {
12
12
 
13
13
  const res = { errMsg: 'setStorage:ok' }
14
14
  webHandleSuccess(res, success, complete)
15
- return Promise.resolve(res)
16
15
  } catch (err) {
17
16
  const res = { errMsg: `setStorage:fail ${err}` }
18
17
  webHandleFail(res, fail, complete)
19
- return Promise.reject(res)
20
18
  }
21
19
  }
22
20
 
@@ -46,11 +44,9 @@ function getStorage (options = {}) {
46
44
  if (result) {
47
45
  const res = { errMsg: 'getStorage:ok', data: data }
48
46
  webHandleSuccess(res, success, complete)
49
- return Promise.resolve(res)
50
47
  } else {
51
48
  const res = { errMsg: 'getStorage:fail', data: null }
52
49
  webHandleFail(res, fail, complete)
53
- return Promise.reject(res)
54
50
  }
55
51
  }
56
52
 
@@ -91,11 +87,9 @@ function getStorageInfo (options = {}) {
91
87
 
92
88
  const res = Object.assign({}, { errMsg: 'getStorageInfo:ok' }, info)
93
89
  webHandleSuccess(res, success, complete)
94
- return Promise.resolve(res)
95
90
  } catch (err) {
96
91
  const res = { errMsg: `getStorageInfo:fail ${err}` }
97
92
  webHandleFail(res, fail, complete)
98
- return Promise.reject(res)
99
93
  }
100
94
  }
101
95
 
@@ -123,11 +117,9 @@ function removeStorage (options = { key: '' }) {
123
117
 
124
118
  const res = { errMsg: 'removeStorage:ok' }
125
119
  webHandleSuccess(res, success, complete)
126
- return Promise.resolve(res)
127
120
  } catch (err) {
128
121
  const res = { errMsg: `removeStorage:fail ${err}` }
129
122
  webHandleFail(res, fail, complete)
130
- return Promise.reject(res)
131
123
  }
132
124
  }
133
125
 
@@ -151,11 +143,9 @@ function clearStorage (options = {}) {
151
143
 
152
144
  const res = { errMsg: 'clearStorage:ok' }
153
145
  webHandleSuccess(res, success, complete)
154
- return Promise.resolve(res)
155
146
  } catch (err) {
156
147
  const res = { errMsg: `clearStorage:fail ${err}` }
157
148
  webHandleFail(res, fail, complete)
158
- return Promise.reject(res)
159
149
  }
160
150
  }
161
151
 
@@ -0,0 +1,38 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function getSystemInfo (options = {}) {
4
+ const opts = changeOpts(options)
5
+
6
+ handleSuccess(opts, res => {
7
+ res.system = `${res.platform} ${res.system}`
8
+ res.SDKVersion = my.SDKVersion
9
+
10
+ // 支付宝 windowHeight 可能为 0
11
+ if (!res.windowHeight) {
12
+ res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
13
+ }
14
+
15
+ return res
16
+ })
17
+
18
+ my.getSystemInfo(opts)
19
+ }
20
+
21
+ function getSystemInfoSync () {
22
+ const res = my.getSystemInfoSync() || {}
23
+
24
+ res.system = `${res.platform} ${res.system}`
25
+ res.SDKVersion = my.SDKVersion
26
+
27
+ // 支付宝 windowHeight 可能为 0
28
+ if (!res.windowHeight) {
29
+ res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
30
+ }
31
+
32
+ return res
33
+ }
34
+
35
+ export {
36
+ getSystemInfo,
37
+ getSystemInfoSync
38
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const getSystemInfo = ENV_OBJ.getSystemInfo || envError('getSystemInfo')
6
+
7
+ const getSystemInfoSync = ENV_OBJ.getSystemInfoSync || envError('getSystemInfoSync')
8
+
9
+ export {
10
+ getSystemInfo,
11
+ getSystemInfoSync
12
+ }
@@ -77,7 +77,6 @@ function getSystemInfo (options = {}) {
77
77
  const info = getSystemInfoSync()
78
78
  const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info)
79
79
  webHandleSuccess(res, options.success, options.complete)
80
- return Promise.resolve(res)
81
80
  }
82
81
 
83
82
  export {
@@ -0,0 +1,18 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setTabBarItem = ENV_OBJ.setTabBarItem || envError('setTabBarItem')
6
+
7
+ const setTabBarStyle = ENV_OBJ.setTabBarStyle || envError('setTabBarStyle')
8
+
9
+ const showTabBar = ENV_OBJ.showTabBar || envError('showTabBar')
10
+
11
+ const hideTabBar = ENV_OBJ.hideTabBar || envError('hideTabBar')
12
+
13
+ export {
14
+ setTabBarItem,
15
+ setTabBarStyle,
16
+ showTabBar,
17
+ hideTabBar
18
+ }
@@ -21,10 +21,8 @@ function setTabBarStyle (options = {}) {
21
21
 
22
22
  if (resolved) {
23
23
  webHandleSuccess(resolved, options.success, options.complete)
24
- return Promise.resolve(resolved)
25
24
  }
26
25
  webHandleFail(rejected, options.fail, options.complete)
27
- return Promise.reject(rejected)
28
26
  }
29
27
 
30
28
  function setTabBarItem (options = {}) {
@@ -52,10 +50,8 @@ function setTabBarItem (options = {}) {
52
50
 
53
51
  if (resolved) {
54
52
  webHandleSuccess(resolved, options.success, options.complete)
55
- return Promise.resolve(resolved)
56
53
  }
57
54
  webHandleFail(rejected, options.fail, options.complete)
58
- return Promise.reject(rejected)
59
55
  }
60
56
 
61
57
  function showTabBar (options = {}) {
@@ -70,10 +66,8 @@ function showTabBar (options = {}) {
70
66
 
71
67
  if (resolved) {
72
68
  webHandleSuccess(resolved, options.success, options.complete)
73
- return Promise.resolve(resolved)
74
69
  }
75
70
  webHandleFail(rejected, options.fail, options.complete)
76
- return Promise.reject(rejected)
77
71
  }
78
72
 
79
73
  function hideTabBar (options = {}) {
@@ -88,10 +82,8 @@ function hideTabBar (options = {}) {
88
82
 
89
83
  if (resolved) {
90
84
  webHandleSuccess(resolved, options.success, options.complete)
91
- return Promise.resolve(resolved)
92
85
  }
93
86
  webHandleFail(rejected, options.fail, options.complete)
94
- return Promise.reject(rejected)
95
87
  }
96
88
 
97
89
  export {
@@ -76,7 +76,6 @@ export default class Toast {
76
76
 
77
77
  const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok'
78
78
  webHandleSuccess({ errMsg }, opts.success, opts.complete)
79
- return Promise.resolve({ errMsg })
80
79
  }
81
80
 
82
81
  hide (options = {}, type) {
@@ -90,11 +89,10 @@ export default class Toast {
90
89
  clearTimeout(this.hideTimer)
91
90
  this.hideTimer = null
92
91
  }
93
-
94
92
  this.hideTimer = setTimeout(() => {
95
93
  this.toast.classList.remove('show')
96
94
  this.toast.remove() // hide 则卸载
97
95
  }, duration)
98
- return Promise.resolve({ errMsg })
96
+ // return Promise.resolve({ errMsg }) todo 验证一下
99
97
  }
100
98
  }
@@ -0,0 +1,39 @@
1
+ import { changeOpts, warn } from '../../../common/js'
2
+
3
+ const TIPS_NAME = '支付宝环境 mpx'
4
+
5
+ function showToast (options = {}) {
6
+ const opts = changeOpts(options, {
7
+ title: 'content',
8
+ icon: 'type'
9
+ })
10
+ my.showToast(opts)
11
+ }
12
+
13
+ function hideToast (options = {}) {
14
+ if (options.success || options.fail || options.complete) {
15
+ warn(`${TIPS_NAME}.hideToast 不支持 success/fail/complete 参数`)
16
+ }
17
+ my.hideToast(options)
18
+ }
19
+
20
+ function showLoading (options = {}) {
21
+ const opts = changeOpts(options, {
22
+ title: 'content'
23
+ })
24
+ my.showLoading(opts)
25
+ }
26
+
27
+ function hideLoading (options = {}) {
28
+ if (options.success || options.fail || options.complete) {
29
+ warn(`${TIPS_NAME}.hideLoading 不支持 success/fail/complete 参数`)
30
+ }
31
+ my.hideLoading(options)
32
+ }
33
+
34
+ export {
35
+ showToast,
36
+ hideToast,
37
+ showLoading,
38
+ hideLoading
39
+ }
@@ -0,0 +1,18 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const showToast = ENV_OBJ.showToast || envError('showToast')
6
+
7
+ const hideToast = ENV_OBJ.hideToast || envError('hideToast')
8
+
9
+ const showLoading = ENV_OBJ.showLoading || envError('showLoading')
10
+
11
+ const hideLoading = ENV_OBJ.hideLoading || envError('hideLoading')
12
+
13
+ export {
14
+ showToast,
15
+ hideToast,
16
+ showLoading,
17
+ hideLoading
18
+ }