userCard.vue 9.9 KB

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