@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002

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 (157) hide show
  1. package/dist/automator.js +1 -1
  2. package/dist/index.css +1 -1
  3. package/dist/index.umd.min.js +1 -1
  4. package/lib/apis.js +14 -4
  5. package/lib/h5/uni.automator.js +1 -1
  6. package/lib/modules.json +4 -1
  7. package/manifest.json +49 -0
  8. package/package.json +2 -3
  9. package/src/core/helpers/api.js +1 -1
  10. package/src/core/helpers/constants.js +1 -0
  11. package/src/core/helpers/i18n/en.json +4 -2
  12. package/src/core/helpers/i18n/es.json +4 -1
  13. package/src/core/helpers/i18n/fr.json +4 -1
  14. package/src/core/helpers/i18n/index.js +155 -4
  15. package/src/core/helpers/i18n/zh-Hans.json +4 -1
  16. package/src/core/helpers/i18n/zh-Hant.json +4 -1
  17. package/src/core/helpers/index.js +1 -1
  18. package/src/core/helpers/interceptor.js +19 -15
  19. package/src/core/helpers/promise.js +1 -1
  20. package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
  21. package/src/core/helpers/protocol/network/request.js +14 -1
  22. package/src/core/helpers/protocol/network/upload-file.js +1 -1
  23. package/src/core/helpers/protocol/ui/popup.js +2 -2
  24. package/src/core/runtime/base.js +2 -0
  25. package/src/core/runtime/locale.js +37 -0
  26. package/src/core/runtime/web-view/index.js +4 -0
  27. package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
  28. package/src/core/runtime/wrapper/util.js +6 -1
  29. package/src/core/service/api/base/interceptor.js +1 -1
  30. package/src/core/service/api/context/canvas.js +3 -2
  31. package/src/core/service/api/context/create-map-context.js +8 -1
  32. package/src/core/service/api/ui/locale.js +50 -0
  33. package/src/core/service/plugins/app/create-app.js +8 -3
  34. package/src/core/service/plugins/app/index.js +2 -2
  35. package/src/core/service/plugins/index.js +8 -2
  36. package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
  37. package/src/core/view/components/canvas/index.vue +3 -1
  38. package/src/core/view/components/editor/formats/image.js +3 -1
  39. package/src/core/view/components/editor/formats/index.js +3 -1
  40. package/src/core/view/components/editor/formats/link.js +9 -0
  41. package/src/core/view/components/editor/index.vue +33 -3
  42. package/src/core/view/components/image/index.vue +4 -5
  43. package/src/core/view/components/input/index.vue +53 -25
  44. package/src/core/view/components/picker-view-column/index.vue +1 -0
  45. package/src/core/view/components/progress/index.vue +20 -13
  46. package/src/core/view/components/rich-text/index.vue +13 -1
  47. package/src/core/view/components/rich-text/nodes-parser.js +23 -4
  48. package/src/core/view/components/scroll-view/index.vue +253 -122
  49. package/src/core/view/components/slider/index.vue +1 -1
  50. package/src/core/view/components/swiper/index.vue +3 -0
  51. package/src/core/view/components/textarea/index.vue +7 -3
  52. package/src/core/view/index.css +4 -0
  53. package/src/core/view/mixins/field.js +27 -9
  54. package/src/core/view/mixins/interact.js +13 -11
  55. package/src/core/view/mixins/keyboard.js +42 -26
  56. package/src/core/view/mixins/touchtrack.js +2 -2
  57. package/src/core/view/plugins/index.js +1 -1
  58. package/src/platforms/app-plus/constants.js +1 -0
  59. package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
  60. package/src/platforms/app-plus/helpers/uuid.js +1 -1
  61. package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
  62. package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
  63. package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
  64. package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
  65. package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
  66. package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
  67. package/src/platforms/app-plus/service/api/device/system.js +3 -2
  68. package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
  69. package/src/platforms/app-plus/service/api/index.js +2 -0
  70. package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
  71. package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
  72. package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
  73. package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
  74. package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
  75. package/src/platforms/app-plus/service/api/network/request.js +27 -1
  76. package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
  77. package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
  78. package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
  79. package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
  80. package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
  81. package/src/platforms/app-plus/service/api/util.js +5 -1
  82. package/src/platforms/app-plus/service/framework/app.js +21 -5
  83. package/src/platforms/app-plus/service/framework/config.js +1 -0
  84. package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
  85. package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
  86. package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
  87. package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
  88. package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
  89. package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
  90. package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
  91. package/src/platforms/app-plus/service/index.js +10 -3
  92. package/src/platforms/app-plus/service/publish-handler.js +3 -0
  93. package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
  94. package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
  95. package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
  96. package/src/platforms/app-plus/view/components/map/index.vue +29 -27
  97. package/src/platforms/app-plus/view/components/video/index.vue +40 -24
  98. package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
  99. package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
  100. package/src/platforms/app-plus/view/index.css +4 -0
  101. package/src/platforms/app-plus/view/mixins/cover.js +10 -15
  102. package/src/platforms/app-plus/view/mixins/native.js +45 -3
  103. package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
  104. package/src/platforms/h5/components/app/observable.js +3 -2
  105. package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
  106. package/src/platforms/h5/components/app/popup/modal.vue +38 -2
  107. package/src/platforms/h5/components/app/popup/toast.vue +9 -1
  108. package/src/platforms/h5/components/app/tabBar.vue +39 -17
  109. package/src/platforms/h5/components/page/index.vue +5 -3
  110. package/src/platforms/h5/components/page/pageHead.vue +94 -75
  111. package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
  112. package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
  113. package/src/platforms/h5/helpers/location.js +26 -0
  114. package/src/platforms/h5/helpers/todo-api.js +2 -2
  115. package/src/platforms/h5/service/api/device/clipboard.js +41 -0
  116. package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
  117. package/src/platforms/h5/service/api/location/get-location.js +47 -18
  118. package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
  119. package/src/platforms/h5/service/api/media/choose-file.js +9 -1
  120. package/src/platforms/h5/service/api/media/choose-image.js +9 -2
  121. package/src/platforms/h5/service/api/media/choose-video.js +9 -1
  122. package/src/platforms/h5/service/api/media/create_input.js +12 -3
  123. package/src/platforms/h5/service/api/ui/popup.js +3 -5
  124. package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
  125. package/src/platforms/h5/service/index.js +5 -0
  126. package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
  127. package/src/platforms/h5/view/components/ad/index.vue +112 -69
  128. package/src/platforms/h5/view/components/map/index.vue +96 -349
  129. package/src/platforms/h5/view/components/map/map-marker.js +287 -0
  130. package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
  131. package/src/platforms/h5/view/components/map/maps/index.js +55 -0
  132. package/src/platforms/h5/view/components/video/index.vue +1 -1
  133. package/src/platforms/h5/view/index.css +4 -0
  134. package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
  135. package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
  136. package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
  137. package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
  138. package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
  139. package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
  140. package/src/platforms/mp-lark/runtime/api/index.js +0 -0
  141. package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
  142. package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
  143. package/src/platforms/mp-lark/runtime/index.js +1 -0
  144. package/src/platforms/mp-lark/runtime/web-view.js +11 -0
  145. package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
  146. package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
  147. package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
  148. package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
  149. package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
  150. package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
  151. package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
  152. package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
  153. package/src/platforms/mp-weixin/runtime/index.js +6 -7
  154. package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
  155. package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
  156. package/src/shared/uni-id-mixin.js +77 -0
  157. package/src/shared/util.js +2 -0
@@ -0,0 +1,257 @@
1
+ import {
2
+ requireNativePlugin
3
+ } from '../../bridge'
4
+
5
+ import {
6
+ eventTypes,
7
+ eventNames
8
+ } from './ad-base.js'
9
+
10
+ const sdkCache = {}
11
+ const sdkQueue = {}
12
+
13
+ function initSDK (options) {
14
+ const provider = options.provider
15
+ if (!sdkCache[provider]) {
16
+ sdkCache[provider] = {}
17
+ }
18
+ if (typeof sdkCache[provider].instance === 'object') {
19
+ options.success(sdkCache[provider].instance)
20
+ return
21
+ }
22
+
23
+ if (!sdkQueue[provider]) {
24
+ sdkQueue[provider] = []
25
+ }
26
+ sdkQueue[provider].push(options)
27
+
28
+ if (sdkCache[provider].loading === true) {
29
+ options.__plugin = sdkCache[provider].plugin
30
+ return
31
+ }
32
+ sdkCache[provider].loading = true
33
+ const plugin = requireNativePlugin(provider) || {}
34
+ const initFunction = plugin.init || plugin.initSDK
35
+ if (!initFunction) {
36
+ sdkQueue[provider].forEach((item) => {
37
+ item.fail({
38
+ code: -1,
39
+ message: 'provider [' + provider + '] invalid'
40
+ })
41
+ })
42
+ sdkQueue[provider].length = 0
43
+ sdkCache[provider].loading = false
44
+ return
45
+ }
46
+ sdkCache[provider].plugin = plugin
47
+ options.__plugin = plugin
48
+ initFunction((res) => {
49
+ const code = res.code
50
+ const isSuccess = (provider === 'BXM-AD') ? (code === 0 || code === 1) : (code === 0)
51
+ if (isSuccess) {
52
+ sdkCache[provider].instance = plugin
53
+ } else {
54
+ sdkCache[provider].loading = false
55
+ }
56
+
57
+ sdkQueue[provider].forEach((item) => {
58
+ if (isSuccess) {
59
+ item.success(item.__plugin)
60
+ } else {
61
+ item.fail(res)
62
+ }
63
+ })
64
+ sdkQueue[provider].length = 0
65
+ })
66
+ }
67
+
68
+ class InteractiveAd {
69
+ constructor (options) {
70
+ const _callbacks = this._callbacks = {}
71
+ eventNames.forEach(item => {
72
+ _callbacks[item] = []
73
+ const name = item[0].toUpperCase() + item.substr(1)
74
+ this[`on${name}`] = function (callback) {
75
+ _callbacks[item].push(callback)
76
+ }
77
+ })
78
+
79
+ this._ad = null
80
+ this._adError = ''
81
+ this._adpid = options.adpid
82
+ this._provider = options.provider
83
+ this._userData = options.userData || {}
84
+ this._isLoaded = false
85
+ this._isLoading = false
86
+ this._loadPromiseResolve = null
87
+ this._loadPromiseReject = null
88
+ this._showPromiseResolve = null
89
+ this._showPromiseReject = null
90
+
91
+ setTimeout(() => {
92
+ this._init()
93
+ })
94
+ }
95
+
96
+ _init () {
97
+ this._adError = ''
98
+ initSDK({
99
+ provider: this._provider,
100
+ success: (res) => {
101
+ this._ad = res
102
+ if (this._userData) {
103
+ this.bindUserData(this._userData)
104
+ }
105
+ this._loadAd()
106
+ },
107
+ fail: (err) => {
108
+ this._adError = err
109
+ this._dispatchEvent(eventTypes.error, err)
110
+ }
111
+ })
112
+ }
113
+
114
+ getProvider () {
115
+ return this._provider
116
+ }
117
+
118
+ load () {
119
+ return new Promise((resolve, reject) => {
120
+ this._loadPromiseResolve = resolve
121
+ this._loadPromiseReject = reject
122
+ if (this._isLoading) {
123
+ return
124
+ }
125
+
126
+ if (this._adError) {
127
+ this._init()
128
+ return
129
+ }
130
+
131
+ if (this._isLoaded) {
132
+ resolve()
133
+ } else {
134
+ this._loadAd()
135
+ }
136
+ })
137
+ }
138
+
139
+ show () {
140
+ return new Promise((resolve, reject) => {
141
+ this._showPromiseResolve = resolve
142
+ this._showPromiseReject = reject
143
+
144
+ if (this._isLoading) {
145
+ return
146
+ }
147
+
148
+ if (this._adError) {
149
+ this._init()
150
+ return
151
+ }
152
+
153
+ if (this._isLoaded) {
154
+ this._showAd()
155
+ resolve()
156
+ } else {
157
+ this._loadAd()
158
+ }
159
+ })
160
+ }
161
+
162
+ destroy () {
163
+ if (this._ad !== null && this._ad.destroy) {
164
+ this._ad.destroy({
165
+ adpid: this._adpid
166
+ })
167
+ }
168
+ }
169
+
170
+ bindUserData (data) {
171
+ if (this._ad !== null && this._ad.bindUserData) {
172
+ this._ad.bindUserData(data)
173
+ }
174
+ }
175
+
176
+ _loadAd () {
177
+ if (this._ad !== null) {
178
+ if (this._isLoading === true) {
179
+ return
180
+ }
181
+ this._isLoading = true
182
+
183
+ this._ad.loadData({
184
+ adpid: this._adpid,
185
+ ...this._userData
186
+ }, (res) => {
187
+ this._isLoaded = true
188
+ this._isLoading = false
189
+
190
+ if (this._loadPromiseResolve != null) {
191
+ this._loadPromiseResolve()
192
+ this._loadPromiseResolve = null
193
+ }
194
+ if (this._showPromiseResolve != null) {
195
+ this._showPromiseResolve()
196
+ this._showPromiseResolve = null
197
+ this._showAd()
198
+ }
199
+
200
+ this._dispatchEvent(eventTypes.load, res)
201
+ }, (err) => {
202
+ this._isLoading = false
203
+
204
+ if (this._showPromiseReject != null) {
205
+ this._showPromiseReject(this._createError(err))
206
+ this._showPromiseReject = null
207
+ }
208
+
209
+ this._dispatchEvent(eventTypes.error, err)
210
+ })
211
+ }
212
+ }
213
+
214
+ _showAd () {
215
+ if (this._ad !== null && this._isLoaded === true) {
216
+ this._ad.show({
217
+ adpid: this._adpid
218
+ }, (res) => {
219
+ this._isLoaded = false
220
+ }, (err) => {
221
+ this._isLoaded = false
222
+
223
+ if (this._showPromiseReject != null) {
224
+ this._showPromiseReject(this._createError(err))
225
+ this._showPromiseReject = null
226
+ }
227
+
228
+ this._dispatchEvent(eventTypes.error, err)
229
+ })
230
+ }
231
+ }
232
+
233
+ _createError (err) {
234
+ const error = new Error(JSON.stringify(err))
235
+ error.code = err.code
236
+ error.errMsg = err.message
237
+ return error
238
+ }
239
+
240
+ _dispatchEvent (name, data) {
241
+ this._callbacks[name].forEach(callback => {
242
+ if (typeof callback === 'function') {
243
+ callback(data || {})
244
+ }
245
+ })
246
+ }
247
+ }
248
+
249
+ export function createInteractiveAd (options) {
250
+ if (!options.provider) {
251
+ return new Error('provider invalid')
252
+ }
253
+ if (!options.adpid) {
254
+ return new Error('adpid invalid')
255
+ }
256
+ return new InteractiveAd(options)
257
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ AdBase
3
+ } from './ad-base.js'
4
+
5
+ class InterstitialAd extends AdBase {
6
+ constructor (options = {}) {
7
+ super(plus.ad.createInterstitialAd(options), options)
8
+
9
+ this._loadAd()
10
+ }
11
+ }
12
+
13
+ export function createInterstitialAd (options) {
14
+ return new InterstitialAd(options)
15
+ }
@@ -24,6 +24,7 @@ class RewardedVideoAd {
24
24
 
25
25
  this._preload = options.preload !== undefined ? options.preload : true
26
26
  this._isLoad = false
27
+ this._isLoading = false
27
28
  this._adError = ''
28
29
  this._loadPromiseResolve = null
29
30
  this._loadPromiseReject = null
@@ -32,6 +33,7 @@ class RewardedVideoAd {
32
33
  const rewardAd = this._rewardAd = plus.ad.createRewardedVideoAd(options)
33
34
  rewardAd.onLoad((e) => {
34
35
  this._isLoad = true
36
+ this._isLoading = false
35
37
  this._lastLoadTime = Date.now()
36
38
  this._dispatchEvent('load', {})
37
39
 
@@ -41,6 +43,8 @@ class RewardedVideoAd {
41
43
  }
42
44
  })
43
45
  rewardAd.onClose((e) => {
46
+ this._isLoad = false
47
+ this._isLoading = false
44
48
  if (this._preload) {
45
49
  this._loadAd()
46
50
  }
@@ -50,6 +54,7 @@ class RewardedVideoAd {
50
54
  this._dispatchEvent('verify', { isValid: e.isValid })
51
55
  })
52
56
  rewardAd.onError((e) => {
57
+ this._isLoading = false
53
58
  const { code, message } = e
54
59
  const data = { code: code, errMsg: message }
55
60
  this._adError = message
@@ -78,18 +83,25 @@ class RewardedVideoAd {
78
83
 
79
84
  load () {
80
85
  return new Promise((resolve, reject) => {
86
+ this._loadPromiseResolve = resolve
87
+ this._loadPromiseReject = reject
88
+ if (this._isLoading) {
89
+ return
90
+ }
81
91
  if (this._isLoad) {
82
92
  resolve()
83
93
  return
84
94
  }
85
- this._loadPromiseResolve = resolve
86
- this._loadPromiseReject = reject
87
95
  this._loadAd()
88
96
  })
89
97
  }
90
98
 
91
99
  show () {
92
100
  return new Promise((resolve, reject) => {
101
+ if (this._isLoading) {
102
+ return
103
+ }
104
+
93
105
  const provider = this.getProvider()
94
106
  if (provider === ProviderType.CSJ && this.isExpired) {
95
107
  this._isLoad = false
@@ -118,6 +130,7 @@ class RewardedVideoAd {
118
130
 
119
131
  _loadAd () {
120
132
  this._isLoad = false
133
+ this._isLoading = true
121
134
  this._rewardAd.load()
122
135
  }
123
136
 
@@ -20,6 +20,7 @@ export function getSystemInfoSync () {
20
20
  export function getSystemInfo () {
21
21
  const platform = plus.os.name.toLowerCase()
22
22
  const ios = platform === 'ios'
23
+ const isAndroid = platform === 'android'
23
24
  const {
24
25
  screenWidth,
25
26
  screenHeight
@@ -86,7 +87,7 @@ export function getSystemInfo () {
86
87
  windowHeight,
87
88
  statusBarHeight,
88
89
  language: plus.os.language,
89
- system: plus.os.version,
90
+ system: `${ios ? 'iOS' : isAndroid ? 'Android' : ''} ${plus.os.version}`,
90
91
  version: plus.runtime.innerVersion,
91
92
  fontSizeSetting: '',
92
93
  platform,
@@ -102,4 +103,4 @@ export function getSystemInfo () {
102
103
  },
103
104
  deviceId: deviceId()
104
105
  }
105
- }
106
+ }
@@ -1,23 +1,15 @@
1
1
  import {
2
- getRealPath
2
+ getRealPath,
3
+ warpPlusSuccessCallback,
4
+ warpPlusErrorCallback
3
5
  } from '../util'
4
6
 
5
- import {
6
- invoke
7
- } from '../../bridge'
8
-
9
7
  export function openDocument ({
10
8
  filePath,
11
9
  fileType
12
10
  } = {}, callbackId) {
13
- plus.io.resolveLocalFileSystemURL(getRealPath(filePath), entry => {
14
- plus.runtime.openFile(getRealPath(filePath))
15
- invoke(callbackId, {
16
- errMsg: 'openDocument:ok'
17
- })
18
- }, err => {
19
- invoke(callbackId, {
20
- errMsg: 'openDocument:fail ' + err.message
21
- })
22
- })
11
+ const successCallback = warpPlusSuccessCallback(callbackId, 'saveFile')
12
+ const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile')
13
+
14
+ plus.runtime.openDocument(getRealPath(filePath), undefined, successCallback, errorCallback)
23
15
  }
@@ -81,3 +81,5 @@ export * from './ui/request-component-info'
81
81
  export * from './ad/ad'
82
82
  export * from './ad/rewarded-video-ad'
83
83
  export * from './ad/full-screen-video-ad'
84
+ export * from './ad/interstitial-ad'
85
+ export * from './ad/interactive-ad'
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  wgs84togcj02,
3
- gcj02towgs84
3
+ gcj02towgs84,
4
+ warpPlusErrorCallback
4
5
  } from '../util'
5
6
 
6
7
  import {
@@ -51,8 +52,10 @@ function getLocationSuccess (type, position, callbackId) {
51
52
  export function getLocation ({
52
53
  type = 'wgs84',
53
54
  geocode = false,
54
- altitude = false
55
+ altitude = false,
56
+ highAccuracyExpireTime
55
57
  } = {}, callbackId) {
58
+ const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation')
56
59
  plus.geolocation.getCurrentPosition(
57
60
  position => {
58
61
  getLocationSuccess(type, position, callbackId)
@@ -63,13 +66,11 @@ export function getLocation ({
63
66
  getLocationSuccess(type, e, callbackId)
64
67
  return
65
68
  }
66
-
67
- invoke(callbackId, {
68
- errMsg: 'getLocation:fail ' + e.message
69
- })
69
+ errorCallback(e)
70
70
  }, {
71
71
  geocode: geocode,
72
- enableHighAccuracy: altitude
72
+ enableHighAccuracy: altitude,
73
+ timeout: highAccuracyExpireTime
73
74
  }
74
75
  )
75
76
  }
@@ -7,8 +7,7 @@ import {
7
7
  } from '../../bridge'
8
8
 
9
9
  import {
10
- warpPlusErrorCallback,
11
- getFileName
10
+ warpPlusErrorCallback
12
11
  } from '../util'
13
12
 
14
13
  import {
@@ -28,64 +27,32 @@ function getFileInfo (filePath) {
28
27
  })
29
28
  }
30
29
 
31
- function compressImage (tempFilePath) {
32
- const dstPath = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
33
- return new Promise((resolve, reject) => {
34
- plus.nativeUI.showWaiting()
35
- plus.zip.compressImage({
36
- src: tempFilePath,
37
- dst: dstPath,
38
- overwrite: true
39
- }, () => {
40
- plus.nativeUI.closeWaiting()
41
- resolve(dstPath)
42
- }, (error) => {
43
- plus.nativeUI.closeWaiting()
44
- reject(error)
45
- })
46
- })
47
- }
48
-
49
30
  export function chooseImage ({
50
31
  count,
51
32
  sizeType,
52
- sourceType
33
+ sourceType,
34
+ crop
53
35
  } = {}, callbackId) {
54
36
  const errorCallback = warpPlusErrorCallback(callbackId, 'chooseImage', 'cancel')
55
37
 
56
38
  function successCallback (paths) {
57
39
  const tempFiles = []
58
40
  const tempFilePaths = []
59
- // plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行
60
- paths.reduce((promise, path) => {
61
- return promise.then(() => {
62
- return getFileInfo(path)
63
- }).then(fileInfo => {
64
- const size = fileInfo.size
65
- // 压缩阈值 0.5 兆
66
- const THRESHOLD = 1024 * 1024 * 0.5
67
- // 判断是否需要压缩
68
- if (sizeType.includes('compressed') && size > THRESHOLD) {
69
- return compressImage(path).then(dstPath => {
70
- path = dstPath
71
- return getFileInfo(path)
72
- })
73
- }
74
- return fileInfo
75
- }).then(({ size }) => {
76
- tempFilePaths.push(path)
77
- tempFiles.push({
78
- path,
79
- size
41
+ Promise.all(paths.map((path) => getFileInfo(path)))
42
+ .then((filesInfo) => {
43
+ filesInfo.forEach((file, index) => {
44
+ const path = paths[index]
45
+ tempFilePaths.push(path)
46
+ tempFiles.push({ path, size: file.size })
47
+ })
48
+
49
+ invoke(callbackId, {
50
+ errMsg: 'chooseImage:ok',
51
+ tempFilePaths,
52
+ tempFiles
80
53
  })
81
54
  })
82
- }, Promise.resolve()).then(() => {
83
- invoke(callbackId, {
84
- errMsg: 'chooseImage:ok',
85
- tempFilePaths,
86
- tempFiles
87
- })
88
- }).catch(errorCallback)
55
+ .catch(errorCallback)
89
56
  }
90
57
 
91
58
  function openCamera () {
@@ -93,7 +60,9 @@ export function chooseImage ({
93
60
  camera.captureImage(path => successCallback([path]),
94
61
  errorCallback, {
95
62
  filename: TEMP_PATH + '/camera/',
96
- resolution: 'high'
63
+ resolution: 'high',
64
+ crop,
65
+ sizeType
97
66
  })
98
67
  }
99
68
 
@@ -103,7 +72,9 @@ export function chooseImage ({
103
72
  multiple: true,
104
73
  system: false,
105
74
  filename: TEMP_PATH + '/gallery/',
106
- permissionAlert: true
75
+ permissionAlert: true,
76
+ crop,
77
+ sizeType
107
78
  })
108
79
  }
109
80
 
@@ -7,8 +7,7 @@ import {
7
7
  } from '../../bridge'
8
8
 
9
9
  import {
10
- warpPlusErrorCallback,
11
- getFileName
10
+ warpPlusErrorCallback
12
11
  } from '../util'
13
12
 
14
13
  import {
@@ -24,38 +23,20 @@ export function chooseVideo ({
24
23
  const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel')
25
24
 
26
25
  function successCallback (tempFilePath = '') {
27
- const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
28
- const compressVideo = compressed ? plus.zip.compressVideo : function (_, callback) {
29
- callback({ tempFilePath })
30
- }
31
- if (compressed) {
32
- plus.nativeUI.showWaiting()
33
- }
34
- compressVideo({
35
- src: tempFilePath,
36
- dst
37
- }, ({ tempFilePath }) => {
38
- if (compressed) {
39
- plus.nativeUI.closeWaiting()
40
- }
41
- plus.io.getVideoInfo({
42
- filePath: tempFilePath,
43
- success (videoInfo) {
44
- const result = {
45
- errMsg: 'chooseVideo:ok',
46
- tempFilePath: tempFilePath
47
- }
48
- result.size = videoInfo.size
49
- result.duration = videoInfo.duration
50
- result.width = videoInfo.width
51
- result.height = videoInfo.height
52
- invoke(callbackId, result)
53
- },
54
- errorCallback
55
- })
56
- }, error => {
57
- plus.nativeUI.closeWaiting()
58
- errorCallback(error)
26
+ plus.io.getVideoInfo({
27
+ filePath: tempFilePath,
28
+ success (videoInfo) {
29
+ const result = {
30
+ errMsg: 'chooseVideo:ok',
31
+ tempFilePath: tempFilePath
32
+ }
33
+ result.size = videoInfo.size
34
+ result.duration = videoInfo.duration
35
+ result.width = videoInfo.width
36
+ result.height = videoInfo.height
37
+ invoke(callbackId, result)
38
+ },
39
+ fail: errorCallback
59
40
  })
60
41
  }
61
42
 
@@ -67,7 +48,8 @@ export function chooseVideo ({
67
48
  multiple: true,
68
49
  maximum: 1,
69
50
  filename: TEMP_PATH + '/gallery/',
70
- permissionAlert: true
51
+ permissionAlert: true,
52
+ videoCompress: compressed
71
53
  })
72
54
  }
73
55
 
@@ -76,7 +58,8 @@ export function chooseVideo ({
76
58
  plusCamera.startVideoCapture(successCallback, errorCallback, {
77
59
  index: camera === 'front' ? 2 : 1,
78
60
  videoMaximumDuration: maxDuration,
79
- filename: TEMP_PATH + '/camera/'
61
+ filename: TEMP_PATH + '/camera/',
62
+ videoCompress: compressed
80
63
  })
81
64
  }
82
65
 
@@ -9,10 +9,10 @@ import {
9
9
  } from '../util'
10
10
 
11
11
  export function compressVideo (options, callbackId) {
12
- const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`
12
+ const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`
13
13
  const successCallback = warpPlusSuccessCallback(callbackId, 'compressVideo')
14
14
  const errorCallback = warpPlusErrorCallback(callbackId, 'compressVideo')
15
15
  plus.zip.compressVideo(Object.assign({}, options, {
16
- dst
16
+ filename
17
17
  }), successCallback, errorCallback)
18
18
  }
@@ -7,10 +7,13 @@ export const getVideoInfo = warpPlusMethod('io', 'getVideoInfo', options => {
7
7
  return options
8
8
  }, data => {
9
9
  return {
10
+ orientation: data.orientation,
11
+ type: data.type,
10
12
  duration: data.duration,
11
- fps: data.fps || 30,
13
+ size: data.size / 1024,
12
14
  height: data.height,
13
15
  width: data.width,
14
- size: data.size
16
+ fps: data.fps || 30,
17
+ bitrate: data.bitrate
15
18
  }
16
19
  })