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
90fb9427
Commit
90fb9427
authored
Nov 10, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
signUp
parent
4d3d6f74
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
177 additions
and
63 deletions
+177
-63
home.js
api/home.js
+3
-1
ActivitySelectedPopup.vue
components/ActivitySelectedPopup.vue
+34
-4
index.vue
pages/index/index.vue
+137
-56
My.vue
views/My.vue
+3
-2
No files found.
api/home.js
View file @
90fb9427
...
...
@@ -9,4 +9,6 @@ const {
*/
export
const
fetchHomeInfo
=
()
=>
api
.
get
(
'/c/user/index'
);
export
const
fetchHomeJSON
=
()
=>
api
.
get
(
'/c/front/content'
,{
type
:
'home_V1'
});
\ No newline at end of file
export
const
fetchHomeJSON
=
()
=>
api
.
get
(
'/c/front/content'
,{
type
:
'home_V1'
});
export
const
fetchUserClickActivity
=
(
data
)
=>
api
.
post
(
'/c/user/clickActivity'
,
data
);
\ No newline at end of file
components/ActivitySelectedPopup.vue
View file @
90fb9427
...
...
@@ -25,7 +25,7 @@
:key=
"index"
class=
"activity-item"
>
<text
class=
"activity-text"
>
已入选
{{
activity
.
name
||
'
鲜活溯源之旅
'
}}
</text>
<text
class=
"activity-text"
>
已入选
{{
activity
.
name
||
''
}}
</text>
<view
class=
"activity-btn"
:class=
"
{ disabled: activity.disabled }"
...
...
@@ -42,7 +42,7 @@
:key=
"index"
class=
"activity-item"
>
<text
class=
"activity-text"
>
已入选
{{
activity
.
name
||
'
鲜活溯源之旅
'
}}
</text>
<text
class=
"activity-text"
>
已入选
{{
activity
.
name
||
''
}}
</text>
<view
class=
"activity-btn"
:class=
"
{ disabled: activity.disabled }"
...
...
@@ -64,6 +64,7 @@
<
script
setup
>
import
{
computed
,
ref
}
from
'vue'
import
{
fetchUserClickActivity
}
from
'../api/home'
const
props
=
defineProps
({
visible
:
{
...
...
@@ -97,15 +98,44 @@ const popupStyle = computed(() => {
})
// 查看活动
const
handleViewActivity
=
(
activity
,
index
)
=>
{
const
handleViewActivity
=
async
(
activity
,
index
)
=>
{
if
(
activity
.
disabled
)
{
return
}
// 调用接口,传单个 activityId
if
(
activity
.
id
)
{
try
{
await
fetchUserClickActivity
({
activityIds
:
[
activity
.
id
]
})
console
.
log
(
'点击活动接口调用成功:'
,
activity
.
id
)
}
catch
(
error
)
{
console
.
error
(
'点击活动接口调用失败:'
,
error
)
}
}
emit
(
'viewActivity'
,
activity
,
index
)
}
// 关闭弹窗
const
handleClose
=
()
=>
{
const
handleClose
=
async
()
=>
{
// 调用接口,传所有 activityIds
const
activityIds
=
props
.
activityList
.
filter
(
activity
=>
activity
.
id
)
.
map
(
activity
=>
activity
.
id
)
if
(
activityIds
.
length
>
0
)
{
try
{
await
fetchUserClickActivity
({
activityIds
:
activityIds
})
console
.
log
(
'关闭弹窗接口调用成功:'
,
activityIds
)
}
catch
(
error
)
{
console
.
error
(
'关闭弹窗接口调用失败:'
,
error
)
}
}
emit
(
'close'
)
}
...
...
pages/index/index.vue
View file @
90fb9427
<
template
>
<view
class=
"container"
>
<Home
v-if=
"globalStore.curTabIndex == 0 && !globalStore.isWxFriendCircle"
:scroll-top=
"scrollTop"
/>
<Brand
v-if=
"globalStore.curTabIndex == 1 && !globalStore.isWxFriendCircle"
:scroll-top=
"scrollTop"
/>
<Integral
v-if=
"globalStore.curTabIndex == 2 && !globalStore.isWxFriendCircle"
:scrollTop=
"scrollTop"
/>
<Home
v-if=
"globalStore.curTabIndex == 0 && !globalStore.isWxFriendCircle"
:scroll-top=
"scrollTop"
/>
<Brand
v-if=
"globalStore.curTabIndex == 1 && !globalStore.isWxFriendCircle"
:scroll-top=
"scrollTop"
/>
<Integral
v-if=
"globalStore.curTabIndex == 2 && !globalStore.isWxFriendCircle"
:scrollTop=
"scrollTop"
/>
<My
v-if=
"globalStore.curTabIndex == 3 && !globalStore.isWxFriendCircle"
/>
<TabBar
v-if=
"!globalStore.isWxFriendCircle"
:curTabIndex=
"globalStore.curTabIndex"
@
tabClick=
"handleTabClick"
/>
<WxFriendCircleSimplePage
v-if=
"globalStore.isWxFriendCircle"
/>
<button
v-if=
"isBackApp"
class=
"back-app"
open-type=
"launchApp"
app-parameter=
"wechat"
@
binderror=
"handleLaunchAppError"
:style=
"
{
backgroundImage: `url(${$baseUrl}homepage/backAppBtn.png)`,
}"
>
<WxFriendCircleSimplePage
v-if=
"globalStore.isWxFriendCircle"
/>
<button
v-if=
"isBackApp"
class=
"back-app"
open-type=
"launchApp"
app-parameter=
"wechat"
@
binderror=
"handleLaunchAppError"
:style=
"
{
backgroundImage: `url(${$baseUrl}homepage/backAppBtn.png)`,
}">
<!--
<text
class=
"back-text"
>
返回app
</text>
-->
</button>
<!-- 活动入选弹窗 -->
<ActivitySelectedPopup
:visible=
"showActivitySelectedPopup"
:activityList=
"selectedActivityList"
@
close=
"showActivitySelectedPopup = false"
@
viewActivity=
"handleViewActivity"
/>
</button>
<!-- 活动入选弹窗 -->
<ActivitySelectedPopup
:visible=
"showActivitySelectedPopup"
:activityList=
"selectedActivityList"
@
close=
"showActivitySelectedPopup = false"
@
viewActivity=
"handleViewActivity"
/>
</view>
</
template
>
<
script
setup
>
import
{
ref
,
getCurrentInstance
}
from
"vue"
;
import
{
onLoad
,
onShareAppMessage
,
onShareTimeline
,
onPageScroll
}
from
"@dcloudio/uni-app"
;
import
{
ref
,
getCurrentInstance
,
watch
,
onMounted
}
from
"vue"
;
import
{
onLoad
,
onShareAppMessage
,
onShareTimeline
,
onPageScroll
,
onShow
}
from
"@dcloudio/uni-app"
;
import
TabBar
from
"@/components/TabBar.vue"
;
import
Home
from
"@/views/Home.vue"
;
import
Brand
from
"@/views/Brand.vue"
;
...
...
@@ -37,8 +32,12 @@ import My from "@/views/My.vue";
import
WxFriendCircleSimplePage
from
"@/components/WxFriendCircleSimplePage.vue"
;
import
ActivitySelectedPopup
from
"@/components/ActivitySelectedPopup.vue"
;
import
{
useGlobalStore
}
from
"@/stores/global.js"
;
import
{
useUserStore
}
from
"@/stores/user.js"
;
import
{
fetchUserClickActivity
}
from
"../../api/home"
;
import
{
jump
,
JumpType
}
from
"../../utils"
;
const
globalStore
=
useGlobalStore
();
const
userStore
=
useUserStore
();
const
{
proxy
}
=
getCurrentInstance
();
const
$baseUrl
=
proxy
.
$baseUrl
;
const
homeRef
=
ref
(
null
);
...
...
@@ -47,6 +46,7 @@ const isBackApp = ref(false);
// 活动入选弹窗
const
showActivitySelectedPopup
=
ref
(
false
);
const
selectedActivityList
=
ref
([]);
const
hasShownActivityPopup
=
ref
(
false
);
// 标记是否已经显示过弹窗
const
shareOptions
=
{
0
:
{
title
:
"8000万中国妈妈信赖的育儿品牌"
,
...
...
@@ -68,13 +68,13 @@ const shareOptions = {
// 处理返回APP失败的情况
const
handleLaunchAppError
=
(
e
)
=>
{
console
.
error
(
'返回APP失败:'
,
e
.
detail
.
errMsg
);
// 根据错误类型给出不同的提示
let
errorMessage
=
'返回APP失败'
;
if
(
e
.
detail
.
errMsg
.
includes
(
'fail'
))
{
errorMessage
=
'无法返回APP,请检查APP是否已安装'
;
}
uni
.
showToast
({
title
:
errorMessage
,
icon
:
'none'
,
...
...
@@ -89,7 +89,23 @@ function handleTabClick({ index }) {
// 查看活动
const
handleViewActivity
=
(
activity
,
index
)
=>
{
console
.
log
(
'查看活动:'
,
activity
,
index
)
// TODO: 根据活动跳转到对应页面
// 接口调用已在组件内部完成,这里只需要处理跳转逻辑
// 根据 activityUri 跳转到对应页面
const
uri
=
activity
.
uri
||
activity
.
activityUri
if
(
!
uri
)
{
console
.
warn
(
'活动没有跳转地址'
)
return
}
console
.
log
(
'跳转到活动页面:'
,
uri
)
// 判断跳转类型
// H5 链接
jump
({
type
:
JumpType
.
H5
,
url
:
uri
})
}
// 显示活动入选弹窗
...
...
@@ -98,19 +114,70 @@ const showActivitySelectedPopupFunc = (activityList) => {
showActivitySelectedPopup
.
value
=
true
}
onLoad
((
options
)
=>
{
const
optionsSync
=
wx
.
getEnterOptionsSync
()
if
(
optionsSync
.
scene
==
'1154'
){
globalStore
.
setIsWxFriendCircle
(
true
)
}
if
(
optionsSync
.
scene
==
'1069'
){
// 检查并显示活动入选弹窗
const
checkAndShowActivityPopup
=
()
=>
{
// 如果已经显示过弹窗,不再重复显示
if
(
hasShownActivityPopup
.
value
)
{
console
.
log
(
'活动入选弹窗已显示过,跳过'
)
return
}
const
memberInfo
=
userStore
.
memberInfo
console
.
log
(
'检查活动入选弹窗 - memberInfo:'
,
memberInfo
)
console
.
log
(
'检查活动入选弹窗 - passedActivityList:'
,
memberInfo
?.
passedActivityList
)
if
(
memberInfo
&&
memberInfo
.
passedActivityList
&&
memberInfo
.
passedActivityList
.
length
>
0
)
{
// 将 passedActivityList 转换为组件需要的格式
const
activityList
=
memberInfo
.
passedActivityList
.
map
(
item
=>
({
id
:
item
.
activityId
,
name
:
item
.
activityName
,
uri
:
item
.
activityUri
,
disabled
:
false
}))
console
.
log
(
'转换后的活动列表:'
,
activityList
)
selectedActivityList
.
value
=
activityList
showActivitySelectedPopup
.
value
=
true
hasShownActivityPopup
.
value
=
true
// 标记已显示
console
.
log
(
'显示活动入选弹窗:'
,
activityList
)
}
else
{
console
.
log
(
'没有活动入选数据,不显示弹窗'
)
}
}
// 监听 memberInfo 变化,检查是否有 passedActivityList
watch
(()
=>
userStore
.
memberInfo
,
(
newVal
,
oldVal
)
=>
{
if
(
newVal
&&
newVal
.
passedActivityList
&&
newVal
.
passedActivityList
.
length
>
0
)
{
// 检查是否是新的活动列表(通过比较 activityId 来判断)
const
oldActivityIds
=
oldVal
?.
passedActivityList
?.
map
(
item
=>
item
.
activityId
)
||
[]
const
newActivityIds
=
newVal
.
passedActivityList
.
map
(
item
=>
item
.
activityId
)
// 如果有新的活动,重置标记并显示弹窗
const
hasNewActivity
=
newActivityIds
.
some
(
id
=>
!
oldActivityIds
.
includes
(
id
))
if
(
hasNewActivity
)
{
hasShownActivityPopup
.
value
=
false
}
// 延迟一下,确保页面已经渲染完成
setTimeout
(()
=>
{
checkAndShowActivityPopup
()
},
300
)
}
},
{
deep
:
true
})
onLoad
(
async
(
options
)
=>
{
const
optionsSync
=
wx
.
getEnterOptionsSync
()
if
(
optionsSync
.
scene
==
'1154'
)
{
globalStore
.
setIsWxFriendCircle
(
true
)
}
if
(
optionsSync
.
scene
==
'1069'
)
{
isBackApp
.
value
=
true
;
}
else
{
}
else
{
isBackApp
.
value
=
false
;
}
console
.
warn
(
'options231'
,
options
,
globalStore
.
isWxFriendCircle
)
console
.
warn
(
'options231'
,
options
,
globalStore
.
isWxFriendCircle
)
if
(
options
.
pageType
)
{
switch
(
options
.
pageType
)
{
case
"home"
:
...
...
@@ -127,6 +194,19 @@ onLoad((options) => {
break
;
}
}
// 加载会员信息,检查是否有活动入选
if
(
userStore
.
isLogin
)
{
await
userStore
.
loadMemberInfo
()
checkAndShowActivityPopup
()
}
});
onShow
(
async
()
=>
{
// 页面显示时,如果已登录,刷新会员信息(但不强制显示弹窗,由 watch 监听处理)
if
(
userStore
.
isLogin
)
{
await
userStore
.
loadMemberInfo
()
}
});
onShareAppMessage
(()
=>
{
...
...
@@ -140,7 +220,7 @@ onShareTimeline(() => {
});
onPageScroll
((
e
)
=>
{
scrollTop
.
value
=
e
.
scrollTop
;
scrollTop
.
value
=
e
.
scrollTop
;
});
</
script
>
...
...
@@ -159,8 +239,9 @@ onPageScroll((e) => {
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
// .back-app{
// position: fixed;
// top: 100rpx;
...
...
@@ -176,26 +257,26 @@ onPageScroll((e) => {
// // }
// }
.back-app
{
position
:
fixed
;
top
:
100rpx
;
border-radius
:
34rpx
;
height
:
68rpx
;
width
:
150rpx
;
left
:
20rpx
;
border
:
none
;
background-size
:
100%
100%
;
background-repeat
:
no-repeat
;
background-position
:
center
;
z-index
:
999
;
&
:active
{
transform
:
scale
(
0
.98
);
}
&
:
:
after
{
border
:
none
!
important
;
}
.back-app
{
position
:
fixed
;
top
:
100rpx
;
border-radius
:
34rpx
;
height
:
68rpx
;
width
:
150rpx
;
left
:
20rpx
;
border
:
none
;
background-size
:
100%
100%
;
background-repeat
:
no-repeat
;
background-position
:
center
;
z-index
:
999
;
&
:active
{
transform
:
scale
(
0
.98
);
}
&
:
:
after
{
border
:
none
!
important
;
}
}
.logo
{
...
...
views/My.vue
View file @
90fb9427
...
...
@@ -99,8 +99,9 @@
<image
class=
"tool-icon"
:src=
"item.bgUrl?.includes('http') ? item.bgUrl : $baseUrl + item.bgUrl"
mode=
"aspectFit"
/>
<!-- || item.title == '产检提醒' || item.title == '喂养记录' || item.title == '生长测评' -->
<button
v-if=
"(item.title == '医生问诊') && !cfgStatus.isRegister"
class=
"tool-btn-register"
type=
"primary"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getRealtimePhoneNumber"
/>
<button
v-if=
"(item.title == '医生问诊' || item.title == '会员活动') && !cfgStatus.isRegister"
class=
"tool-btn-register"
type=
"primary"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getRealtimePhoneNumber"
/>
</view>
</
template
>
</view>
...
...
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