@mpxjs/api-proxy 2.8.39 → 2.8.40-test.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.
Files changed (111) 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 +16 -0
  6. package/src/common/stylus/Preview.styl +29 -0
  7. package/src/index.js +4 -75
  8. package/src/install.js +62 -0
  9. package/src/{web → platform}/api/action-sheet/ActionSheet.js +2 -7
  10. package/src/platform/api/action-sheet/index.ali.js +28 -0
  11. package/src/platform/api/action-sheet/index.js +9 -0
  12. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  13. package/src/platform/api/add-phone-contact/index.js +9 -0
  14. package/src/platform/api/animation/index.js +9 -0
  15. package/src/platform/api/app/index.js +24 -0
  16. package/src/platform/api/audio/index.js +9 -0
  17. package/src/platform/api/base/index.js +12 -0
  18. package/src/platform/api/ble-connection/index.ali.js +17 -0
  19. package/src/platform/api/ble-connection/index.js +15 -0
  20. package/src/platform/api/canvas/index.ali.js +16 -0
  21. package/src/platform/api/canvas/index.js +15 -0
  22. package/src/platform/api/check-session/index.js +9 -0
  23. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  24. package/src/platform/api/clipboard-data/index.js +12 -0
  25. package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +2 -10
  26. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  27. package/src/platform/api/create-intersection-observer/index.js +9 -0
  28. package/src/{web → platform}/api/create-selector-query/SelectQuery.js +11 -3
  29. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  30. package/src/platform/api/create-selector-query/index.js +9 -0
  31. package/src/platform/api/device/network/index.js +15 -0
  32. package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +13 -14
  33. package/src/platform/api/file/index.ali.js +35 -0
  34. package/src/platform/api/file/index.js +12 -0
  35. package/src/platform/api/get-user-info/index.ali.js +18 -0
  36. package/src/platform/api/get-user-info/index.js +9 -0
  37. package/src/platform/api/image/Preview.js +80 -0
  38. package/src/platform/api/image/index.ali.js +36 -0
  39. package/src/platform/api/image/index.js +12 -0
  40. package/src/platform/api/image/index.web.js +12 -0
  41. package/src/platform/api/login/index.ali.js +15 -0
  42. package/src/platform/api/login/index.js +9 -0
  43. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  44. package/src/platform/api/make-phone-call/index.js +9 -0
  45. package/src/{web → platform}/api/modal/Modal.js +2 -7
  46. package/src/platform/api/modal/index.ali.js +32 -0
  47. package/src/platform/api/modal/index.js +9 -0
  48. package/src/platform/api/next-tick/index.ali.js +7 -0
  49. package/src/platform/api/next-tick/index.js +9 -0
  50. package/src/platform/api/next-tick/index.tt.js +7 -0
  51. package/src/platform/api/page-scroll-to/index.js +9 -0
  52. package/src/platform/api/pull-down/index.js +12 -0
  53. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  54. package/src/platform/api/request/index.ali.js +26 -0
  55. package/src/platform/api/request/index.js +9 -0
  56. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +14 -7
  57. package/src/platform/api/request-payment/index.ali.js +45 -0
  58. package/src/platform/api/request-payment/index.js +9 -0
  59. package/src/platform/api/route/index.js +21 -0
  60. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +71 -78
  61. package/src/platform/api/scan-code/index.ali.js +17 -0
  62. package/src/platform/api/scan-code/index.js +9 -0
  63. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  64. package/src/platform/api/screen-brightness/index.js +12 -0
  65. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  66. package/src/platform/api/set-navigation-bar/index.js +12 -0
  67. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  68. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  69. package/src/platform/api/socket/index.js +9 -0
  70. package/src/platform/api/storage/index.ali.js +59 -0
  71. package/src/platform/api/storage/index.js +36 -0
  72. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  73. package/src/platform/api/system/index.ali.js +38 -0
  74. package/src/platform/api/system/index.js +12 -0
  75. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  76. package/src/platform/api/tab-bar/index.js +18 -0
  77. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  78. package/src/{web → platform}/api/toast/Toast.js +1 -10
  79. package/src/platform/api/toast/index.ali.js +39 -0
  80. package/src/platform/api/toast/index.js +18 -0
  81. package/src/platform/api/video/index.js +9 -0
  82. package/src/platform/api/window/index.js +12 -0
  83. package/src/platform/index.js +106 -0
  84. package/src/web/api/index.js +3 -0
  85. package/src/common/js/ToPromise.js +0 -25
  86. package/src/index.web.js +0 -27
  87. package/src/mini/platform/wxToAli.js +0 -667
  88. package/src/mini/platform/wxToQq.js +0 -20
  89. package/src/mini/platform/wxToTt.js +0 -9
  90. package/src/mini/transform.js +0 -71
  91. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  92. /package/src/{web → platform}/api/animation/animation.js +0 -0
  93. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  94. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  95. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  96. /package/src/{web → platform}/api/base/base64.js +0 -0
  97. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  98. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  99. /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
  100. /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
  101. /package/src/{web → platform}/api/device/network/getNetworkType.js +0 -0
  102. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  103. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  104. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  105. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  106. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  107. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  108. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  109. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  110. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  111. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
@@ -0,0 +1,45 @@
1
+ import { changeOpts, error, noop } from '../../../common/js'
2
+
3
+ const TIPS_NAME = '支付宝环境 mpx'
4
+
5
+ function requestPayment (options = {}) {
6
+ if (!options.tradeNO) {
7
+ error(`请在支付函数 ${TIPS_NAME}.requestPayment 中添加 tradeNO 参数用于支付宝支付`)
8
+ }
9
+
10
+ const opts = changeOpts(options, {
11
+ timeStamp: '',
12
+ nonceStr: '',
13
+ package: '',
14
+ signType: '',
15
+ paySign: ''
16
+ })
17
+
18
+ const cacheSuc = opts.success || noop
19
+ const cacheFail = opts.fail || noop
20
+
21
+ // 抹平用微信的 complete
22
+ if (typeof opts.complete === 'function') {
23
+ const cacheComplete = opts.complete
24
+ opts.complete = function (res) {
25
+ if (+res.resultCode === 9000) {
26
+ res.errMsg = 'requestPayment:ok'
27
+ cacheComplete.call(this, res)
28
+ }
29
+ }
30
+ }
31
+
32
+ opts.success = function (res) {
33
+ if (+res.resultCode === 9000) {
34
+ cacheSuc.call(this, res)
35
+ } else {
36
+ cacheFail.call(this, res)
37
+ }
38
+ }
39
+
40
+ my.tradePay(opts)
41
+ }
42
+
43
+ export {
44
+ requestPayment
45
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const requestPayment = ENV_OBJ.requestPayment || envError('requestPayment')
6
+
7
+ export {
8
+ requestPayment
9
+ }
@@ -0,0 +1,21 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const redirectTo = ENV_OBJ.redirectTo || envError('redirectTo')
6
+
7
+ const navigateTo = ENV_OBJ.navigateTo || envError('navigateTo')
8
+
9
+ const navigateBack = ENV_OBJ.navigateBack || envError('navigateBack')
10
+
11
+ const reLaunch = ENV_OBJ.reLaunch || envError('reLaunch')
12
+
13
+ const switchTab = ENV_OBJ.switchTab || envError('switchTab')
14
+
15
+ export {
16
+ redirectTo,
17
+ navigateTo,
18
+ navigateBack,
19
+ reLaunch,
20
+ switchTab
21
+ }
@@ -1,6 +1,8 @@
1
1
  import { webHandleSuccess, webHandleFail, isTabBarPage } from '../../../common/js'
2
2
  import { EventChannel } from '../event-channel'
3
3
 
4
+ let routeCount = 0
5
+
4
6
  function redirectTo (options = {}) {
5
7
  const router = global.__mpxRouter
6
8
  if (router) {
@@ -10,23 +12,23 @@ function redirectTo (options = {}) {
10
12
  return Promise.reject(res)
11
13
  }
12
14
  router.__mpxAction = { type: 'redirect' }
13
- return new Promise((resolve, reject) => {
14
- router.replace(
15
- {
16
- path: options.url
17
- },
18
- () => {
19
- const res = { errMsg: 'redirectTo:ok' }
20
- webHandleSuccess(res, options.success, options.complete)
21
- resolve(res)
22
- },
23
- err => {
24
- const res = { errMsg: `redirectTo:fail ${err}` }
25
- webHandleFail(res, options.fail, options.complete)
26
- reject(res)
15
+ if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
16
+ router.replace(
17
+ {
18
+ path: options.url,
19
+ query: {
20
+ routeCount: ++routeCount
27
21
  }
28
- )
29
- })
22
+ },
23
+ () => {
24
+ const res = { errMsg: 'redirectTo:ok' }
25
+ webHandleSuccess(res, options.success, options.complete)
26
+ },
27
+ err => {
28
+ const res = { errMsg: `redirectTo:fail ${err}` }
29
+ webHandleFail(res, options.fail, options.complete)
30
+ }
31
+ )
30
32
  }
31
33
  }
32
34
 
@@ -46,30 +48,34 @@ function navigateTo (options = {}) {
46
48
  if (options.events) {
47
49
  eventChannel._addListeners(options.events)
48
50
  }
49
- return new Promise((resolve, reject) => {
50
- router.push(
51
- {
52
- path: options.url
53
- },
54
- () => {
55
- const res = { errMsg: 'navigateTo:ok', eventChannel }
56
- webHandleSuccess(res, options.success, options.complete)
57
- resolve(res)
58
- },
59
- err => {
60
- const res = { errMsg: err }
61
- webHandleFail(res, options.fail, options.complete)
62
- reject(res)
51
+ if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
52
+ router.push(
53
+ {
54
+ path: options.url,
55
+ query: {
56
+ routeCount: ++routeCount
63
57
  }
64
- )
65
- })
58
+ },
59
+ () => {
60
+ const res = { errMsg: 'navigateTo:ok', eventChannel }
61
+ webHandleSuccess(res, options.success, options.complete)
62
+ },
63
+ err => {
64
+ const res = { errMsg: err }
65
+ webHandleFail(res, options.fail, options.complete)
66
+ }
67
+ )
66
68
  }
67
69
  }
68
70
 
69
71
  function navigateBack (options = {}) {
70
72
  const router = global.__mpxRouter
71
73
  if (router) {
72
- const delta = options.delta || 1
74
+ let delta = options.delta || 1
75
+ const stackLength = router.stack.length
76
+ if (stackLength > 1 && delta >= stackLength) {
77
+ delta = stackLength - 1
78
+ }
73
79
  router.__mpxAction = {
74
80
  type: 'back',
75
81
  delta
@@ -77,52 +83,44 @@ function navigateBack (options = {}) {
77
83
  router.go(-delta)
78
84
  const res = { errMsg: 'navigateBack:ok' }
79
85
  webHandleSuccess(res, options.success, options.complete)
80
- return Promise.resolve(res)
81
86
  }
82
87
  }
83
88
 
84
- let reLaunchCount = 0
85
-
86
89
  function reLaunch (options = {}) {
87
90
  const router = global.__mpxRouter
88
91
  if (router) {
89
- if (reLaunchCount === 0 && router.currentRoute.query.reLaunchCount) reLaunchCount = router.currentRoute.query.reLaunchCount
90
- const delta = router.stack.length - 1
92
+ if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
91
93
  router.__mpxAction = {
92
94
  type: 'reLaunch',
93
95
  path: options.url,
94
- reLaunchCount: ++reLaunchCount,
96
+ routeCount: ++routeCount,
95
97
  replaced: false
96
98
  }
99
+ const delta = router.stack.length - 1
97
100
  // 在需要操作后退时,先操作后退,在beforeEach中基于当前action通过next()进行replace操作,避免部分浏览器的表现不一致
98
101
  if (delta > 0) {
99
102
  router.go(-delta)
100
103
  } else {
101
104
  router.__mpxAction.replaced = true
102
- return new Promise((resolve, reject) => {
103
- router.replace(
104
- {
105
- path: options.url,
106
- query: {
107
- reLaunchCount
108
- }
109
- },
110
- () => {
111
- const res = { errMsg: 'reLaunch:ok' }
112
- webHandleSuccess(res, options.success, options.complete)
113
- resolve(res)
114
- },
115
- err => {
116
- const res = { errMsg: err }
117
- webHandleFail(res, options.fail, options.complete)
118
- !options.fail && reject(res)
105
+ router.replace(
106
+ {
107
+ path: options.url,
108
+ query: {
109
+ routeCount
119
110
  }
120
- )
121
- })
111
+ },
112
+ () => {
113
+ const res = { errMsg: 'reLaunch:ok' }
114
+ webHandleSuccess(res, options.success, options.complete)
115
+ },
116
+ err => {
117
+ const res = { errMsg: err }
118
+ webHandleFail(res, options.fail, options.complete)
119
+ }
120
+ )
122
121
  }
123
122
  const res = { errMsg: 'reLaunch:ok' }
124
123
  webHandleSuccess(res, options.success, options.complete)
125
- return Promise.resolve(res)
126
124
  }
127
125
  }
128
126
 
@@ -137,38 +135,33 @@ function switchTab (options = {}) {
137
135
  webHandleFail(res, options.fail, options.complete)
138
136
  return Promise.reject(res)
139
137
  }
140
- const delta = router.stack.length - 1
141
138
  router.__mpxAction = {
142
139
  type: 'switch',
143
140
  path: options.url,
144
141
  replaced: false
145
142
  }
143
+ const delta = router.stack.length - 1
146
144
  if (delta > 0) {
147
145
  router.go(-delta)
148
146
  } else {
149
147
  router.__mpxAction.replaced = true
150
- return new Promise((resolve, reject) => {
151
- router.replace(
152
- {
153
- path: options.url
154
- },
155
- () => {
156
- const res = { errMsg: 'switchTab:ok' }
157
- webHandleSuccess(res, options.success, options.complete)
158
- resolve(res)
159
- },
160
- err => {
161
- const res = { errMsg: err }
162
- webHandleFail(res, options.fail, options.complete)
163
- !options.fail && reject(res)
164
- }
165
- )
166
- })
148
+ router.replace(
149
+ {
150
+ path: options.url
151
+ },
152
+ () => {
153
+ const res = { errMsg: 'switchTab:ok' }
154
+ webHandleSuccess(res, options.success, options.complete)
155
+ },
156
+ err => {
157
+ const res = { errMsg: err }
158
+ webHandleFail(res, options.fail, options.complete)
159
+ }
160
+ )
167
161
  }
168
162
  }
169
163
  const res = { errMsg: 'switchTab:ok' }
170
164
  webHandleSuccess(res, options.success, options.complete)
171
- return Promise.resolve(res)
172
165
  }
173
166
  }
174
167
 
@@ -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
+ }
@@ -2,7 +2,6 @@ import { webHandleSuccess } from '../../../common/js'
2
2
 
3
3
  function setNavigationBarTitle (options = {}) {
4
4
  const { title, success, complete } = options
5
-
6
5
  if (document.title !== title) {
7
6
  document.title = title
8
7
  }
@@ -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
+ }
@@ -8,11 +8,9 @@ function setStorage (options = {}) {
8
8
 
9
9
  const res = { errMsg: 'setStorage:ok' }
10
10
  webHandleSuccess(res, success, complete)
11
- return Promise.resolve(res)
12
11
  } catch (err) {
13
12
  const res = { errMsg: `setStorage:fail ${err}` }
14
13
  webHandleFail(res, fail, complete)
15
- return Promise.reject(res)
16
14
  }
17
15
  }
18
16
 
@@ -34,11 +32,9 @@ function getStorage (options = {}) {
34
32
  if (result) {
35
33
  const res = { errMsg: 'getStorage:ok', data: data }
36
34
  webHandleSuccess(res, success, complete)
37
- return Promise.resolve(res)
38
35
  } else {
39
36
  const res = { errMsg: 'getStorage:fail', data: null }
40
37
  webHandleFail(res, fail, complete)
41
- return Promise.reject(res)
42
38
  }
43
39
  }
44
40
 
@@ -71,11 +67,9 @@ function getStorageInfo (options = {}) {
71
67
 
72
68
  const res = Object.assign({}, { errMsg: 'getStorageInfo:ok' }, info)
73
69
  webHandleSuccess(res, success, complete)
74
- return Promise.resolve(res)
75
70
  } catch (err) {
76
71
  const res = { errMsg: `getStorageInfo:fail ${err}` }
77
72
  webHandleFail(res, fail, complete)
78
- return Promise.reject(res)
79
73
  }
80
74
  }
81
75
 
@@ -95,11 +89,9 @@ function removeStorage (options = { key: '' }) {
95
89
 
96
90
  const res = { errMsg: 'removeStorage:ok' }
97
91
  webHandleSuccess(res, success, complete)
98
- return Promise.resolve(res)
99
92
  } catch (err) {
100
93
  const res = { errMsg: `removeStorage:fail ${err}` }
101
94
  webHandleFail(res, fail, complete)
102
- return Promise.reject(res)
103
95
  }
104
96
  }
105
97
 
@@ -115,11 +107,9 @@ function clearStorage (options = {}) {
115
107
 
116
108
  const res = { errMsg: 'clearStorage:ok' }
117
109
  webHandleSuccess(res, success, complete)
118
- return Promise.resolve(res)
119
110
  } catch (err) {
120
111
  const res = { errMsg: `clearStorage:fail ${err}` }
121
112
  webHandleFail(res, fail, complete)
122
- return Promise.reject(res)
123
113
  }
124
114
  }
125
115
 
@@ -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
+ }
@@ -69,7 +69,6 @@ function getSystemInfo (options = {}) {
69
69
  const info = getSystemInfoSync()
70
70
  const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info)
71
71
  webHandleSuccess(res, options.success, options.complete)
72
- return Promise.resolve(res)
73
72
  }
74
73
 
75
74
  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
+ }