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