userCard.vue 4.9 KB

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