Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzj-java
uni-app
提交
b2fa9cd6
U
uni-app
项目概览
wzj-java
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b2fa9cd6
编写于
5月 28, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(mp): hostName
上级
6fadc886
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
481 addition
and
299 deletion
+481
-299
packages/uni-mp-weixin/dist/index.js
packages/uni-mp-weixin/dist/index.js
+479
-298
src/platforms/mp-weixin/helpers/enhance-system-info.js
src/platforms/mp-weixin/helpers/enhance-system-info.js
+2
-1
未找到文件。
packages/uni-mp-weixin/dist/index.js
浏览文件 @
b2fa9cd6
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
import
{
initVueI18n
}
from
'
@dcloudio/uni-i18n
'
;
let
realAtob
;
let
realAtob
;
const
b64
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
'
;
const
b64
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
'
;
const
b64re
=
/^
(?:[
A-Za-z
\d
+
/]{4})
*
?(?:[
A-Za-z
\d
+
/]{2}(?:
==
)?
|
[
A-Za-z
\d
+
/]{3}
=
?)?
$/
;
const
b64re
=
/^
(?:[
A-Za-z
\d
+
/]{4})
*
?(?:[
A-Za-z
\d
+
/]{2}(?:
==
)?
|
[
A-Za-z
\d
+
/]{3}
=
?)?
$/
;
if
(
typeof
atob
!==
'
function
'
)
{
if
(
typeof
atob
!==
'
function
'
)
{
realAtob
=
function
(
str
)
{
realAtob
=
function
(
str
)
{
str
=
String
(
str
).
replace
(
/
[\t\n\f\r
]
+/g
,
''
);
str
=
String
(
str
).
replace
(
/
[\t\n\f\r
]
+/g
,
''
);
if
(
!
b64re
.
test
(
str
))
{
throw
new
Error
(
"
Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
"
)
}
if
(
!
b64re
.
test
(
str
))
{
throw
new
Error
(
"
Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
"
)
}
// Adding the padding if missing, for semplicity
// Adding the padding if missing, for semplicity
str
+=
'
==
'
.
slice
(
2
-
(
str
.
length
&
3
));
str
+=
'
==
'
.
slice
(
2
-
(
str
.
length
&
3
));
var
bitmap
;
var
result
=
''
;
var
r1
;
var
r2
;
var
i
=
0
;
var
bitmap
;
var
result
=
''
;
var
r1
;
var
r2
;
var
i
=
0
;
for
(;
i
<
str
.
length
;)
{
for
(;
i
<
str
.
length
;)
{
bitmap
=
b64
.
indexOf
(
str
.
charAt
(
i
++
))
<<
18
|
b64
.
indexOf
(
str
.
charAt
(
i
++
))
<<
12
|
bitmap
=
b64
.
indexOf
(
str
.
charAt
(
i
++
))
<<
18
|
b64
.
indexOf
(
str
.
charAt
(
i
++
))
<<
12
|
(
r1
=
b64
.
indexOf
(
str
.
charAt
(
i
++
)))
<<
6
|
(
r2
=
b64
.
indexOf
(
str
.
charAt
(
i
++
)));
(
r1
=
b64
.
indexOf
(
str
.
charAt
(
i
++
)))
<<
6
|
(
r2
=
b64
.
indexOf
(
str
.
charAt
(
i
++
)));
result
+=
r1
===
64
?
String
.
fromCharCode
(
bitmap
>>
16
&
255
)
result
+=
r1
===
64
?
String
.
fromCharCode
(
bitmap
>>
16
&
255
)
:
r2
===
64
?
String
.
fromCharCode
(
bitmap
>>
16
&
255
,
bitmap
>>
8
&
255
)
:
r2
===
64
?
String
.
fromCharCode
(
bitmap
>>
16
&
255
,
bitmap
>>
8
&
255
)
:
String
.
fromCharCode
(
bitmap
>>
16
&
255
,
bitmap
>>
8
&
255
,
bitmap
&
255
);
:
String
.
fromCharCode
(
bitmap
>>
16
&
255
,
bitmap
>>
8
&
255
,
bitmap
&
255
);
}
}
return
result
return
result
};
};
}
else
{
}
else
{
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
realAtob
=
atob
;
realAtob
=
atob
;
}
}
function
b64DecodeUnicode
(
str
)
{
function
b64DecodeUnicode
(
str
)
{
return
decodeURIComponent
(
realAtob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
decodeURIComponent
(
realAtob
(
str
).
split
(
''
).
map
(
function
(
c
)
{
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
return
'
%
'
+
(
'
00
'
+
c
.
charCodeAt
(
0
).
toString
(
16
)).
slice
(
-
2
)
}).
join
(
''
))
}).
join
(
''
))
}
}
function
getCurrentUserInfo
()
{
function
getCurrentUserInfo
()
{
const
token
=
(
wx
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
token
=
(
wx
).
getStorageSync
(
'
uni_id_token
'
)
||
''
;
const
tokenArr
=
token
.
split
(
'
.
'
);
const
tokenArr
=
token
.
split
(
'
.
'
);
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
if
(
!
token
||
tokenArr
.
length
!==
3
)
{
return
{
return
{
uid
:
null
,
uid
:
null
,
role
:
[],
role
:
[],
permission
:
[],
permission
:
[],
tokenExpired
:
0
tokenExpired
:
0
}
}
}
}
let
userInfo
;
let
userInfo
;
try
{
try
{
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
userInfo
=
JSON
.
parse
(
b64DecodeUnicode
(
tokenArr
[
1
]));
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
throw
new
Error
(
'
获取当前用户信息出错,详细错误信息为:
'
+
error
.
message
)
}
}
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
userInfo
.
tokenExpired
=
userInfo
.
exp
*
1000
;
delete
userInfo
.
exp
;
delete
userInfo
.
exp
;
delete
userInfo
.
iat
;
delete
userInfo
.
iat
;
return
userInfo
return
userInfo
}
}
function
uniIdMixin
(
Vue
)
{
function
uniIdMixin
(
Vue
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
Vue
.
prototype
.
uniIDHasRole
=
function
(
roleId
)
{
const
{
const
{
role
role
}
=
getCurrentUserInfo
();
}
=
getCurrentUserInfo
();
return
role
.
indexOf
(
roleId
)
>
-
1
return
role
.
indexOf
(
roleId
)
>
-
1
};
};
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
Vue
.
prototype
.
uniIDHasPermission
=
function
(
permissionId
)
{
const
{
const
{
permission
permission
}
=
getCurrentUserInfo
();
}
=
getCurrentUserInfo
();
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
return
this
.
uniIDHasRole
(
'
admin
'
)
||
permission
.
indexOf
(
permissionId
)
>
-
1
};
};
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
Vue
.
prototype
.
uniIDTokenValid
=
function
()
{
const
{
const
{
tokenExpired
tokenExpired
}
=
getCurrentUserInfo
();
}
=
getCurrentUserInfo
();
return
tokenExpired
>
Date
.
now
()
return
tokenExpired
>
Date
.
now
()
};
};
}
}
const
_toString
=
Object
.
prototype
.
toString
;
const
_toString
=
Object
.
prototype
.
toString
;
...
@@ -314,7 +314,7 @@ const promiseInterceptor = {
...
@@ -314,7 +314,7 @@ const promiseInterceptor = {
};
};
const
SYNC_API_RE
=
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|
getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback
/
;
/^
\$
|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|
requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo
/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
const
CONTEXT_API_RE
=
/^create|Manager$/
;
...
@@ -546,37 +546,164 @@ var previewImage = {
...
@@ -546,37 +546,164 @@ var previewImage = {
}
}
};
};
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
function
_getDeviceBrand
(
model
)
{
let
deviceId
;
if
(
/iphone/gi
.
test
(
model
)
||
/ipad/gi
.
test
(
model
)
||
/mac/gi
.
test
(
model
))
{
return
'
apple
'
}
function
addUuid
(
result
)
{
if
(
/windows/gi
.
test
(
model
))
{
return
'
microsoft
'
}
deviceId
=
deviceId
||
wx
.
getStorageSync
(
UUID_KEY
);
return
''
if
(
!
deviceId
)
{
}
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
wx
.
setStorage
({
const
UUID_KEY
=
'
__DC_STAT_UUID
'
;
key
:
UUID_KEY
,
let
deviceId
;
data
:
deviceId
function
useDeviceId
(
result
)
{
});
deviceId
=
deviceId
||
wx
.
getStorageSync
(
UUID_KEY
);
}
if
(
!
deviceId
)
{
result
.
deviceId
=
deviceId
;
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
);
}
wx
.
setStorage
({
key
:
UUID_KEY
,
function
addSafeAreaInsets
(
result
)
{
data
:
deviceId
if
(
result
.
safeArea
)
{
});
const
safeArea
=
result
.
safeArea
;
}
result
.
safeAreaInsets
=
{
result
.
deviceId
=
deviceId
;
top
:
safeArea
.
top
,
}
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
function
addSafeAreaInsets
(
result
)
{
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
if
(
result
.
safeArea
)
{
};
const
safeArea
=
result
.
safeArea
;
}
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
screenHeight
-
safeArea
.
bottom
};
}
}
function
populateParameters
(
result
)
{
const
{
brand
=
''
,
model
=
''
,
system
=
''
,
language
=
''
,
theme
,
version
,
hostName
,
platform
,
fontSizeSetting
,
SDKVersion
,
pixelRatio
,
deviceOrientation
,
environment
}
=
result
;
const
isQuickApp
=
"
mp-weixin
"
.
indexOf
(
'
quickapp-webview
'
)
!==
-
1
;
// osName osVersion
let
osName
=
''
;
let
osVersion
=
''
;
{
osName
=
system
.
split
(
'
'
)[
0
]
||
''
;
osVersion
=
system
.
split
(
'
'
)[
1
]
||
''
;
}
let
hostVersion
=
version
;
// deviceType
const
deviceType
=
getGetDeviceType
(
result
,
model
);
// deviceModel
const
deviceBrand
=
getDeviceBrand
(
brand
,
model
,
isQuickApp
);
// hostName
const
_platform
=
'
WeChat
'
;
let
_hostName
=
hostName
||
_platform
;
// mp-jd
{
if
(
environment
)
{
_hostName
=
environment
;
}
else
if
(
result
.
host
&&
result
.
host
.
env
)
{
_hostName
=
result
.
host
.
env
;
}
}
// deviceOrientation
let
_deviceOrientation
=
deviceOrientation
;
// 仅 微信 百度 支持
// devicePixelRatio
let
_devicePixelRatio
=
pixelRatio
;
// SDKVersion
let
_SDKVersion
=
SDKVersion
;
// wx.getAccountInfoSync
const
parameters
=
{
appId
:
process
.
env
.
UNI_APP_ID
,
appName
:
process
.
env
.
UNI_APP_NAME
,
appVersion
:
process
.
env
.
UNI_APP_VERSION_NAME
,
appVersionCode
:
process
.
env
.
UNI_APP_VERSION_CODE
,
uniCompileVersion
:
process
.
env
.
UNI_COMPILER_VERSION
,
uniRuntimeVersion
:
process
.
env
.
UNI_COMPILER_VERSION
,
uniPlatform
:
process
.
env
.
UNI_SUB_PLATFORM
||
process
.
env
.
UNI_PLATFORM
,
deviceBrand
,
deviceModel
:
model
,
deviceType
,
devicePixelRatio
:
_devicePixelRatio
,
deviceOrientation
:
_deviceOrientation
,
osName
:
osName
.
toLocaleLowerCase
(),
osVersion
,
hostTheme
:
theme
,
hostVersion
,
hostLanguage
:
language
.
replace
(
'
_
'
,
'
-
'
),
hostName
:
_hostName
,
hostSDKVersion
:
_SDKVersion
,
hostFontSizeSetting
:
fontSizeSetting
,
windowTop
:
0
,
windowBottom
:
0
,
// TODO
osLanguage
:
undefined
,
osTheme
:
undefined
,
ua
:
undefined
,
hostPackageName
:
undefined
,
browserName
:
undefined
,
browseVersion
:
undefined
};
Object
.
assign
(
result
,
parameters
);
}
function
getGetDeviceType
(
result
,
model
)
{
let
deviceType
=
result
.
deviceType
||
'
phone
'
;
{
const
deviceTypeMaps
=
{
ipad
:
'
pad
'
,
windows
:
'
pc
'
,
mac
:
'
pc
'
};
const
deviceTypeMapsKeys
=
Object
.
keys
(
deviceTypeMaps
);
const
_model
=
model
.
toLocaleLowerCase
();
for
(
let
index
=
0
;
index
<
deviceTypeMapsKeys
.
length
;
index
++
)
{
const
_m
=
deviceTypeMapsKeys
[
index
];
if
(
_model
.
indexOf
(
_m
)
!==
-
1
)
{
deviceType
=
deviceTypeMaps
[
_m
];
break
}
}
}
return
deviceType
}
function
getDeviceBrand
(
brand
,
model
,
isQuickApp
=
false
)
{
let
deviceBrand
=
model
.
split
(
'
'
)[
0
].
toLocaleLowerCase
();
if
(
isQuickApp
)
{
deviceBrand
=
brand
.
toLocaleLowerCase
();
}
else
{
deviceBrand
=
_getDeviceBrand
(
deviceBrand
);
}
return
deviceBrand
}
}
var
getSystemInfo
=
{
var
getSystemInfo
=
{
returnValue
:
function
(
result
)
{
returnValue
:
function
(
result
)
{
addUuid
(
result
);
useDeviceId
(
result
);
addSafeAreaInsets
(
result
);
addSafeAreaInsets
(
result
);
}
populateParameters
(
result
);
}
};
};
var
showActionSheet
=
{
var
showActionSheet
=
{
...
@@ -587,6 +714,57 @@ var showActionSheet = {
...
@@ -587,6 +714,57 @@ var showActionSheet = {
}
}
};
};
var
getAppBaseInfo
=
{
returnValue
:
function
(
result
)
{
const
{
version
,
language
,
SDKVersion
,
theme
}
=
result
;
let
_hostName
=
"
mp-weixin
"
.
split
(
'
-
'
)[
1
];
// mp-jd
{
if
(
result
.
host
&&
result
.
host
.
env
)
{
_hostName
=
result
.
host
.
env
;
}
}
Object
.
assign
(
result
,
{
hostVersion
:
version
,
hostLanguage
:
language
.
replace
(
'
_
'
,
'
-
'
),
hostName
:
_hostName
,
hostSDKVersion
:
SDKVersion
,
hostTheme
:
theme
,
appId
:
process
.
env
.
UNI_APP_ID
,
appName
:
process
.
env
.
UNI_APP_NAME
,
appVersion
:
process
.
env
.
UNI_APP_VERSION_NAME
,
appVersionCode
:
process
.
env
.
UNI_APP_VERSION_CODE
});
}
};
var
getDeviceInfo
=
{
returnValue
:
function
(
result
)
{
const
{
brand
,
model
}
=
result
;
const
deviceType
=
getGetDeviceType
(
result
,
model
);
const
deviceBrand
=
getDeviceBrand
(
brand
,
model
);
useDeviceId
(
result
);
Object
.
assign
(
result
,
{
deviceType
,
deviceBrand
,
deviceModel
:
model
});
}
};
var
getWindowInfo
=
{
returnValue
:
function
(
result
)
{
addSafeAreaInsets
(
result
);
Object
.
assign
(
result
,
{
windowTop
:
0
,
windowBottom
:
0
});
}
};
// import navigateTo from 'uni-helpers/navigate-to'
// import navigateTo from 'uni-helpers/navigate-to'
const
protocols
=
{
const
protocols
=
{
...
@@ -595,7 +773,10 @@ const protocols = {
...
@@ -595,7 +773,10 @@ const protocols = {
previewImage
,
previewImage
,
getSystemInfo
,
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
,
showActionSheet
showActionSheet
,
getAppBaseInfo
,
getDeviceInfo
,
getWindowInfo
};
};
const
todos
=
[
const
todos
=
[
'
vibrate
'
,
'
vibrate
'
,
...
@@ -861,7 +1042,7 @@ function invokeGetPushCidCallbacks (cid, errMsg) {
...
@@ -861,7 +1042,7 @@ function invokeGetPushCidCallbacks (cid, errMsg) {
getPushCidCallbacks
.
length
=
0
;
getPushCidCallbacks
.
length
=
0
;
}
}
function
getPushCid
(
args
)
{
function
getPushC
lient
id
(
args
)
{
if
(
!
isPlainObject
(
args
))
{
if
(
!
isPlainObject
(
args
))
{
args
=
{};
args
=
{};
}
}
...
@@ -877,13 +1058,13 @@ function getPushCid (args) {
...
@@ -877,13 +1058,13 @@ function getPushCid (args) {
let
res
;
let
res
;
if
(
cid
)
{
if
(
cid
)
{
res
=
{
res
=
{
errMsg
:
'
getPushCid:ok
'
,
errMsg
:
'
getPushC
lient
id:ok
'
,
cid
cid
};
};
hasSuccess
&&
success
(
res
);
hasSuccess
&&
success
(
res
);
}
else
{
}
else
{
res
=
{
res
=
{
errMsg
:
'
getPushCid:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
errMsg
:
'
getPushC
lient
id:fail
'
+
(
errMsg
?
'
'
+
errMsg
:
''
)
};
};
hasFail
&&
fail
(
res
);
hasFail
&&
fail
(
res
);
}
}
...
@@ -915,7 +1096,7 @@ const offPushMessage = (fn) => {
...
@@ -915,7 +1096,7 @@ const offPushMessage = (fn) => {
var
api
=
/*#__PURE__*/
Object
.
freeze
({
var
api
=
/*#__PURE__*/
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
getPushC
id
:
getPushC
id
,
getPushC
lientid
:
getPushClient
id
,
onPushMessage
:
onPushMessage
,
onPushMessage
:
onPushMessage
,
offPushMessage
:
offPushMessage
,
offPushMessage
:
offPushMessage
,
invokePushCallback
:
invokePushCallback
invokePushCallback
:
invokePushCallback
...
@@ -1609,172 +1790,172 @@ function getEventChannel (id) {
...
@@ -1609,172 +1790,172 @@ function getEventChannel (id) {
return
eventChannelStack
.
shift
()
return
eventChannelStack
.
shift
()
}
}
const
hooks
=
[
const
hooks
=
[
'
onShow
'
,
'
onShow
'
,
'
onHide
'
,
'
onHide
'
,
'
onError
'
,
'
onError
'
,
'
onPageNotFound
'
,
'
onPageNotFound
'
,
'
onThemeChange
'
,
'
onThemeChange
'
,
'
onUnhandledRejection
'
'
onUnhandledRejection
'
];
];
function
initEventChannel
()
{
function
initEventChannel
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
Vue
.
prototype
.
getOpenerEventChannel
=
function
()
{
// 微信小程序使用自身getOpenerEventChannel
// 微信小程序使用自身getOpenerEventChannel
{
{
return
this
.
$scope
.
getOpenerEventChannel
()
return
this
.
$scope
.
getOpenerEventChannel
()
}
}
};
};
const
callHook
=
Vue
.
prototype
.
__call_hook
;
const
callHook
=
Vue
.
prototype
.
__call_hook
;
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
Vue
.
prototype
.
__call_hook
=
function
(
hook
,
args
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
hook
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
delete
args
.
__id__
;
}
}
return
callHook
.
call
(
this
,
hook
,
args
)
return
callHook
.
call
(
this
,
hook
,
args
)
};
};
}
}
function
initScopedSlotsParams
()
{
function
initScopedSlotsParams
()
{
const
center
=
{};
const
center
=
{};
const
parents
=
{};
const
parents
=
{};
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
Vue
.
prototype
.
$hasScopedSlotsParams
=
function
(
vueId
)
{
const
has
=
center
[
vueId
];
const
has
=
center
[
vueId
];
if
(
!
has
)
{
if
(
!
has
)
{
parents
[
vueId
]
=
this
;
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destroyed
'
,
()
=>
{
this
.
$on
(
'
hook:destroyed
'
,
()
=>
{
delete
parents
[
vueId
];
delete
parents
[
vueId
];
});
});
}
}
return
has
return
has
};
};
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
Vue
.
prototype
.
$getScopedSlotsParams
=
function
(
vueId
,
name
,
key
)
{
const
data
=
center
[
vueId
];
const
data
=
center
[
vueId
];
if
(
data
)
{
if
(
data
)
{
const
object
=
data
[
name
]
||
{};
const
object
=
data
[
name
]
||
{};
return
key
?
object
[
key
]
:
object
return
key
?
object
[
key
]
:
object
}
else
{
}
else
{
parents
[
vueId
]
=
this
;
parents
[
vueId
]
=
this
;
this
.
$on
(
'
hook:destroyed
'
,
()
=>
{
this
.
$on
(
'
hook:destroyed
'
,
()
=>
{
delete
parents
[
vueId
];
delete
parents
[
vueId
];
});
});
}
}
};
};
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
Vue
.
prototype
.
$setScopedSlotsParams
=
function
(
name
,
value
)
{
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
const
vueIds
=
this
.
$options
.
propsData
.
vueId
;
if
(
vueIds
)
{
if
(
vueIds
)
{
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
vueId
=
vueIds
.
split
(
'
,
'
)[
0
];
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
const
object
=
center
[
vueId
]
=
center
[
vueId
]
||
{};
object
[
name
]
=
value
;
object
[
name
]
=
value
;
if
(
parents
[
vueId
])
{
if
(
parents
[
vueId
])
{
parents
[
vueId
].
$forceUpdate
();
parents
[
vueId
].
$forceUpdate
();
}
}
}
}
};
};
Vue
.
mixin
({
Vue
.
mixin
({
destroyed
()
{
destroyed
()
{
const
propsData
=
this
.
$options
.
propsData
;
const
propsData
=
this
.
$options
.
propsData
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
const
vueId
=
propsData
&&
propsData
.
vueId
;
if
(
vueId
)
{
if
(
vueId
)
{
delete
center
[
vueId
];
delete
center
[
vueId
];
delete
parents
[
vueId
];
delete
parents
[
vueId
];
}
}
}
}
});
});
}
}
function
parseBaseApp
(
vm
,
{
function
parseBaseApp
(
vm
,
{
mocks
,
mocks
,
initRefs
initRefs
})
{
})
{
initEventChannel
();
initEventChannel
();
{
{
initScopedSlotsParams
();
initScopedSlotsParams
();
}
}
if
(
vm
.
$options
.
store
)
{
if
(
vm
.
$options
.
store
)
{
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
Vue
.
prototype
.
$store
=
vm
.
$options
.
store
;
}
}
uniIdMixin
(
Vue
);
uniIdMixin
(
Vue
);
Vue
.
prototype
.
mpHost
=
"
mp-weixin
"
;
Vue
.
prototype
.
mpHost
=
"
mp-weixin
"
;
Vue
.
mixin
({
Vue
.
mixin
({
beforeCreate
()
{
beforeCreate
()
{
if
(
!
this
.
$options
.
mpType
)
{
if
(
!
this
.
$options
.
mpType
)
{
return
return
}
}
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
mpType
=
this
.
$options
.
mpType
;
this
.
$mp
=
{
this
.
$mp
=
{
data
:
{},
data
:
{},
[
this
.
mpType
]:
this
.
$options
.
mpInstance
[
this
.
mpType
]:
this
.
$options
.
mpInstance
};
};
this
.
$scope
=
this
.
$options
.
mpInstance
;
this
.
$scope
=
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpType
;
delete
this
.
$options
.
mpInstance
;
delete
this
.
$options
.
mpInstance
;
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
if
(
this
.
mpType
===
'
page
'
&&
typeof
getApp
===
'
function
'
)
{
// hack vue-i18n
const
app
=
getApp
();
const
app
=
getApp
();
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
if
(
app
.
$vm
&&
app
.
$vm
.
$i18n
)
{
this
.
_i18n
=
app
.
$vm
.
$i18n
;
this
.
_i18n
=
app
.
$vm
.
$i18n
;
}
}
}
}
if
(
this
.
mpType
!==
'
app
'
)
{
if
(
this
.
mpType
!==
'
app
'
)
{
initRefs
(
this
);
initRefs
(
this
);
initMocks
(
this
,
mocks
);
initMocks
(
this
,
mocks
);
}
}
}
}
});
});
const
appOptions
=
{
const
appOptions
=
{
onLaunch
(
args
)
{
onLaunch
(
args
)
{
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
if
(
this
.
$vm
)
{
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return
return
}
}
{
{
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
if
(
wx
.
canIUse
&&
!
wx
.
canIUse
(
'
nextTick
'
))
{
// 事实 上2.2.3 即可,简单使用 2.3.0 的 nextTick 判断
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
console
.
error
(
'
当前微信基础库版本过低,请将 微信开发者工具-详情-项目设置-调试基础库版本 更换为`2.3.0`以上
'
);
}
}
}
}
this
.
$vm
=
vm
;
this
.
$vm
=
vm
;
this
.
$vm
.
$mp
=
{
this
.
$vm
.
$mp
=
{
app
:
this
app
:
this
};
};
this
.
$vm
.
$scope
=
this
;
this
.
$vm
.
$scope
=
this
;
// vm 上也挂载 globalData
// vm 上也挂载 globalData
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
globalData
=
this
.
globalData
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
mounted
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
this
.
$vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
}
};
};
// 兼容旧版本 globalData
// 兼容旧版本 globalData
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
appOptions
.
globalData
=
vm
.
$options
.
globalData
||
{};
// 将 methods 中的方法挂在 getApp() 中
// 将 methods 中的方法挂在 getApp() 中
const
methods
=
vm
.
$options
.
methods
;
const
methods
=
vm
.
$options
.
methods
;
if
(
methods
)
{
if
(
methods
)
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
Object
.
keys
(
methods
).
forEach
(
name
=>
{
appOptions
[
name
]
=
methods
[
name
];
appOptions
[
name
]
=
methods
[
name
];
});
});
}
}
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initAppLocale
(
Vue
,
vm
,
wx
.
getSystemInfoSync
().
language
||
'
zh-Hans
'
);
initHooks
(
appOptions
,
hooks
);
initHooks
(
appOptions
,
hooks
);
return
appOptions
return
appOptions
}
}
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
const
mocks
=
[
'
__route__
'
,
'
__wxExparserNodeId__
'
,
'
__wxWebviewId__
'
];
...
@@ -2062,10 +2243,10 @@ function parsePage (vuePageOptions) {
...
@@ -2062,10 +2243,10 @@ function parsePage (vuePageOptions) {
})
})
}
}
function
createPage
(
vuePageOptions
)
{
function
createPage
(
vuePageOptions
)
{
{
{
return
Component
(
parsePage
(
vuePageOptions
))
return
Component
(
parsePage
(
vuePageOptions
))
}
}
}
}
function
createComponent
(
vueOptions
)
{
function
createComponent
(
vueOptions
)
{
...
@@ -2110,23 +2291,23 @@ function createSubpackageApp (vm) {
...
@@ -2110,23 +2291,23 @@ function createSubpackageApp (vm) {
return
vm
return
vm
}
}
function
createPlugin
(
vm
)
{
function
createPlugin
(
vm
)
{
const
appOptions
=
parseApp
(
vm
);
const
appOptions
=
parseApp
(
vm
);
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
if
(
isFn
(
appOptions
.
onShow
)
&&
wx
.
onAppShow
)
{
wx
.
onAppShow
((...
args
)
=>
{
wx
.
onAppShow
((...
args
)
=>
{
vm
.
__call_hook
(
'
onShow
'
,
args
);
vm
.
__call_hook
(
'
onShow
'
,
args
);
});
});
}
}
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
if
(
isFn
(
appOptions
.
onHide
)
&&
wx
.
onAppHide
)
{
wx
.
onAppHide
((...
args
)
=>
{
wx
.
onAppHide
((...
args
)
=>
{
vm
.
__call_hook
(
'
onHide
'
,
args
);
vm
.
__call_hook
(
'
onHide
'
,
args
);
});
});
}
}
if
(
isFn
(
appOptions
.
onLaunch
))
{
if
(
isFn
(
appOptions
.
onLaunch
))
{
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
const
args
=
wx
.
getLaunchOptionsSync
&&
wx
.
getLaunchOptionsSync
();
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
vm
.
__call_hook
(
'
onLaunch
'
,
args
);
}
}
return
vm
return
vm
}
}
todos
.
forEach
(
todoApi
=>
{
todos
.
forEach
(
todoApi
=>
{
...
...
src/platforms/mp-weixin/helpers/enhance-system-info.js
浏览文件 @
b2fa9cd6
...
@@ -66,7 +66,8 @@ export function populateParameters (result) {
...
@@ -66,7 +66,8 @@ export function populateParameters (result) {
const
deviceBrand
=
getDeviceBrand
(
brand
,
model
,
isQuickApp
)
const
deviceBrand
=
getDeviceBrand
(
brand
,
model
,
isQuickApp
)
// hostName
// hostName
let
_hostName
=
hostName
||
__PLATFORM__
.
split
(
'
-
'
)[
1
]
// mp-jd
const
_platform
=
__PLATFORM__
===
'
mp-weixin
'
?
'
WeChat
'
:
__PLATFORM__
.
split
(
'
-
'
)[
1
]
let
_hostName
=
hostName
||
_platform
// mp-jd
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
environment
)
{
if
(
environment
)
{
_hostName
=
environment
_hostName
=
environment
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录