card.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 pageIn = ref(false)
  59. const contentIn = ref(false)
  60. const cardStyle = computed(() => ({
  61. opacity: '1',
  62. transform: pageIn.value ? 'scale(1) translateY(0)' : 'scale(0.92) translateY(-20px)',
  63. transition: pageIn.value ? 'all 0.55s cubic-bezier(0.34, 1.3, 0.64, 1)' : 'none',
  64. }))
  65. const contentCardStyle = computed(() => ({
  66. opacity: '1',
  67. transform: contentIn.value ? 'translateY(0)' : 'translateY(40px)',
  68. transition: contentIn.value ? 'all 0.45s ease-out' : 'none',
  69. }))
  70. onMounted(() => {
  71. // 初始:偏移位置(无动画)
  72. pageIn.value = false
  73. contentIn.value = false
  74. // 30ms 后触发名片动画
  75. setTimeout(() => { pageIn.value = true }, 30)
  76. // 350ms 后触发内容动画
  77. setTimeout(() => { contentIn.value = true }, 350)
  78. })
  79. const makeCall = () => {
  80. if (cardInfo.value.phonenumber) {
  81. uni.makePhoneCall({
  82. phoneNumber: cardInfo.value.phonenumber
  83. })
  84. } else {
  85. uni.showToast({
  86. title: '暂无电话号码',
  87. icon: 'none'
  88. })
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .card-container {
  94. background: #f5f6f8;
  95. }
  96. .left-title {
  97. font-size: 44rpx;
  98. font-weight: bold;
  99. color: #ffffff;
  100. text-shadow: 2px 2px 0 black;
  101. }
  102. .top-bg {
  103. width: 100%;
  104. position: fixed;
  105. top: 0;
  106. left: 0;
  107. z-index: 1;
  108. }
  109. // 顶部背景区域
  110. .header-bg {
  111. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  112. padding: 0 40rpx;
  113. padding-top: calc(var(--status-bar-height) + 20rpx);
  114. padding-bottom: 60rpx;
  115. position: relative;
  116. overflow: hidden;
  117. // 背景光效
  118. &::before {
  119. content: '';
  120. position: absolute;
  121. top: -100rpx;
  122. right: -100rpx;
  123. width: 500rpx;
  124. height: 500rpx;
  125. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  126. border-radius: 50%;
  127. }
  128. // 导航栏
  129. .nav-bar {
  130. display: flex;
  131. align-items: center;
  132. justify-content: space-between;
  133. height: 88rpx;
  134. position: relative;
  135. z-index: 10;
  136. .nav-back {
  137. width: 60rpx;
  138. height: 60rpx;
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. }
  143. .nav-title {
  144. font-size: 32rpx;
  145. font-weight: 600;
  146. color: #ffffff;
  147. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  148. }
  149. .nav-right {
  150. display: flex;
  151. align-items: center;
  152. .more-btn,
  153. .refresh-btn {
  154. width: 64rpx;
  155. height: 64rpx;
  156. border-radius: 50%;
  157. background: rgba(255, 255, 255, 0.15);
  158. display: flex;
  159. align-items: center;
  160. justify-content: center;
  161. margin-left: 16rpx;
  162. }
  163. }
  164. }
  165. }
  166. .page-top {
  167. margin: 0 24rpx 24rpx;
  168. position: relative;
  169. z-index: 2;
  170. }
  171. // 名片内容区域
  172. .card-content {
  173. margin: 0 24rpx;
  174. padding: 20rpx 40rpx;
  175. border-radius: 24rpx;
  176. background: #ffffff;
  177. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  178. position: relative;
  179. bottom: 24rpx;
  180. z-index: 2;
  181. }
  182. </style>