card.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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" :style="cardStyle">
  12. <UserCard :info="cardInfo" @call="makeCall" />
  13. <ShareButton />
  14. </view>
  15. <view class="card-content" :style="contentCardStyle">
  16. <!-- 企业简介 -->
  17. <CompanyIntroduce></CompanyIntroduce>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {
  23. ref,
  24. computed,
  25. onMounted
  26. } from 'vue'
  27. import NavBar from '@/components/nav-bar/index.vue'
  28. import UserAvatar from '@/components/user-avatar/index.vue'
  29. import EmptyState from '@/components/empty-state/index.vue'
  30. import ShareButton from '@/components/shareButton/index.vue'
  31. import CompanyIntroduce from '@/components/companyIntroduce/index.vue'
  32. import UserCard from '@/components/user-card/index.vue'
  33. import {
  34. useUserStore
  35. } from '@/store/modules/user.js'
  36. import {
  37. storeToRefs
  38. } from 'pinia'
  39. import {
  40. onShareAppMessage
  41. } from '@dcloudio/uni-app';
  42. // 使用 Pinia 管理用户状态
  43. const userStore = useUserStore()
  44. const {
  45. cardInfo,
  46. companyInfo,
  47. cardImage
  48. } = storeToRefs(userStore)
  49. onShareAppMessage(() => {
  50. return {
  51. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  52. imageUrl: cardImage.value,
  53. title:`${cardInfo.value.nickName} 向你分享了名片`
  54. };
  55. });
  56. let appName = ref('')
  57. // 入场动画
  58. const pageReady = ref(false)
  59. const contentReady = ref(false)
  60. onMounted(() => {
  61. requestAnimationFrame(() => { pageReady.value = true })
  62. setTimeout(() => { contentReady.value = true }, 400)
  63. })
  64. const cardStyle = computed(() => ({
  65. opacity: pageReady.value ? 1 : 0,
  66. transform: pageReady.value ? 'scale(1) translateY(0)' : 'scale(0.92) translateY(-20px)',
  67. transition: 'all 0.5s cubic-bezier(0.34, 1.3, 0.64, 1)',
  68. }))
  69. const contentCardStyle = computed(() => ({
  70. opacity: contentReady.value ? 1 : 0,
  71. transform: contentReady.value ? 'translateY(0)' : 'translateY(40px)',
  72. transition: 'all 0.45s ease-out',
  73. }))
  74. const makeCall = () => {
  75. if (cardInfo.value.phonenumber) {
  76. uni.makePhoneCall({
  77. phoneNumber: cardInfo.value.phonenumber
  78. })
  79. } else {
  80. uni.showToast({
  81. title: '暂无电话号码',
  82. icon: 'none'
  83. })
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .card-container {
  89. background: #f5f6f8;
  90. }
  91. .left-title {
  92. font-size: 44rpx;
  93. font-weight: bold;
  94. color: #ffffff;
  95. text-shadow: 2px 2px 0 black;
  96. }
  97. .top-bg {
  98. width: 100%;
  99. position: fixed;
  100. top: 0;
  101. left: 0;
  102. z-index: 1;
  103. }
  104. // 顶部背景区域
  105. .header-bg {
  106. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  107. padding: 0 40rpx;
  108. padding-top: calc(var(--status-bar-height) + 20rpx);
  109. padding-bottom: 60rpx;
  110. position: relative;
  111. overflow: hidden;
  112. // 背景光效
  113. &::before {
  114. content: '';
  115. position: absolute;
  116. top: -100rpx;
  117. right: -100rpx;
  118. width: 500rpx;
  119. height: 500rpx;
  120. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  121. border-radius: 50%;
  122. }
  123. // 导航栏
  124. .nav-bar {
  125. display: flex;
  126. align-items: center;
  127. justify-content: space-between;
  128. height: 88rpx;
  129. position: relative;
  130. z-index: 10;
  131. .nav-back {
  132. width: 60rpx;
  133. height: 60rpx;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. }
  138. .nav-title {
  139. font-size: 32rpx;
  140. font-weight: 600;
  141. color: #ffffff;
  142. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  143. }
  144. .nav-right {
  145. display: flex;
  146. align-items: center;
  147. .more-btn,
  148. .refresh-btn {
  149. width: 64rpx;
  150. height: 64rpx;
  151. border-radius: 50%;
  152. background: rgba(255, 255, 255, 0.15);
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. margin-left: 16rpx;
  157. }
  158. }
  159. }
  160. }
  161. .page-top {
  162. margin: 0 24rpx 24rpx;
  163. }
  164. // 名片内容区域
  165. .card-content {
  166. margin: 0 24rpx;
  167. padding: 20rpx 40rpx;
  168. border-radius: 24rpx;
  169. background: #ffffff;
  170. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  171. position: relative;
  172. bottom: 24rpx;
  173. z-index: 2;
  174. }
  175. </style>