| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <template>
- <scroll-view class="card-container" scroll-y @scroll="onScroll" :scroll-top="0">
- <!-- 顶部背景 -->
- <NavBar :title="'首页'" :show_back="false" :color="'#fff'" :fixed="true" :bgImg="'/static/image/home/top-bg.png'"
- :bg="'transparent'">
- <template #left>
- <!-- <view class="left-title">{{appName}}</view> -->
- </template>
- </NavBar>
- <image class="top-bg" src="/static/image/home/top-bg.png" />
- <!-- 名片轮播 -->
- <view class="page-top" :class="{activeCard:pageIn}">
- <swiper class="card-swiper" :current="currentIndex" @change="onSwiperChange" :indicator-dots="false"
- :autoplay="false" :next-margin="'12rpx'">
- <swiper-item v-for="(card, idx) in cardList" :key="card.userId || idx">
- <view class="swiper-item-wrapper" :style="{'padding-right':cardList.length - 1 == currentIndex ? 0: '10rpx'}">
- <UserCard :info="card" @call="makeCall" :isCall="false" />
- </view>
- </swiper-item>
- </swiper>
- <ShareButton />
- </view>
- <view class="card-content" :class="{activeCard:pageIn}">
- <!-- 企业简介 -->
- <CompanyIntroduce></CompanyIntroduce>
- </view>
- <!-- 隐藏的 Canvas 用于生成名片快照 -->
- <canvas id="posterCanvas" type="2d"
- style="position: fixed; left: -9999px; top: -9999px; width: 750px; height: 780px;"></canvas>
- <!-- 隐藏的 Canvas 用于生成二维码海报 -->
- <view class="hidden-canvas-box">
- <canvas id="qrPosterCanvas" type="2d" style="width: 600px; height: 700px;"></canvas>
- </view>
- </scroll-view>
- </template>
- <script setup>
- import {
- ref,
- computed,
- onMounted
- } from 'vue'
- import {
- onShareAppMessage
- } from '@dcloudio/uni-app';
- import NavBar from '@/components/nav-bar/index.vue'
- import UserAvatar from '@/components/user-avatar/index.vue'
- import EmptyState from '@/components/empty-state/index.vue'
- import ShareButton from '@/components/shareButton/index.vue'
- import CompanyIntroduce from '@/components/companyIntroduce/index.vue'
- import UserCard from '@/components/user-card/index.vue'
- import {
- useUserStore
- } from '@/store/modules/user.js'
- import {
- storeToRefs
- } from 'pinia'
- // 使用 Pinia 管理用户状态
- const userStore = useUserStore()
- const {
- cardInfo,
- cardList,
- currentIndex,
- cardImage,
- queryCardPoster
- } = storeToRefs(userStore)
- let appName = ref('')
- // 入场动画状态
- const pageIn = ref(false)
- onMounted(() => {
- pageIn.value = true
- })
- const loading = ref(false)
- const onSwiperChange = (e) => {
- userStore.setCurrentIndex(e.detail.current)
- }
- onShareAppMessage(() => {
- return {
- path: `pages/splash/splash?userId=${cardInfo.value.userId}¤tId=${cardInfo.value.companyDTO.id}`,
- imageUrl: cardImage.value,
- title: `${cardInfo.value.nickName} 向你分享了名片`
- };
- });
- // 导航栏滚动渐变
- const navBg = ref('transparent')
- const navColor = ref('#ffffff')
- const onScroll = (e) => {
- const scrollTop = e.detail.scrollTop
- if (scrollTop > 30) {
- navBg.value = '#ffffff'
- navColor.value = '#333333'
- } else {
- navBg.value = 'transparent'
- navColor.value = '#ffffff'
- }
- }
- // 拨打电话交由 UserCard 组件内部处理,这里只是留空以备后续扩展
- const makeCall = () => {}
- </script>
- <style lang="scss" scoped>
- .card-container {
- background: #f5f6f8;
- height: 100vh;
- }
- .left-title {
- font-size: 44rpx;
- font-weight: bold;
- color: #ffffff;
- text-shadow: 2px 2px 0 black;
- }
- .top-bg {
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 1;
- }
- // 顶部背景区域
- .header-bg {
- background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
- padding: 0 40rpx;
- padding-top: calc(var(--status-bar-height) + 20rpx);
- padding-bottom: 60rpx;
- position: relative;
- overflow: hidden;
- // 背景光效
- &::before {
- content: '';
- position: absolute;
- top: -100rpx;
- right: -100rpx;
- width: 500rpx;
- height: 500rpx;
- background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
- border-radius: 50%;
- }
- // 导航栏
- .nav-bar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 88rpx;
- position: relative;
- z-index: 10;
- .nav-back {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .nav-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #ffffff;
- text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
- }
- .nav-right {
- display: flex;
- align-items: center;
- .more-btn,
- .refresh-btn {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.15);
- display: flex;
- align-items: center;
- justify-content: center;
- margin-left: 16rpx;
- }
- }
- }
- }
- .page-top {
- margin: 0 24rpx 24rpx;
- position: relative;
- z-index: 2;
- transform: scale(0.85);
- }
- // 名片轮播
- .card-swiper {
- height: 400rpx;
- overflow: visible;
- position: relative;
- z-index: 2;
- }
- // 轮播索引指示器
- .swiper-indicator {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 12rpx;
- margin-top: 16rpx;
- padding-bottom: 8rpx;
- .indicator-dot {
- width: 14rpx;
- height: 14rpx;
- border-radius: 50%;
- background: rgba(0, 0, 0, 0.15);
- transition: all 0.3s ease;
- &.active {
- width: 32rpx;
- border-radius: 8rpx;
- background: rgba(64, 128, 255, 0.8);
- }
- }
- }
- // 名片内容区域
- .card-content {
- margin: 0 24rpx;
- padding: 20rpx 40rpx;
- border-radius: 24rpx;
- background: #ffffff;
- box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
- position: relative;
- bottom: 24rpx;
- z-index: 2;
- transform: translateY(150rpx);
- }
- // 隐藏的 canvas 容器
- .hidden-canvas-box {
- position: fixed;
- left: -9999px;
- top: -9999px;
- width: 1px;
- height: 1px;
- overflow: hidden;
- }
- </style>
|