@smart100/spu-web-plugin 1.0.17 → 1.0.19
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/dist/index.d.ts +4 -3
- package/dist/spu-web-plugin.mjs +323 -189
- package/package.json +1 -1
- package/src/envService.ts +1 -1
- package/src/index.ts +12 -2
- package/src/login.ts +97 -7
- package/src/map/MapService.ts +51 -38
- package/src/map/index.ts +7 -7
- package/src/tenantSetting.ts +0 -58
- package/src/types/index.d.ts +4 -3
- package/src/utils.ts +37 -1
package/package.json
CHANGED
package/src/envService.ts
CHANGED
|
@@ -22,7 +22,7 @@ async function getEnvname(): Promise<string> {
|
|
|
22
22
|
envname = queryEnvname
|
|
23
23
|
} else if (window?.aPaaS?.getWebInitParams && window?.Native?.setNavigationBarReturnButton) {
|
|
24
24
|
// 手机端 查 envname
|
|
25
|
-
// 只有手机端有 setNavigationBarReturnButton 方法
|
|
25
|
+
// 只有手机端有 setNavigationBarReturnButton 和 getWebInitParams 方法
|
|
26
26
|
envname = await new Promise((resolve, reject) => {
|
|
27
27
|
window.aPaaS.getWebInitParams((params: any) => {
|
|
28
28
|
resolve(params?.envname || '')
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,15 @@ import { globalConfig } from './globalConfig'
|
|
|
9
9
|
import { downloadService, uploadService } from './oss'
|
|
10
10
|
import { getServToken } from './oss/servtoken'
|
|
11
11
|
import { getCloudServ } from './oss/cloudServ'
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
getUniqueid,
|
|
14
|
+
functionCheck,
|
|
15
|
+
setTitle,
|
|
16
|
+
isInApp,
|
|
17
|
+
isdebugger,
|
|
18
|
+
isvirtuallocation,
|
|
19
|
+
getServerTime
|
|
20
|
+
} from './utils'
|
|
13
21
|
import { installUrlquery } from './urlquery'
|
|
14
22
|
import { mapService } from './map/MapService'
|
|
15
23
|
import AMapLoader from './map/AMapLoader'
|
|
@@ -45,6 +53,7 @@ const getDefaultGlobalOptions = () => {
|
|
|
45
53
|
modulekey: arr[1] || '',
|
|
46
54
|
moduleversion: arr[2] || '',
|
|
47
55
|
storageproxyprefix: '',
|
|
56
|
+
isfixapptokenexpired: false, // 是否修复apptoken过期问题 目前版本暂时不默认修复 等门户引擎验证通过之后 再改成默认修复
|
|
48
57
|
singleLoginCallback: null,
|
|
49
58
|
router: null
|
|
50
59
|
}
|
|
@@ -73,7 +82,7 @@ const install = (app: any, options: any) => {
|
|
|
73
82
|
console.log(globalOptions)
|
|
74
83
|
|
|
75
84
|
// setTimeout(() => {
|
|
76
|
-
// console.error('
|
|
85
|
+
// console.error('9999')
|
|
77
86
|
// }, 1000)
|
|
78
87
|
|
|
79
88
|
// if (install.installed) return
|
|
@@ -116,6 +125,7 @@ export {
|
|
|
116
125
|
getUniqueid,
|
|
117
126
|
getUuid,
|
|
118
127
|
functionCheck,
|
|
128
|
+
getServerTime,
|
|
119
129
|
setTitle,
|
|
120
130
|
isInApp,
|
|
121
131
|
AMapLoader,
|
package/src/login.ts
CHANGED
|
@@ -3,7 +3,7 @@ import jwtDecode from 'jwt-decode'
|
|
|
3
3
|
import { lsProxy } from './storageProxy'
|
|
4
4
|
import { axios } from './axios'
|
|
5
5
|
import cloudServ from './oss/cloudServ'
|
|
6
|
-
import core from './core'
|
|
6
|
+
import core, { Module } from './core'
|
|
7
7
|
import { urlquery } from './urlquery'
|
|
8
8
|
import { getData, setData, removeData } from './storageCache'
|
|
9
9
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
removeTecode
|
|
18
18
|
} from './envService'
|
|
19
19
|
import { tenantSetting } from './tenantSetting'
|
|
20
|
+
import { globalOptions } from './index'
|
|
20
21
|
|
|
21
22
|
type JwtResult = {
|
|
22
23
|
LoginUser: IAny
|
|
@@ -24,11 +25,14 @@ type JwtResult = {
|
|
|
24
25
|
} | null
|
|
25
26
|
|
|
26
27
|
function getToken() {
|
|
27
|
-
|
|
28
|
-
//
|
|
28
|
+
const token = getData('token')
|
|
29
|
+
// const token = lsProxy.getItem('token') as string
|
|
30
|
+
return token
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
function setToken(value: string) {
|
|
34
|
+
// console.log('setToken', value)
|
|
35
|
+
// debugger
|
|
32
36
|
setData('token', value)
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -110,6 +114,7 @@ function removeUser() {
|
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
function parseToken(token?: string) {
|
|
117
|
+
// debugger
|
|
113
118
|
if (!token) {
|
|
114
119
|
console.error('token为空 jwt解析token出错')
|
|
115
120
|
return null
|
|
@@ -328,9 +333,11 @@ function formatTenant(tenant: ITenantInfo) {
|
|
|
328
333
|
|
|
329
334
|
async function getAndSetTenant(tenantcode?: string) {
|
|
330
335
|
try {
|
|
331
|
-
const tenantsRes: null | ITenantInfo[] = await axios
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
const tenantsRes: null | ITenantInfo[] = await axios
|
|
337
|
+
.get('/api/auth/tenantlist', {})
|
|
338
|
+
.then((res: any) => {
|
|
339
|
+
return res?.data?.tenants
|
|
340
|
+
})
|
|
334
341
|
|
|
335
342
|
let tenant: ITenantInfo | null = null
|
|
336
343
|
if (tenantsRes?.length) {
|
|
@@ -445,9 +452,88 @@ function startRefreshtoken() {
|
|
|
445
452
|
}, time)
|
|
446
453
|
}
|
|
447
454
|
|
|
455
|
+
// 获取 spu 容器 token
|
|
456
|
+
const getSPUContainerToken = (): Promise<any> => {
|
|
457
|
+
return new Promise((resolve, reject) => {
|
|
458
|
+
if (window.aPaaS?.getToken) {
|
|
459
|
+
window.aPaaS.getToken((res: any) => {
|
|
460
|
+
console.log('window.aPaaS.getToken success', res)
|
|
461
|
+
const token = res?.token
|
|
462
|
+
const tokenexpires = res?.tokenExpires
|
|
463
|
+
const refreshtoken = res?.refreshToken
|
|
464
|
+
|
|
465
|
+
if (token && tokenexpires && refreshtoken) {
|
|
466
|
+
resolve({
|
|
467
|
+
token,
|
|
468
|
+
tokenexpires,
|
|
469
|
+
refreshtoken
|
|
470
|
+
})
|
|
471
|
+
} else {
|
|
472
|
+
console.error('window.aPaaS.getToken fail')
|
|
473
|
+
resolve(null)
|
|
474
|
+
}
|
|
475
|
+
})
|
|
476
|
+
} else {
|
|
477
|
+
console.warn('window.aPaaS.getToken fail: not in SPU container')
|
|
478
|
+
resolve(null)
|
|
479
|
+
}
|
|
480
|
+
})
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// 如果APP端在SPU页面切到后台 然后又切回前台 有可能发生
|
|
484
|
+
// 1、切后台时间过长导致 token 过期
|
|
485
|
+
// 2、切后台后打开太多别的应用 导致切回前台时内存不足 从而导致 SPU 的 webview reload
|
|
486
|
+
// 如果 1 2 同时发生 那么当前SPU页面重走单点登录流程 而url上的token已经过期 会导致单点登录失败
|
|
487
|
+
// 因此 在APP端 单点登录不使用url上的token 而是直接拿App端的 App端能保证拿到的token一直不过期
|
|
488
|
+
const fixLoginQuery = async (query: IAny) => {
|
|
489
|
+
const newQuery = cloneDeep(query)
|
|
490
|
+
const type = await Module.getSpuContainerType()
|
|
491
|
+
if (type === 'app' && window.aPaaS?.getToken) {
|
|
492
|
+
console.log('SPU is in App, singleLogin use App token.')
|
|
493
|
+
const tokenData = await getSPUContainerToken()
|
|
494
|
+
if (tokenData) {
|
|
495
|
+
newQuery.token = tokenData.token
|
|
496
|
+
newQuery.tokenexpires = tokenData.tokenexpires
|
|
497
|
+
newQuery.refreshtoken = tokenData.refreshtoken
|
|
498
|
+
}
|
|
499
|
+
} else {
|
|
500
|
+
console.log('SPU is not in App, singleLogin use query token.')
|
|
501
|
+
}
|
|
502
|
+
return newQuery
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// 修复 App 切到后台时间过长导致 token 过期
|
|
506
|
+
// 监听 App 切换到前台 判断token是否过期 如果过期就调用获取tokne方法更新token
|
|
507
|
+
const fixAppTokenExpired = () => {
|
|
508
|
+
if (globalOptions.isfixapptokenexpired && window.Native?.onHostEnterForceground) {
|
|
509
|
+
console.log('listen App enter forceground')
|
|
510
|
+
window.Native.onHostEnterForceground(async () => {
|
|
511
|
+
console.log('App enter forceground')
|
|
512
|
+
const loginState = getLoginState()
|
|
513
|
+
if (!loginState.islogin && loginState.type === 2 && loginState.role !== 'center') {
|
|
514
|
+
const tokenData = await getSPUContainerToken()
|
|
515
|
+
if (tokenData) {
|
|
516
|
+
setToken(tokenData.token)
|
|
517
|
+
setRefreshToken(tokenData.refreshtoken)
|
|
518
|
+
setTokenExpires(tokenData.tokenexpires)
|
|
519
|
+
} else {
|
|
520
|
+
try {
|
|
521
|
+
await updateToken()
|
|
522
|
+
} catch (err) {
|
|
523
|
+
console.error(err)
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
})
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
448
531
|
// 单点登录
|
|
449
532
|
async function singleLogin(query: IAny) {
|
|
450
533
|
query = cloneDeep(query)
|
|
534
|
+
if (globalOptions.isfixapptokenexpired) {
|
|
535
|
+
query = await fixLoginQuery(query)
|
|
536
|
+
}
|
|
451
537
|
|
|
452
538
|
let flag = false // 是否登录成功
|
|
453
539
|
const token = query.token
|
|
@@ -572,6 +658,9 @@ async function singleLogin(query: IAny) {
|
|
|
572
658
|
|
|
573
659
|
function installAuth(options: any) {
|
|
574
660
|
startRefreshtoken()
|
|
661
|
+
|
|
662
|
+
fixAppTokenExpired()
|
|
663
|
+
|
|
575
664
|
if (options.router) {
|
|
576
665
|
options.router.beforeEach(async (to: any, from: any, next: any) => {
|
|
577
666
|
// console.log(from)
|
|
@@ -583,6 +672,7 @@ function installAuth(options: any) {
|
|
|
583
672
|
if (to.query.token) {
|
|
584
673
|
const singleLoginRes = await singleLogin(to.query)
|
|
585
674
|
if (singleLoginRes.flag) {
|
|
675
|
+
// next()
|
|
586
676
|
next({
|
|
587
677
|
path: to.path,
|
|
588
678
|
params: to.params,
|
|
@@ -598,7 +688,7 @@ function installAuth(options: any) {
|
|
|
598
688
|
})
|
|
599
689
|
} else {
|
|
600
690
|
console.warn(
|
|
601
|
-
'@smart100/spu-web-plugin 需要传入一个 vue-router 实例以便执行单点登录逻辑,如果您没传 vue-router
|
|
691
|
+
'@smart100/spu-web-plugin 需要传入一个 vue-router 实例以便执行单点登录逻辑,如果您没传 vue-router 实例则需要自行在合适的位置执行单点登录代码,如果您已自行实现,请忽略该提示。'
|
|
602
692
|
)
|
|
603
693
|
}
|
|
604
694
|
|
package/src/map/MapService.ts
CHANGED
|
@@ -22,12 +22,51 @@ class MapService {
|
|
|
22
22
|
private isInit = false
|
|
23
23
|
private initPromise: any = null
|
|
24
24
|
|
|
25
|
+
get lbssetting(): ILbsSettingData | undefined {
|
|
26
|
+
return tenantSetting.get('lbssetting')
|
|
27
|
+
// const lbssetting: any = {
|
|
28
|
+
// enable: '1',
|
|
29
|
+
// setting: {
|
|
30
|
+
// type: '',
|
|
31
|
+
// key: {
|
|
32
|
+
// web: '',
|
|
33
|
+
// android: '',
|
|
34
|
+
// ios: '',
|
|
35
|
+
// harmony: ''
|
|
36
|
+
// },
|
|
37
|
+
// secretkey: {
|
|
38
|
+
// web: '',
|
|
39
|
+
// android: '',
|
|
40
|
+
// ios: '',
|
|
41
|
+
// harmony: ''
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
// // // 高德地图公司key
|
|
46
|
+
// // lbssetting.setting.type = 'amap'
|
|
47
|
+
// // lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
|
|
48
|
+
// // lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
|
|
49
|
+
// // 高德地图个人key
|
|
50
|
+
// lbssetting.setting.type = 'amap'
|
|
51
|
+
// lbssetting.setting.key.web = 'e4d25fe4661a34198c4e6f79abe9afac'
|
|
52
|
+
// lbssetting.setting.secretkey.web = 'a6b674affd9a3278c68602cf7ba02fcb'
|
|
53
|
+
// // // 腾讯地图
|
|
54
|
+
// // lbssetting.setting.type = 'tencent'
|
|
55
|
+
// // lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
|
|
56
|
+
// // lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0'
|
|
57
|
+
// // // 百度地图
|
|
58
|
+
// // lbssetting.setting.type = 'baidu'
|
|
59
|
+
// // lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
|
|
60
|
+
// // lbssetting.setting.secretkey.web = ''
|
|
61
|
+
// return lbssetting
|
|
62
|
+
}
|
|
63
|
+
|
|
25
64
|
get isLbssettingEnable() {
|
|
26
|
-
return
|
|
65
|
+
return this.lbssetting?.enable === '1'
|
|
27
66
|
}
|
|
28
67
|
|
|
29
68
|
private get setting(): ILbsSetting | undefined {
|
|
30
|
-
return
|
|
69
|
+
return this.lbssetting?.setting
|
|
31
70
|
}
|
|
32
71
|
|
|
33
72
|
get key() {
|
|
@@ -57,35 +96,6 @@ class MapService {
|
|
|
57
96
|
AMap: any = null
|
|
58
97
|
TMap: any = null
|
|
59
98
|
BMap: any = null
|
|
60
|
-
MapCore: any = null
|
|
61
|
-
|
|
62
|
-
// get AMap() {
|
|
63
|
-
// if (!this.isInit || this.type !== 'amap') {
|
|
64
|
-
// return null
|
|
65
|
-
// }
|
|
66
|
-
// return window.AMap
|
|
67
|
-
// }
|
|
68
|
-
|
|
69
|
-
// get TMap() {
|
|
70
|
-
// if (!this.isInit || this.type !== 'tencent') {
|
|
71
|
-
// return null
|
|
72
|
-
// }
|
|
73
|
-
// return window.TMap
|
|
74
|
-
// }
|
|
75
|
-
|
|
76
|
-
// get BMap() {
|
|
77
|
-
// if (!this.isInit || this.type !== 'baidu') {
|
|
78
|
-
// return null
|
|
79
|
-
// }
|
|
80
|
-
// return window.BMap
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
|
-
// get MapCore() {
|
|
84
|
-
// if (!this.isInit) {
|
|
85
|
-
// return null
|
|
86
|
-
// }
|
|
87
|
-
// return window.BMap
|
|
88
|
-
// }
|
|
89
99
|
|
|
90
100
|
async init() {
|
|
91
101
|
if (this.isInit) return
|
|
@@ -134,10 +144,11 @@ class MapService {
|
|
|
134
144
|
this.isInit = true
|
|
135
145
|
}
|
|
136
146
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
|
|
147
|
+
// 腾讯地图 key 配置错误
|
|
148
|
+
// 1 如果是地图 会在地图上明确文字提示 鉴权失败,请传入正确的key
|
|
149
|
+
// 2 如果是调用 api 会返回 catch 和详细的错误信息
|
|
150
|
+
// getIPLocationByTMap fail: {"status":311,"message":"key格式错误","request_id":"ccedb04fd95e4f3f9cd45cfbad729d10","id":"cbm919vjdj0"}
|
|
151
|
+
// getIPLocationByTMap fail: {"status":190,"message":"无效的key","request_id":"b6ca9d0749eb4c91a47db9412b1253ca","id":"cbm919wxo40"}
|
|
141
152
|
private async initTecent() {
|
|
142
153
|
await importJS(
|
|
143
154
|
`https://map.qq.com/api/gljs?v=1.exp&libraries=service&key=${this.key}`,
|
|
@@ -145,10 +156,12 @@ class MapService {
|
|
|
145
156
|
'TMap'
|
|
146
157
|
)
|
|
147
158
|
this.TMap = window.TMap
|
|
148
|
-
this.MapCore = window.TMap
|
|
149
159
|
await delay(300)
|
|
150
160
|
}
|
|
151
161
|
|
|
162
|
+
// 高德地图 key 配置错误
|
|
163
|
+
// 1 如果是 key 格式不对 那么没返回 promise 连 window.AMap 都拿不到 地图和都不能用
|
|
164
|
+
// 1 如果是 key 格式对 但 key 不对 有返回 window.AMap 但 api 定位调用失败 地图可以渲染空白地图
|
|
152
165
|
private async initAmap() {
|
|
153
166
|
return new Promise(async (resolve, reject) => {
|
|
154
167
|
// 高德地图api初始化失败 没有返回reject 因此用超时机制检测
|
|
@@ -180,7 +193,6 @@ class MapService {
|
|
|
180
193
|
|
|
181
194
|
window.AMap = AMap
|
|
182
195
|
this.AMap = window.AMap
|
|
183
|
-
this.MapCore = window.AMap
|
|
184
196
|
// console.log(window)
|
|
185
197
|
// console.log(window.AMap)
|
|
186
198
|
// console.log(window.AMapUI)
|
|
@@ -190,13 +202,14 @@ class MapService {
|
|
|
190
202
|
})
|
|
191
203
|
}
|
|
192
204
|
|
|
205
|
+
// 百度地图 key 配置错误
|
|
206
|
+
// alert以下信息: 您提供的密钥不是有效的百度LBS开放平台密钥,或此密钥未对本应用的百度地图JavaScriptAPI授权。您可以访问如下网址了解如何获取有效的密钥:http://lbsyun.baidu.com/apiconsole/key#。
|
|
193
207
|
private async initBaidu() {
|
|
194
208
|
return new Promise((resolve, reject) => {
|
|
195
209
|
window.BMAP_INITIAL_CALLBACK = (e: any) => {
|
|
196
210
|
// console.log(e)
|
|
197
211
|
// debugger
|
|
198
212
|
this.BMap = window.BMap
|
|
199
|
-
this.MapCore = window.BMap
|
|
200
213
|
// debugger
|
|
201
214
|
// 启用google标准坐标体系
|
|
202
215
|
// coordsType 指定输入输出的坐标类型,BMAP_COORD_GCJ02为gcj02坐标,BMAP_COORD_BD09为bd0ll坐标,默认为BMAP_COORD_BD09。
|
package/src/map/index.ts
CHANGED
|
@@ -479,7 +479,7 @@ const getAddressByBmap = async (position: Location): Promise<string> => {
|
|
|
479
479
|
})
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
const getLocationPromise = async (
|
|
482
|
+
const getLocationPromise = async (isuseiplocation = false): Promise<Location> => {
|
|
483
483
|
let location: Location = null
|
|
484
484
|
|
|
485
485
|
// 在 SPU 容器里使用 Native-API 的定位
|
|
@@ -490,18 +490,18 @@ const getLocationPromise = async (isuseiplocarion = false): Promise<Location> =>
|
|
|
490
490
|
if (!location) {
|
|
491
491
|
if (mapService.type === 'amap') {
|
|
492
492
|
location = await getLocationByAMap()
|
|
493
|
-
if (!location &&
|
|
493
|
+
if (!location && isuseiplocation) {
|
|
494
494
|
location = await getCityLocationByAMap()
|
|
495
495
|
}
|
|
496
496
|
// 改成不使用ipaas了
|
|
497
|
-
// if (!location &&
|
|
497
|
+
// if (!location && isuseiplocation) {
|
|
498
498
|
// location = await getIPLocationByIpaas()
|
|
499
499
|
// }
|
|
500
|
-
} else if (mapService.type === 'tencent' &&
|
|
500
|
+
} else if (mapService.type === 'tencent' && isuseiplocation) {
|
|
501
501
|
location = await getIPLocationByTMap()
|
|
502
502
|
} else if (mapService.type === 'baidu') {
|
|
503
503
|
location = await getLocationByBMap()
|
|
504
|
-
if (!location &&
|
|
504
|
+
if (!location && isuseiplocation) {
|
|
505
505
|
location = await getCityLocationByBMap()
|
|
506
506
|
}
|
|
507
507
|
}
|
|
@@ -544,7 +544,7 @@ const getLocationPromise = async (isuseiplocarion = false): Promise<Location> =>
|
|
|
544
544
|
// WGS84 GCJ-02 BD-09 坐标系
|
|
545
545
|
// https://www.jianshu.com/p/559029832a67
|
|
546
546
|
// 不能精确定位的情况下是否启用ip城市定位,ip定位用于不需要精确定位的场景
|
|
547
|
-
async function getLocation(
|
|
547
|
+
async function getLocation(isuseiplocation = false) {
|
|
548
548
|
await mapService.init()
|
|
549
549
|
// debugger
|
|
550
550
|
// 缓存30秒
|
|
@@ -557,7 +557,7 @@ async function getLocation(isuseiplocarion = false) {
|
|
|
557
557
|
}
|
|
558
558
|
// console.log('runing')
|
|
559
559
|
runing = true
|
|
560
|
-
locationPromise = getLocationPromise(
|
|
560
|
+
locationPromise = getLocationPromise(isuseiplocation)
|
|
561
561
|
const locationRes = await locationPromise
|
|
562
562
|
runing = false
|
|
563
563
|
if (locationRes) {
|
package/src/tenantSetting.ts
CHANGED
|
@@ -39,64 +39,6 @@ class TenantSetting {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
get(key: string) {
|
|
42
|
-
// const tenantsetting = {
|
|
43
|
-
// lbssetting: {
|
|
44
|
-
// enable: '1',
|
|
45
|
-
// setting: {
|
|
46
|
-
// type: '',
|
|
47
|
-
// key: {
|
|
48
|
-
// web: '',
|
|
49
|
-
// android: '',
|
|
50
|
-
// ios: '',
|
|
51
|
-
// harmony: ''
|
|
52
|
-
// },
|
|
53
|
-
// secretkey: {
|
|
54
|
-
// web: '',
|
|
55
|
-
// android: '',
|
|
56
|
-
// ios: '',
|
|
57
|
-
// harmony: ''
|
|
58
|
-
// }
|
|
59
|
-
// }
|
|
60
|
-
// }
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
|
-
// 高德地图key配置错误
|
|
64
|
-
// 1 如果是key格式不对 那么没返回promise 连window.AMap都拿不到 地图和都不能用
|
|
65
|
-
// 1 如果是key对式对 但key不对 有返回 window.AMap 但api定位调用失败 地图可以渲染空白地图
|
|
66
|
-
|
|
67
|
-
// // 高德地图公司key
|
|
68
|
-
// tenantsetting.lbssetting.setting.type = 'amap'
|
|
69
|
-
// tenantsetting.lbssetting.setting.key.web = '1993ac213d2f4675ac1bffb1b03ef1f0'
|
|
70
|
-
// tenantsetting.lbssetting.setting.secretkey.web = '816fe46b7b7bce145940b93c1e4818fa'
|
|
71
|
-
|
|
72
|
-
// // 高德地图个人key
|
|
73
|
-
// tenantsetting.lbssetting.setting.type = 'amap'
|
|
74
|
-
// tenantsetting.lbssetting.setting.key.web = 'e4d25fe4661a34198c4e6f79abe9afac'
|
|
75
|
-
// tenantsetting.lbssetting.setting.secretkey.web = 'a6b674affd9a3278c68602cf7ba02fcb'
|
|
76
|
-
|
|
77
|
-
// tencent地图key配置错误
|
|
78
|
-
// 1 如果是地图 会在地图上明确文字提示 鉴权失败,请传入正确的key
|
|
79
|
-
// 2 如果是调用定位等api 会返回 catch 和详细的错误信息
|
|
80
|
-
// getIPLocationByTMap fail: {"status":311,"message":"key格式错误","request_id":"ccedb04fd95e4f3f9cd45cfbad729d10","id":"cbm919vjdj0"}
|
|
81
|
-
// getIPLocationByTMap fail: {"status":190,"message":"无效的key","request_id":"b6ca9d0749eb4c91a47db9412b1253ca","id":"cbm919wxo40"}
|
|
82
|
-
// tenantsetting.lbssetting.setting.type = 'tencent'
|
|
83
|
-
// tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT'
|
|
84
|
-
// tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0'
|
|
85
|
-
|
|
86
|
-
// 百度地图key配置错误alert以下信息
|
|
87
|
-
// 您提供的密钥不是有效的百度LBS开放平台密钥,或此密钥未对本应用的百度地图JavaScriptAPI授权。您可以访问如下网址了解如何获取有效的密钥:http://lbsyun.baidu.com/apiconsole/key#。
|
|
88
|
-
// tenantsetting.lbssetting.setting.type = 'baidu'
|
|
89
|
-
// tenantsetting.lbssetting.setting.key.web = '7r3bsPeQqJ74vsxf3EOXg7C1AM4lOWA1'
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// tenantsetting.lbssetting.setting.type = 'tencent'
|
|
94
|
-
// tenantsetting.lbssetting.setting.key.web = 'NHBBZ-K5LCQ-LF35M-2CTDP-E4OO7-AIBFT是的是的'
|
|
95
|
-
// tenantsetting.lbssetting.setting.secretkey.web = 'zowvV5I2pSxqgGb2Sgr1x62HGXbqdxT0对对对'
|
|
96
|
-
|
|
97
|
-
// lsProxy.setItem('tenantsetting', JSON.stringify(tenantsetting))
|
|
98
|
-
|
|
99
|
-
|
|
100
42
|
let tenantsettingStr = lsProxy.getItem('tenantsetting')
|
|
101
43
|
if (tenantsettingStr) {
|
|
102
44
|
const tenantsetting = JSON.parse(tenantsettingStr)
|
package/src/types/index.d.ts
CHANGED
|
@@ -31,12 +31,11 @@ interface IAMapLoader {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
interface IMapService {
|
|
34
|
-
init: () => Promise<
|
|
34
|
+
init: () => Promise<void>
|
|
35
35
|
type: 'amap' | 'tencent' | 'baidu'
|
|
36
36
|
AMap: any
|
|
37
37
|
BMap: any
|
|
38
38
|
TMap: any
|
|
39
|
-
MapCore: any
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
type StorageType = 'storage' | 'storage-1d' | 'storage-3m' | 'storage-1y'
|
|
@@ -81,6 +80,7 @@ interface IUploadService {
|
|
|
81
80
|
// modulename: string
|
|
82
81
|
// moduleversion: string
|
|
83
82
|
// storageproxyprefix?: string
|
|
83
|
+
// isfixapptokenexpired?: boolean
|
|
84
84
|
// router?: any
|
|
85
85
|
// }
|
|
86
86
|
|
|
@@ -98,7 +98,7 @@ export default SPUWebPlugin
|
|
|
98
98
|
export const globalOptions: any
|
|
99
99
|
export const lsProxy: any
|
|
100
100
|
export const ssProxy: any
|
|
101
|
-
export const getLocation: () => Promise<{
|
|
101
|
+
export const getLocation: (isuseiplocation?: boolean) => Promise<{
|
|
102
102
|
longitude: string
|
|
103
103
|
latitude: string
|
|
104
104
|
address: string
|
|
@@ -127,6 +127,7 @@ export const getCloudServ: (type?: StorageType) => any
|
|
|
127
127
|
export const getUniqueid: () => string
|
|
128
128
|
export const getUuid: () => string
|
|
129
129
|
export const functionCheck: (functioncode?: string) => boolean
|
|
130
|
+
export const getServerTime: () => Promise<string>
|
|
130
131
|
export const setTitle: (pagetitle?: string) => void
|
|
131
132
|
export const isInApp: () => boolean
|
|
132
133
|
export const AMapLoader: IAMapLoader
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getUser } from './login'
|
|
2
2
|
import { urlquery } from './urlquery'
|
|
3
3
|
import { get } from 'lodash-es'
|
|
4
|
+
import { axios } from './axios'
|
|
4
5
|
|
|
5
6
|
function isIOS() {
|
|
6
7
|
const ua = navigator.userAgent
|
|
@@ -128,6 +129,40 @@ const delay = (timeout = 1000) => {
|
|
|
128
129
|
})
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
const getServerTime = () => {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
if (window?.Native?.getServerTime) {
|
|
135
|
+
window.Native.getServerTime((res: any) => {
|
|
136
|
+
if (res) {
|
|
137
|
+
resolve(res.toString())
|
|
138
|
+
} else {
|
|
139
|
+
resolve(Date.now().toString())
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
} else {
|
|
143
|
+
axios
|
|
144
|
+
.get(
|
|
145
|
+
'/api/teapi/offline/servertime',
|
|
146
|
+
{},
|
|
147
|
+
{
|
|
148
|
+
isShowLoading: false
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
.then((res: any) => {
|
|
152
|
+
if (res.data) {
|
|
153
|
+
resolve(res.data.toString())
|
|
154
|
+
} else {
|
|
155
|
+
resolve(Date.now().toString())
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.catch((err: any) => {
|
|
159
|
+
resolve(Date.now().toString())
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
131
166
|
export {
|
|
132
167
|
isIOS,
|
|
133
168
|
isMobile,
|
|
@@ -139,5 +174,6 @@ export {
|
|
|
139
174
|
isvirtuallocation,
|
|
140
175
|
toggleHttpOrHttps,
|
|
141
176
|
importJS,
|
|
142
|
-
delay
|
|
177
|
+
delay,
|
|
178
|
+
getServerTime
|
|
143
179
|
}
|