@mpxjs/api-proxy 2.8.28-beta.11 → 2.8.40-test

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 +3 -3
  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 +3 -77
  8. package/src/install.js +56 -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 -676
  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
@@ -1,676 +0,0 @@
1
- import { changeOpts, handleSuccess, getEnvObj, error, warn, noop } from '../../common/js'
2
-
3
- const ALI_OBJ = getEnvObj()
4
- const TIPS_NAME = '支付宝环境 mpx'
5
-
6
- // canvas api 用
7
- const CANVAS_MAP = {}
8
-
9
- // optimize case avoid call api multi times with getSystemInfoSync
10
- let systemInfo
11
-
12
- const getWxToAliApi = ({ optimize = false }) => {
13
- return {
14
- /**
15
- * 基础
16
- */
17
-
18
- getSystemInfo (options = {}) {
19
- const opts = changeOpts(options)
20
-
21
- handleSuccess(opts, res => {
22
- res.system = `${res.platform} ${res.system}`
23
- res.SDKVersion = ALI_OBJ.SDKVersion
24
-
25
- // 支付宝 windowHeight 可能为 0
26
- if (!res.windowHeight) {
27
- res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
28
- }
29
-
30
- return res
31
- })
32
-
33
- ALI_OBJ.getSystemInfo(opts)
34
- },
35
-
36
- getSystemInfoSync () {
37
- if (optimize) {
38
- if (systemInfo) return systemInfo
39
- }
40
-
41
- const res = ALI_OBJ.getSystemInfoSync() || {}
42
-
43
- res.system = `${res.platform} ${res.system}`
44
- res.SDKVersion = ALI_OBJ.SDKVersion
45
-
46
- // 支付宝 windowHeight 可能为 0
47
- if (!res.windowHeight) {
48
- res.windowHeight = Math.floor(res.screenHeight * res.windowWidth / res.screenWidth) - 50
49
- }
50
-
51
- if (optimize) systemInfo = res
52
-
53
- return res
54
- },
55
-
56
- nextTick (fn) {
57
- Promise.resolve().then(fn)
58
- },
59
-
60
- /**
61
- * 界面
62
- */
63
-
64
- showToast (options = {}) {
65
- const opts = changeOpts(options, {
66
- title: 'content',
67
- icon: 'type'
68
- })
69
- ALI_OBJ.showToast(opts)
70
- },
71
-
72
- hideToast (options = {}) {
73
- if (options.success || options.fail || options.complete) {
74
- warn(`${TIPS_NAME}.hideToast 不支持 success/fail/complete 参数`)
75
- }
76
- ALI_OBJ.hideToast(options)
77
- },
78
-
79
- showModal (options = {}) {
80
- let opts
81
-
82
- if (options.showCancel === undefined || options.showCancel) {
83
- opts = changeOpts(options, {
84
- confirmText: 'confirmButtonText',
85
- cancelText: 'cancelButtonText'
86
- })
87
-
88
- handleSuccess(opts, res => {
89
- return changeOpts(res, undefined, { cancel: !res.confirm })
90
- })
91
-
92
- ALI_OBJ.confirm(opts)
93
- } else {
94
- opts = changeOpts(options, {
95
- confirmText: 'buttonText'
96
- })
97
-
98
- handleSuccess(opts, res => {
99
- return changeOpts(res, undefined, { cancel: false, confirm: true })
100
- })
101
-
102
- ALI_OBJ.alert(opts)
103
- }
104
- },
105
-
106
- showLoading (options = {}) {
107
- const opts = changeOpts(options, {
108
- title: 'content'
109
- })
110
- ALI_OBJ.showLoading(opts)
111
- },
112
-
113
- hideLoading (options = {}) {
114
- if (options.success || options.fail || options.complete) {
115
- warn(`${TIPS_NAME}.hideLoading 不支持 success/fail/complete 参数`)
116
- }
117
- ALI_OBJ.hideLoading(options)
118
- },
119
-
120
- showActionSheet (options = {}) {
121
- const opts = changeOpts(options, {
122
- itemList: 'items'
123
- })
124
-
125
- const cacheSuc = opts.success || noop
126
- const cacheFail = opts.fail || noop
127
-
128
- opts.success = function (res) {
129
- const sucRes = changeOpts(res, {
130
- index: 'tapIndex'
131
- })
132
- if (sucRes.tapIndex === -1) {
133
- cacheFail.call(this, {
134
- errMsg: 'showActionSheet:fail cancel'
135
- })
136
- } else {
137
- cacheSuc.call(this, sucRes)
138
- }
139
- }
140
-
141
- ALI_OBJ.showActionSheet(opts)
142
- },
143
-
144
- showNavigationBarLoading (options = {}) {
145
- if (options.success || options.fail || options.complete) {
146
- warn(`${TIPS_NAME}.showNavigationBarLoading 不支持 success/fail/complete 参数`)
147
- }
148
- ALI_OBJ.showNavigationBarLoading(options)
149
- },
150
-
151
- hideNavigationBarLoading (options = {}) {
152
- if (options.success || options.fail || options.complete) {
153
- warn(`${TIPS_NAME}.hideNavigationBarLoading 不支持 success/fail/complete 参数`)
154
- }
155
- ALI_OBJ.hideNavigationBarLoading(options)
156
- },
157
-
158
- setNavigationBarTitle (options = {}) {
159
- ALI_OBJ.setNavigationBar(options)
160
- },
161
-
162
- setNavigationBarColor (options = {}) {
163
- ALI_OBJ.setNavigationBar(options)
164
- },
165
-
166
- /**
167
- * 网络
168
- */
169
-
170
- request (options = {}) {
171
- const opts = changeOpts(options, {
172
- header: 'headers'
173
- })
174
-
175
- handleSuccess(opts, res => {
176
- return changeOpts(res, {
177
- headers: 'header',
178
- status: 'statusCode'
179
- })
180
- })
181
-
182
- // request 在 1.11.0 以上版本才支持
183
- // httpRequest 即将被废弃,钉钉端仍需要使用
184
- if (ALI_OBJ.canIUse('request')) {
185
- return ALI_OBJ.request(opts)
186
- } else {
187
- return ALI_OBJ.httpRequest(opts)
188
- }
189
- },
190
-
191
- downloadFile (options = {}) {
192
- const opts = changeOpts(options)
193
-
194
- handleSuccess(opts, res => {
195
- return changeOpts(res, { apFilePath: 'tempFilePath' })
196
- })
197
-
198
- return ALI_OBJ.downloadFile(opts)
199
- },
200
-
201
- uploadFile (options = {}) {
202
- const opts = changeOpts(options, { name: 'fileName' })
203
-
204
- return ALI_OBJ.uploadFile(opts)
205
- },
206
-
207
- /**
208
- * 数据缓存
209
- */
210
-
211
- setStorageSync (key, data) {
212
- ALI_OBJ.setStorageSync({
213
- key,
214
- data
215
- })
216
- },
217
-
218
- removeStorageSync (key) {
219
- ALI_OBJ.removeStorageSync({
220
- key
221
- })
222
- },
223
-
224
- getStorageSync (key) {
225
- return ALI_OBJ.getStorageSync({
226
- key
227
- }).data
228
- },
229
-
230
- /**
231
- * 媒体
232
- */
233
-
234
- saveImageToPhotosAlbum (key) {
235
- warn(`如果想要保存在线图片链接,可以直接使用 ${TIPS_NAME}.saveImage`)
236
- },
237
-
238
- previewImage (options = {}) {
239
- const opts = changeOpts(options)
240
-
241
- if (opts.current) {
242
- const idx = options.urls.indexOf(opts.current)
243
- opts.current = idx !== -1 ? idx : 0
244
- }
245
-
246
- ALI_OBJ.previewImage(opts)
247
- },
248
-
249
- compressImage (options = {}) {
250
- const opts = changeOpts(options, {
251
- quality: ''
252
- }, {
253
- compressLevel: Math.round(options.quality / 100 * 4), // 支付宝图片压缩质量为 0 ~ 4,微信是 0 ~ 100
254
- apFilePaths: [options.src]
255
- })
256
-
257
- handleSuccess(opts, res => {
258
- return changeOpts(
259
- res,
260
- { apFilePaths: '' },
261
- { tempFilePath: res.apFilePaths[0] }
262
- )
263
- })
264
-
265
- ALI_OBJ.compressImage(opts)
266
- },
267
-
268
- chooseImage (options = {}) {
269
- const opts = changeOpts(options)
270
-
271
- handleSuccess(opts, res => {
272
- return changeOpts(res, { apFilePaths: 'tempFilePaths' })
273
- })
274
-
275
- ALI_OBJ.chooseImage(opts)
276
- },
277
-
278
- /**
279
- * 位置
280
- */
281
-
282
- getLocation (options = {}) {
283
- if (options.aliType === undefined && options.type) {
284
- warn(`如果要针对支付宝设置 ${TIPS_NAME}.getLocation 中的 type 参数,请使用 aliType, 取值为 0~3`)
285
- options.aliType = 0
286
- }
287
- if (options.altitude) {
288
- error(`支付宝 ${TIPS_NAME}.getLocation 不支持获取高度信息`)
289
- }
290
-
291
- const opts = changeOpts(options, {
292
- type: '',
293
- aliType: 'type'
294
- })
295
-
296
- ALI_OBJ.getLocation(opts)
297
- },
298
-
299
- /**
300
- * 文件
301
- */
302
-
303
- saveFile (options = {}) {
304
- const opts = changeOpts(options, {
305
- tempFilePath: 'apFilePath'
306
- })
307
-
308
- handleSuccess(opts, res => {
309
- return changeOpts(res, { apFilePath: 'savedFilePath' })
310
- })
311
-
312
- ALI_OBJ.saveFile(opts)
313
- },
314
-
315
- removeSavedFile (options = {}) {
316
- const opts = changeOpts(options, {
317
- filePath: 'apFilePath'
318
- })
319
-
320
- handleSuccess(opts, res => {
321
- return changeOpts(res, { apFilePath: 'savedFilePath' })
322
- })
323
-
324
- ALI_OBJ.removeSavedFile(opts)
325
- },
326
-
327
- getSavedFileList (options = {}) {
328
- const opts = changeOpts(options, {
329
- filePath: 'apFilePath'
330
- })
331
-
332
- handleSuccess(opts, res => {
333
- if (res.fileList) {
334
- res.fileList.forEach(file => {
335
- const resFile = changeOpts(file, {
336
- apFilePath: 'filePath'
337
- })
338
- file = resFile
339
- })
340
- }
341
- return res
342
- })
343
-
344
- ALI_OBJ.getSavedFileList(opts)
345
- },
346
-
347
- getSavedFileInfo (options = {}) {
348
- const opts = changeOpts(options, {
349
- filePath: 'apFilePath'
350
- })
351
-
352
- ALI_OBJ.getSavedFileInfo(opts)
353
- },
354
-
355
- getFileInfo (options = {}) {
356
- const opts = changeOpts(options, {
357
- filePath: 'apFilePath'
358
- })
359
-
360
- ALI_OBJ.getFileInfo(opts)
361
- },
362
-
363
- /**
364
- * 设备
365
- */
366
-
367
- addPhoneContact (options = {}) {
368
- const opts = changeOpts(options, {
369
- weChatNumber: 'alipayAccount'
370
- })
371
-
372
- ALI_OBJ.addPhoneContact(opts)
373
- },
374
-
375
- setClipboardData (options = {}) {
376
- const opts = changeOpts(options, {
377
- data: 'text'
378
- })
379
-
380
- ALI_OBJ.setClipboard(opts)
381
- },
382
-
383
- getClipboardData (options = {}) {
384
- const opts = changeOpts(options)
385
-
386
- handleSuccess(opts, res => {
387
- return changeOpts(res, { text: 'data' })
388
- })
389
-
390
- ALI_OBJ.getClipboard(opts)
391
- },
392
-
393
- setScreenBrightness (options = {}) {
394
- const opts = changeOpts(options, {
395
- value: 'brightness'
396
- })
397
-
398
- ALI_OBJ.setScreenBrightness(opts)
399
- },
400
-
401
- getScreenBrightness (options = {}) {
402
- const opts = changeOpts(options)
403
-
404
- handleSuccess(opts, res => {
405
- return changeOpts(res, { brightness: 'value' })
406
- })
407
-
408
- ALI_OBJ.getScreenBrightness(opts)
409
- },
410
-
411
- makePhoneCall (options = {}) {
412
- const opts = changeOpts(options, {
413
- phoneNumber: 'number'
414
- })
415
-
416
- ALI_OBJ.makePhoneCall(opts)
417
- },
418
-
419
- stopAccelerometer (options = {}) {
420
- ALI_OBJ.offAccelerometerChange(options)
421
- },
422
-
423
- startAccelerometer () {
424
- warn(`支付宝加速计不需要使用 ${TIPS_NAME}.startAccelerometer 开始,可以直接在 ${TIPS_NAME}.onAccelerometerChange 中监听`)
425
- },
426
-
427
- stopCompass (options = {}) {
428
- ALI_OBJ.offCompassChange(options)
429
- },
430
-
431
- startCompass () {
432
- warn(`支付宝罗盘不需要使用 ${TIPS_NAME}.startCompass 开始,可以直接在 ${TIPS_NAME}.onCompassChange 中监听`)
433
- },
434
-
435
- stopGyroscope (options = {}) {
436
- ALI_OBJ.offGyroscopeChange(options)
437
- },
438
-
439
- startGyroscope () {
440
- warn(`支付宝陀螺仪不需要使用 ${TIPS_NAME}.startGyroscope 开始,可以直接在 ${TIPS_NAME}.onGyroscopeChange 中监听`)
441
- },
442
-
443
- scanCode (options = {}) {
444
- const opts = changeOpts(options, {
445
- onlyFromCamera: 'hideAlbum',
446
- scanType: 'type'
447
- })
448
-
449
- if (opts.type) {
450
- switch (opts.type) {
451
- case 'barCode':
452
- opts.type = 'bar'
453
- break
454
- case 'qrCode':
455
- opts.type = 'qr'
456
- break
457
- default:
458
- error(`${TIPS_NAME}.scanCode 只支持扫描条形码和二维码,请将 type 设置为 barCode/qrCode`)
459
- opts.type = 'qr'
460
- break
461
- }
462
- }
463
-
464
- handleSuccess(opts, res => {
465
- return changeOpts(res, { code: 'result' })
466
- })
467
-
468
- ALI_OBJ.scan(opts)
469
- },
470
-
471
- /**
472
- * 开放接口
473
- */
474
-
475
- login (options = {}) {
476
- const opts = changeOpts(options)
477
-
478
- handleSuccess(opts, res => {
479
- return changeOpts(res, { authCode: 'code' })
480
- })
481
-
482
- ALI_OBJ.getAuthCode(opts)
483
- },
484
-
485
- checkSession () {
486
- warn(`支付宝不支持 ${TIPS_NAME}.checkSession 检查登录过期`)
487
- },
488
-
489
- getUserInfo (options = {}) {
490
- if (options.withCredentials === true) {
491
- warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 使用 withCredentials 参数中获取等敏感信息`)
492
- }
493
- if (options.lang) {
494
- warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
495
- }
496
-
497
- const opts = changeOpts(options)
498
-
499
- handleSuccess(opts, res => {
500
- const userInfo = changeOpts(res, { avatar: 'avatarUrl' }, { gender: 0 })
501
- const params = ['country', 'province', 'city', 'language']
502
-
503
- params.forEach(key => {
504
- Object.defineProperty(userInfo, key, {
505
- get () {
506
- warn(`支付宝 ${TIPS_NAME}.getUserInfo 不能获取 ${key}`)
507
- return ''
508
- }
509
- })
510
- })
511
-
512
- return {
513
- userInfo
514
- }
515
- })
516
-
517
- ALI_OBJ.getAuthUserInfo(opts)
518
- },
519
-
520
- requestPayment (options = {}) {
521
- if (!options.tradeNO) {
522
- error(`请在支付函数 ${TIPS_NAME}.requestPayment 中添加 tradeNO 参数用于支付宝支付`)
523
- }
524
-
525
- const opts = changeOpts(options, {
526
- timeStamp: '',
527
- nonceStr: '',
528
- package: '',
529
- signType: '',
530
- paySign: ''
531
- })
532
-
533
- const cacheSuc = opts.success || noop
534
- const cacheFail = opts.fail || noop
535
-
536
- // 抹平用微信的 complete
537
- if (typeof opts.complete === 'function') {
538
- const cacheComplete = opts.complete
539
- opts.complete = function (res) {
540
- if (+res.resultCode === 9000) {
541
- res.errMsg = 'requestPayment:ok'
542
- cacheComplete.call(this, res)
543
- }
544
- }
545
- }
546
-
547
- opts.success = function (res) {
548
- if (+res.resultCode === 9000) {
549
- cacheSuc.call(this, res)
550
- } else {
551
- cacheFail.call(this, res)
552
- }
553
- }
554
-
555
- ALI_OBJ.tradePay(opts)
556
- },
557
-
558
- /**
559
- * 画布
560
- */
561
-
562
- createCanvasContext (canvasId = {}) {
563
- const ctx = ALI_OBJ.createCanvasContext(canvasId)
564
-
565
- CANVAS_MAP[canvasId] = ctx
566
-
567
- return ctx
568
- },
569
-
570
- canvasToTempFilePath (options = {}) {
571
- if (!CANVAS_MAP[options.canvasId]) {
572
- error(`支付宝调用 ${TIPS_NAME}.toTempFilePath 方法之前需要先调用 ${TIPS_NAME}.createCanvasContext 创建 context`)
573
- return
574
- }
575
-
576
- const opts = changeOpts(options, { canvasId: '' })
577
- const ctx = CANVAS_MAP[options.canvasId]
578
-
579
- handleSuccess(opts, res => {
580
- return changeOpts(
581
- res,
582
- { apFilePath: 'tempFilePath' },
583
- { errMsg: 'canvasToTempFilePath:ok' }
584
- )
585
- })
586
-
587
- ctx.toTempFilePath(opts)
588
- },
589
-
590
- canvasPutImageData (options = {}) {
591
- if (!CANVAS_MAP[options.canvasId]) {
592
- error(`支付宝调用 ${TIPS_NAME}.putImageData 方法之前需要先调用 ${TIPS_NAME}.createCanvasContext 创建 context`)
593
- return
594
- }
595
-
596
- const opts = changeOpts(options, { canvasId: '' })
597
- const ctx = CANVAS_MAP[options.canvasId]
598
-
599
- // success 里面的 this 指向参数 options
600
- handleSuccess(opts, res => {
601
- return changeOpts(res, undefined, { errMsg: 'canvasPutImageData:ok' }
602
- )
603
- }, options)
604
-
605
- ctx.putImageData(opts)
606
- },
607
-
608
- canvasGetImageData (options = {}) {
609
- if (!CANVAS_MAP[options.canvasId]) {
610
- error(`支付宝调用 ${TIPS_NAME}.getImageData 方法之前需要先调用 ${TIPS_NAME}.createCanvasContext 创建 context`)
611
- return
612
- }
613
-
614
- const opts = changeOpts(options, { canvasId: '' })
615
- const ctx = CANVAS_MAP[options.canvasId]
616
-
617
- // success 里面的 this 指向参数 options
618
- handleSuccess(opts, undefined, options)
619
-
620
- ctx.getImageData(opts)
621
- },
622
-
623
- /**
624
- * WXML
625
- */
626
-
627
- // todo 支付宝基础库升级至2.7.4以上可去除
628
- createSelectorQuery (options = {}) {
629
- const selectorQuery = ALI_OBJ.createSelectorQuery(options)
630
- const proxyMethods = ['boundingClientRect', 'scrollOffset']
631
- const cbs = []
632
- proxyMethods.forEach((name) => {
633
- const originalMethod = selectorQuery[name]
634
- selectorQuery[name] = function (cb = noop) {
635
- cbs.push(cb)
636
- return originalMethod.call(this)
637
- }
638
- })
639
-
640
- const originalExec = selectorQuery.exec
641
- selectorQuery.exec = function (originalCb = noop) {
642
- const cb = function (results) {
643
- results.forEach((item, index) => {
644
- cbs[index] && cbs[index](item)
645
- })
646
- originalCb(results)
647
- }
648
- return originalExec.call(this, cb)
649
- }
650
-
651
- selectorQuery.in = function () {
652
- return this
653
- }
654
-
655
- return selectorQuery
656
- },
657
-
658
- closeBLEConnection (options = {}) {
659
- ALI_OBJ.disconnectBLEDevice(options)
660
- },
661
-
662
- createBLEConnection (options = {}) {
663
- ALI_OBJ.connectBLEDevice(options)
664
- },
665
-
666
- onBLEConnectionStateChange (callback) {
667
- ALI_OBJ.onBLEConnectionStateChanged(callback)
668
- },
669
-
670
- offBLEConnectionStateChange (callback) {
671
- ALI_OBJ.offBLEConnectionStateChanged(callback)
672
- }
673
- }
674
- }
675
-
676
- export default getWxToAliApi
@@ -1,20 +0,0 @@
1
- import { changeOpts, getEnvObj } from '../../common/js'
2
-
3
- const QQ_OBJ = getEnvObj()
4
-
5
- const getWxToQqApi = () => {
6
- return {
7
- /**
8
- * 订阅消息
9
- * @param options
10
- */
11
- requestSubscribeMessage (options = {}) {
12
- const opts = changeOpts(options, undefined, {
13
- subscribe: true
14
- })
15
- QQ_OBJ.subscribeAppMsg(opts)
16
- }
17
- }
18
- }
19
-
20
- export default getWxToQqApi
@@ -1,9 +0,0 @@
1
- const getWxToTtApi = () => {
2
- return {
3
- nextTick (fn) {
4
- Promise.resolve().then(fn)
5
- }
6
- }
7
- }
8
-
9
- export default getWxToTtApi