index.vue 7.1 KB

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