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