@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,287 @@
1
+ import getRealPath from 'uni-platform/helpers/get-real-path'
2
+
3
+ export default {
4
+ props: {
5
+ id: {
6
+ type: [Number, String],
7
+ default: ''
8
+ },
9
+ latitude: {
10
+ type: [Number, String],
11
+ require: true
12
+ },
13
+ longitude: {
14
+ type: [Number, String],
15
+ require: true
16
+ },
17
+ title: {
18
+ type: String,
19
+ default: ''
20
+ },
21
+ iconPath: {
22
+ type: String,
23
+ require: true
24
+ },
25
+ rotate: {
26
+ type: [Number, String],
27
+ default: 0
28
+ },
29
+ alpha: {
30
+ type: [Number, String],
31
+ default: 1
32
+ },
33
+ width: {
34
+ type: [Number, String],
35
+ default: ''
36
+ },
37
+ height: {
38
+ type: [Number, String],
39
+ default: ''
40
+ },
41
+ callout: {
42
+ type: Object,
43
+ default: null
44
+ },
45
+ label: {
46
+ type: Object,
47
+ default: null
48
+ },
49
+ anchor: {
50
+ type: Object,
51
+ default: null
52
+ },
53
+ clusterId: {
54
+ type: [Number, String],
55
+ default: ''
56
+ },
57
+ customCallout: {
58
+ type: Object,
59
+ default: null
60
+ },
61
+ ariaLabel: {
62
+ type: String,
63
+ default: ''
64
+ }
65
+ },
66
+ mounted () {
67
+ const $parent = this.$parent
68
+ $parent.mapReady(() => {
69
+ this._maps = $parent._maps
70
+ this._map = $parent._map
71
+ this.addMarker(this.$props)
72
+ Object.keys(this.$props).forEach(key => {
73
+ this.$watch(key, () => {
74
+ this.updateMarker(this.$props)
75
+ })
76
+ })
77
+ })
78
+ },
79
+ beforeDestroy () {
80
+ this.removeMarker()
81
+ },
82
+ methods: {
83
+ addMarker (props) {
84
+ const maps = this._maps
85
+ const map = this._map
86
+ const marker = this._marker = new maps.Marker({
87
+ map,
88
+ flat: true,
89
+ autoRotation: false
90
+ })
91
+ this.$parent._markers[this.id] = marker
92
+ this.updateMarker(props)
93
+ maps.event.addListener(marker, 'click', () => {
94
+ const callout = marker.callout
95
+ if (callout) {
96
+ const div = callout.div
97
+ const parent = div.parentNode
98
+ if (!callout.alwaysVisible) {
99
+ callout.set('visible', !callout.visible)
100
+ }
101
+ if (callout.visible) {
102
+ parent.removeChild(div)
103
+ parent.appendChild(div)
104
+ }
105
+ }
106
+ if (this.id) {
107
+ this.$parent.$trigger('markertap', {}, {
108
+ markerId: this.id
109
+ })
110
+ }
111
+ })
112
+ },
113
+ updateMarker (option) {
114
+ const map = this._map
115
+ const maps = this._maps
116
+ const marker = this._marker
117
+ const title = option.title
118
+ const position = new maps.LatLng(option.latitude, option.longitude)
119
+ const img = new Image()
120
+ img.onload = () => {
121
+ const anchor = option.anchor || {}
122
+ let icon
123
+ let w
124
+ let h
125
+ const x = typeof anchor.x === 'number' ? anchor.x : 0.5
126
+ const y = typeof anchor.y === 'number' ? anchor.y : 1
127
+ if (option.iconPath && (option.width || option.height)) {
128
+ w = option.width || (img.width / img.height) * option.height
129
+ h = option.height || (img.height / img.width) * option.width
130
+ } else {
131
+ w = img.width / 2
132
+ h = img.height / 2
133
+ }
134
+ const top = h - (h - y * h)
135
+ if ('MarkerImage' in maps) {
136
+ icon = new maps.MarkerImage(
137
+ img.src,
138
+ null,
139
+ null,
140
+ new maps.Point(x * w, y * h),
141
+ new maps.Size(w, h)
142
+ )
143
+ } else {
144
+ icon = {
145
+ url: img.src,
146
+ anchor: new maps.Point(x, y),
147
+ size: new maps.Size(w, h)
148
+ }
149
+ }
150
+ marker.setPosition(position)
151
+ marker.setIcon(icon)
152
+ if ('setRotation' in marker) {
153
+ marker.setRotation(option.rotate || 0)
154
+ }
155
+ const labelOpt = option.label || {}
156
+ if ('label' in marker) {
157
+ marker.label.setMap(null)
158
+ delete marker.label
159
+ }
160
+ let label
161
+ if (labelOpt.content) {
162
+ const labelStyle = {
163
+ borderColor: labelOpt.borderColor,
164
+ borderWidth: (Number(labelOpt.borderWidth) || 0) + 'px',
165
+ padding: (Number(labelOpt.padding) || 0) + 'px',
166
+ borderRadius: (Number(labelOpt.borderRadius) || 0) + 'px',
167
+ backgroundColor: labelOpt.bgColor,
168
+ color: labelOpt.color,
169
+ fontSize: (labelOpt.fontSize || 14) + 'px',
170
+ lineHeight: (labelOpt.fontSize || 14) + 'px',
171
+ marginLeft: (Number(labelOpt.anchorX || labelOpt.x) || 0) + 'px',
172
+ marginTop: (Number(labelOpt.anchorY || labelOpt.y) || 0) + 'px'
173
+ }
174
+ if ('Label' in maps) {
175
+ label = new maps.Label({
176
+ position: position,
177
+ map: map,
178
+ clickable: false,
179
+ content: labelOpt.content,
180
+ style: labelStyle
181
+ })
182
+ marker.label = label
183
+ } else if ('setLabel' in marker) {
184
+ const className = this.updateMarkerLabelStyle(this.id, labelStyle)
185
+ marker.setLabel({
186
+ text: labelOpt.content,
187
+ color: labelStyle.color,
188
+ fontSize: labelStyle.fontSize,
189
+ className
190
+ })
191
+ }
192
+ }
193
+ const calloutOpt = option.callout || {}
194
+ let callout = marker.callout
195
+ let calloutStyle
196
+ if (calloutOpt.content || title) {
197
+ const boxShadow = '0px 0px 3px 1px rgba(0,0,0,0.5)'
198
+ calloutStyle = calloutOpt.content
199
+ ? {
200
+ position,
201
+ map,
202
+ top,
203
+ content: calloutOpt.content,
204
+ color: calloutOpt.color,
205
+ fontSize: calloutOpt.fontSize,
206
+ borderRadius: calloutOpt.borderRadius,
207
+ bgColor: calloutOpt.bgColor,
208
+ padding: calloutOpt.padding,
209
+ boxShadow: calloutOpt.boxShadow || boxShadow,
210
+ display: calloutOpt.display
211
+ }
212
+ : {
213
+ position,
214
+ map,
215
+ top,
216
+ content: title,
217
+ boxShadow: boxShadow
218
+ }
219
+ if (callout) {
220
+ callout.setOption(calloutStyle)
221
+ } else {
222
+ callout = marker.callout = new maps.Callout(calloutStyle)
223
+ callout.div.onclick = ($event) => {
224
+ if (this.id !== '') {
225
+ this.$parent.$trigger('callouttap', $event, {
226
+ markerId: this.id
227
+ })
228
+ }
229
+ $event.stopPropagation()
230
+ $event.preventDefault()
231
+ }
232
+ }
233
+ } else {
234
+ if (callout) {
235
+ callout.setMap(null)
236
+ delete marker.callout
237
+ }
238
+ }
239
+ }
240
+ if (option.iconPath) {
241
+ img.src = getRealPath(option.iconPath)
242
+ } else {
243
+ console.error('Marker.iconPath is required.')
244
+ }
245
+ },
246
+ updateMarkerLabelStyle (id, style) {
247
+ const className = 'uni-map-marker-label-' + id
248
+ let styleEl = document.getElementById(className)
249
+ if (!styleEl) {
250
+ styleEl = document.createElement('style')
251
+ styleEl.id = className
252
+ document.head.appendChild(styleEl)
253
+ this.$once('hook:destroyed', () => {
254
+ styleEl.remove()
255
+ })
256
+ }
257
+ const newStyle = Object.assign({}, style, {
258
+ position: 'absolute',
259
+ top: '70px',
260
+ borderStyle: 'solid'
261
+ })
262
+ const div = document.createElement('div')
263
+ Object.keys(newStyle).forEach(key => {
264
+ div.style[key] = newStyle[key] || ''
265
+ })
266
+ styleEl.innerText = `.${className}{${div.getAttribute('style')}}`
267
+ return className
268
+ },
269
+ removeMarker () {
270
+ const marker = this._marker
271
+ if (marker) {
272
+ if (marker.label && 'setMap' in marker.label) {
273
+ marker.label.setMap(null)
274
+ }
275
+ if (marker.callout) {
276
+ marker.callout.setMap(null)
277
+ }
278
+ marker.setMap(null)
279
+ }
280
+ delete this.$parent._markers[this.id]
281
+ this._marker = null
282
+ }
283
+ },
284
+ render () {
285
+ return null
286
+ }
287
+ }
@@ -0,0 +1,117 @@
1
+ export function createCallout (maps) {
2
+ const overlay = new (maps.OverlayView || maps.Overlay)()
3
+ function onAdd () {
4
+ const div = this.div
5
+ const panes = this.getPanes()
6
+ panes.floatPane.appendChild(div)
7
+ }
8
+ function onRemove () {
9
+ const parentNode = this.div.parentNode
10
+ if (parentNode) {
11
+ parentNode.removeChild(this.div)
12
+ }
13
+ }
14
+
15
+ class Callout {
16
+ option
17
+ position
18
+ index
19
+ visible
20
+ alwaysVisible
21
+ div
22
+ triangle
23
+
24
+ set onclick (callback) {
25
+ this.div.onclick = callback
26
+ }
27
+
28
+ get onclick () {
29
+ return this.div.onclick
30
+ }
31
+
32
+ constructor (option = {}) {
33
+ this.option = option || {}
34
+ const map = option.map
35
+ this.position = option.position
36
+ this.index = 1
37
+ const visible = (this.visible = this.alwaysVisible = option.display === 'ALWAYS')
38
+ const div = (this.div = document.createElement('div'))
39
+ const divStyle = div.style
40
+ divStyle.position = 'absolute'
41
+ divStyle.whiteSpace = 'nowrap'
42
+ divStyle.transform = 'translateX(-50%) translateY(-100%)'
43
+ divStyle.zIndex = '1'
44
+ divStyle.boxShadow = option.boxShadow || 'none'
45
+ divStyle.display = visible ? 'block' : 'none'
46
+ const triangle = (this.triangle = document.createElement('div'))
47
+ triangle.setAttribute(
48
+ 'style',
49
+ 'position: absolute;white-space: nowrap;border-width: 4px;border-style: solid;border-color: #fff transparent transparent;border-image: initial;font-size: 12px;padding: 0px;background-color: transparent;width: 0px;height: 0px;transform: translate(-50%, 100%);left: 50%;bottom: 0;'
50
+ )
51
+ this.setStyle(option)
52
+ div.appendChild(triangle)
53
+ if (map) {
54
+ this.setMap(map)
55
+ }
56
+ }
57
+
58
+ onAdd = onAdd
59
+ construct = onAdd
60
+ setOption (option) {
61
+ this.option = option
62
+ this.setPosition(option.position)
63
+ if (option.display === 'ALWAYS') {
64
+ this.alwaysVisible = this.visible = true
65
+ } else {
66
+ this.alwaysVisible = false
67
+ }
68
+ this.setStyle(option)
69
+ }
70
+
71
+ setStyle (option) {
72
+ const div = this.div
73
+ const divStyle = div.style
74
+ div.innerText = option.content || ''
75
+ divStyle.lineHeight = (option.fontSize || 14) + 'px'
76
+ divStyle.fontSize = (option.fontSize || 14) + 'px'
77
+ divStyle.padding = (option.padding || 8) + 'px'
78
+ divStyle.color = option.color || '#000'
79
+ divStyle.borderRadius = (option.borderRadius || 0) + 'px'
80
+ divStyle.backgroundColor = option.bgColor || '#fff'
81
+ divStyle.marginTop = '-' + ((option.top || 0) + 5) + 'px'
82
+ this.triangle.style.borderColor = `${option.bgColor || '#fff'} transparent transparent`
83
+ }
84
+
85
+ setPosition (position) {
86
+ this.position = position
87
+ this.draw()
88
+ }
89
+
90
+ draw () {
91
+ const overlayProjection = this.getProjection()
92
+ if (!this.position || !this.div || !overlayProjection) {
93
+ return
94
+ }
95
+ const pixel = overlayProjection.fromLatLngToDivPixel(this.position)
96
+ const divStyle = this.div.style
97
+ divStyle.left = pixel.x + 'px'
98
+ divStyle.top = pixel.y + 'px'
99
+ }
100
+
101
+ changed () {
102
+ const divStyle = this.div.style
103
+ divStyle.display = this.visible ? 'block' : 'none'
104
+ }
105
+
106
+ onRemove = onRemove
107
+
108
+ destroy = onRemove
109
+ }
110
+ const prototype = Callout.prototype
111
+ for (const key in overlay) {
112
+ if (!(key in prototype)) {
113
+ prototype[key] = overlay[key]
114
+ }
115
+ }
116
+ return Callout
117
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ MapType,
3
+ getMapInfo
4
+ } from '../../../../helpers/location'
5
+ import { createCallout } from './callout'
6
+
7
+ let maps
8
+ const callbacksMap = {}
9
+ const GOOGLE_MAP_CALLBACKNAME = '__map_callback__'
10
+
11
+ export function loadMaps (libraries, callback) {
12
+ const mapInfo = getMapInfo()
13
+ if (!mapInfo.key) {
14
+ console.error('Map key not configured.')
15
+ return
16
+ }
17
+ const callbacks = (callbacksMap[mapInfo.type] = callbacksMap[mapInfo.type] || [])
18
+ if (maps) {
19
+ callback(maps)
20
+ } else if (
21
+ window[mapInfo.type] &&
22
+ window[mapInfo.type].maps
23
+ ) {
24
+ maps = window[mapInfo.type].maps
25
+ maps.Callout = maps.Callout || createCallout(maps)
26
+ callback(maps)
27
+ } else if (callbacks.length) {
28
+ callbacks.push(callback)
29
+ } else {
30
+ callbacks.push(callback)
31
+ const globalExt = window
32
+ const callbackName = GOOGLE_MAP_CALLBACKNAME + mapInfo.type
33
+ globalExt[callbackName] = function () {
34
+ delete globalExt[callbackName]
35
+ maps = window[mapInfo.type].maps
36
+ maps.Callout = createCallout(maps)
37
+ callbacks.forEach((callback) => callback(maps))
38
+ callbacks.length = 0
39
+ }
40
+ const script = document.createElement('script')
41
+ let src =
42
+ mapInfo.type === MapType.GOOGLE ? 'https://maps.googleapis.com/maps/api/js?' : 'https://map.qq.com/api/js?v=2.exp&'
43
+ if (mapInfo.type === MapType.QQ) {
44
+ libraries.push('geometry')
45
+ }
46
+ if (libraries.length) {
47
+ src += `libraries=${libraries.join('%2C')}&`
48
+ }
49
+ script.src = `${src}key=${mapInfo.key}&callback=${callbackName}`
50
+ script.onerror = function () {
51
+ console.error('Map load failed.')
52
+ }
53
+ document.body.appendChild(script)
54
+ }
55
+ }
@@ -364,7 +364,7 @@ export default {
364
364
  }
365
365
  const danmuList = this.otherData.danmuList = JSON.parse(JSON.stringify(this.danmuList || []))
366
366
  danmuList.sort(function (a, b) {
367
- return (a.time || 0) - (a.time || 0)
367
+ return (a.time || 0) - (b.time || 0)
368
368
  })
369
369
  },
370
370
  mounted () {
@@ -64,6 +64,10 @@ body {
64
64
  content: "\EA08";
65
65
  }
66
66
 
67
+ .uni-icon-error:before {
68
+ content: "\EA0B";
69
+ }
70
+
67
71
  .uni-loading,
68
72
  uni-button[loading]:before {
69
73
  background: transparent url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=") no-repeat;
@@ -1,5 +1,6 @@
1
1
  import {
2
- isPlainObject
2
+ isPlainObject,
3
+ hasOwn
3
4
  } from 'uni-shared'
4
5
  import navigateTo from 'uni-helpers/navigate-to'
5
6
  import redirectTo from '../../../mp-weixin/helpers/redirect-to'
@@ -251,8 +252,17 @@ const protocols = { // 需要做转换的 API 列表
251
252
  // TODO 有没有返回值还需要测试下
252
253
  },
253
254
  chooseImage: {
254
- returnValue: {
255
- apFilePaths: 'tempFilePaths'
255
+ returnValue (result) {
256
+ const hasTempFilePaths = hasOwn(result, 'tempFilePaths') && result.tempFilePaths
257
+ if (hasOwn(result, 'apFilePaths') && !hasTempFilePaths) {
258
+ result.tempFilePaths = result.apFilePaths
259
+ delete result.apFilePaths
260
+ }
261
+ if (!hasOwn(result, 'tempFiles') && hasTempFilePaths) {
262
+ result.tempFiles = []
263
+ result.tempFilePaths.forEach(tempFilePath => result.tempFiles.push({ path: tempFilePath }))
264
+ }
265
+ return {}
256
266
  }
257
267
  },
258
268
  previewImage: {
@@ -381,6 +391,23 @@ const protocols = { // 需要做转换的 API 列表
381
391
  }
382
392
  }
383
393
  },
394
+ getUserProfile: {
395
+ name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
396
+ returnValue (result) {
397
+ if (my.canIUse('getOpenUserInfo')) {
398
+ let response = {}
399
+ try {
400
+ response = JSON.parse(result.response).response
401
+ } catch (e) {}
402
+ result.nickName = response.nickName
403
+ result.avatar = response.avatar
404
+ }
405
+ result.userInfo = {
406
+ nickName: result.nickName,
407
+ avatarUrl: result.avatar
408
+ }
409
+ }
410
+ },
384
411
  requestPayment: {
385
412
  name: 'tradePay',
386
413
  args: {
@@ -2,6 +2,7 @@ import navigateTo from 'uni-helpers/navigate-to'
2
2
  import redirectTo from '../../../mp-weixin/helpers/redirect-to'
3
3
  import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
4
4
  import getSystemInfo from '../../../mp-weixin/helpers/system-info'
5
+ import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
5
6
 
6
7
  // 不支持的 API 列表
7
8
  const todos = [
@@ -89,6 +90,7 @@ const protocols = {
89
90
  previewImage,
90
91
  getSystemInfo,
91
92
  getSystemInfoSync: getSystemInfo,
93
+ getUserProfile,
92
94
  getRecorderManager: {
93
95
  returnValue (fromRet) {
94
96
  fromRet.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded')
@@ -122,6 +124,9 @@ const protocols = {
122
124
  getAccountInfoSync: {
123
125
  name: 'getEnvInfoSync',
124
126
  returnValue: _handleEnvInfo
127
+ },
128
+ login: {
129
+ name: 'getLoginCode'
125
130
  }
126
131
  }
127
132
 
@@ -8,9 +8,19 @@ import {
8
8
 
9
9
  import {
10
10
  isPage,
11
- initRelation
11
+ initRelation,
12
+ mocks
12
13
  } from './util'
13
14
 
15
+ import {
16
+ initMocks
17
+ } from 'uni-wrapper/util'
18
+
19
+ import {
20
+ fixSetDataStart,
21
+ fixSetDataEnd
22
+ } from '../../../mp-weixin/runtime/wrapper/fix-set-data'
23
+
14
24
  import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser'
15
25
 
16
26
  const newLifecycle = swan.canIUse('lifecycle-2-0')
@@ -27,23 +37,14 @@ export default function parseComponent (vueOptions) {
27
37
  const oldAttached = componentOptions.lifetimes.attached
28
38
  // 百度小程序基础库 3.260 以上支持页面 onInit 生命周期,提前创建 vm 实例
29
39
  componentOptions.lifetimes.onInit = function onInit (query) {
30
- // 处理百度小程序 onInit 生命周期调用 setData 无效的问题
31
- const setData = this.setData
32
- const setDataArgs = []
33
- this.setData = function () {
34
- setDataArgs.push(arguments)
35
- }
36
- this.__fixInitData = function () {
37
- delete this.__fixInitData
38
- this.setData = setData
39
- if (setDataArgs.length) {
40
- this.groupSetData(() => {
41
- setDataArgs.forEach(args => {
42
- setData.apply(this, args)
43
- })
44
- })
45
- }
40
+ // 百度小程序后续可能移除 pageinstance 属性,为向后兼容进行补充
41
+ if (!this.pageinstance || !this.pageinstance.setData) {
42
+ const pages = getCurrentPages()
43
+ this.pageinstance = pages[pages.length - 1]
46
44
  }
45
+
46
+ // 处理百度小程序 onInit 生命周期调用 setData 无效的问题
47
+ fixSetDataStart(this)
47
48
  oldAttached.call(this)
48
49
  this.pageinstance.$vm = this.$vm
49
50
  this.$vm.__call_hook('onInit', query)
@@ -52,7 +53,8 @@ export default function parseComponent (vueOptions) {
52
53
  if (!this.$vm) {
53
54
  oldAttached.call(this)
54
55
  } else {
55
- this.__fixInitData && this.__fixInitData()
56
+ initMocks(this.$vm, mocks)
57
+ fixSetDataEnd(this)
56
58
  }
57
59
  if (isPage.call(this)) { // 百度 onLoad 在 attached 之前触发(基础库小于 3.70)
58
60
  // 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
@@ -3,7 +3,8 @@ export const mocks = ['nodeId', 'componentName', '_componentId', 'uniquePrefix']
3
3
  export function isPage () {
4
4
  // 百度小程序组件的id,某些情况下可能是number类型的0,不能直接return !this.ownerId 判断当前组件是否是Page
5
5
  // 否则会导致mounted不执行
6
- return typeof this.ownerId === 'undefined'
6
+ // 基础库 3.290.33 及以上 ownerId null
7
+ return typeof this.ownerId === 'undefined' || this.ownerId === null
7
8
  }
8
9
 
9
10
  export function initRelation (detail) {
@@ -2,13 +2,15 @@ import navigateTo from 'uni-helpers/navigate-to'
2
2
  import redirectTo from '../../../mp-weixin/helpers/redirect-to'
3
3
  import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
4
4
  import getSystemInfo from '../../../mp-weixin/helpers/system-info'
5
+ import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
5
6
 
6
7
  export const protocols = {
7
8
  navigateTo,
8
9
  redirectTo,
9
10
  previewImage,
10
11
  getSystemInfo,
11
- getSystemInfoSync: getSystemInfo
12
+ getSystemInfoSync: getSystemInfo,
13
+ getUserProfile
12
14
  }
13
15
  export const todos = [
14
16
  'vibrate'
@@ -1,5 +1,25 @@
1
1
  import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser'
2
2
 
3
+ import { isPage } from '../../../mp-weixin/runtime/wrapper/util'
4
+
5
+ import {
6
+ fixSetDataStart,
7
+ fixSetDataEnd
8
+ } from '../../../mp-weixin/runtime/wrapper/fix-set-data'
9
+
3
10
  export default function parseComponent (vueComponentOptions) {
4
- return parseBaseComponent(vueComponentOptions)
11
+ const componentOptions = parseBaseComponent(vueComponentOptions)
12
+ const oldAttached = componentOptions.lifetimes.attached
13
+ componentOptions.lifetimes.attached = function attached () {
14
+ // 暂不区分版本
15
+ if (isPage.call(this)) {
16
+ // 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
17
+ fixSetDataStart(this)
18
+ setTimeout(() => {
19
+ fixSetDataEnd(this)
20
+ }, 0)
21
+ }
22
+ oldAttached.call(this)
23
+ }
24
+ return componentOptions
5
25
  }
File without changes