@mpxjs/api-proxy 2.9.13 → 2.9.14
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/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 +106 -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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function previewImage (options = {}) {
|
|
4
|
+
const opts = changeOpts(options)
|
|
5
|
+
|
|
6
|
+
if (opts.current) {
|
|
7
|
+
const idx = options.urls.indexOf(opts.current)
|
|
8
|
+
opts.current = idx !== -1 ? idx : 0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
my.previewImage(opts)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function compressImage (options = {}) {
|
|
15
|
+
const opts = changeOpts(options, {
|
|
16
|
+
quality: ''
|
|
17
|
+
}, {
|
|
18
|
+
compressLevel: Math.round(options.quality / 100 * 4), // 支付宝图片压缩质量为 0 ~ 4,微信是 0 ~ 100
|
|
19
|
+
apFilePaths: [options.src]
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
handleSuccess(opts, res => {
|
|
23
|
+
return changeOpts(
|
|
24
|
+
res,
|
|
25
|
+
{ apFilePaths: '' },
|
|
26
|
+
{ tempFilePath: res.apFilePaths[0] }
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
my.compressImage(opts)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
previewImage,
|
|
35
|
+
compressImage
|
|
36
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const previewImage = ENV_OBJ.previewImage || envError('previewImage')
|
|
6
|
+
|
|
7
|
+
const compressImage = ENV_OBJ.compressImage || envError('compressImage')
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
previewImage,
|
|
11
|
+
compressImage
|
|
12
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Preview from './Preview'
|
|
2
|
+
import { envError } from '../../../common/js'
|
|
2
3
|
|
|
3
4
|
let preview = null
|
|
4
5
|
|
|
@@ -6,7 +7,13 @@ let preview = null
|
|
|
6
7
|
* 预览图片
|
|
7
8
|
* @param {Object} options - 预览图片的配置项
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
const previewImage = (options) => {
|
|
10
11
|
if (!preview) preview = new Preview()
|
|
11
12
|
preview.show(options)
|
|
12
13
|
}
|
|
14
|
+
const compressImage = envError('compressImage')
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
previewImage,
|
|
18
|
+
compressImage
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function login (options = {}) {
|
|
4
|
+
const opts = changeOpts(options)
|
|
5
|
+
|
|
6
|
+
handleSuccess(opts, res => {
|
|
7
|
+
return changeOpts(res, { authCode: 'code' }, { errMsg: 'login:ok' })
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
my.getAuthCode(opts)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
login
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDom, getRootElement, webHandleSuccess } from '../../../common/js'
|
|
2
2
|
import '../../../common/stylus/Modal.styl'
|
|
3
3
|
// import { forEach } from '@didi/mpx-fetch/src/util'
|
|
4
4
|
// 汉字为两个字符,字母/数字为一个字符
|
|
@@ -13,9 +13,8 @@ const _getLength = (t) => {
|
|
|
13
13
|
}
|
|
14
14
|
return len
|
|
15
15
|
}
|
|
16
|
-
export default class Modal
|
|
16
|
+
export default class Modal {
|
|
17
17
|
constructor () {
|
|
18
|
-
super()
|
|
19
18
|
this.defaultOpts = {
|
|
20
19
|
title: '',
|
|
21
20
|
content: '',
|
|
@@ -82,7 +81,6 @@ export default class Modal extends ToPromise {
|
|
|
82
81
|
confirm: false
|
|
83
82
|
}
|
|
84
83
|
webHandleSuccess(result, opts.success, opts.complete)
|
|
85
|
-
this.toPromiseResolve(result)
|
|
86
84
|
}
|
|
87
85
|
this.confirmBtn.onclick = () => {
|
|
88
86
|
this.hide()
|
|
@@ -92,12 +90,9 @@ export default class Modal extends ToPromise {
|
|
|
92
90
|
confirm: true
|
|
93
91
|
}
|
|
94
92
|
webHandleSuccess(result, opts.success, opts.complete)
|
|
95
|
-
this.toPromiseResolve(result)
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
this.modal.classList.add('show')
|
|
99
|
-
|
|
100
|
-
return this.toPromiseInitPromise()
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
hide () {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function showModal (options = {}) {
|
|
4
|
+
let opts
|
|
5
|
+
|
|
6
|
+
if (options.showCancel === undefined || options.showCancel) {
|
|
7
|
+
opts = changeOpts(options, {
|
|
8
|
+
confirmText: 'confirmButtonText',
|
|
9
|
+
cancelText: 'cancelButtonText'
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
handleSuccess(opts, res => {
|
|
13
|
+
return changeOpts(res, undefined, { cancel: !res.confirm })
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
my.confirm(opts)
|
|
17
|
+
} else {
|
|
18
|
+
opts = changeOpts(options, {
|
|
19
|
+
confirmText: 'buttonText'
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
handleSuccess(opts, res => {
|
|
23
|
+
return changeOpts(res, undefined, { cancel: false, confirm: true })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
my.alert(opts)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
showModal
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const stopPullDownRefresh = ENV_OBJ.stopPullDownRefresh || envError('stopPullDownRefresh')
|
|
6
|
+
|
|
7
|
+
const startPullDownRefresh = ENV_OBJ.startPullDownRefresh || envError('startPullDownRefresh')
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
stopPullDownRefresh,
|
|
11
|
+
startPullDownRefresh
|
|
12
|
+
}
|
|
@@ -20,17 +20,13 @@ function stopPullDownRefresh (options = {}) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
webHandleSuccess(res, options.success, options.complete)
|
|
31
|
-
resolve(res)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
23
|
+
if (err) {
|
|
24
|
+
const res = { errMsg: `stopPullDownRefresh:fail ${err}` }
|
|
25
|
+
webHandleFail(res, options.fail, options.complete)
|
|
26
|
+
} else {
|
|
27
|
+
const res = { errMsg: 'stopPullDownRefresh:ok' }
|
|
28
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
29
|
+
}
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
|
|
@@ -54,17 +50,13 @@ function startPullDownRefresh (options = {}) {
|
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
webHandleSuccess(res, options.success, options.complete)
|
|
65
|
-
resolve(res)
|
|
66
|
-
}
|
|
67
|
-
})
|
|
53
|
+
if (err) {
|
|
54
|
+
const res = { errMsg: `startPullDownRefresh:fail ${err}` }
|
|
55
|
+
webHandleFail(res, options.fail, options.complete)
|
|
56
|
+
} else {
|
|
57
|
+
const res = { errMsg: 'startPullDownRefresh:ok' }
|
|
58
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
59
|
+
}
|
|
68
60
|
}
|
|
69
61
|
}
|
|
70
62
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function request (options = {}) {
|
|
4
|
+
const opts = changeOpts(options, {
|
|
5
|
+
header: 'headers'
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
handleSuccess(opts, res => {
|
|
9
|
+
return changeOpts(res, {
|
|
10
|
+
headers: 'header',
|
|
11
|
+
status: 'statusCode'
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
// request 在 1.11.0 以上版本才支持
|
|
16
|
+
// httpRequest 即将被废弃,钉钉端仍需要使用
|
|
17
|
+
if (my.canIUse('request')) {
|
|
18
|
+
return my.request(opts)
|
|
19
|
+
} else {
|
|
20
|
+
return my.httpRequest(opts)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
request
|
|
26
|
+
}
|
|
@@ -51,13 +51,11 @@ function request (options = { url: '' }) {
|
|
|
51
51
|
clarifyTimeoutError: false
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
55
54
|
if (method === 'GET') {
|
|
56
55
|
rOptions.params = rOptions.data || {}
|
|
57
56
|
delete rOptions.data
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
const promise = axios(rOptions).then(res => {
|
|
58
|
+
axios(rOptions).then(res => {
|
|
61
59
|
let data = res.data
|
|
62
60
|
if (dataType === 'json' && typeof data === 'string') {
|
|
63
61
|
try {
|
|
@@ -81,8 +79,7 @@ function request (options = { url: '' }) {
|
|
|
81
79
|
}
|
|
82
80
|
})
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
return promise
|
|
82
|
+
return requestTask
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
export {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { changeOpts, error, noop } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const TIPS_NAME = '支付宝环境 mpx'
|
|
4
|
+
|
|
5
|
+
function requestPayment (options = {}) {
|
|
6
|
+
if (!options.tradeNO) {
|
|
7
|
+
error(`请在支付函数 ${TIPS_NAME}.requestPayment 中添加 tradeNO 参数用于支付宝支付`)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const opts = changeOpts(options, {
|
|
11
|
+
timeStamp: '',
|
|
12
|
+
nonceStr: '',
|
|
13
|
+
package: '',
|
|
14
|
+
signType: '',
|
|
15
|
+
paySign: ''
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const cacheSuc = opts.success || noop
|
|
19
|
+
const cacheFail = opts.fail || noop
|
|
20
|
+
|
|
21
|
+
// 抹平用微信的 complete
|
|
22
|
+
if (typeof opts.complete === 'function') {
|
|
23
|
+
const cacheComplete = opts.complete
|
|
24
|
+
opts.complete = function (res) {
|
|
25
|
+
if (+res.resultCode === 9000) {
|
|
26
|
+
res.errMsg = 'requestPayment:ok'
|
|
27
|
+
cacheComplete.call(this, res)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
opts.success = function (res) {
|
|
33
|
+
if (+res.resultCode === 9000) {
|
|
34
|
+
cacheSuc.call(this, res)
|
|
35
|
+
} else {
|
|
36
|
+
cacheFail.call(this, res)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
my.tradePay(opts)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
requestPayment
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getEnvObj, envError } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
const ENV_OBJ = getEnvObj()
|
|
4
|
+
|
|
5
|
+
const redirectTo = ENV_OBJ.redirectTo || envError('redirectTo')
|
|
6
|
+
|
|
7
|
+
const navigateTo = ENV_OBJ.navigateTo || envError('navigateTo')
|
|
8
|
+
|
|
9
|
+
const navigateBack = ENV_OBJ.navigateBack || envError('navigateBack')
|
|
10
|
+
|
|
11
|
+
const reLaunch = ENV_OBJ.reLaunch || envError('reLaunch')
|
|
12
|
+
|
|
13
|
+
const switchTab = ENV_OBJ.switchTab || envError('switchTab')
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
redirectTo,
|
|
17
|
+
navigateTo,
|
|
18
|
+
navigateBack,
|
|
19
|
+
reLaunch,
|
|
20
|
+
switchTab
|
|
21
|
+
}
|
|
@@ -15,30 +15,24 @@ function redirectTo (options = {}) {
|
|
|
15
15
|
webHandleFail(res, options.fail, options.complete)
|
|
16
16
|
return Promise.reject(res)
|
|
17
17
|
}
|
|
18
|
-
router.__mpxAction = {
|
|
19
|
-
type: 'redirect'
|
|
20
|
-
}
|
|
18
|
+
router.__mpxAction = { type: 'redirect' }
|
|
21
19
|
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
routeCount: ++routeCount
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
() => {
|
|
31
|
-
const res = { errMsg: 'redirectTo:ok' }
|
|
32
|
-
webHandleSuccess(res, options.success, options.complete)
|
|
33
|
-
resolve(res)
|
|
34
|
-
},
|
|
35
|
-
err => {
|
|
36
|
-
const res = { errMsg: `redirectTo:fail ${err}` }
|
|
37
|
-
webHandleFail(res, options.fail, options.complete)
|
|
38
|
-
reject(res)
|
|
20
|
+
router.replace(
|
|
21
|
+
{
|
|
22
|
+
path: options.url,
|
|
23
|
+
query: {
|
|
24
|
+
routeCount: ++routeCount
|
|
39
25
|
}
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
},
|
|
27
|
+
() => {
|
|
28
|
+
const res = { errMsg: 'redirectTo:ok' }
|
|
29
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
30
|
+
},
|
|
31
|
+
err => {
|
|
32
|
+
const res = { errMsg: `redirectTo:fail ${err}` }
|
|
33
|
+
webHandleFail(res, options.fail, options.complete)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
38
|
|
|
@@ -63,26 +57,22 @@ function navigateTo (options = {}) {
|
|
|
63
57
|
eventChannel._addListeners(options.events)
|
|
64
58
|
}
|
|
65
59
|
if (routeCount === 0 && router.currentRoute.query.routeCount) routeCount = router.currentRoute.query.routeCount
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
routeCount: ++routeCount
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
() => {
|
|
75
|
-
const res = { errMsg: 'navigateTo:ok', eventChannel }
|
|
76
|
-
webHandleSuccess(res, options.success, options.complete)
|
|
77
|
-
resolve(res)
|
|
78
|
-
},
|
|
79
|
-
err => {
|
|
80
|
-
const res = { errMsg: err }
|
|
81
|
-
webHandleFail(res, options.fail, options.complete)
|
|
82
|
-
reject(res)
|
|
60
|
+
router.push(
|
|
61
|
+
{
|
|
62
|
+
path: options.url,
|
|
63
|
+
query: {
|
|
64
|
+
routeCount: ++routeCount
|
|
83
65
|
}
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
},
|
|
67
|
+
() => {
|
|
68
|
+
const res = { errMsg: 'navigateTo:ok', eventChannel }
|
|
69
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
70
|
+
},
|
|
71
|
+
err => {
|
|
72
|
+
const res = { errMsg: err }
|
|
73
|
+
webHandleFail(res, options.fail, options.complete)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
86
76
|
}
|
|
87
77
|
}
|
|
88
78
|
|
|
@@ -105,7 +95,6 @@ function navigateBack (options = {}) {
|
|
|
105
95
|
router.go(-delta)
|
|
106
96
|
const res = { errMsg: 'navigateBack:ok' }
|
|
107
97
|
webHandleSuccess(res, options.success, options.complete)
|
|
108
|
-
return Promise.resolve(res)
|
|
109
98
|
}
|
|
110
99
|
}
|
|
111
100
|
|
|
@@ -129,30 +118,25 @@ function reLaunch (options = {}) {
|
|
|
129
118
|
router.go(-delta)
|
|
130
119
|
} else {
|
|
131
120
|
router.__mpxAction.replaced = true
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
routeCount
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
() => {
|
|
141
|
-
const res = { errMsg: 'reLaunch:ok' }
|
|
142
|
-
webHandleSuccess(res, options.success, options.complete)
|
|
143
|
-
resolve(res)
|
|
144
|
-
},
|
|
145
|
-
err => {
|
|
146
|
-
const res = { errMsg: err }
|
|
147
|
-
webHandleFail(res, options.fail, options.complete)
|
|
148
|
-
!options.fail && reject(res)
|
|
121
|
+
router.replace(
|
|
122
|
+
{
|
|
123
|
+
path: options.url,
|
|
124
|
+
query: {
|
|
125
|
+
routeCount
|
|
149
126
|
}
|
|
150
|
-
|
|
151
|
-
|
|
127
|
+
},
|
|
128
|
+
() => {
|
|
129
|
+
const res = { errMsg: 'reLaunch:ok' }
|
|
130
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
131
|
+
},
|
|
132
|
+
err => {
|
|
133
|
+
const res = { errMsg: err }
|
|
134
|
+
webHandleFail(res, options.fail, options.complete)
|
|
135
|
+
}
|
|
136
|
+
)
|
|
152
137
|
}
|
|
153
138
|
const res = { errMsg: 'reLaunch:ok' }
|
|
154
139
|
webHandleSuccess(res, options.success, options.complete)
|
|
155
|
-
return Promise.resolve(res)
|
|
156
140
|
}
|
|
157
141
|
}
|
|
158
142
|
|
|
@@ -181,28 +165,23 @@ function switchTab (options = {}) {
|
|
|
181
165
|
router.go(-delta)
|
|
182
166
|
} else {
|
|
183
167
|
router.__mpxAction.replaced = true
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
!options.fail && reject(res)
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
})
|
|
168
|
+
router.replace(
|
|
169
|
+
{
|
|
170
|
+
path: options.url
|
|
171
|
+
},
|
|
172
|
+
() => {
|
|
173
|
+
const res = { errMsg: 'switchTab:ok' }
|
|
174
|
+
webHandleSuccess(res, options.success, options.complete)
|
|
175
|
+
},
|
|
176
|
+
err => {
|
|
177
|
+
const res = { errMsg: err }
|
|
178
|
+
webHandleFail(res, options.fail, options.complete)
|
|
179
|
+
}
|
|
180
|
+
)
|
|
201
181
|
}
|
|
202
182
|
}
|
|
203
183
|
const res = { errMsg: 'switchTab:ok' }
|
|
204
184
|
webHandleSuccess(res, options.success, options.complete)
|
|
205
|
-
return Promise.resolve(res)
|
|
206
185
|
}
|
|
207
186
|
}
|
|
208
187
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { changeOpts, handleSuccess } from '../../../common/js'
|
|
2
|
+
|
|
3
|
+
function scanCode (options = {}) {
|
|
4
|
+
const opts = changeOpts(options, {
|
|
5
|
+
onlyFromCamera: 'hideAlbum'
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
handleSuccess(opts, res => {
|
|
9
|
+
return changeOpts(res, { code: 'result' })
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
my.scan(opts)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
scanCode
|
|
17
|
+
}
|