index.vue 6.7 KB

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