Commit 1e7f1e03 authored by 劳琪峰's avatar 劳琪峰

chore: 未登录处理

parent 69f84a38
...@@ -9,8 +9,10 @@ const props = defineProps<{ ...@@ -9,8 +9,10 @@ const props = defineProps<{
area?: { x: number, y: number, width: number, height: number } area?: { x: number, y: number, width: number, height: number }
link?: { type: number, url: string, extra: any } link?: { type: number, url: string, extra: any }
mdConfig?: MdConfig mdConfig?: MdConfig
needLogin?: boolean
} }
openType?: string openType?: string
isLogin?: boolean
debugMode?: boolean debugMode?: boolean
}>() }>()
...@@ -36,7 +38,7 @@ const emit = defineEmits<{ ...@@ -36,7 +38,7 @@ const emit = defineEmits<{
function onClick(e) { function onClick(e) {
emit('click', e) emit('click', e)
if (props.properties.link) { if ((!props.properties.needLogin || props.isLogin) && props.properties.link) {
jump(props.properties.link) jump(props.properties.link)
} }
logClick() logClick()
...@@ -46,7 +48,7 @@ function onClick(e) { ...@@ -46,7 +48,7 @@ function onClick(e) {
<template> <template>
<button class="click-area" :class="{'debug-mode': debugMode}" :style="style" <button class="click-area" :class="{'debug-mode': debugMode}" :style="style"
:open-type="openType" :open-type="openType ?? (properties.needLogin && !isLogin ? 'getPhoneNumber' : undefined)"
@click="onClick" @click="onClick"
@getphonenumber="(e) => emit('getphonenumber', e)" @getphonenumber="(e) => emit('getphonenumber', e)"
/> />
...@@ -57,6 +59,7 @@ function onClick(e) { ...@@ -57,6 +59,7 @@ function onClick(e) {
position: absolute; position: absolute;
border: none; border: none;
border-radius: 0; border-radius: 0;
background-color: transparent;
&.debug-mode { &.debug-mode {
background-color: rgba(255, 0, 0, 0.3); background-color: rgba(255, 0, 0, 0.3);
......
<script setup lang="ts"> <script setup lang="ts">
import {ref, computed, inject, onMounted} from 'vue' import {ref, computed, inject, onMounted, watch} from 'vue'
import ClickArea from "./ClickArea.vue"; import ClickArea from "./ClickArea.vue";
import {InvitationInfo} from "../types" import {InvitationInfo} from "../types"
import {getCdnUrl} from "../utils" import {getCdnUrl} from "../utils"
...@@ -18,13 +18,10 @@ const props = defineProps<{ ...@@ -18,13 +18,10 @@ const props = defineProps<{
area?: { x: number, y: number, width: number, height: number } area?: { x: number, y: number, width: number, height: number }
mdConfig?: MdConfig mdConfig?: MdConfig
} }
isLogin?: boolean
debugMode?: boolean debugMode?: boolean
}>() }>()
const isLogin = computed(() => {
return !invitationInfo.value?.notLogin
})
const style = computed(() => { const style = computed(() => {
const area = props.properties.area const area = props.properties.area
return { return {
...@@ -54,7 +51,7 @@ async function tryAssist() { ...@@ -54,7 +51,7 @@ async function tryAssist() {
const options = currentPage.options; const options = currentPage.options;
const invitationCode = options.invitationCode; const invitationCode = options.invitationCode;
if (invitationCode && !isAssist.value && isLogin.value) { if (invitationCode && !isAssist.value && props.isLogin) {
console.log('处理助力邀请码:', invitationCode) console.log('处理助力邀请码:', invitationCode)
try { try {
...@@ -92,6 +89,12 @@ async function tryAssist() { ...@@ -92,6 +89,12 @@ async function tryAssist() {
} }
} }
watch(() => props.isLogin, async (newVal) => {
if (newVal) {
await updateInvitationInfo()
}
})
onMounted(async () => { onMounted(async () => {
await updateInvitationInfo() await updateInvitationInfo()
......
...@@ -10,16 +10,21 @@ ...@@ -10,16 +10,21 @@
<ImageSwiper <ImageSwiper
v-if="component.type === 'image-swiper'" v-if="component.type === 'image-swiper'"
v-bind="component" v-bind="component"
:is-login="isLogin"
:debug-mode="DEBUG_MODE"
/> />
<ClickArea <ClickArea
v-else-if="component.type === 'click-area'" v-else-if="component.type === 'click-area'"
v-bind="component" v-bind="component"
debug-mode :is-login="isLogin"
@getphonenumber="onGetPhoneNumber"
:debug-mode="DEBUG_MODE"
/> />
<InviteTask <InviteTask
v-else-if="component.type === 'invite-task'" v-else-if="component.type === 'invite-task'"
v-bind="component" v-bind="component"
:debug-mode="true" :is-login="isLogin"
:debug-mode="DEBUG_MODE"
/> />
</template> </template>
</view> </view>
...@@ -29,12 +34,13 @@ ...@@ -29,12 +34,13 @@
<script setup lang="ts"> <script setup lang="ts">
import {ref, onMounted, computed, getCurrentInstance, provide} from 'vue' import {ref, onMounted, computed, getCurrentInstance, provide} from 'vue'
import {fetchPageConfig} from './api.ts' import {fetchPageConfig} from './api.ts'
import {useHomeStore} from '@/stores/home'; // Assuming homeStore path import {useUserStore} from '@/stores/user';
import {useUserStore} from '@/stores/user'; // Import userStore
import ClickArea from "./components/ClickArea.vue"; import ClickArea from "./components/ClickArea.vue";
import ImageSwiper from "./components/ImageSwiper.vue"; import ImageSwiper from "./components/ImageSwiper.vue";
import InviteTask from "./components/InviteTask.vue"; import InviteTask from "./components/InviteTask.vue";
const DEBUG_MODE = false
// 响应式数据 // 响应式数据
const pageConfig = ref({}) // 配置对象 const pageConfig = ref({}) // 配置对象
const loading = ref(true) // 加载状态 const loading = ref(true) // 加载状态
...@@ -47,9 +53,13 @@ const shareData = ref({ ...@@ -47,9 +53,13 @@ const shareData = ref({
}) })
// 获取store实例 // 获取store实例
const homeStore = useHomeStore();
const userStore = useUserStore(); const userStore = useUserStore();
const isLogin = computed(()=>{
//return false
return userStore.isLogin
})
function updateShareData(data) { function updateShareData(data) {
Object.assign(shareData.value, data) Object.assign(shareData.value, data)
} }
...@@ -137,6 +147,9 @@ const updatePageConfig = async () => { ...@@ -137,6 +147,9 @@ const updatePageConfig = async () => {
const initPage = async () => { const initPage = async () => {
console.log('开始初始化页面...') console.log('开始初始化页面...')
await Promise.all([
userStore.loadUserInfo(),
])
// 获取页面配置 // 获取页面配置
await updatePageConfig() await updatePageConfig()
...@@ -184,8 +197,10 @@ const onGetPhoneNumber = async (e) => { ...@@ -184,8 +197,10 @@ const onGetPhoneNumber = async (e) => {
// 隐藏授权弹窗 // 隐藏授权弹窗
userStore.phoneCallback(e.detail, null, null, async () => { userStore.phoneCallback(e.detail, null, null, async () => {
// 重新获取用户信息(登录后) // 重新获取用户信息(登录后)
// todo 更新组件状态 await new Promise.all([
userStore.loadUserInfo(),
userStore.loadMemberInfo(),
])
console.warn('授权后重新获取用户信息') console.warn('授权后重新获取用户信息')
}, { }, {
wxLoginBusinessDTO: { wxLoginBusinessDTO: {
......
...@@ -12,7 +12,7 @@ export function homeConfig(){ ...@@ -12,7 +12,7 @@ export function homeConfig(){
} }
}, },
shareConfig: { shareConfig: {
title: '星妈会超级品牌周来啦!', title: '星妈会超级品牌周来啦!北纬47°六水香大米上新!',
path: '/activities/1015/home', path: '/activities/1015/home',
imageUrl: 'https://course.feihe.com/momclub-picture/Act915Page/v2/act915ShareImg.png', imageUrl: 'https://course.feihe.com/momclub-picture/Act915Page/v2/act915ShareImg.png',
}, },
...@@ -170,6 +170,7 @@ export function homeConfig(){ ...@@ -170,6 +170,7 @@ export function homeConfig(){
"type": 1, "type": 1,
"url": "/activities/1015/lottery/index" "url": "/activities/1015/lottery/index"
}, },
"needLogin": true,
}, },
}, },
{ {
......
...@@ -29,6 +29,11 @@ export const useUserStore = defineStore("userInfo", { ...@@ -29,6 +29,11 @@ export const useUserStore = defineStore("userInfo", {
babyNickCache: [], babyNickCache: [],
cepingjieguoInfo: null, cepingjieguoInfo: null,
}; };
},
getters: {
isLogin: (state) => {
return state.userInfo?.memberId !== "not_login"
}
}, },
actions: { actions: {
/** /**
......
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