userCard.vue 4.7 KB

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