Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
29f21749
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
29f21749
编写于
10月 11, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build index.v3.js
上级
ab082993
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
270 addition
and
573 deletion
+270
-573
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+270
-573
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
29f21749
...
@@ -546,13 +546,32 @@ var serviceContext = (function () {
...
@@ -546,13 +546,32 @@ var serviceContext = (function () {
)
)
)
{
)
{
return
false
return
false
}
}
const
titleImage
=
windowOptions
.
titleImage
||
''
;
const
transparentTitle
=
windowOptions
.
transparentTitle
||
'
none
'
;
const
titleNViewTypeList
=
{
'
none
'
:
'
default
'
,
'
auto
'
:
'
transparent
'
,
'
always
'
:
'
float
'
};
const
ret
=
{
const
ret
=
{
autoBackButton
:
!
routeOptions
.
meta
.
isQuit
,
autoBackButton
:
!
routeOptions
.
meta
.
isQuit
,
backgroundColor
:
windowOptions
.
navigationBarBackgroundColor
||
'
#000000
'
,
titleText
:
titleImage
===
''
?
windowOptions
.
navigationBarTitleText
||
''
:
''
,
titleText
:
windowOptions
.
navigationBarTitleText
||
''
,
titleColor
:
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
#000000
'
:
'
#ffffff
'
,
titleColor
:
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
#000000
'
:
'
#ffffff
'
type
:
titleNViewTypeList
[
transparentTitle
],
backgroundColor
:
transparentTitle
!==
'
always
'
?
windowOptions
.
navigationBarBackgroundColor
||
'
#000000
'
:
'
rgba(0,0,0,0)
'
,
tags
:
titleImage
===
''
?
[]
:
[{
'
tag
'
:
'
img
'
,
'
src
'
:
titleImage
,
'
position
'
:
{
'
left
'
:
'
auto
'
,
'
top
'
:
'
auto
'
,
'
width
'
:
'
auto
'
,
'
height
'
:
'
26px
'
}
}]
};
};
routeOptions
.
meta
.
statusBarStyle
=
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
dark
'
:
'
light
'
;
routeOptions
.
meta
.
statusBarStyle
=
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
dark
'
:
'
light
'
;
...
@@ -604,14 +623,6 @@ var serviceContext = (function () {
...
@@ -604,14 +623,6 @@ var serviceContext = (function () {
}
}
}
}
const
ANI_SHOW
=
'
pop-in
'
;
const
ANI_DURATION
=
300
;
const
TABBAR_HEIGHT
=
56
;
const
TITLEBAR_HEIGHT
=
44
;
const
VIEW_WEBVIEW_PATH
=
'
__uniappview.html
'
;
const
WEBVIEW_STYLE_BLACKLIST
=
[
const
WEBVIEW_STYLE_BLACKLIST
=
[
'
navigationBarBackgroundColor
'
,
'
navigationBarBackgroundColor
'
,
'
navigationBarTextStyle
'
,
'
navigationBarTextStyle
'
,
...
@@ -675,14 +686,16 @@ var serviceContext = (function () {
...
@@ -675,14 +686,16 @@ var serviceContext = (function () {
};
};
}
}
if
(
routeOptions
.
meta
.
isTabBar
)
{
webviewStyle
.
top
=
0
;
webviewStyle
.
bottom
=
TABBAR_HEIGHT
;
}
return
webviewStyle
return
webviewStyle
}
}
const
ANI_SHOW
=
'
pop-in
'
;
const
ANI_DURATION
=
300
;
const
TITLEBAR_HEIGHT
=
44
;
const
VIEW_WEBVIEW_PATH
=
'
__uniappview.html
'
;
let
preloadWebview
;
let
preloadWebview
;
let
id
=
2
;
let
id
=
2
;
...
@@ -827,6 +840,148 @@ var serviceContext = (function () {
...
@@ -827,6 +840,148 @@ var serviceContext = (function () {
console
.
log
(
`[PERF]
${
type
}
耗时[
${
Date
.
now
()
-
startTime
}
]`
);
console
.
log
(
`[PERF]
${
type
}
耗时[
${
Date
.
now
()
-
startTime
}
]`
);
}
}
const
TABBAR_HEIGHT
=
56
;
let
config
;
/**
* tabbar显示状态
*/
let
visible
=
true
;
let
tabBar
;
/**
* 设置角标
* @param {string} type
* @param {number} index
* @param {string} text
*/
function
setTabBarBadge
(
type
,
index
,
text
)
{
if
(
!
tabBar
)
{
return
}
if
(
type
===
'
none
'
)
{
tabBar
.
hideTabBarRedDot
({
index
});
tabBar
.
removeTabBarBadge
({
index
});
}
else
if
(
type
===
'
text
'
)
{
tabBar
.
setTabBarBadge
({
index
,
text
});
}
else
if
(
type
===
'
redDot
'
)
{
tabBar
.
showTabBarRedDot
({
index
});
}
}
/**
* 动态设置 tabBar 某一项的内容
*/
function
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
)
{
const
item
=
{};
if
(
iconPath
)
{
item
.
iconPath
=
getRealPath
(
iconPath
);
}
if
(
selectedIconPath
)
{
item
.
selectedIconPath
=
getRealPath
(
selectedIconPath
);
}
tabBar
&&
tabBar
.
setTabBarItem
(
Object
.
assign
({
index
,
text
},
item
));
}
/**
* 动态设置 tabBar 的整体样式
* @param {Object} style 样式
*/
function
setTabBarStyle
(
style
)
{
tabBar
&&
tabBar
.
setTabBarStyle
(
style
);
}
/**
* 隐藏 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持
*/
function
hideTabBar
(
animation
)
{
visible
=
false
;
tabBar
&&
tabBar
.
hideTabBar
({
animation
});
}
/**
* 显示 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持
*/
function
showTabBar
(
animation
)
{
visible
=
true
;
tabBar
&&
tabBar
.
showTabBar
({
animation
});
}
var
tabBar$1
=
{
init
(
options
,
clickCallback
)
{
if
(
options
&&
options
.
list
.
length
)
{
config
=
options
;
}
try
{
tabBar
=
requireNativePlugin
(
'
uni-tabview
'
);
}
catch
(
error
)
{
console
.
log
(
`uni.requireNativePlugin("uni-tabview") error
${
error
}
`
);
}
tabBar
&&
tabBar
.
onClick
(({
index
})
=>
{
clickCallback
(
config
.
list
[
index
],
index
,
true
);
});
tabBar
&&
tabBar
.
onMidButtonClick
(()
=>
{
publish
(
'
onTabBarMidButtonTap
'
,
{});
});
},
switchTab
(
page
)
{
const
itemLength
=
config
.
list
.
length
;
if
(
itemLength
)
{
for
(
let
i
=
0
;
i
<
itemLength
;
i
++
)
{
if
(
config
.
list
[
i
].
pagePath
===
page
||
config
.
list
[
i
].
pagePath
===
`
${
page
}
.html`
)
{
tabBar
&&
tabBar
.
switchSelect
({
index
:
i
});
return
true
}
}
}
return
false
},
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
hideTabBar
,
showTabBar
,
append
(
webview
)
{
tabBar
&&
tabBar
.
append
({
id
:
webview
.
id
},
({
code
})
=>
{
if
(
code
!==
0
)
{
// console.log('tab append error')
setTimeout
(()
=>
{
this
.
append
(
webview
);
},
20
);
}
});
},
get
visible
()
{
return
visible
},
get
height
()
{
return
config
&&
config
.
height
?
parseFloat
(
config
.
height
)
:
TABBAR_HEIGHT
}
};
const
pages
=
[];
const
pages
=
[];
function
getCurrentPages$1
(
returnAll
)
{
function
getCurrentPages$1
(
returnAll
)
{
...
@@ -867,6 +1022,8 @@ var serviceContext = (function () {
...
@@ -867,6 +1022,8 @@ var serviceContext = (function () {
if
(
openType
===
'
reLaunch
'
||
pages
.
length
===
0
)
{
if
(
openType
===
'
reLaunch
'
||
pages
.
length
===
0
)
{
// pages.length===0 表示首页触发 redirectTo
// pages.length===0 表示首页触发 redirectTo
routeOptions
.
meta
.
isQuit
=
true
;
routeOptions
.
meta
.
isQuit
=
true
;
}
else
if
(
!
routeOptions
.
meta
.
isTabBar
)
{
routeOptions
.
meta
.
isQuit
=
false
;
}
}
if
(
!
webview
)
{
if
(
!
webview
)
{
...
@@ -880,8 +1037,7 @@ var serviceContext = (function () {
...
@@ -880,8 +1037,7 @@ var serviceContext = (function () {
}
}
if
(
routeOptions
.
meta
.
isTabBar
&&
webview
.
id
!==
'
1
'
)
{
if
(
routeOptions
.
meta
.
isTabBar
&&
webview
.
id
!==
'
1
'
)
{
const
launchWebview
=
plus
.
webview
.
getLaunchWebview
();
tabBar$1
.
append
(
webview
);
launchWebview
&&
launchWebview
.
append
(
webview
);
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
...
@@ -977,500 +1133,6 @@ var serviceContext = (function () {
...
@@ -977,500 +1133,6 @@ var serviceContext = (function () {
callbacks
[
type
]
=
callback
;
callbacks
[
type
]
=
callback
;
}
}
var
safeArea
=
{
get
bottom
()
{
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
const
safeArea
=
plus
.
navigator
.
getSafeAreaInsets
();
return
safeArea
?
safeArea
.
bottom
:
0
}
return
0
}
};
const
IMAGE_TOP
=
7
;
const
IMAGE_WIDTH
=
24
;
const
IMAGE_HEIGHT
=
24
;
const
TEXT_TOP
=
36
;
const
TEXT_SIZE
=
12
;
const
TEXT_NOICON_SIZE
=
17
;
const
TEXT_HEIGHT
=
12
;
const
IMAGE_ID
=
'
TABITEM_IMAGE_
'
;
const
TABBAR_VIEW_ID
=
'
TABBAR_VIEW_
'
;
let
view
;
let
config
;
let
winWidth
;
let
itemWidth
;
let
itemLength
;
let
itemImageLeft
;
let
itemRects
=
[];
const
itemIcons
=
[];
const
itemLayouts
=
[];
const
itemDot
=
[];
const
itemBadge
=
[];
let
itemClickCallback
;
let
selected
=
0
;
/**
* tabbar显示状态
*/
let
visible
=
true
;
const
init
=
function
()
{
const
list
=
config
.
list
;
itemLength
=
config
.
list
.
length
;
calcItemLayout
();
// 计算选项卡布局
initBitmaps
(
list
);
// 初始化选项卡图标
initView
();
};
let
initView
=
function
()
{
const
viewStyles
=
{
height
:
TABBAR_HEIGHT
};
if
(
config
.
position
===
'
top
'
)
{
viewStyles
.
top
=
0
;
}
else
{
viewStyles
.
bottom
=
0
;
viewStyles
.
height
+=
safeArea
.
bottom
;
}
view
=
new
plus
.
nativeObj
.
View
(
TABBAR_VIEW_ID
,
viewStyles
,
getDraws
());
view
.
interceptTouchEvent
(
true
);
view
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
if
(
!
__uniConfig
.
__ready__
)
{
// 未 ready,不允许点击
return
}
const
x
=
e
.
clientX
;
const
y
=
e
.
clientY
;
for
(
let
i
=
0
;
i
<
itemRects
.
length
;
i
++
)
{
if
(
isCross
(
x
,
y
,
itemRects
[
i
]))
{
const
draws
=
getSelectedDraws
(
i
);
const
drawTab
=
!!
draws
.
length
;
itemClickCallback
&&
itemClickCallback
(
config
.
list
[
i
],
i
,
drawTab
);
if
(
drawTab
)
{
setTimeout
(()
=>
view
.
draw
(
draws
));
}
break
}
}
});
plus
.
globalEvent
.
addEventListener
(
'
orientationchange
'
,
()
=>
{
calcItemLayout
(
config
.
list
);
if
(
config
.
position
!==
'
top
'
)
{
let
height
=
TABBAR_HEIGHT
+
safeArea
.
bottom
;
view
.
setStyle
({
height
:
height
});
if
(
visible
)
{
setWebviewPosition
(
height
);
}
}
view
.
draw
(
getDraws
());
});
if
(
!
visible
)
{
view
.
hide
();
}
};
let
isCross
=
function
(
x
,
y
,
rect
)
{
if
(
x
>
rect
.
left
&&
x
<
(
rect
.
left
+
rect
.
width
)
&&
y
>
rect
.
top
&&
y
<
(
rect
.
top
+
rect
.
height
))
{
return
true
}
return
false
};
let
initBitmaps
=
function
(
list
)
{
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
const
item
=
list
[
i
];
if
(
item
.
iconData
)
{
const
bitmap
=
new
plus
.
nativeObj
.
Bitmap
(
IMAGE_ID
+
i
);
bitmap
.
loadBase64Data
(
item
.
iconData
);
const
selectedBitmap
=
new
plus
.
nativeObj
.
Bitmap
(
`
${
IMAGE_ID
}
SELECTED_
${
i
}
`
);
selectedBitmap
.
loadBase64Data
(
item
.
selectedIconData
);
itemIcons
[
i
]
=
{
icon
:
bitmap
,
selectedIcon
:
selectedBitmap
};
}
else
if
(
item
.
iconPath
)
{
itemIcons
[
i
]
=
{
icon
:
item
.
iconPath
,
selectedIcon
:
item
.
selectedIconPath
};
}
else
{
itemIcons
[
i
]
=
{
icon
:
false
,
selectedIcon
:
false
};
}
}
};
let
getDraws
=
function
()
{
const
backgroundColor
=
config
.
backgroundColor
;
const
borderHeight
=
Math
.
max
(
0.5
,
1
/
plus
.
screen
.
scale
);
// 高分屏最少0.5
const
borderTop
=
config
.
position
===
'
top
'
?
(
TABBAR_HEIGHT
-
borderHeight
)
:
0
;
const
borderStyle
=
config
.
borderStyle
===
'
white
'
?
'
rgba(255,255,255,0.33)
'
:
'
rgba(0,0,0,0.33)
'
;
const
draws
=
[{
id
:
`
${
TABBAR_VIEW_ID
}
BG`
,
// 背景色
tag
:
'
rect
'
,
color
:
backgroundColor
,
position
:
{
top
:
0
,
left
:
0
,
width
:
'
100%
'
,
height
:
TABBAR_HEIGHT
+
safeArea
.
bottom
}
},
{
id
:
`
${
TABBAR_VIEW_ID
}
BORDER`
,
tag
:
'
rect
'
,
color
:
borderStyle
,
position
:
{
top
:
borderTop
,
left
:
0
,
width
:
'
100%
'
,
height
:
`
${
borderHeight
}
px`
}
}];
for
(
let
i
=
0
;
i
<
itemLength
;
i
++
)
{
const
item
=
config
.
list
[
i
];
if
(
i
===
selected
)
{
drawTabItem
(
draws
,
i
,
item
.
text
,
config
.
selectedColor
,
itemIcons
[
i
].
selectedIcon
);
}
else
{
drawTabItem
(
draws
,
i
,
item
.
text
,
config
.
color
,
itemIcons
[
i
].
icon
);
}
}
return
draws
};
let
getSelectedDraws
=
function
(
newSelected
)
{
if
(
selected
===
newSelected
)
{
return
false
}
const
draws
=
[];
const
lastSelected
=
selected
;
selected
=
newSelected
;
drawTabItem
(
draws
,
lastSelected
);
drawTabItem
(
draws
,
selected
);
return
draws
};
/**
* 获取文字宽度(全角为1)
* @param {*} text
*/
function
getFontWidth
(
text
)
{
// eslint-disable-next-line
return
text
.
length
-
(
text
.
match
(
/
[\u
0000-
\u
00ff
]
/g
)
||
[]).
length
/
2
}
let
calcItemLayout
=
function
()
{
winWidth
=
plus
.
screen
.
resolutionWidth
;
itemWidth
=
winWidth
/
itemLength
;
itemImageLeft
=
(
itemWidth
-
IMAGE_WIDTH
)
/
2
;
itemRects
=
[];
let
dotTop
=
0
;
let
dotLeft
=
0
;
for
(
let
i
=
0
;
i
<
itemLength
;
i
++
)
{
itemRects
.
push
({
top
:
0
,
left
:
i
*
itemWidth
,
width
:
itemWidth
,
height
:
TABBAR_HEIGHT
});
}
for
(
let
i
=
0
;
i
<
itemLength
;
i
++
)
{
const
item
=
config
.
list
[
i
];
let
imgLeft
=
itemWidth
*
i
+
itemImageLeft
;
if
((
item
.
iconData
||
item
.
iconPath
)
&&
item
.
text
)
{
// 图文
itemLayouts
[
i
]
=
{
text
:
{
top
:
TEXT_TOP
,
left
:
`
${
i
*
itemWidth
}
px`
,
width
:
`
${
itemWidth
}
px`
,
height
:
TEXT_HEIGHT
},
img
:
{
top
:
IMAGE_TOP
,
left
:
`
${
imgLeft
}
px`
,
width
:
IMAGE_WIDTH
,
height
:
IMAGE_HEIGHT
}
};
dotTop
=
IMAGE_TOP
;
dotLeft
=
imgLeft
+
IMAGE_WIDTH
;
}
else
if
(
!
(
item
.
iconData
||
item
.
iconPath
)
&&
item
.
text
)
{
// 仅文字
let
textLeft
=
i
*
itemWidth
;
itemLayouts
[
i
]
=
{
text
:
{
top
:
0
,
left
:
`
${
textLeft
}
px`
,
width
:
`
${
itemWidth
}
px`
,
height
:
TABBAR_HEIGHT
}
};
dotTop
=
(
44
-
TEXT_NOICON_SIZE
)
/
2
;
dotLeft
=
textLeft
+
itemWidth
*
0.5
+
getFontWidth
(
item
.
text
)
*
TEXT_NOICON_SIZE
*
0.5
;
}
else
if
((
item
.
iconData
||
item
.
iconPath
)
&&
!
item
.
text
)
{
// 仅图片
const
diff
=
10
;
let
imgTop
=
(
TABBAR_HEIGHT
-
IMAGE_HEIGHT
-
diff
)
/
2
;
let
imgLeft
=
itemWidth
*
i
+
itemImageLeft
-
diff
/
2
;
itemLayouts
[
i
]
=
{
img
:
{
top
:
`
${
imgTop
}
px`
,
left
:
`
${
imgLeft
}
px`
,
width
:
IMAGE_WIDTH
+
diff
,
height
:
IMAGE_HEIGHT
+
diff
}
};
dotTop
=
imgTop
;
dotLeft
=
imgLeft
+
IMAGE_WIDTH
+
diff
;
}
let
height
=
itemBadge
[
i
]
?
14
:
10
;
let
badge
=
itemBadge
[
i
]
||
'
0
'
;
let
font
=
getFontWidth
(
badge
)
-
0.5
;
font
=
font
>
1
?
1
:
font
;
let
width
=
height
+
font
*
12
;
width
=
width
<
height
?
height
:
width
;
let
itemLayout
=
itemLayouts
[
i
];
if
(
itemLayout
)
{
itemLayout
.
doc
=
{
top
:
dotTop
,
left
:
`
${
dotLeft
-
width
*
0.382
}
px`
,
width
:
`
${
width
}
px`
,
height
:
`
${
height
}
px`
};
itemLayout
.
badge
=
{
top
:
dotTop
,
left
:
`
${
dotLeft
-
width
*
0.382
}
px`
,
width
:
`
${
width
}
px`
,
height
:
`
${
height
}
px`
};
}
}
};
let
drawTabItem
=
function
(
draws
,
index
)
{
const
layout
=
itemLayouts
[
index
];
const
item
=
config
.
list
[
index
];
let
color
=
config
.
color
;
let
icon
=
itemIcons
[
index
].
icon
;
let
dot
=
itemDot
[
index
];
let
badge
=
itemBadge
[
index
]
||
''
;
if
(
index
===
selected
)
{
color
=
config
.
selectedColor
;
icon
=
itemIcons
[
index
].
selectedIcon
;
}
if
(
icon
)
{
draws
.
push
({
id
:
`
${
TABBAR_VIEW_ID
}
ITEM_
${
index
}
_ICON`
,
tag
:
'
img
'
,
position
:
layout
.
img
,
src
:
icon
});
}
if
(
item
.
text
)
{
draws
.
push
({
id
:
`
${
TABBAR_VIEW_ID
}
ITEM_
${
index
}
_TEXT`
,
tag
:
'
font
'
,
position
:
layout
.
text
,
text
:
item
.
text
,
textStyles
:
{
size
:
icon
?
TEXT_SIZE
:
`
${
TEXT_NOICON_SIZE
}
px`
,
color
}
});
}
const
hiddenPosition
=
{
letf
:
0
,
top
:
0
,
width
:
0
,
height
:
0
};
// 绘制小红点(角标背景)
draws
.
push
({
id
:
`
${
TABBAR_VIEW_ID
}
ITEM_
${
index
}
_DOT`
,
tag
:
'
rect
'
,
position
:
(
dot
||
badge
)
?
layout
.
doc
:
hiddenPosition
,
rectStyles
:
{
color
:
'
#ff0000
'
,
radius
:
badge
?
'
7px
'
:
'
5px
'
}
});
// 绘制角标文本
draws
.
push
({
id
:
`
${
TABBAR_VIEW_ID
}
ITEM_
${
index
}
_BADGE`
,
tag
:
'
font
'
,
position
:
badge
?
layout
.
badge
:
hiddenPosition
,
text
:
badge
||
'
'
,
textStyles
:
{
align
:
'
center
'
,
verticalAlign
:
'
middle
'
,
color
:
badge
?
'
#ffffff
'
:
'
rgba(0,0,0,0)
'
,
overflow
:
'
ellipsis
'
,
size
:
'
10px
'
}
});
};
/**
* {
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "page/component/index.html",
"iconData": "",
"selectedIconData": "",
"text": "组件"
}, {
"pagePath": "page/API/index.html",
"iconData": "",
"selectedIconData": "",
"text": "接口"
}],
"position":"bottom"//bottom|top
}
*/
/**
* 设置角标
* @param {string} type
* @param {number} index
* @param {string} text
*/
function
setTabBarBadge
(
type
,
index
,
text
)
{
if
(
type
===
'
none
'
)
{
itemDot
[
index
]
=
false
;
itemBadge
[
index
]
=
''
;
}
else
if
(
type
===
'
text
'
)
{
itemBadge
[
index
]
=
text
;
}
else
if
(
type
===
'
redDot
'
)
{
itemDot
[
index
]
=
true
;
}
if
(
view
)
{
calcItemLayout
(
config
.
list
);
view
.
draw
(
getDraws
());
}
}
/**
* 动态设置 tabBar 某一项的内容
*/
function
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
)
{
if
(
iconPath
||
selectedIconPath
)
{
let
itemIcon
=
itemIcons
[
index
]
=
itemIcons
[
index
]
||
{};
if
(
iconPath
)
{
itemIcon
.
icon
=
getRealPath
(
iconPath
);
}
if
(
selectedIconPath
)
{
itemIcon
.
selectedIcon
=
getRealPath
(
selectedIconPath
);
}
}
if
(
text
)
{
config
.
list
[
index
].
text
=
text
;
}
view
.
draw
(
getDraws
());
}
/**
* 动态设置 tabBar 的整体样式
* @param {Object} style 样式
*/
function
setTabBarStyle
(
style
)
{
for
(
const
key
in
style
)
{
config
[
key
]
=
style
[
key
];
}
view
.
draw
(
getDraws
());
}
/**
* 设置tab页底部或顶部距离
* @param {*} value 距离
*/
function
setWebviewPosition
(
value
)
{
const
position
=
config
.
position
===
'
top
'
?
'
top
'
:
'
bottom
'
;
plus
.
webview
.
all
().
forEach
(
webview
=>
{
if
(
isTabBarPage
(
String
(
webview
.
__uniapp_route
)))
{
webview
.
setStyle
({
[
position
]:
value
});
}
});
}
/**
* 隐藏 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持
*/
function
hideTabBar
(
animation
)
{
if
(
visible
===
false
)
{
return
}
visible
=
false
;
if
(
view
)
{
view
.
hide
();
setWebviewPosition
(
0
);
}
}
/**
* 显示 tabBar
* @param {boolean} animation 是否需要动画效果 暂未支持
*/
function
showTabBar
(
animation
)
{
if
(
visible
===
true
)
{
return
}
visible
=
true
;
if
(
view
)
{
view
.
show
();
setWebviewPosition
(
TABBAR_HEIGHT
+
safeArea
.
bottom
);
}
}
var
tabBar
=
{
init
(
options
,
clickCallback
)
{
if
(
options
&&
options
.
list
.
length
)
{
selected
=
options
.
selected
||
0
;
config
=
options
;
config
.
position
=
'
bottom
'
;
// 暂时强制使用bottom
itemClickCallback
=
clickCallback
;
init
();
return
view
}
},
switchTab
(
page
)
{
if
(
itemLength
)
{
for
(
let
i
=
0
;
i
<
itemLength
;
i
++
)
{
if
(
config
.
list
[
i
].
pagePath
===
page
||
config
.
list
[
i
].
pagePath
===
`
${
page
}
.html`
)
{
const
draws
=
getSelectedDraws
(
i
);
if
(
draws
.
length
)
{
view
.
draw
(
draws
);
}
return
true
}
}
}
return
false
},
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
hideTabBar
,
showTabBar
,
get
visible
()
{
return
visible
}
};
const
PAGE_CREATE
=
2
;
const
PAGE_CREATE
=
2
;
const
MOUNTED_DATA
=
4
;
const
MOUNTED_DATA
=
4
;
const
UPDATED_DATA
=
6
;
const
UPDATED_DATA
=
6
;
...
@@ -1585,7 +1247,7 @@ var serviceContext = (function () {
...
@@ -1585,7 +1247,7 @@ var serviceContext = (function () {
plus
.
globalEvent
.
addEventListener
(
'
plusMessage
'
,
function
(
e
)
{
plus
.
globalEvent
.
addEventListener
(
'
plusMessage
'
,
function
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
UNIAPP
[plusMessage]:[
'
+
Date
.
now
()
+
'
]
'
+
JSON
.
stringify
(
e
.
data
));
console
.
log
(
'
[plusMessage]:[
'
+
Date
.
now
()
+
'
]
'
+
JSON
.
stringify
(
e
.
data
));
}
}
if
(
e
.
data
&&
e
.
data
.
type
)
{
if
(
e
.
data
&&
e
.
data
.
type
)
{
const
type
=
e
.
data
.
type
;
const
type
=
e
.
data
.
type
;
...
@@ -1620,26 +1282,20 @@ var serviceContext = (function () {
...
@@ -1620,26 +1282,20 @@ var serviceContext = (function () {
__uniConfig
.
__ready__
=
true
;
__uniConfig
.
__ready__
=
true
;
const
onLaunchWebviewReady
=
function
onLaunchWebviewReady
()
{
tabBar$1
.
init
(
__uniConfig
.
tabBar
,
(
item
,
index
)
=>
{
const
tabBarView
=
tabBar
.
init
(
__uniConfig
.
tabBar
,
(
item
,
index
)
=>
{
uni
.
switchTab
(
{
UniServiceJSBridge
.
emit
(
'
onTabItemTap
'
,
{
url
:
'
/
'
+
item
.
pagePath
,
index
,
openType
:
'
switchTab
'
,
text
:
item
.
text
,
from
:
'
tabBar
'
,
pagePath
:
item
.
pagePath
success
()
{
});
UniServiceJSBridge
.
emit
(
'
onTabItemTap
'
,
{
uni
.
switchTab
({
index
,
url
:
'
/
'
+
item
.
pagePath
,
text
:
item
.
text
,
openType
:
'
switchTab
'
,
pagePath
:
item
.
pagePath
from
:
'
tabbar
'
});
}
);
}
});
});
tabBarView
&&
plus
.
webview
.
getLaunchWebview
().
append
(
tabBarView
);
});
};
if
(
plus
.
webview
.
getLaunchWebview
())
{
onLaunchWebviewReady
();
}
else
{
registerPlusMessage
(
'
UniWebviewReady-
'
+
plus
.
runtime
.
appid
,
onLaunchWebviewReady
,
false
);
}
}
}
function
registerApp
(
appVm
)
{
function
registerApp
(
appVm
)
{
...
@@ -2211,7 +1867,7 @@ var serviceContext = (function () {
...
@@ -2211,7 +1867,7 @@ var serviceContext = (function () {
];
];
const
keyboard
=
[
const
keyboard
=
[
'
hideKeyboard
'
,
'
hideKeyboard
'
,
'
onKeyboardHeightChange
'
'
onKeyboardHeightChange
'
];
];
...
@@ -2234,6 +1890,7 @@ var serviceContext = (function () {
...
@@ -2234,6 +1890,7 @@ var serviceContext = (function () {
'
removeTabBarBadge
'
,
'
removeTabBarBadge
'
,
'
showTabBarRedDot
'
,
'
showTabBarRedDot
'
,
'
hideTabBarRedDot
'
,
'
hideTabBarRedDot
'
,
'
onTabBarMidButtonTap
'
,
'
setBackgroundColor
'
,
'
setBackgroundColor
'
,
'
setBackgroundTextStyle
'
,
'
setBackgroundTextStyle
'
,
'
createAnimation
'
,
'
createAnimation
'
,
...
@@ -5475,7 +5132,7 @@ var serviceContext = (function () {
...
@@ -5475,7 +5132,7 @@ var serviceContext = (function () {
safeAreaInsets
=
ios
?
plus
.
navigator
.
getSafeAreaInsets
()
:
getSafeAreaInsets
();
safeAreaInsets
=
ios
?
plus
.
navigator
.
getSafeAreaInsets
()
:
getSafeAreaInsets
();
}
}
var
windowHeight
=
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
var
windowHeight
=
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
:
0
)
-
(
isTabBarPage
()
&&
tabBar
.
visible
?
TABBAR_HEIGHT
:
0
),
screenHeight
);
:
0
)
-
(
isTabBarPage
()
&&
tabBar
$1
.
visible
?
tabBar$1
.
height
:
0
),
screenHeight
);
var
windowWidth
=
screenWidth
;
var
windowWidth
=
screenWidth
;
var
safeArea
=
{
var
safeArea
=
{
left
:
safeAreaInsets
.
left
,
left
:
safeAreaInsets
.
left
,
...
@@ -7364,7 +7021,7 @@ var serviceContext = (function () {
...
@@ -7364,7 +7021,7 @@ var serviceContext = (function () {
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
function
showWebview
(
webview
,
animationType
,
animationDuration
,
showCallback
)
{
function
showWebview
(
webview
,
animationType
,
animationDuration
,
showCallback
,
delay
=
50
)
{
animationDuration
=
typeof
animationDuration
===
'
undefined
'
?
ANI_DURATION$1
:
parseInt
(
animationDuration
);
animationDuration
=
typeof
animationDuration
===
'
undefined
'
?
ANI_DURATION$1
:
parseInt
(
animationDuration
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
webview
.
show
(
webview
.
show
(
...
@@ -7375,7 +7032,7 @@ var serviceContext = (function () {
...
@@ -7375,7 +7032,7 @@ var serviceContext = (function () {
navigateStack
(
webview
);
navigateStack
(
webview
);
}
}
);
);
},
50
);
},
delay
);
}
}
let
firstBackTime
=
0
;
let
firstBackTime
=
0
;
...
@@ -7450,7 +7107,7 @@ var serviceContext = (function () {
...
@@ -7450,7 +7107,7 @@ var serviceContext = (function () {
animationType
,
animationType
,
animationDuration
animationDuration
})
{
})
{
const
pages
=
getCurrentPages
();
const
pages
=
getCurrentPages
();
const
currentPage
=
pages
[
pages
.
length
-
1
];
const
currentPage
=
pages
[
pages
.
length
-
1
];
if
(
if
(
...
@@ -7462,13 +7119,17 @@ var serviceContext = (function () {
...
@@ -7462,13 +7119,17 @@ var serviceContext = (function () {
})
})
)
{
)
{
return
return
}
}
uni
.
hideToast
();
// 后退时,关闭 toast,loading
uni
.
hideToast
();
// 后退时,关闭 toast,loading
currentPage
.
$page
.
meta
.
isQuit
currentPage
.
$page
.
meta
.
isQuit
?
quit
()
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
);
:
back
(
delta
,
animationType
,
animationDuration
);
return
{
errMsg
:
'
navigateBack:ok
'
}
}
}
function
_navigateTo
({
function
_navigateTo
({
...
@@ -7476,11 +7137,12 @@ var serviceContext = (function () {
...
@@ -7476,11 +7137,12 @@ var serviceContext = (function () {
query
,
query
,
animationType
,
animationType
,
animationDuration
animationDuration
}
)
{
}
,
callbackId
)
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
type
:
'
navigateTo
'
,
path
path
});
});
showWebview
(
showWebview
(
registerPage
({
registerPage
({
path
,
path
,
...
@@ -7488,7 +7150,12 @@ var serviceContext = (function () {
...
@@ -7488,7 +7150,12 @@ var serviceContext = (function () {
openType
:
'
navigate
'
openType
:
'
navigate
'
}),
}),
animationType
,
animationType
,
animationDuration
animationDuration
,
()
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
navigateTo:ok
'
});
}
);
);
setStatusBarStyle
();
setStatusBarStyle
();
}
}
...
@@ -7513,7 +7180,7 @@ var serviceContext = (function () {
...
@@ -7513,7 +7180,7 @@ var serviceContext = (function () {
function
reLaunch$1
({
function
reLaunch$1
({
url
url
})
{
}
,
callbackId
)
{
const
urls
=
url
.
split
(
'
?
'
);
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
path
=
urls
[
0
];
...
@@ -7524,7 +7191,7 @@ var serviceContext = (function () {
...
@@ -7524,7 +7191,7 @@ var serviceContext = (function () {
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
if
(
routeOptions
.
meta
.
isTabBar
)
{
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
url
);
tabBar
$1
.
switchTab
(
url
);
}
}
showWebview
(
showWebview
(
...
@@ -7534,7 +7201,12 @@ var serviceContext = (function () {
...
@@ -7534,7 +7201,12 @@ var serviceContext = (function () {
openType
:
'
reLaunch
'
openType
:
'
reLaunch
'
}),
}),
'
none
'
,
'
none
'
,
0
0
,
()
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
reLaunch:ok
'
});
}
);
);
pages
.
forEach
(
page
=>
{
pages
.
forEach
(
page
=>
{
...
@@ -7547,7 +7219,7 @@ var serviceContext = (function () {
...
@@ -7547,7 +7219,7 @@ var serviceContext = (function () {
function
redirectTo$1
({
function
redirectTo$1
({
url
url
})
{
}
,
callbackId
)
{
const
urls
=
url
.
split
(
'
?
'
);
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
path
=
urls
[
0
];
...
@@ -7568,6 +7240,9 @@ var serviceContext = (function () {
...
@@ -7568,6 +7240,9 @@ var serviceContext = (function () {
0
,
0
,
()
=>
{
()
=>
{
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
invoke
(
callbackId
,
{
errMsg
:
'
redirectTo:ok
'
});
}
}
);
);
...
@@ -7577,8 +7252,8 @@ var serviceContext = (function () {
...
@@ -7577,8 +7252,8 @@ var serviceContext = (function () {
function
_switchTab
({
function
_switchTab
({
path
,
path
,
from
from
}
)
{
}
,
callbackId
)
{
tabBar
.
switchTab
(
path
.
slice
(
1
));
tabBar
$1
.
switchTab
(
path
.
slice
(
1
));
const
pages
=
getCurrentPages
();
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
const
len
=
pages
.
length
;
...
@@ -7593,11 +7268,14 @@ var serviceContext = (function () {
...
@@ -7593,11 +7268,14 @@ var serviceContext = (function () {
}
}
});
});
currentPage
.
$remove
();
currentPage
.
$remove
();
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 延迟执行避免iOS应用退出
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
setTimeout
(()
=>
{
}
else
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
}
else
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
},
100
);
}
else
{
}
else
{
// 前一个 tabBar 触发 onHide
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
...
@@ -7621,17 +7299,23 @@ var serviceContext = (function () {
...
@@ -7621,17 +7299,23 @@ var serviceContext = (function () {
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
}
else
{
}
else
{
showWebview
(
return
showWebview
(
registerPage
({
registerPage
({
path
,
path
,
query
:
{},
query
:
{},
openType
:
'
switchTab
'
openType
:
'
switchTab
'
}),
'
none
'
,
0
,
()
=>
{
})
invoke
(
callbackId
,
{
);
errMsg
:
'
switchTab:ok
'
});
},
70
)
}
}
setStatusBarStyle
();
setStatusBarStyle
();
}
return
{
errMsg
:
'
switchTab:ok
'
}
}
function
switchTab$1
({
function
switchTab$1
({
url
,
url
,
from
from
...
@@ -7908,7 +7592,7 @@ var serviceContext = (function () {
...
@@ -7908,7 +7592,7 @@ var serviceContext = (function () {
text
,
text
,
type
=
'
text
'
type
=
'
text
'
})
{
})
{
tabBar
.
setTabBarBadge
(
type
,
index
,
text
);
tabBar
$1
.
setTabBarBadge
(
type
,
index
,
text
);
return
{
return
{
errMsg
:
'
setTabBarBadge:ok
'
errMsg
:
'
setTabBarBadge:ok
'
}
}
...
@@ -7925,7 +7609,7 @@ var serviceContext = (function () {
...
@@ -7925,7 +7609,7 @@ var serviceContext = (function () {
errMsg
:
'
setTabBarItem:fail not TabBar page
'
errMsg
:
'
setTabBarItem:fail not TabBar page
'
}
}
}
}
tabBar
.
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
);
tabBar
$1
.
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
);
return
{
return
{
errMsg
:
'
setTabBarItem:ok
'
errMsg
:
'
setTabBarItem:ok
'
}
}
...
@@ -7942,11 +7626,11 @@ var serviceContext = (function () {
...
@@ -7942,11 +7626,11 @@ var serviceContext = (function () {
errMsg
:
'
setTabBarStyle:fail not TabBar page
'
errMsg
:
'
setTabBarStyle:fail not TabBar page
'
}
}
}
}
tabBar
.
setTabBarStyle
({
tabBar
$1
.
setTabBarStyle
({
color
,
color
,
selectedColor
,
selectedColor
,
backgroundColor
,
backgroundColor
,
borderStyle
borderStyle
:
borderStyle
===
'
white
'
?
'
#ffffff
'
:
'
#c6c6c6
'
});
});
return
{
return
{
errMsg
:
'
setTabBarStyle:ok
'
errMsg
:
'
setTabBarStyle:ok
'
...
@@ -7961,7 +7645,7 @@ var serviceContext = (function () {
...
@@ -7961,7 +7645,7 @@ var serviceContext = (function () {
errMsg
:
'
hideTabBar:fail not TabBar page
'
errMsg
:
'
hideTabBar:fail not TabBar page
'
}
}
}
}
tabBar
.
hideTabBar
(
animation
);
tabBar
$1
.
hideTabBar
(
animation
);
return
{
return
{
errMsg
:
'
hideTabBar:ok
'
errMsg
:
'
hideTabBar:ok
'
}
}
...
@@ -7975,7 +7659,7 @@ var serviceContext = (function () {
...
@@ -7975,7 +7659,7 @@ var serviceContext = (function () {
errMsg
:
'
showTabBar:fail not TabBar page
'
errMsg
:
'
showTabBar:fail not TabBar page
'
}
}
}
}
tabBar
.
showTabBar
(
animation
);
tabBar
$1
.
showTabBar
(
animation
);
return
{
return
{
errMsg
:
'
showTabBar:ok
'
errMsg
:
'
showTabBar:ok
'
}
}
...
@@ -9368,28 +9052,41 @@ var serviceContext = (function () {
...
@@ -9368,28 +9052,41 @@ var serviceContext = (function () {
})
})
}
}
const
hideTabBarRedDot$1
=
removeTabBarBadge$1
;
const
hideTabBarRedDot$1
=
removeTabBarBadge$1
;
const
callbacks$8
=
[];
onMethod
(
'
onTabBarMidButtonTap
'
,
res
=>
{
callbacks$8
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
function
onTabBarMidButtonTap
(
callbackId
)
{
callbacks$8
.
push
(
callbackId
);
}
var
require_context_module_1_19
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_1_19
=
/*#__PURE__*/
Object
.
freeze
({
removeTabBarBadge
:
removeTabBarBadge$1
,
removeTabBarBadge
:
removeTabBarBadge$1
,
showTabBarRedDot
:
showTabBarRedDot$1
,
showTabBarRedDot
:
showTabBarRedDot$1
,
hideTabBarRedDot
:
hideTabBarRedDot$1
hideTabBarRedDot
:
hideTabBarRedDot$1
,
onTabBarMidButtonTap
:
onTabBarMidButtonTap
});
});
const
callbacks$
8
=
[];
const
callbacks$
9
=
[];
onMethod
(
'
onViewDidResize
'
,
res
=>
{
onMethod
(
'
onViewDidResize
'
,
res
=>
{
callbacks$
8
.
forEach
(
callbackId
=>
{
callbacks$
9
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
invoke
(
callbackId
,
res
);
});
});
});
});
function
onWindowResize
(
callbackId
)
{
function
onWindowResize
(
callbackId
)
{
callbacks$
8
.
push
(
callbackId
);
callbacks$
9
.
push
(
callbackId
);
}
}
function
offWindowResize
(
callbackId
)
{
function
offWindowResize
(
callbackId
)
{
// 此处和微信平台一致查询不到去掉最后一个
// 此处和微信平台一致查询不到去掉最后一个
callbacks$
8
.
splice
(
callbacks$8
.
indexOf
(
callbackId
),
1
);
callbacks$
9
.
splice
(
callbacks$9
.
indexOf
(
callbackId
),
1
);
}
}
var
require_context_module_1_20
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_1_20
=
/*#__PURE__*/
Object
.
freeze
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录