userCard.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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="#FFFFFF" :fixed="true" :bg="'transparent'"></NavBar>
  6. <!-- 名片卡片 -->
  7. <view class="page-top">
  8. <view class="user-card">
  9. <!-- 背景图 -->
  10. <image class="user-card-bg" src="/static/image/home/usecard-bg.png" />
  11. <!-- 左上:姓名 + 职位 -->
  12. <view class="user-header">
  13. <view class="name-row">
  14. <text class="user-name">{{ cardInfo.nickName || '用户' }}</text>
  15. <text class="user-role">{{ cardInfo.postName || '职位' }}</text>
  16. </view>
  17. <text class="company-name">{{ cardInfo.companyName || '公司名称' }}</text>
  18. </view>
  19. <!-- 右上:头像 -->
  20. <view class="avatar-wrapper">
  21. <UserAvatar :src="cardInfo.avatar" :name="cardInfo.nickName" :size="130"
  22. :badge-src="'/static/image/public/badge-icon.png'" :badge-size="56" />
  23. </view>
  24. <!-- 左下:联系方式 -->
  25. <view class="user-contact">
  26. <view class="contact-row" @click="makeCall">
  27. <uni-icons type="phone" :size="18" color="#666666"></uni-icons>
  28. <text class="contact-text">{{ cardInfo.phonenumber || '暂无电话' }}</text>
  29. </view>
  30. <view class="contact-row">
  31. <uni-icons type="email" :size="18" color="#666666"></uni-icons>
  32. <text class="contact-text">{{ cardInfo.email || '暂无邮箱' }}</text>
  33. </view>
  34. <view class="contact-row">
  35. <uni-icons type="location" :size="18" color="#666666"></uni-icons>
  36. <text class="contact-text">{{ cardInfo.companyAddress || '暂无地址' }}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="card-content">
  42. <!-- 企业简介 -->
  43. <view class="company-section">
  44. <view class="company-title">
  45. 企业简介
  46. </view>
  47. <rich-text class="company-text" :nodes="companyInfo.introduce"></rich-text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import {
  54. ref,
  55. onMounted
  56. } from 'vue'
  57. import {
  58. onShareAppMessage
  59. } from '@dcloudio/uni-app';
  60. import NavBar from '@/components/nav-bar/index.vue'
  61. import UserAvatar from '@/components/user-avatar/index.vue'
  62. import EmptyState from '@/components/empty-state/index.vue'
  63. import {
  64. useUserStore
  65. } from '@/store/modules/user.js'
  66. import {
  67. storeToRefs
  68. } from 'pinia'
  69. // 使用 Pinia 管理用户状态
  70. const userStore = useUserStore()
  71. const {
  72. cardInfo,
  73. companyInfo
  74. } = storeToRefs(userStore)
  75. const currentTab = ref('company')
  76. const productList = ref([])
  77. onMounted(async () => {
  78. // 如果没有数据,重新获取
  79. if (!cardInfo.value.nickName) {
  80. await userStore.queryCardInfo()
  81. }
  82. if (!companyInfo.value.name) {
  83. await userStore.queryCompanyInfo()
  84. }
  85. })
  86. onShareAppMessage(() => {
  87. return {
  88. userName: '小程序',
  89. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  90. };
  91. });
  92. const makeCall = () => {
  93. if (cardInfo.value.phonenumber) {
  94. uni.makePhoneCall({
  95. phoneNumber: cardInfo.value.phonenumber
  96. })
  97. } else {
  98. uni.showToast({
  99. title: '暂无电话号码',
  100. icon: 'none'
  101. })
  102. }
  103. }
  104. const shareCard = () => {
  105. uni.showShareMenu({
  106. withShareTicket: true
  107. })
  108. uni.showToast({
  109. title: '分享名片',
  110. icon: 'none'
  111. })
  112. }
  113. const saveCard = () => {
  114. uni.showToast({
  115. title: '已保存到手机相册',
  116. icon: 'success'
  117. })
  118. }
  119. const showQRCode = () => {
  120. uni.showToast({
  121. title: '名片码',
  122. icon: 'none'
  123. })
  124. }
  125. const switchTab = (tab) => {
  126. currentTab.value = tab
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .card-container {
  131. background: #f5f6f8;
  132. }
  133. .top-bg {
  134. width: 750rpx;
  135. height: 634rpx;
  136. position: fixed;
  137. top: 0;
  138. left: 0;
  139. z-index: 1;
  140. }
  141. // 顶部背景区域
  142. .header-bg {
  143. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  144. padding: 0 40rpx;
  145. padding-top: calc(var(--status-bar-height) + 20rpx);
  146. padding-bottom: 60rpx;
  147. position: relative;
  148. overflow: hidden;
  149. // 背景光效
  150. &::before {
  151. content: '';
  152. position: absolute;
  153. top: -100rpx;
  154. right: -100rpx;
  155. width: 500rpx;
  156. height: 500rpx;
  157. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  158. border-radius: 50%;
  159. }
  160. // 导航栏
  161. .nav-bar {
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. height: 88rpx;
  166. position: relative;
  167. z-index: 10;
  168. .nav-back {
  169. width: 60rpx;
  170. height: 60rpx;
  171. display: flex;
  172. align-items: center;
  173. justify-content: center;
  174. }
  175. .nav-title {
  176. font-size: 32rpx;
  177. font-weight: 600;
  178. color: #ffffff;
  179. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  180. }
  181. .nav-right {
  182. display: flex;
  183. align-items: center;
  184. .more-btn,
  185. .refresh-btn {
  186. width: 64rpx;
  187. height: 64rpx;
  188. border-radius: 50%;
  189. background: rgba(255, 255, 255, 0.15);
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. margin-left: 16rpx;
  194. }
  195. }
  196. }
  197. }
  198. /* 用户信息卡片 */
  199. .page-top {
  200. margin: 0 24rpx 24rpx;
  201. .user-card {
  202. position: relative;
  203. z-index: 2;
  204. width: 100%;
  205. height: 400rpx;
  206. box-sizing: border-box;
  207. padding: 80rpx 40rpx 32rpx;
  208. position: relative;
  209. .user-card-bg {
  210. position: absolute;
  211. top: 0;
  212. left: 0;
  213. width: 100%;
  214. height: 100%;
  215. z-index: 0;
  216. }
  217. view,
  218. text {
  219. position: relative;
  220. z-index: 1;
  221. }
  222. .user-header {
  223. .name-row {
  224. display: flex;
  225. align-items: center;
  226. margin-bottom: 16rpx;
  227. .user-name {
  228. font-size: 44rpx;
  229. font-weight: 700;
  230. color: #202020;
  231. line-height: 1.2;
  232. }
  233. .user-role {
  234. margin-left: 16rpx;
  235. padding: 6rpx 16rpx;
  236. background: rgba(68, 110, 255, 0.10);
  237. border-radius: 8rpx;
  238. font-size: 24rpx;
  239. font-weight: 500;
  240. color: #446eff;
  241. }
  242. }
  243. .company-name {
  244. font-size: 28rpx;
  245. font-weight: 500;
  246. color: #666666;
  247. line-height: 1.4;
  248. }
  249. }
  250. .avatar-wrapper {
  251. position: absolute;
  252. top: 32rpx;
  253. right: 36rpx;
  254. z-index: 2;
  255. }
  256. .user-contact {
  257. margin-top: 32rpx;
  258. .contact-row {
  259. display: flex;
  260. align-items: center;
  261. margin-bottom: 16rpx;
  262. uni-icons {
  263. margin-right: 12rpx;
  264. flex-shrink: 0;
  265. }
  266. .contact-text {
  267. font-size: 26rpx;
  268. color: #666666;
  269. }
  270. }
  271. }
  272. }
  273. .control-card {
  274. background-color: #fff;
  275. border-radius: 0 0 24rpx 24rpx;
  276. position: relative;
  277. z-index: 1;
  278. bottom: 24rpx;
  279. display: flex;
  280. align-items: center;
  281. justify-content: space-around;
  282. padding-top: 48rpx;
  283. padding-bottom: 24rpx;
  284. .item {
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. justify-content: center;
  289. gap: 4rpx;
  290. image {
  291. width: 64rpx;
  292. height: 64rpx;
  293. }
  294. text {
  295. font-size: 26rpx;
  296. color: #202020;
  297. }
  298. }
  299. }
  300. }
  301. // 名片内容区域
  302. .card-content {
  303. margin: 0 24rpx;
  304. padding: 20rpx 40rpx;
  305. border-radius: 24rpx;
  306. background: #ffffff;
  307. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  308. position: relative;
  309. bottom: 24rpx;
  310. z-index: 2;
  311. // 企业简介
  312. .company-section {
  313. background: #ffffff;
  314. .company-title{
  315. font-weight: bold;
  316. font-size: 32rpx;
  317. margin-bottom: 12rpx;
  318. }
  319. .company-text {
  320. display: block;
  321. font-size: 28rpx;
  322. color: #666666;
  323. line-height: 1.8;
  324. margin-bottom: 24rpx;
  325. ::v-deep img {
  326. max-width: 100% !important;
  327. height: auto !important;
  328. }
  329. &:last-child {
  330. margin-bottom: 0;
  331. }
  332. }
  333. }
  334. }
  335. // Tab 切换区域
  336. .tab-section {
  337. border-radius: 24rpx 24rpx 0 0;
  338. padding: 0 40rpx;
  339. .tab-wrapper {
  340. display: flex;
  341. border-bottom: 1rpx solid #f0f0f0;
  342. .tab-item {
  343. flex: 1;
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. padding: 32rpx 0;
  348. position: relative;
  349. .tab-text {
  350. font-size: 28rpx;
  351. color: #999999;
  352. font-weight: 500;
  353. }
  354. &.active .tab-text {
  355. color: #333333;
  356. font-weight: 600;
  357. }
  358. .tab-indicator {
  359. position: absolute;
  360. bottom: 0;
  361. width: 60rpx;
  362. height: 4rpx;
  363. background: linear-gradient(90deg, #4A90E2 0%, #6FB3F2 100%);
  364. border-radius: 2rpx;
  365. }
  366. }
  367. }
  368. }
  369. // 产品列表
  370. .product-list {
  371. padding: 24rpx 40rpx;
  372. .product-item {
  373. display: flex;
  374. padding: 24rpx 0;
  375. border-bottom: 1rpx solid #f0f0f0;
  376. &:last-child {
  377. border-bottom: none;
  378. }
  379. .product-image {
  380. width: 160rpx;
  381. height: 160rpx;
  382. border-radius: 12rpx;
  383. background: #f5f5f5;
  384. flex-shrink: 0;
  385. margin-right: 24rpx;
  386. }
  387. .product-info {
  388. flex: 1;
  389. display: flex;
  390. flex-direction: column;
  391. justify-content: center;
  392. .product-title {
  393. font-size: 28rpx;
  394. color: #333333;
  395. margin-bottom: 12rpx;
  396. line-height: 1.5;
  397. }
  398. .product-desc {
  399. font-size: 24rpx;
  400. color: #999999;
  401. }
  402. }
  403. }
  404. }
  405. </style>