@mpxjs/api-proxy 2.7.52 → 2.8.0-beta.0
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/ToPromise.js +3 -0
- package/src/common/js/utils.js +10 -3
- package/src/index.js +1 -1
- package/src/index.web.js +1 -1
- package/src/mini/platform/wxToAli.js +12 -11
- package/src/mini/platform/wxToQq.js +1 -1
- package/src/mini/platform/wxToTt.js +9 -0
- package/src/mini/transform.js +9 -6
- package/src/web/api/base/base64.js +28 -28
- package/src/web/api/create-selector-query/NodesRef.js +1 -0
- package/src/web/api/create-selector-query/SelectQuery.js +1 -0
- package/src/web/api/device/network/onNetworkStatusChange.js +3 -3
- package/src/web/api/event-channel/index.js +9 -3
- package/src/web/api/modal/Modal.js +3 -1
- package/src/web/api/socket/SocketTask.js +5 -5
- package/src/web/api/storage/index.js +5 -4
- package/src/web/api/system/index.js +1 -1
- package/src/web/api/tab-bar/index.js +3 -3
- package/src/web/api/toast/Toast.js +1 -1
- package/src/web/api/window/index.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0-beta.0",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"axios": "^0.21.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "bce2bb22d8990ad02879f45fc95c02ead43ba0e4"
|
|
43
43
|
}
|
|
@@ -3,15 +3,18 @@ class ToPromise {
|
|
|
3
3
|
this._resolve = null
|
|
4
4
|
this._reject = null
|
|
5
5
|
}
|
|
6
|
+
|
|
6
7
|
toPromiseInitPromise () {
|
|
7
8
|
return new Promise((resolve, reject) => {
|
|
8
9
|
this._resolve = resolve
|
|
9
10
|
this._reject = reject
|
|
10
11
|
})
|
|
11
12
|
}
|
|
13
|
+
|
|
12
14
|
toPromiseResolve (res) {
|
|
13
15
|
this._resolve(res)
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
toPromiseReject (err) {
|
|
16
19
|
this._reject(err)
|
|
17
20
|
}
|
package/src/common/js/utils.js
CHANGED
|
@@ -12,12 +12,17 @@
|
|
|
12
12
|
* d: 4 // 增加 d
|
|
13
13
|
* })
|
|
14
14
|
*/
|
|
15
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty
|
|
16
|
+
|
|
17
|
+
function hasOwn (obj, key) {
|
|
18
|
+
return hasOwnProperty.call(obj, key)
|
|
19
|
+
}
|
|
15
20
|
|
|
16
21
|
function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
17
22
|
let opts = {}
|
|
18
23
|
|
|
19
24
|
Object.keys(options).forEach(key => {
|
|
20
|
-
|
|
25
|
+
const myKey = hasOwn(updateOrRemoveOpt, key) ? updateOrRemoveOpt[key] : key
|
|
21
26
|
if (myKey !== '') {
|
|
22
27
|
opts[myKey] = options[key]
|
|
23
28
|
}
|
|
@@ -31,6 +36,7 @@ function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
|
|
|
31
36
|
/**
|
|
32
37
|
* @param {Object} opts 原参数
|
|
33
38
|
* @param {Function} getOptions 获取 success 回调修改后的参数
|
|
39
|
+
* @param {Object} thisObj this对象
|
|
34
40
|
*/
|
|
35
41
|
const handleSuccess = (opts, getOptions = noop, thisObj) => {
|
|
36
42
|
if (!opts.success) {
|
|
@@ -92,7 +98,7 @@ function makeMap (arr) {
|
|
|
92
98
|
}, {})
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
const
|
|
101
|
+
const isBrowser = typeof window !== 'undefined'
|
|
96
102
|
|
|
97
103
|
export {
|
|
98
104
|
changeOpts,
|
|
@@ -103,5 +109,6 @@ export {
|
|
|
103
109
|
warn,
|
|
104
110
|
noop,
|
|
105
111
|
makeMap,
|
|
106
|
-
|
|
112
|
+
isBrowser,
|
|
113
|
+
hasOwn
|
|
107
114
|
}
|
package/src/index.js
CHANGED
package/src/index.web.js
CHANGED
|
@@ -38,7 +38,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
38
38
|
if (systemInfo) return systemInfo
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const res = ALI_OBJ.getSystemInfoSync() || {}
|
|
42
42
|
|
|
43
43
|
res.system = `${res.platform} ${res.system}`
|
|
44
44
|
res.SDKVersion = ALI_OBJ.SDKVersion
|
|
@@ -54,7 +54,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
54
54
|
},
|
|
55
55
|
|
|
56
56
|
nextTick (fn) {
|
|
57
|
-
|
|
57
|
+
Promise.resolve().then(fn)
|
|
58
58
|
},
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -86,7 +86,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
86
86
|
})
|
|
87
87
|
|
|
88
88
|
handleSuccess(opts, res => {
|
|
89
|
-
return changeOpts(res, undefined, {
|
|
89
|
+
return changeOpts(res, undefined, { cancel: !res.confirm })
|
|
90
90
|
})
|
|
91
91
|
|
|
92
92
|
ALI_OBJ.confirm(opts)
|
|
@@ -122,7 +122,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
122
122
|
const cacheFail = opts.fail || noop
|
|
123
123
|
|
|
124
124
|
opts.success = function (res) {
|
|
125
|
-
|
|
125
|
+
const sucRes = changeOpts(res, {
|
|
126
126
|
index: 'tapIndex'
|
|
127
127
|
})
|
|
128
128
|
if (sucRes.tapIndex === -1) {
|
|
@@ -235,7 +235,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
235
235
|
const opts = changeOpts(options)
|
|
236
236
|
|
|
237
237
|
if (opts.current) {
|
|
238
|
-
|
|
238
|
+
const idx = options.urls.indexOf(opts.current)
|
|
239
239
|
opts.current = idx !== -1 ? idx : 0
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -328,7 +328,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
328
328
|
handleSuccess(opts, res => {
|
|
329
329
|
if (res.fileList) {
|
|
330
330
|
res.fileList.forEach(file => {
|
|
331
|
-
|
|
331
|
+
const resFile = changeOpts(file, {
|
|
332
332
|
apFilePath: 'filePath'
|
|
333
333
|
})
|
|
334
334
|
file = resFile
|
|
@@ -490,10 +490,10 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
490
490
|
warn(`支付宝不支持在 ${TIPS_NAME}.getUserInfo 中使用 lang 参数`)
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
|
|
493
|
+
const opts = changeOpts(options)
|
|
494
494
|
|
|
495
495
|
handleSuccess(opts, res => {
|
|
496
|
-
|
|
496
|
+
const userInfo = changeOpts(res, { avatar: 'avatarUrl' }, { gender: 0 })
|
|
497
497
|
const params = ['country', 'province', 'city', 'language']
|
|
498
498
|
|
|
499
499
|
params.forEach(key => {
|
|
@@ -518,7 +518,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
518
518
|
error(`请在支付函数 ${TIPS_NAME}.requestPayment 中添加 tradeNO 参数用于支付宝支付`)
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
-
|
|
521
|
+
const opts = changeOpts(options, {
|
|
522
522
|
timeStamp: '',
|
|
523
523
|
nonceStr: '',
|
|
524
524
|
package: '',
|
|
@@ -556,7 +556,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
556
556
|
*/
|
|
557
557
|
|
|
558
558
|
createCanvasContext (canvasId = {}) {
|
|
559
|
-
|
|
559
|
+
const ctx = ALI_OBJ.createCanvasContext(canvasId)
|
|
560
560
|
|
|
561
561
|
CANVAS_MAP[canvasId] = ctx
|
|
562
562
|
|
|
@@ -620,6 +620,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
620
620
|
* WXML
|
|
621
621
|
*/
|
|
622
622
|
|
|
623
|
+
// todo 支付宝基础库升级至2.7.4以上可去除
|
|
623
624
|
createSelectorQuery (options = {}) {
|
|
624
625
|
const selectorQuery = ALI_OBJ.createSelectorQuery(options)
|
|
625
626
|
const proxyMethods = ['boundingClientRect', 'scrollOffset']
|
|
@@ -636,7 +637,7 @@ const getWxToAliApi = ({ optimize = false }) => {
|
|
|
636
637
|
selectorQuery.exec = function (originalCb = noop) {
|
|
637
638
|
const cb = function (results) {
|
|
638
639
|
results.forEach((item, index) => {
|
|
639
|
-
cbs[index]
|
|
640
|
+
cbs[index](item)
|
|
640
641
|
})
|
|
641
642
|
originalCb(results)
|
|
642
643
|
}
|
package/src/mini/transform.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { error, getEnvObj, genFromMap, makeMap } from '../common/js'
|
|
2
2
|
import getWxToAliApi from './platform/wxToAli'
|
|
3
3
|
import getWxToQqApi from './platform/wxToQq'
|
|
4
|
+
import getWxToTtApi from './platform/wxToTt'
|
|
4
5
|
|
|
5
6
|
const fromMap = genFromMap()
|
|
6
7
|
|
|
@@ -14,17 +15,19 @@ function transformApi (options) {
|
|
|
14
15
|
const to = options.to
|
|
15
16
|
const fromTo = joinName(from, to)
|
|
16
17
|
const wxToAliApi = getWxToAliApi({ optimize: options.optimize })
|
|
17
|
-
const wxToQqApi = getWxToQqApi(
|
|
18
|
+
const wxToQqApi = getWxToQqApi()
|
|
19
|
+
const wxToTtApi = getWxToTtApi()
|
|
18
20
|
const platformMap = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
wx_ali: wxToAliApi,
|
|
22
|
+
wx_qq: wxToQqApi,
|
|
23
|
+
wx_tt: wxToTtApi
|
|
21
24
|
}
|
|
22
25
|
const needProxy = Object.create(null)
|
|
23
26
|
const excludeMap = makeMap(options.exclude)
|
|
24
|
-
const
|
|
25
|
-
Object.keys(envObj).concat(Object.keys(
|
|
27
|
+
const platformApi = platformMap[fromTo] || {}
|
|
28
|
+
Object.keys(envObj).concat(Object.keys(platformApi)).forEach((key) => {
|
|
26
29
|
if (!excludeMap[key]) {
|
|
27
|
-
needProxy[key] = envObj[key] ||
|
|
30
|
+
needProxy[key] = envObj[key] || platformApi[key]
|
|
28
31
|
}
|
|
29
32
|
})
|
|
30
33
|
const result = Object.create(null)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// fork base64-js@1.3.1
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const lookup = []
|
|
3
|
+
const revLookup = []
|
|
4
|
+
const Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
for (
|
|
6
|
+
const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
7
|
+
for (let i = 0, len = code.length; i < len; ++i) {
|
|
8
8
|
lookup[i] = code[i]
|
|
9
9
|
revLookup[code.charCodeAt(i)] = i
|
|
10
10
|
}
|
|
@@ -15,7 +15,7 @@ revLookup['-'.charCodeAt(0)] = 62
|
|
|
15
15
|
revLookup['_'.charCodeAt(0)] = 63
|
|
16
16
|
|
|
17
17
|
function getLens (b64) {
|
|
18
|
-
|
|
18
|
+
const len = b64.length
|
|
19
19
|
|
|
20
20
|
if (len % 4 > 0) {
|
|
21
21
|
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
@@ -23,10 +23,10 @@ function getLens (b64) {
|
|
|
23
23
|
|
|
24
24
|
// Trim off extra bytes after placeholder bytes are found
|
|
25
25
|
// See: https://github.com/beatgammit/base64-js/issues/42
|
|
26
|
-
|
|
26
|
+
let validLen = b64.indexOf('=')
|
|
27
27
|
if (validLen === -1) validLen = len
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const placeHoldersLen = validLen === len
|
|
30
30
|
? 0
|
|
31
31
|
: 4 - (validLen % 4)
|
|
32
32
|
|
|
@@ -35,9 +35,9 @@ function getLens (b64) {
|
|
|
35
35
|
|
|
36
36
|
// base64 is 4/3 + up to two characters of the original data
|
|
37
37
|
function byteLength (b64) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const lens = getLens(b64)
|
|
39
|
+
const validLen = lens[0]
|
|
40
|
+
const placeHoldersLen = lens[1]
|
|
41
41
|
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -46,21 +46,21 @@ function _byteLength (b64, validLen, placeHoldersLen) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function toByteArray (b64) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let tmp
|
|
50
|
+
const lens = getLens(b64)
|
|
51
|
+
const validLen = lens[0]
|
|
52
|
+
const placeHoldersLen = lens[1]
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
const arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
let curByte = 0
|
|
57
57
|
|
|
58
58
|
// if there are placeholders, only get up to the last complete 4 chars
|
|
59
|
-
|
|
59
|
+
const len = placeHoldersLen > 0
|
|
60
60
|
? validLen - 4
|
|
61
61
|
: validLen
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
let i
|
|
64
64
|
for (i = 0; i < len; i += 4) {
|
|
65
65
|
tmp =
|
|
66
66
|
(revLookup[b64.charCodeAt(i)] << 18) |
|
|
@@ -99,9 +99,9 @@ function tripletToBase64 (num) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function encodeChunk (uint8, start, end) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (
|
|
102
|
+
let tmp
|
|
103
|
+
const output = []
|
|
104
|
+
for (let i = start; i < end; i += 3) {
|
|
105
105
|
tmp =
|
|
106
106
|
((uint8[i] << 16) & 0xFF0000) +
|
|
107
107
|
((uint8[i + 1] << 8) & 0xFF00) +
|
|
@@ -112,14 +112,14 @@ function encodeChunk (uint8, start, end) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
function fromByteArray (uint8) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
let tmp
|
|
116
|
+
const len = uint8.length
|
|
117
|
+
const extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
118
|
+
const parts = []
|
|
119
|
+
const maxChunkLength = 16383 // must be multiple of 3
|
|
120
120
|
|
|
121
121
|
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
122
|
-
for (
|
|
122
|
+
for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
123
123
|
parts.push(encodeChunk(
|
|
124
124
|
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
|
|
125
125
|
))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBrowser } from '../../../../common/js/utils'
|
|
2
2
|
const fnMap = new Map()
|
|
3
3
|
|
|
4
4
|
const oldObserveList = new Set()
|
|
5
5
|
|
|
6
|
-
if (
|
|
6
|
+
if (isBrowser) {
|
|
7
7
|
window.addEventListener('offline', () => {
|
|
8
8
|
oldObserveList.forEach(fn => fn({ isConnected: false, type: 'none' }))
|
|
9
9
|
})
|
|
@@ -14,7 +14,7 @@ if (inBrowser) {
|
|
|
14
14
|
|
|
15
15
|
export function onNetworkStatusChange (callbackFn) {
|
|
16
16
|
if (navigator.connection) {
|
|
17
|
-
|
|
17
|
+
const proxyCallback = evt => {
|
|
18
18
|
const isConnected = navigator.onLine
|
|
19
19
|
callbackFn({
|
|
20
20
|
isConnected,
|
|
@@ -2,10 +2,11 @@ class EventChannel {
|
|
|
2
2
|
constructor () {
|
|
3
3
|
this.listener = {}
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
emit (eventName, ...args) {
|
|
6
7
|
const cbs = this.listener[eventName]
|
|
7
8
|
if (cbs) {
|
|
8
|
-
cbs.
|
|
9
|
+
cbs.forEach((item, index) => {
|
|
9
10
|
try {
|
|
10
11
|
item.fn.apply(this, args)
|
|
11
12
|
} catch (e) {
|
|
@@ -17,12 +18,13 @@ class EventChannel {
|
|
|
17
18
|
})
|
|
18
19
|
}
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
off (eventName, EventCallback) {
|
|
21
23
|
if (EventCallback) {
|
|
22
24
|
const cbs = this.listener[eventName]
|
|
23
25
|
const copyCbs = []
|
|
24
26
|
if (cbs) {
|
|
25
|
-
cbs.
|
|
27
|
+
cbs.forEach((item) => {
|
|
26
28
|
if (item.fn !== EventCallback) {
|
|
27
29
|
copyCbs.push(item)
|
|
28
30
|
}
|
|
@@ -33,18 +35,22 @@ class EventChannel {
|
|
|
33
35
|
this.listener[eventName] && (this.listener[eventName].length = 0)
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
on (eventName, EventCallback) {
|
|
37
40
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'on' })
|
|
38
41
|
}
|
|
42
|
+
|
|
39
43
|
once (eventName, EventCallback) {
|
|
40
44
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type: 'once' })
|
|
41
45
|
}
|
|
46
|
+
|
|
42
47
|
_addListener (eventName, EventCallback, type) {
|
|
43
48
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: EventCallback, type })
|
|
44
49
|
}
|
|
50
|
+
|
|
45
51
|
_addListeners (events) {
|
|
46
52
|
if (Object.prototype.toString.call(events) === '[object Object]') {
|
|
47
|
-
Object.keys(events).
|
|
53
|
+
Object.keys(events).forEach((eventName) => {
|
|
48
54
|
(this.listener[eventName] || (this.listener[eventName] = [])).push({ fn: events[eventName], type: 'on' })
|
|
49
55
|
})
|
|
50
56
|
}
|
|
@@ -2,7 +2,7 @@ import { ToPromise, webHandleSuccess } from '../../../common/js'
|
|
|
2
2
|
import '../../../common/stylus/Modal.styl'
|
|
3
3
|
// import { forEach } from '@didi/mpx-fetch/src/util'
|
|
4
4
|
// 汉字为两个字符,字母/数字为一个字符
|
|
5
|
-
|
|
5
|
+
const _getLength = (t) => {
|
|
6
6
|
let len = 0
|
|
7
7
|
for (let i = 0; i < t.length; i++) {
|
|
8
8
|
if (t.charCodeAt(i) > 127 || t.charCodeAt(i) === 94) {
|
|
@@ -72,6 +72,7 @@ export default class Modal extends ToPromise {
|
|
|
72
72
|
this.cancelBtn = cancelBtn
|
|
73
73
|
this.confirmBtn = confirmBtn
|
|
74
74
|
}
|
|
75
|
+
|
|
75
76
|
show (options = {}) {
|
|
76
77
|
if (options.confirmText && _getLength(options.confirmText) > 8) {
|
|
77
78
|
// eslint-disable-next-line
|
|
@@ -126,6 +127,7 @@ export default class Modal extends ToPromise {
|
|
|
126
127
|
|
|
127
128
|
return this.toPromiseInitPromise()
|
|
128
129
|
}
|
|
130
|
+
|
|
129
131
|
hide () {
|
|
130
132
|
if (this.hideTimer) {
|
|
131
133
|
clearTimeout(this.hideTimer)
|
|
@@ -20,23 +20,23 @@ class SocketTask {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
get CONNECTING () {
|
|
23
|
-
return this._socket
|
|
23
|
+
return this._socket.CONNECTING || 0
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
get OPEN () {
|
|
27
|
-
return this._socket
|
|
27
|
+
return this._socket.OPEN || 1
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
get CLOSING () {
|
|
31
|
-
return this._socket
|
|
31
|
+
return this._socket.CLOSING || 2
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
get CLOSED () {
|
|
35
|
-
return this._socket
|
|
35
|
+
return this._socket.CLOSED || 3
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
get readyState () {
|
|
39
|
-
return this._socket
|
|
39
|
+
return this._socket.readyState
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
send (options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webHandleSuccess, webHandleFail } from '../../../common/js'
|
|
1
|
+
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setStorage (options = {}) {
|
|
4
4
|
const { key, data, success, fail, complete } = options
|
|
@@ -43,7 +43,7 @@ function getStorage (options = {}) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function getStorageSync (key) {
|
|
46
|
-
|
|
46
|
+
const res = getItem(key)
|
|
47
47
|
if (res.result) return res.data
|
|
48
48
|
|
|
49
49
|
return ''
|
|
@@ -53,9 +53,10 @@ function getItem (key) {
|
|
|
53
53
|
let item
|
|
54
54
|
try {
|
|
55
55
|
item = JSON.parse(window.localStorage.getItem(key))
|
|
56
|
-
} catch (e) {
|
|
56
|
+
} catch (e) {
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
if (item && typeof item === 'object' && item
|
|
59
|
+
if (item && typeof item === 'object' && hasOwn(item, 'data')) {
|
|
59
60
|
return { result: true, data: item.data }
|
|
60
61
|
} else {
|
|
61
62
|
return { result: false }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webHandleSuccess, webHandleFail } from '../../../common/js'
|
|
1
|
+
import { webHandleSuccess, webHandleFail, hasOwn } from '../../../common/js'
|
|
2
2
|
import Vue from 'vue'
|
|
3
3
|
|
|
4
4
|
function setTabBarStyle (options = {}) {
|
|
@@ -9,7 +9,7 @@ function setTabBarStyle (options = {}) {
|
|
|
9
9
|
rejected = { errMsg: 'setTabBarStyle:fail custom Tabbar' }
|
|
10
10
|
} else {
|
|
11
11
|
'color|selectedColor|backgroundColor|borderStyle'.split('|').forEach((key) => {
|
|
12
|
-
if (options
|
|
12
|
+
if (hasOwn(options, key)) {
|
|
13
13
|
Vue.set(tabBar, key, options[key])
|
|
14
14
|
}
|
|
15
15
|
})
|
|
@@ -37,7 +37,7 @@ function setTabBarItem (options = {}) {
|
|
|
37
37
|
const item = tabBar.list[options.index]
|
|
38
38
|
if (item) {
|
|
39
39
|
'text|iconPath|selectedIconPath'.split('|').forEach((key) => {
|
|
40
|
-
if (options
|
|
40
|
+
if (hasOwn(options, key)) {
|
|
41
41
|
Vue.set(item, key, options[key])
|
|
42
42
|
}
|
|
43
43
|
})
|
|
@@ -3,7 +3,7 @@ import '../../../common/stylus/Toast.styl'
|
|
|
3
3
|
import '../../../common/stylus/Loading.styl'
|
|
4
4
|
|
|
5
5
|
function createDom (tag, attrs = {}, children = []) {
|
|
6
|
-
|
|
6
|
+
const dom = document.createElement(tag)
|
|
7
7
|
Object.keys(attrs).forEach(k => dom.setAttribute(k, attrs[k]))
|
|
8
8
|
children.length && children.forEach(child => dom.appendChild(child))
|
|
9
9
|
return dom
|