card.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="card-container">
  3. <!-- 顶部背景 -->
  4. <image class="top-bg" src="/static/image/home/top-bg.png" />
  5. <NavBar :title="'我的名片'" color="#fff" :fixed="true" :bgImg="'/static/image/home/top-bg.png'" :bg="'transparent'">
  6. <template #left>
  7. <!-- <view class="left-title">{{appName}}</view> -->
  8. </template>
  9. </NavBar>
  10. <!-- 名片轮播 -->
  11. <view class="page-top" :class="{activeCard:pageIn}">
  12. <swiper
  13. class="card-swiper"
  14. :current="currentIndex"
  15. @change="onSwiperChange"
  16. circular
  17. :indicator-dots="false"
  18. :autoplay="false"
  19. >
  20. <swiper-item v-for="(card, idx) in cardList" :key="card.userId || idx">
  21. <view class="swiper-item-wrapper">
  22. <UserCard :info="card" @call="makeCall" />
  23. <ShareButton />
  24. </view>
  25. </swiper-item>
  26. </swiper>
  27. </view>
  28. <view class="card-content" :class="{activeCard:pageIn}">
  29. <!-- 企业简介 -->
  30. <CompanyIntroduce></CompanyIntroduce>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import {
  36. ref,
  37. onMounted
  38. } from 'vue'
  39. import NavBar from '@/components/nav-bar/index.vue'
  40. import UserAvatar from '@/components/user-avatar/index.vue'
  41. import EmptyState from '@/components/empty-state/index.vue'
  42. import ShareButton from '@/components/shareButton/index.vue'
  43. import CompanyIntroduce from '@/components/companyIntroduce/index.vue'
  44. import UserCard from '@/components/user-card/index.vue'
  45. import {
  46. useUserStore
  47. } from '@/store/modules/user.js'
  48. import {
  49. storeToRefs
  50. } from 'pinia'
  51. import {
  52. onShareAppMessage
  53. } from '@dcloudio/uni-app';
  54. // 使用 Pinia 管理用户状态
  55. const userStore = useUserStore()
  56. const {
  57. cardInfo,
  58. cardList,
  59. currentIndex,
  60. cardImage
  61. } = storeToRefs(userStore)
  62. onShareAppMessage(() => {
  63. return {
  64. path: `pages/splash/splash?userId=${cardInfo.value.userId}&currentIndex=${currentIndex.value}`,
  65. imageUrl: cardImage.value,
  66. title:`${cardInfo.value.nickName} 向你分享了名片`
  67. };
  68. });
  69. let appName = ref('')
  70. // 入场动画
  71. const pageIn = ref(false)
  72. onMounted(() => {
  73. pageIn.value = true
  74. })
  75. const onSwiperChange = (e) => {
  76. userStore.setCurrentIndex(e.detail.current)
  77. }
  78. const makeCall = () => {
  79. if (cardInfo.value.phonenumber) {
  80. uni.makePhoneCall({
  81. phoneNumber: cardInfo.value.phonenumber
  82. })
  83. } else {
  84. uni.showToast({
  85. title: '暂无电话号码',
  86. icon: 'none'
  87. })
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .card-container {
  93. background: #f5f6f8;
  94. }
  95. .left-title {
  96. font-size: 44rpx;
  97. font-weight: bold;
  98. color: #ffffff;
  99. text-shadow: 2px 2px 0 black;
  100. }
  101. .top-bg {
  102. width: 100%;
  103. position: fixed;
  104. top: 0;
  105. left: 0;
  106. z-index: 1;
  107. }
  108. // 顶部背景区域
  109. .header-bg {
  110. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  111. padding: 0 40rpx;
  112. padding-top: calc(var(--status-bar-height) + 20rpx);
  113. padding-bottom: 60rpx;
  114. position: relative;
  115. overflow: hidden;
  116. // 背景光效
  117. &::before {
  118. content: '';
  119. position: absolute;
  120. top: -100rpx;
  121. right: -100rpx;
  122. width: 500rpx;
  123. height: 500rpx;
  124. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  125. border-radius: 50%;
  126. }
  127. // 导航栏
  128. .nav-bar {
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. height: 88rpx;
  133. position: relative;
  134. z-index: 10;
  135. .nav-back {
  136. width: 60rpx;
  137. height: 60rpx;
  138. display: flex;
  139. align-items: center;
  140. justify-content: center;
  141. }
  142. .nav-title {
  143. font-size: 32rpx;
  144. font-weight: 600;
  145. color: #ffffff;
  146. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  147. }
  148. .nav-right {
  149. display: flex;
  150. align-items: center;
  151. .more-btn,
  152. .refresh-btn {
  153. width: 64rpx;
  154. height: 64rpx;
  155. border-radius: 50%;
  156. background: rgba(255, 255, 255, 0.15);
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. margin-left: 16rpx;
  161. }
  162. }
  163. }
  164. }
  165. .page-top {
  166. margin: 0 24rpx 24rpx;
  167. position: relative;
  168. z-index: 2;
  169. transform: scale(0.85);
  170. }
  171. // 名片轮播
  172. .card-swiper {
  173. height: 550rpx;
  174. }
  175. // 轮播索引指示器
  176. .swiper-indicator {
  177. display: flex;
  178. align-items: center;
  179. justify-content: center;
  180. gap: 12rpx;
  181. margin-top: 16rpx;
  182. padding-bottom: 8rpx;
  183. .indicator-dot {
  184. width: 14rpx;
  185. height: 14rpx;
  186. border-radius: 50%;
  187. background: rgba(0, 0, 0, 0.15);
  188. transition: all 0.3s ease;
  189. &.active {
  190. width: 32rpx;
  191. border-radius: 8rpx;
  192. background: rgba(64, 128, 255, 0.8);
  193. }
  194. }
  195. }
  196. // 名片内容区域
  197. .card-content {
  198. margin: 0 24rpx;
  199. padding: 20rpx 40rpx;
  200. border-radius: 24rpx;
  201. background: #ffffff;
  202. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  203. position: relative;
  204. bottom: 24rpx;
  205. z-index: 2;
  206. transform: translateY(150rpx);
  207. }
  208. .activeCard {
  209. transform: none !important;
  210. transition: all 0.3s cubic-bezier(.68, -0.55, .265, 1.55);
  211. }
  212. </style>