Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
79c1bc55
Commit
79c1bc55
authored
Mar 26, 2021
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
底部栏逻辑重构
parent
dcabe71f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
96 deletions
+36
-96
src/components/tabbarPage.vue
+4
-15
src/pages/home/index.vue
+11
-21
src/utils/mayi.js
+13
-13
static/nativeComponents/custom-tab-bar/index.js
+8
-47
No files found.
src/components/tabbarPage.vue
View file @
79c1bc55
...
...
@@ -14,10 +14,10 @@
<
script
>
import
{
getUrlofLink
,
getUrlofQuery
,
noLoginListPath
,
checkTabbarPage
,
}
from
"../utils/mayi.js"
;
import
{
serialize
}
from
"@/utils/index"
;
export
default
{
props
:
{
index
:
{
...
...
@@ -48,8 +48,6 @@ export default {
},
},
onLoad
(
options
)
{
console
.
log
(
'onload'
)
let
ss
=
wx
.
getStorageSync
(
"sessionid"
);
this
.
ss
=
ss
?
`&sessionid=
${
ss
}
`
:
""
;
if
(
!
ss
)
{
...
...
@@ -62,19 +60,10 @@ export default {
this
.
page
=
getUrlofLink
(
this
.
mpApp
.
globalData
.
footerVal
.
componentData
.
list
[
this
.
index
].
link
);
// this.params+='&'+getUrlofQuery( this.mpApp.globalData.footerVal.componentData.list[this.index].link)
let
query
=
serialize
(
options
)
this
.
params
+=
query
?
'&'
+
query
:
''
}
},
onShow
()
{
console
.
log
(
'onshow'
)
// 登录态更新
// let ss = wx.getStorageSync("sessionid");
// if (!this.ss && ss) {
// this.ss = `&sessionid=${ss}`;
// } else if (!ss) {
// this.params += this.params.includes("logOut") ? "" : "&logOut=true";
// }
},
methods
:
{
handleError
(
data
)
{
wx
.
showLoading
({
...
...
src/pages/home/index.vue
View file @
79c1bc55
...
...
@@ -104,8 +104,8 @@
<div
v-if=
"applySucessEntry"
>
<apply-sucess-entry></apply-sucess-entry>
</div>
<custom-tab-bar></custom-tab-bar>
<!-- 底部栏 -->
<custom-tab-bar
class=
"custom-tab-bar"
:selected=
"active"
></custom-tab-bar>
</div>
</
template
>
...
...
@@ -145,6 +145,7 @@ export default {
showHomepage
:
false
,
//分销商首页入口
applySucessEntry
:
false
,
//成为分销弹框
getDistributorHomepageName
:
''
,
//小店入口名称
active
:
-
1
};
},
components
:{
...
...
@@ -163,11 +164,9 @@ export default {
spellGroup
},
onShareAppMessage
(
res
)
{
let
shareVal
=
{};
let
{
shopCode
}
=
app
.
globalData
.
shopInfo
;
if
(
res
.
from
===
"button"
)
{
console
.
log
(
res
.
target
,
'-----------78'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
shop
.
getShopInfo
({
shopMixId
:
shopCode
}).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
...
...
@@ -285,13 +284,7 @@ export default {
},
onShow
()
{
// let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?from=_goodsInfo'
// app.$themeToLink({
// type: 1,
// link:linkVal,
// });
this
.
getCartNum
();
setTabBarActive
.
bind
(
this
)(
checkTabbarPage
(
'/'
));
this
.
$mp
.
page
.
onPageScroll
=
(
el
)
=>
{
throttle
(
this
.
scrolls
(
el
),
100
)
};
...
...
@@ -299,8 +292,8 @@ export default {
methods
:
{
init
(
pageList
)
{
this
.
getCartNum
()
setTabBarActive
.
bind
(
this
)(
checkTabbarPage
(
'/'
)
);
this
.
getCartNum
()
;
this
.
active
=
checkTabbarPage
(
'/'
);
this
.
pageInfo
=
pageList
.
filter
((
item
)
=>
item
.
pageCode
==
1
)[
0
];
this
.
pageData
=
JSON
.
parse
(
this
.
pageInfo
.
pageData
);
...
...
@@ -344,7 +337,7 @@ export default {
})
},
scrolls
(
el
){
//
this.setFooterShow(el);
this
.
setFooterShow
(
el
);
if
(
this
.
pageData
)
{
for
(
let
i
=
0
;
i
<
this
.
pageData
.
length
;
i
++
)
{
const
element
=
this
.
pageData
[
i
]
...
...
@@ -363,9 +356,7 @@ export default {
}
}
// this.setFooterShow(el);
if
(
this
.
$mp
.
page
&&
this
.
$mp
.
page
.
selectComponent
(
".getIndexHomePage"
)){
this
.
$mp
.
page
.
selectComponent
(
".getIndexHomePage"
).
getScroll
(
el
);
}
...
...
@@ -377,7 +368,7 @@ export default {
// return
let
afterScrollTop
=
el
.
scrollTop
;
let
delta
=
afterScrollTop
-
this
.
beforeScrollTop
;
let
{
showFlag
}
=
this
.
$mp
.
page
.
getTabBar
(
).
data
;
let
{
showFlag
}
=
this
.
$mp
.
page
.
selectComponent
(
".custom-tab-bar"
).
data
;
if
(
delta
===
0
||
afterScrollTop
<
0
||
...
...
@@ -388,9 +379,8 @@ export default {
this
.
beforeScrollTop
=
afterScrollTop
;
return
;
}
// this.$mp.page.getTabBar().animation({'showFlag':delta>0?'down':'up'})
// console.log(showFlag,'set296' )
this
.
$mp
.
page
.
getTabBar
().
setData
({
'showFlag'
:
delta
>
0
?
'down'
:
'up'
})
this
.
$mp
.
page
.
selectComponent
(
".custom-tab-bar"
).
setData
({
'showFlag'
:
delta
>
0
?
'down'
:
'up'
})
console
.
log
(
'---------383'
)
},
scrolltolower
(){
console
.
log
(
"scrolltolower"
)
...
...
@@ -398,7 +388,7 @@ export default {
getCartNum
()
{
app
.
cartApi
.
my_cart_count
().
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
this
.
$mp
.
page
.
getTabBar
(
).
setData
({
"cartNum"
:
Number
(
res
.
data
.
data
)});
this
.
$mp
.
page
.
selectComponent
(
".custom-tab-bar"
).
setData
({
"cartNum"
:
Number
(
res
.
data
.
data
)});
}
});
}
...
...
src/utils/mayi.js
View file @
79c1bc55
...
...
@@ -10,7 +10,7 @@ export const noLoginListPath = noLoginList.map(item => {
return
item
})
// 有底部栏页面
export
const
containFooterPage
=
[
"/"
,
"/goods/commodityMenu"
,
"/shopCart/shoppingCart"
,
"/personalCenter"
]
export
const
containFooterPage
=
[
"/"
,
"/goods/commodityMenu"
,
"/shopCart/shoppingCart"
,
"/personalCenter"
]
// 主题色
export
let
themeColor
=
{
"--main-color"
:
"#ffffff"
,
...
...
@@ -28,14 +28,14 @@ export function getUrlofQuery(data) {
export
function
$themeToLink
(
data
,
option
)
{
let
app
=
getApp
();
let
type
=
data
.
type
;
console
.
log
(
'299999'
,
data
,
noLoginListPath
)
// 登录拦截和底部导航栏拦截(非功能项)
if
(
type
!=
2
)
{
// 登录拦截
let
parseLink
=
getUrlofLink
(
data
);
let
aa
=
noLoginListPath
.
includes
(
parseLink
)
||
parseLink
.
substr
(
0
,
7
)
==
"/goods/"
||
parseLink
.
includes
(
'/brandTopics'
);
console
.
log
(
noLoginListPath
.
includes
(
parseLink
),
'3535'
,
aa
)
if
(
!
aa
&&
!
wx
.
getStorageSync
(
"sessionid"
))
{
let
parseQuery
=
getUrlofQuery
(
data
);
let
noLogin
=
noLoginListPath
.
includes
(
parseLink
)
||
parseLink
.
substr
(
0
,
7
)
==
"/goods/"
||
parseLink
.
includes
(
'/brandTopics'
);
if
(
!
noLogin
&&
!
wx
.
getStorageSync
(
"sessionid"
))
{
let
url
=
`/pages/login/main?back=
${
parseLink
}
`
;
wx
.
navigateTo
({
url
});
return
...
...
@@ -44,14 +44,14 @@ export function $themeToLink(data, option) {
let
isTabbarIndex
=
checkTabbarPage
(
parseLink
);
if
(
isTabbarIndex
>=
0
)
{
// 无底部栏h5页面
if
(
!
containFooterPage
.
includes
(
parseLink
))
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
if
(
!
containFooterPage
.
includes
(
parseLink
))
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
return
}
isTabbarIndex
=
isTabbarIndex
==
0
?
checkTabbarPage
(
'/'
)
:
isTabbarIndex
let
query
=
parseQuery
?
`?
${
parseQuery
}
`
:
''
wx
.
reLaunch
({
url
:
parseLink
==
'/'
?
'/pages/home/main'
:
`/pages/tabBar
${
isTabbarIndex
}
/main
`
,
url
:
parseLink
==
'/'
?
`/pages/home/main
${
query
}
`
:
`/pages/tabBar
${
isTabbarIndex
}
/main
${
query
}
`
,
})
return
}
...
...
@@ -61,7 +61,7 @@ export function $themeToLink(data, option) {
// 历史数据
if
(
type
==
undefined
||
type
==
'undefined'
)
{
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
return
}
...
...
@@ -71,7 +71,7 @@ export function $themeToLink(data, option) {
}
else
if
(
type
==
1
)
{
//h5页面
//兼容
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
else
{
if
(
data
.
link
.
startsWith
(
'http'
)
||
data
.
link
.
startsWith
(
'https'
))
{
wx
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
...
...
@@ -87,7 +87,7 @@ export function $themeToLink(data, option) {
return
}
if
(
data
.
link
.
substring
(
0
,
1
)
==
"/"
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
else
{
wx
.
navigateTo
({
url
:
'/pages/wxArticle/main?link='
+
encodeURIComponent
(
data
.
link
)
});
}
...
...
@@ -108,7 +108,7 @@ export function $themeToLink(data, option) {
}
else
{
//向后兼容
if
(
data
.
length
>
0
)
{
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
toPage
(
getUrlofLink
(
data
),
getUrlofQuery
(
data
))
}
}
}
...
...
static/nativeComponents/custom-tab-bar/index.js
View file @
79c1bc55
const
app
=
getApp
();
Component
({
properties
:{
selected
:{
type
:
Number
,
default
:
-
1
}
},
data
:
{
selected
:
0
,
color
:
"#7A7E83"
,
selectedColor
:
"#3cc51f"
,
list
:
[
{
pagePath
:
"/pages/home/main"
,
iconPath
:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png"
,
selectedIconPath
:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png"
,
text
:
"组件"
,
//--多主题
condition
:
""
,
icon
:
"ant-daishouhuo"
,
iconType
:
1
,
//0 iconfont 1 image
imgUrl
:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png"
,
selectImgUrl
:
"https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png"
,
link
:
{
key
:
"1.1.1.7"
,
link
:
"/personalCenter/spokesmanCenter?distributionModel=1"
,
name
:
"分销商中心"
,
type
:
1
},
show
:
true
,
title
:
"分类页"
,
version
:
"1.0.0"
,
visible
:
1
},
{
pagePath
:
"/pages/index/main"
,
iconPath
:
"/static/images/bofang.png"
,
selectedIconPath
:
"/static/images/bofang.png"
,
text
:
"接口"
,
//--多主题
condition
:
""
,
icon
:
"ant-daishouhuo"
,
iconType
:
0
,
//0 iconfont 1 image
imgUrl
:
""
,
selectImgUrl
:
""
,
link
:
{},
show
:
true
,
title
:
"分类页"
,
version
:
"1.0.0"
,
visible
:
1
}
],
mm
:
false
,
componentData
:
{},
...
...
@@ -73,7 +33,8 @@ Component({
};
}
this
.
setData
({
mmm
:
Math
.
ceil
(
app
.
globalData
.
footerVal
.
componentData
.
list
.
length
/
2
-
1
)
mmm
:
Math
.
ceil
(
app
.
globalData
.
footerVal
.
componentData
.
list
.
length
/
2
-
1
),
selected
:
this
.
data
.
active
});
},
attached
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment