userCard.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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" :fixed="true" :bg="'transparent'">
  6. <template #left>
  7. <!-- <view class="left-title">{{appName}}</view> -->
  8. </template>
  9. </NavBar>
  10. <!-- 名片卡片 -->
  11. <view class="page-top">
  12. <view class="user-card" id="user-card">
  13. <!-- 背景图 -->
  14. <image class="user-card-bg" src="/static/image/home/usecard-bg.png" />
  15. <!-- 左上:姓名 + 职位 -->
  16. <view class="user-header">
  17. <view class="name-row">
  18. <text class="user-name">{{ cardInfo.nickName || '用户' }}</text>
  19. <text class="user-role">{{ cardInfo.postName || '职位' }}</text>
  20. </view>
  21. <text class="company-name">{{ cardInfo.companyName || '公司名称' }}</text>
  22. </view>
  23. <!-- 右上:头像 -->
  24. <view class="avatar-wrapper">
  25. <UserAvatar :src="cardInfo.avatar" :name="cardInfo.nickName" :size="130"
  26. :badge-src="'/static/image/public/badge-icon.png'" :badge-size="56" />
  27. </view>
  28. <!-- 左下:联系方式 -->
  29. <view class="user-contact">
  30. <view class="contact-row" @click="makeCall">
  31. <uni-icons type="phone" :size="18" color="#666666"></uni-icons>
  32. <text class="contact-text">{{ cardInfo.phonenumber || '暂无电话' }}</text>
  33. </view>
  34. <view class="contact-row">
  35. <uni-icons type="email" :size="18" color="#666666"></uni-icons>
  36. <text class="contact-text">{{ cardInfo.email || '暂无邮箱' }}</text>
  37. </view>
  38. <view class="contact-row">
  39. <uni-icons type="location" :size="18" color="#666666"></uni-icons>
  40. <text class="contact-text">{{ cardInfo.companyAddress || '暂无地址' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="card-content">
  46. <!-- 企业简介 -->
  47. <view class="company-section">
  48. <view class="company-title">
  49. 企业简介
  50. </view>
  51. <rich-text class="company-text" :nodes="companyInfo.introduce"></rich-text>
  52. </view>
  53. </view>
  54. <!-- 隐藏的 Canvas 用于生成名片快照 -->
  55. <canvas id="posterCanvas" type="2d"
  56. style="position: fixed; left: -9999px; top: -9999px; width: 750px; height: 780px;"></canvas>
  57. <!-- 隐藏的 Canvas 用于生成二维码海报 -->
  58. <view class="hidden-canvas-box">
  59. <canvas id="qrPosterCanvas" type="2d" style="width: 600px; height: 700px;"></canvas>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup>
  64. import {
  65. ref,
  66. onMounted
  67. } from 'vue'
  68. import NavBar from '@/components/nav-bar/index.vue'
  69. import UserAvatar from '@/components/user-avatar/index.vue'
  70. import EmptyState from '@/components/empty-state/index.vue'
  71. import ShareButton from '@/components/shareButton/index.vue'
  72. import {
  73. useUserStore
  74. } from '@/store/modules/user.js'
  75. import {
  76. storeToRefs
  77. } from 'pinia'
  78. import {
  79. onShareAppMessage
  80. } from '@dcloudio/uni-app';
  81. // 使用 Pinia 管理用户状态
  82. const userStore = useUserStore()
  83. const {
  84. cardInfo,
  85. companyInfo,
  86. cardImage
  87. } = storeToRefs(userStore)
  88. let appName = ref('')
  89. onShareAppMessage(() => {
  90. return {
  91. userName: '小程序',
  92. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  93. imageUrl: cardImage.value
  94. };
  95. });
  96. const makeCall = () => {
  97. if (cardInfo.value.phonenumber) {
  98. uni.makePhoneCall({
  99. phoneNumber: cardInfo.value.phonenumber
  100. })
  101. } else {
  102. uni.showToast({
  103. title: '暂无电话号码',
  104. icon: 'none'
  105. })
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .card-container {
  111. background: #f5f6f8;
  112. }
  113. .left-title {
  114. font-size: 44rpx;
  115. font-weight: bold;
  116. color: #ffffff;
  117. text-shadow: 2px 2px 0 black;
  118. }
  119. .top-bg {
  120. width: 750rpx;
  121. height: 634rpx;
  122. position: fixed;
  123. top: 0;
  124. left: 0;
  125. z-index: 1;
  126. }
  127. // 顶部背景区域
  128. .header-bg {
  129. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  130. padding: 0 40rpx;
  131. padding-top: calc(var(--status-bar-height) + 20rpx);
  132. padding-bottom: 60rpx;
  133. position: relative;
  134. overflow: hidden;
  135. // 背景光效
  136. &::before {
  137. content: '';
  138. position: absolute;
  139. top: -100rpx;
  140. right: -100rpx;
  141. width: 500rpx;
  142. height: 500rpx;
  143. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  144. border-radius: 50%;
  145. }
  146. // 导航栏
  147. .nav-bar {
  148. display: flex;
  149. align-items: center;
  150. justify-content: space-between;
  151. height: 88rpx;
  152. position: relative;
  153. z-index: 10;
  154. .nav-back {
  155. width: 60rpx;
  156. height: 60rpx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. .nav-title {
  162. font-size: 32rpx;
  163. font-weight: 600;
  164. color: #ffffff;
  165. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  166. }
  167. .nav-right {
  168. display: flex;
  169. align-items: center;
  170. .more-btn,
  171. .refresh-btn {
  172. width: 64rpx;
  173. height: 64rpx;
  174. border-radius: 50%;
  175. background: rgba(255, 255, 255, 0.15);
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. margin-left: 16rpx;
  180. }
  181. }
  182. }
  183. }
  184. .page-top {
  185. margin: 0 24rpx 24rpx;
  186. .user-card {
  187. position: relative;
  188. z-index: 2;
  189. width: 100%;
  190. height: 400rpx;
  191. box-sizing: border-box;
  192. padding: 80rpx 40rpx 32rpx;
  193. position: relative;
  194. .user-card-bg {
  195. position: absolute;
  196. top: 0;
  197. left: 0;
  198. width: 100%;
  199. height: 100%;
  200. z-index: 0;
  201. }
  202. view,
  203. text {
  204. position: relative;
  205. z-index: 1;
  206. }
  207. .user-header {
  208. .name-row {
  209. display: flex;
  210. align-items: center;
  211. margin-bottom: 16rpx;
  212. .user-name {
  213. font-size: 44rpx;
  214. font-weight: 700;
  215. color: #202020;
  216. line-height: 1.2;
  217. }
  218. .user-role {
  219. margin-left: 16rpx;
  220. padding: 6rpx 16rpx;
  221. background: rgba(68, 110, 255, 0.10);
  222. border-radius: 8rpx;
  223. font-size: 24rpx;
  224. font-weight: 500;
  225. color: #446eff;
  226. }
  227. }
  228. .company-name {
  229. font-size: 28rpx;
  230. font-weight: 500;
  231. color: #666666;
  232. line-height: 1.4;
  233. }
  234. }
  235. .avatar-wrapper {
  236. position: absolute;
  237. top: 32rpx;
  238. right: 36rpx;
  239. z-index: 2;
  240. }
  241. .user-contact {
  242. margin-top: 32rpx;
  243. .contact-row {
  244. display: flex;
  245. align-items: center;
  246. margin-bottom: 16rpx;
  247. uni-icons {
  248. margin-right: 12rpx;
  249. flex-shrink: 0;
  250. }
  251. .contact-text {
  252. font-size: 26rpx;
  253. color: #666666;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. // 名片内容区域
  260. .card-content {
  261. margin: 0 24rpx;
  262. padding: 20rpx 40rpx;
  263. border-radius: 24rpx;
  264. background: #ffffff;
  265. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  266. position: relative;
  267. z-index: 2;
  268. // 企业简介
  269. .company-section {
  270. background: #ffffff;
  271. .company-title {
  272. font-weight: bold;
  273. font-size: 32rpx;
  274. margin-bottom: 12rpx;
  275. }
  276. .company-text {
  277. display: block;
  278. font-size: 28rpx;
  279. color: #666666;
  280. line-height: 1.8;
  281. margin-bottom: 24rpx;
  282. ::v-deep img {
  283. max-width: 100% !important;
  284. height: auto !important;
  285. }
  286. &:last-child {
  287. margin-bottom: 0;
  288. }
  289. }
  290. }
  291. }
  292. // 隐藏的 canvas 容器
  293. .hidden-canvas-box {
  294. position: fixed;
  295. left: -9999px;
  296. top: -9999px;
  297. width: 1px;
  298. height: 1px;
  299. overflow: hidden;
  300. }
  301. </style>