refactor: 清理冗余代码与优化模板格式
优化HomeHeroCarousel组件模板格式,移除轮播图多余操作按钮文本;清理我的页面冗余代码,删除未使用的导入、函数与事件定义,移除联系管家、头像授权相关逻辑与按钮
This commit is contained in:
1 parent
ed3b9a26f5
commit
5210a7385a
4 files changed
+1831
-126
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,24 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="relative w-full overflow-hidden bg-[#1f2924]">
|
<view class="relative w-full overflow-hidden bg-[#1f2924]">
|
||||||
<swiper
|
<swiper class="h-[620px]" circular autoplay :interval="4600" :current="heroIndex" @change="onSlideChange">
|
||||||
class="h-[620px]"
|
|
||||||
circular
|
|
||||||
autoplay
|
|
||||||
:interval="4600"
|
|
||||||
:current="heroIndex"
|
|
||||||
@change="onSlideChange"
|
|
||||||
>
|
|
||||||
<swiper-item v-for="(slide, index) in props.slides" :key="slide.id || slide.image">
|
<swiper-item v-for="(slide, index) in props.slides" :key="slide.id || slide.image">
|
||||||
<view
|
<view class="relative m-0 h-full w-full overflow-hidden rounded-none p-0 text-left"
|
||||||
class="relative m-0 h-full w-full overflow-hidden rounded-none p-0 text-left"
|
@click="$emit('select', slide.title)">
|
||||||
@click="$emit('select', slide.title)"
|
<image class="absolute inset-0 h-full w-full" :src="getSlideImage(slide, index)" mode="aspectFill"
|
||||||
>
|
@error="onImageError(slide, index)" />
|
||||||
<image
|
|
||||||
class="absolute inset-0 h-full w-full"
|
|
||||||
:src="getSlideImage(slide, index)"
|
|
||||||
mode="aspectFill"
|
|
||||||
@error="onImageError(slide, index)"
|
|
||||||
/>
|
|
||||||
<view class="hero-scrim absolute inset-0 flex items-end px-6 pb-[68px]">
|
<view class="hero-scrim absolute inset-0 flex items-end px-6 pb-[68px]">
|
||||||
<view class="min-w-0 text-white">
|
<view class="min-w-0 text-white">
|
||||||
<text v-if="slide.kicker" class="block text-[12px] font-medium leading-5 tracking-[0.12em] text-white/80">
|
<text v-if="slide.kicker" class="block text-[12px] font-medium leading-5 tracking-[0.12em] text-white/80">
|
||||||
@@ -27,12 +14,6 @@
|
|||||||
<text v-if="slide.title" class="mt-1 block text-[25px] font-semibold leading-8 tracking-[0.04em]">
|
<text v-if="slide.title" class="mt-1 block text-[25px] font-semibold leading-8 tracking-[0.04em]">
|
||||||
{{ slide.title }}
|
{{ slide.title }}
|
||||||
</text>
|
</text>
|
||||||
<text
|
|
||||||
v-if="slide.actionLabel || slide.action"
|
|
||||||
class="mt-3 inline-flex rounded-[8px] border border-white/55 px-3 py-1 text-[12px] leading-5 text-white/95"
|
|
||||||
>
|
|
||||||
{{ slide.actionLabel || slide.action }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -40,12 +21,8 @@
|
|||||||
</swiper>
|
</swiper>
|
||||||
|
|
||||||
<view class="absolute bottom-8 left-0 right-0 flex justify-center gap-2">
|
<view class="absolute bottom-8 left-0 right-0 flex justify-center gap-2">
|
||||||
<text
|
<text v-for="(_, index) in props.slides" :key="index" class="h-1.5 rounded-full transition-all"
|
||||||
v-for="(_, index) in props.slides"
|
:class="heroIndex === index ? 'w-6 bg-white' : 'w-1.5 bg-white/50'" />
|
||||||
:key="index"
|
|
||||||
class="h-1.5 rounded-full transition-all"
|
|
||||||
:class="heroIndex === index ? 'w-6 bg-white' : 'w-1.5 bg-white/50'"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="px-6 pb-[calc(28px+env(safe-area-inset-bottom))] pt-6">
|
||||||
class="px-6 pb-[calc(28px+env(safe-area-inset-bottom))] pt-6">
|
|
||||||
<view
|
<view
|
||||||
class="w-full rounded-[22px] border border-[#ded6cd] bg-white/95 px-4 py-4 shadow-[0_12px_30px_rgba(80,58,45,0.08)]">
|
class="w-full rounded-[22px] border border-[#ded6cd] bg-white/95 px-4 py-4 shadow-[0_12px_30px_rgba(80,58,45,0.08)]">
|
||||||
<view class="flex items-center gap-3">
|
<view class="flex items-center gap-3">
|
||||||
@@ -29,7 +28,8 @@
|
|||||||
|
|
||||||
<view class="min-w-0 flex-1">
|
<view class="min-w-0 flex-1">
|
||||||
<view class="flex items-center justify-between gap-2">
|
<view class="flex items-center justify-between gap-2">
|
||||||
<text class="truncate text-[17px] font-semibold tracking-[0.02em] text-[#24211f]">{{ customerName }}</text>
|
<text class="truncate text-[17px] font-semibold tracking-[0.02em] text-[#24211f]">{{ customerName
|
||||||
|
}}</text>
|
||||||
<view class="shrink-0 rounded-full bg-[#edf5ef] px-2 py-1">
|
<view class="shrink-0 rounded-full bg-[#edf5ef] px-2 py-1">
|
||||||
<text class="text-[10px] font-medium tracking-[0.06em] text-[#3f7b57]">已登录</text>
|
<text class="text-[10px] font-medium tracking-[0.06em] text-[#3f7b57]">已登录</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -37,50 +37,10 @@
|
|||||||
<text class="mt-2 block truncate text-[12px] leading-5 text-[#857d75]">{{ customerLine }}</text>
|
<text class="mt-2 block truncate text-[12px] leading-5 text-[#857d75]">{{ customerLine }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<button
|
|
||||||
v-if="showAvatarAction && !avatarUrl"
|
|
||||||
class="m-0 mt-4 flex min-h-[40px] w-full items-center justify-center rounded-full border border-[#d9c7bb] bg-[#fffaf5] px-4 text-[12px] font-medium tracking-[0.04em] text-[#8c4f39]"
|
|
||||||
@click="emit('request-avatar')">
|
|
||||||
<uni-icons type="person" :size="16" color="#8c4f39" />
|
|
||||||
<text class="ml-1">获取微信头像</text>
|
|
||||||
</button>
|
|
||||||
<text v-else-if="avatarUrl" class="mt-3 block text-[11px] leading-5 text-[#9a9189]">头像仅保存在当前设备</text>
|
|
||||||
<text v-else class="mt-3 block text-[11px] leading-5 text-[#9a9189]">微信头像可在授权后显示</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<button
|
<MineRecentViews :items="props.recentViews" @open-vehicle="emit('open-vehicle')"
|
||||||
class="m-0 mt-5 flex min-h-[58px] w-full items-center gap-3 rounded-[16px] bg-[#a45a3d] px-4 text-left text-white shadow-[0_8px_20px_rgba(164,90,61,0.16)]"
|
@select="(item) => emit('select-recent', item)" @explore="emit('open-play')" />
|
||||||
@click="emit('open-concierge')"
|
|
||||||
>
|
|
||||||
<view class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white/15">
|
|
||||||
<uni-icons type="headphones" :size="18" color="#fffaf5" />
|
|
||||||
</view>
|
|
||||||
<view class="min-w-0 flex-1">
|
|
||||||
<text class="block text-[14px] font-semibold">联系管家</text>
|
|
||||||
<text class="mt-1 block text-[10px] leading-4 text-white/75">获取适合你的出行建议</text>
|
|
||||||
</view>
|
|
||||||
<uni-icons type="right" :size="16" color="#fffaf5" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<MineRecentViews
|
|
||||||
:items="props.recentViews"
|
|
||||||
@open-vehicle="emit('open-vehicle')"
|
|
||||||
@select="(item) => emit('select-recent', item)"
|
|
||||||
@explore="emit('open-play')"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<view class="mt-6 rounded-[16px] border border-[#e2d9d0] bg-white px-4 py-4 shadow-[0_8px_20px_rgba(80,58,45,0.04)]">
|
|
||||||
<text class="block text-[14px] font-semibold text-[#2b2724]">账号操作</text>
|
|
||||||
<text class="mt-1 block text-[11px] leading-5 text-[#9a9189]">退出登录会清除本机最近浏览记录</text>
|
|
||||||
<button
|
|
||||||
class="m-0 mt-4 flex min-h-[42px] w-full items-center justify-center rounded-full border border-[#d9c7bb] bg-[#fffaf5] px-4 text-[12px] font-medium tracking-[0.04em] text-[#8c4f39]"
|
|
||||||
@click="emit('logout')"
|
|
||||||
>
|
|
||||||
<uni-icons type="forward" :size="16" color="#8c4f39" />
|
|
||||||
<text class="ml-1">退出登录</text>
|
|
||||||
</button>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -107,12 +67,9 @@ const props = withDefaults(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
"request-avatar": [];
|
|
||||||
"open-concierge": [];
|
|
||||||
"open-play": [];
|
"open-play": [];
|
||||||
"open-vehicle": [];
|
"open-vehicle": [];
|
||||||
"select-recent": [item: RecentlyViewedItem];
|
"select-recent": [item: RecentlyViewedItem];
|
||||||
logout: [];
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const menuButtonTop = ref<number | null>(null);
|
const menuButtonTop = ref<number | null>(null);
|
||||||
|
|||||||
@@ -3,18 +3,9 @@
|
|||||||
<view class="wq-phone h-screen overflow-hidden">
|
<view class="wq-phone h-screen overflow-hidden">
|
||||||
<MineGuest v-if="!session" @login="goLogin" />
|
<MineGuest v-if="!session" @login="goLogin" />
|
||||||
<scroll-view v-else scroll-y class="h-full no-scrollbar">
|
<scroll-view v-else scroll-y class="h-full no-scrollbar">
|
||||||
<MineMember
|
<MineMember :customer-line="customerLine" :customer-name="wechatProfile?.nickName || '万趣会员'"
|
||||||
:customer-line="customerLine"
|
:avatar-url="wechatProfile?.avatarUrl" :show-avatar-action="isWechatMiniProgram" :recent-views="recentViews"
|
||||||
:customer-name="wechatProfile?.nickName || '万趣会员'"
|
@open-play="goPlay" @open-vehicle="goVehicleDemand" @select-recent="openRecent" />
|
||||||
:avatar-url="wechatProfile?.avatarUrl"
|
|
||||||
:show-avatar-action="isWechatMiniProgram"
|
|
||||||
:recent-views="recentViews"
|
|
||||||
@request-avatar="loadWechatProfile"
|
|
||||||
@open-concierge="goConcierge"
|
|
||||||
@open-play="goPlay"
|
|
||||||
@open-vehicle="goVehicleDemand"
|
|
||||||
@select-recent="openRecent"
|
|
||||||
@logout="logout" />
|
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -23,14 +14,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import { clearAuthSession, getAuthSession, loginWithPhoneCode } from "@/lib/auth";
|
import { getAuthSession, loginWithPhoneCode } from "@/lib/auth";
|
||||||
import {
|
import {
|
||||||
clearRecentlyViewed,
|
|
||||||
getRecentlyViewed,
|
getRecentlyViewed,
|
||||||
type RecentlyViewedItem,
|
type RecentlyViewedItem,
|
||||||
} from "@/lib/recentlyViewed";
|
} from "@/lib/recentlyViewed";
|
||||||
import {
|
import {
|
||||||
goConcierge,
|
|
||||||
goPlay,
|
goPlay,
|
||||||
goVehicleDemand,
|
goVehicleDemand,
|
||||||
goTeamBuildingDetail,
|
goTeamBuildingDetail,
|
||||||
@@ -39,7 +28,6 @@ import {
|
|||||||
} from "@/lib/navigation";
|
} from "@/lib/navigation";
|
||||||
import { loadAppData } from "@/lib/store";
|
import { loadAppData } from "@/lib/store";
|
||||||
import {
|
import {
|
||||||
clearWechatProfile,
|
|
||||||
getStoredWechatProfile,
|
getStoredWechatProfile,
|
||||||
requestWechatProfile,
|
requestWechatProfile,
|
||||||
saveWechatProfile,
|
saveWechatProfile,
|
||||||
@@ -103,27 +91,6 @@ async function goLogin(event: WechatPhoneNumberEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadWechatProfile() {
|
|
||||||
if (isLoadingWechatProfile.value) return;
|
|
||||||
|
|
||||||
isLoadingWechatProfile.value = true;
|
|
||||||
uni.showLoading({ title: "获取头像中" });
|
|
||||||
try {
|
|
||||||
const profile = await requestWechatProfile();
|
|
||||||
if (!profile) {
|
|
||||||
uni.showToast({ title: "未获取到头像,请允许授权后重试", icon: "none" });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
saveWechatProfile(profile);
|
|
||||||
wechatProfile.value = profile;
|
|
||||||
uni.showToast({ title: "头像已更新", icon: "none" });
|
|
||||||
} finally {
|
|
||||||
isLoadingWechatProfile.value = false;
|
|
||||||
uni.hideLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openRecent(item: RecentlyViewedItem) {
|
function openRecent(item: RecentlyViewedItem) {
|
||||||
if (item.type === "wanfa-route") {
|
if (item.type === "wanfa-route") {
|
||||||
goWanfaRouteDetail(item.id);
|
goWanfaRouteDetail(item.id);
|
||||||
@@ -135,15 +102,4 @@ function openRecent(item: RecentlyViewedItem) {
|
|||||||
}
|
}
|
||||||
goWildArchiveDetail(item.id);
|
goWildArchiveDetail(item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout() {
|
|
||||||
clearAuthSession();
|
|
||||||
clearWechatProfile();
|
|
||||||
clearRecentlyViewed();
|
|
||||||
session.value = null;
|
|
||||||
wechatProfile.value = null;
|
|
||||||
recentViews.value = [];
|
|
||||||
customerLine.value = "登录后管理头像与手机号,继续探索旅程。";
|
|
||||||
uni.showToast({ title: "已退出登录", icon: "none" });
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user