Commit 90fb9427 authored by spc's avatar spc

signUp

parent 4d3d6f74
...@@ -9,4 +9,6 @@ const { ...@@ -9,4 +9,6 @@ const {
*/ */
export const fetchHomeInfo = () => api.get('/c/user/index'); export const fetchHomeInfo = () => api.get('/c/user/index');
export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home_V1'}); export const fetchHomeJSON = () => api.get('/c/front/content',{type:'home_V1'});
\ No newline at end of file
export const fetchUserClickActivity = (data) => api.post('/c/user/clickActivity', data);
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
:key="index" :key="index"
class="activity-item" class="activity-item"
> >
<text class="activity-text">已入选{{ activity.name || '鲜活溯源之旅' }}</text> <text class="activity-text">已入选{{ activity.name || '' }}</text>
<view <view
class="activity-btn" class="activity-btn"
:class="{ disabled: activity.disabled }" :class="{ disabled: activity.disabled }"
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
:key="index" :key="index"
class="activity-item" class="activity-item"
> >
<text class="activity-text">已入选{{ activity.name || '鲜活溯源之旅' }}</text> <text class="activity-text">已入选{{ activity.name || '' }}</text>
<view <view
class="activity-btn" class="activity-btn"
:class="{ disabled: activity.disabled }" :class="{ disabled: activity.disabled }"
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
<script setup> <script setup>
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { fetchUserClickActivity } from '../api/home'
const props = defineProps({ const props = defineProps({
visible: { visible: {
...@@ -97,15 +98,44 @@ const popupStyle = computed(() => { ...@@ -97,15 +98,44 @@ const popupStyle = computed(() => {
}) })
// 查看活动 // 查看活动
const handleViewActivity = (activity, index) => { const handleViewActivity = async (activity, index) => {
if (activity.disabled) { if (activity.disabled) {
return return
} }
// 调用接口,传单个 activityId
if (activity.id) {
try {
await fetchUserClickActivity({
activityIds: [activity.id]
})
console.log('点击活动接口调用成功:', activity.id)
} catch (error) {
console.error('点击活动接口调用失败:', error)
}
}
emit('viewActivity', activity, index) 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') emit('close')
} }
......
<template> <template>
<view class="container"> <view class="container">
<Home v-if="globalStore.curTabIndex == 0 && !globalStore.isWxFriendCircle" :scroll-top="scrollTop"/> <Home v-if="globalStore.curTabIndex == 0 && !globalStore.isWxFriendCircle" :scroll-top="scrollTop" />
<Brand v-if="globalStore.curTabIndex == 1 && !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"/> <Integral v-if="globalStore.curTabIndex == 2 && !globalStore.isWxFriendCircle" :scrollTop="scrollTop" />
<My v-if="globalStore.curTabIndex == 3 && !globalStore.isWxFriendCircle" /> <My v-if="globalStore.curTabIndex == 3 && !globalStore.isWxFriendCircle" />
<TabBar v-if="!globalStore.isWxFriendCircle" :curTabIndex="globalStore.curTabIndex" @tabClick="handleTabClick" /> <TabBar v-if="!globalStore.isWxFriendCircle" :curTabIndex="globalStore.curTabIndex" @tabClick="handleTabClick" />
<WxFriendCircleSimplePage v-if="globalStore.isWxFriendCircle" /> <WxFriendCircleSimplePage v-if="globalStore.isWxFriendCircle" />
<button v-if="isBackApp" class="back-app" open-type="launchApp" app-parameter="wechat" @binderror="handleLaunchAppError" <button v-if="isBackApp" class="back-app" open-type="launchApp" app-parameter="wechat"
:style="{ @binderror="handleLaunchAppError" :style="{
backgroundImage: `url(${$baseUrl}homepage/backAppBtn.png)`, backgroundImage: `url(${$baseUrl}homepage/backAppBtn.png)`,
}" }">
>
<!-- <text class="back-text">返回app</text> --> <!-- <text class="back-text">返回app</text> -->
</button> </button>
<!-- 活动入选弹窗 --> <!-- 活动入选弹窗 -->
<ActivitySelectedPopup <ActivitySelectedPopup :visible="showActivitySelectedPopup" :activityList="selectedActivityList"
:visible="showActivitySelectedPopup" @close="showActivitySelectedPopup = false" @viewActivity="handleViewActivity" />
:activityList="selectedActivityList"
@close="showActivitySelectedPopup = false"
@viewActivity="handleViewActivity"
/>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, getCurrentInstance } from "vue"; import { ref, getCurrentInstance, watch, onMounted } from "vue";
import { onLoad, onShareAppMessage, onShareTimeline, onPageScroll } from "@dcloudio/uni-app"; import { onLoad, onShareAppMessage, onShareTimeline, onPageScroll, onShow } from "@dcloudio/uni-app";
import TabBar from "@/components/TabBar.vue"; import TabBar from "@/components/TabBar.vue";
import Home from "@/views/Home.vue"; import Home from "@/views/Home.vue";
import Brand from "@/views/Brand.vue"; import Brand from "@/views/Brand.vue";
...@@ -37,8 +32,12 @@ import My from "@/views/My.vue"; ...@@ -37,8 +32,12 @@ import My from "@/views/My.vue";
import WxFriendCircleSimplePage from "@/components/WxFriendCircleSimplePage.vue"; import WxFriendCircleSimplePage from "@/components/WxFriendCircleSimplePage.vue";
import ActivitySelectedPopup from "@/components/ActivitySelectedPopup.vue"; import ActivitySelectedPopup from "@/components/ActivitySelectedPopup.vue";
import { useGlobalStore } from "@/stores/global.js"; 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 globalStore = useGlobalStore();
const userStore = useUserStore();
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const $baseUrl = proxy.$baseUrl; const $baseUrl = proxy.$baseUrl;
const homeRef = ref(null); const homeRef = ref(null);
...@@ -47,6 +46,7 @@ const isBackApp = ref(false); ...@@ -47,6 +46,7 @@ const isBackApp = ref(false);
// 活动入选弹窗 // 活动入选弹窗
const showActivitySelectedPopup = ref(false); const showActivitySelectedPopup = ref(false);
const selectedActivityList = ref([]); const selectedActivityList = ref([]);
const hasShownActivityPopup = ref(false); // 标记是否已经显示过弹窗
const shareOptions = { const shareOptions = {
0: { 0: {
title: "8000万中国妈妈信赖的育儿品牌", title: "8000万中国妈妈信赖的育儿品牌",
...@@ -68,13 +68,13 @@ const shareOptions = { ...@@ -68,13 +68,13 @@ const shareOptions = {
// 处理返回APP失败的情况 // 处理返回APP失败的情况
const handleLaunchAppError = (e) => { const handleLaunchAppError = (e) => {
console.error('返回APP失败:', e.detail.errMsg); console.error('返回APP失败:', e.detail.errMsg);
// 根据错误类型给出不同的提示 // 根据错误类型给出不同的提示
let errorMessage = '返回APP失败'; let errorMessage = '返回APP失败';
if (e.detail.errMsg.includes('fail')) { if (e.detail.errMsg.includes('fail')) {
errorMessage = '无法返回APP,请检查APP是否已安装'; errorMessage = '无法返回APP,请检查APP是否已安装';
} }
uni.showToast({ uni.showToast({
title: errorMessage, title: errorMessage,
icon: 'none', icon: 'none',
...@@ -89,7 +89,23 @@ function handleTabClick({ index }) { ...@@ -89,7 +89,23 @@ function handleTabClick({ index }) {
// 查看活动 // 查看活动
const handleViewActivity = (activity, index) => { const handleViewActivity = (activity, index) => {
console.log('查看活动:', 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) => { ...@@ -98,19 +114,70 @@ const showActivitySelectedPopupFunc = (activityList) => {
showActivitySelectedPopup.value = true showActivitySelectedPopup.value = true
} }
onLoad((options) => { // 检查并显示活动入选弹窗
const optionsSync= wx.getEnterOptionsSync() const checkAndShowActivityPopup = () => {
if(optionsSync.scene == '1154'){ // 如果已经显示过弹窗,不再重复显示
globalStore.setIsWxFriendCircle(true) if (hasShownActivityPopup.value) {
console.log('活动入选弹窗已显示过,跳过')
} return
if(optionsSync.scene == '1069'){ }
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; isBackApp.value = true;
}else{ } else {
isBackApp.value = false; isBackApp.value = false;
} }
console.warn('options231',options,globalStore.isWxFriendCircle) console.warn('options231', options, globalStore.isWxFriendCircle)
if (options.pageType) { if (options.pageType) {
switch (options.pageType) { switch (options.pageType) {
case "home": case "home":
...@@ -127,6 +194,19 @@ onLoad((options) => { ...@@ -127,6 +194,19 @@ onLoad((options) => {
break; break;
} }
} }
// 加载会员信息,检查是否有活动入选
if (userStore.isLogin) {
await userStore.loadMemberInfo()
checkAndShowActivityPopup()
}
});
onShow(async () => {
// 页面显示时,如果已登录,刷新会员信息(但不强制显示弹窗,由 watch 监听处理)
if (userStore.isLogin) {
await userStore.loadMemberInfo()
}
}); });
onShareAppMessage(() => { onShareAppMessage(() => {
...@@ -140,7 +220,7 @@ onShareTimeline(() => { ...@@ -140,7 +220,7 @@ onShareTimeline(() => {
}); });
onPageScroll((e) => { onPageScroll((e) => {
scrollTop.value = e.scrollTop; scrollTop.value = e.scrollTop;
}); });
</script> </script>
...@@ -159,8 +239,9 @@ onPageScroll((e) => { ...@@ -159,8 +239,9 @@ onPageScroll((e) => {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
// .back-app{ // .back-app{
// position: fixed; // position: fixed;
// top: 100rpx; // top: 100rpx;
...@@ -176,26 +257,26 @@ onPageScroll((e) => { ...@@ -176,26 +257,26 @@ onPageScroll((e) => {
// // } // // }
// } // }
.back-app{ .back-app {
position: fixed; position: fixed;
top: 100rpx; top: 100rpx;
border-radius: 34rpx; border-radius: 34rpx;
height: 68rpx; height: 68rpx;
width: 150rpx; width: 150rpx;
left:20rpx; left: 20rpx;
border: none; border: none;
background-size: 100% 100%; background-size: 100% 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
z-index: 999; z-index: 999;
&:active { &:active {
transform: scale(0.98); transform: scale(0.98);
} }
&::after { &::after {
border: none !important; border: none !important;
} }
} }
.logo { .logo {
......
...@@ -99,8 +99,9 @@ ...@@ -99,8 +99,9 @@
<image class="tool-icon" :src="item.bgUrl?.includes('http') ? item.bgUrl : $baseUrl + item.bgUrl" <image class="tool-icon" :src="item.bgUrl?.includes('http') ? item.bgUrl : $baseUrl + item.bgUrl"
mode="aspectFit" /> mode="aspectFit" />
<!-- || item.title == '产检提醒' || item.title == '喂养记录' || item.title == '生长测评' --> <!-- || item.title == '产检提醒' || item.title == '喂养记录' || item.title == '生长测评' -->
<button v-if="(item.title == '医生问诊') && !cfgStatus.isRegister" class="tool-btn-register" type="primary" <button v-if="(item.title == '医生问诊' || item.title == '会员活动') && !cfgStatus.isRegister"
open-type="getPhoneNumber" @getphonenumber="getRealtimePhoneNumber" /> class="tool-btn-register" type="primary" open-type="getPhoneNumber"
@getphonenumber="getRealtimePhoneNumber" />
</view> </view>
</template> </template>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment