Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
b319c446
Commit
b319c446
authored
Jun 10, 2025
by
tao.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 分享
parent
250f1c9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
87 deletions
+97
-87
index.vue
pages/index/index.vue
+97
-87
No files found.
pages/index/index.vue
View file @
b319c446
<
template
>
<view
class=
"container"
>
<Home
v-if=
"globalStore.curTabIndex == 0"
></Home
>
<Brand
v-if=
"globalStore.curTabIndex == 1"
></Brand
>
<Integral
v-if=
"globalStore.curTabIndex == 2"
></Integral
>
<My
v-if=
"globalStore.curTabIndex == 3"
></My
>
<TabBar
:curTabIndex=
"globalStore.curTabIndex"
@
tabClick=
"handleTabClick"
/>
</view>
<view
class=
"container"
>
<Home
v-if=
"globalStore.curTabIndex == 0"
/
>
<Brand
v-if=
"globalStore.curTabIndex == 1"
/
>
<Integral
v-if=
"globalStore.curTabIndex == 2"
/
>
<My
v-if=
"globalStore.curTabIndex == 3"
/
>
<TabBar
:curTabIndex=
"globalStore.curTabIndex"
@
tabClick=
"handleTabClick"
/>
</view>
</
template
>
<
script
>
import
TabBar
from
'@/components/TabBar.vue'
import
Home
from
'@/views/Home.vue'
;
import
Brand
from
'@/views/Brand.vue'
;
import
Integral
from
'@/views/Integral.vue'
;
import
My
from
'@/views/My.vue'
;
import
{
useGlobalStore
}
from
'@/stores/global.js'
;
<
script
setup
>
import
{
ref
,
getCurrentInstance
}
from
"vue"
;
import
{
onLoad
,
onShareAppMessage
,
onShareTimeline
}
from
"@dcloudio/uni-app"
;
import
TabBar
from
"@/components/TabBar.vue"
;
import
Home
from
"@/views/Home.vue"
;
import
Brand
from
"@/views/Brand.vue"
;
import
Integral
from
"@/views/Integral.vue"
;
import
My
from
"@/views/My.vue"
;
import
{
useGlobalStore
}
from
"@/stores/global.js"
;
export
default
{
setup
()
{
const
globalStore
=
useGlobalStore
();
return
{
globalStore
}
},
onLoad
(
options
)
{
// 如果有页面参数,设置对应的tab页
if
(
options
.
pageType
)
{
const
globalStore
=
useGlobalStore
();
const
{
proxy
}
=
getCurrentInstance
();
const
$baseUrl
=
proxy
.
$baseUrl
;
switch
(
options
.
pageType
)
{
case
'home'
:
this
.
globalStore
.
setCurTabIndex
(
0
)
break
;
case
'brand'
:
this
.
globalStore
.
setCurTabIndex
(
1
)
break
;
case
'integral'
:
this
.
globalStore
.
setCurTabIndex
(
2
)
break
;
case
'my'
:
this
.
globalStore
.
setCurTabIndex
(
3
)
break
;
}
const
shareOptions
=
{
0
:
{
title
:
"8000万中国妈妈信赖的育儿品牌"
,
path
:
"/pages/index/index?pageType=home"
,
imageUrl
:
$baseUrl
+
"share/share_home.png"
,
},
1
:
{
title
:
"飞鹤提供家庭营养一站式解决方案"
,
path
:
"/pages/index/index?pageType=brand"
,
imageUrl
:
$baseUrl
+
"share/share_brand.png"
,
},
2
:
{
title
:
"超凡吸收!更多妈妈推荐的奶粉"
,
path
:
"/pages/index/index?pageType=integral"
,
imageUrl
:
$baseUrl
+
"share/share_integral.png"
,
},
};
}
},
methods
:
{
handleTabClick
({
index
,
item
})
{
console
.
log
(
'Tab clicked:'
,
index
,
item
)
// 这里可以根据index或item进行相应的页面跳转或其他操作
this
.
globalStore
.
setCurTabIndex
(
index
)
}
},
components
:
{
TabBar
,
Home
,
Brand
,
Integral
,
My
}
};
function
handleTabClick
({
index
})
{
globalStore
.
setCurTabIndex
(
index
);
}
onLoad
((
options
)
=>
{
if
(
options
.
pageType
)
{
switch
(
options
.
pageType
)
{
case
"home"
:
globalStore
.
setCurTabIndex
(
0
);
break
;
case
"brand"
:
globalStore
.
setCurTabIndex
(
1
);
break
;
case
"integral"
:
globalStore
.
setCurTabIndex
(
2
);
break
;
case
"my"
:
globalStore
.
setCurTabIndex
(
3
);
break
;
}
}
});
onShareAppMessage
(()
=>
{
const
pageType
=
globalStore
.
curTabIndex
;
return
shareOptions
[
pageType
]
||
shareOptions
[
0
];
});
onShareTimeline
(()
=>
{
const
pageType
=
globalStore
.
curTabIndex
;
return
shareOptions
[
pageType
]
||
shareOptions
[
0
];
});
</
script
>
<
style
lang=
"scss"
scoped
>
.container
{
min-height
:
100vh
;
background-color
:
#f5f5f5
;
.container
{
min-height
:
100vh
;
background-color
:
#f5f5f5
;
.content
{
padding-bottom
:
100rpx
;
// 为底部TabBar留出空间
}
}
.content
{
padding-bottom
:
100rpx
;
// 为底部TabBar留出空间
}
}
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
.content
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
.logo
{
height
:
200rpx
;
width
:
200rpx
;
margin-top
:
200rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
50rpx
;
}
.logo
{
height
:
200rpx
;
width
:
200rpx
;
margin-top
:
200rpx
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-bottom
:
50rpx
;
}
.text-area
{
display
:
flex
;
justify-content
:
center
;
}
.text-area
{
display
:
flex
;
justify-content
:
center
;
}
.title
{
font-size
:
36rpx
;
color
:
#8f8f94
;
}
.title
{
font-size
:
36rpx
;
color
:
#8f8f94
;
}
</
style
>
\ No newline at end of file
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