card.vue 5.0 KB

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