userCard.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. <image class="avatar" :src="cardInfo.avatar || '/static/image/public/avatar-default.png'" />
  22. <image class="badge-icon" src="/static/image/public/badge-icon.png" />
  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 class="control-card">
  41. <view class="item">
  42. <image src="/static/image/public/card-sharing.png"></image>
  43. <text>分享名片</text>
  44. </view>
  45. <view class="item">
  46. <image src="/static/image/public/card-save.png"></image>
  47. <text>保存名片</text>
  48. </view>
  49. <view class="item">
  50. <image src="/static/image/public/card-qr.png"></image>
  51. <text>名片码</text>
  52. </view>
  53. </view> -->
  54. </view>
  55. <view class="card-content">
  56. <!-- Tab 切换 -->
  57. <view class="tab-section">
  58. <view class="tab-wrapper">
  59. <view class="tab-item" :class="{ active: currentTab === 'products' }"
  60. @click="switchTab('products')">
  61. <text class="tab-text">产品列表</text>
  62. <view class="tab-indicator" v-if="currentTab === 'products'"></view>
  63. </view>
  64. <view class="tab-item" :class="{ active: currentTab === 'company' }" @click="switchTab('company')">
  65. <text class="tab-text">企业简介</text>
  66. <view class="tab-indicator" v-if="currentTab === 'company'"></view>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 产品列表 -->
  71. <view class="product-list" v-if="currentTab === 'products'">
  72. <view class="product-item" v-for="(item, index) in productList" :key="index">
  73. <image class="product-image" :src="item.image" mode="aspectFill" />
  74. <view class="product-info">
  75. <text class="product-title">{{ item.title }}</text>
  76. <text class="product-desc">{{ item.description }}</text>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 企业简介 -->
  81. <view class="company-section" v-if="currentTab === 'company'">
  82. <view class="company-content">
  83. <rich-text class="company-text" :nodes="companyInfo.introduce"></rich-text>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script setup>
  90. import {
  91. ref,
  92. onMounted
  93. } from 'vue'
  94. import NavBar from '@/components/nav-bar/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: 40rpx;
  280. width: 140rpx;
  281. height: 140rpx;
  282. border-radius: 50%;
  283. box-shadow: 0rpx 0rpx 4rpx 0rpx rgba(21, 93, 252, 0.20);
  284. .avatar {
  285. width: 100%;
  286. height: 100%;
  287. }
  288. .badge-icon {
  289. width: 64rpx;
  290. height: 64rpx;
  291. position: absolute;
  292. bottom: 0;
  293. right: 0;
  294. transform: translate(50% 50%);
  295. z-index: 1;
  296. }
  297. }
  298. .user-contact {
  299. margin-top: 32rpx;
  300. .contact-row {
  301. display: flex;
  302. align-items: center;
  303. margin-bottom: 16rpx;
  304. uni-icons {
  305. margin-right: 12rpx;
  306. flex-shrink: 0;
  307. }
  308. .contact-text {
  309. font-size: 26rpx;
  310. color: #666666;
  311. }
  312. }
  313. }
  314. }
  315. .control-card {
  316. background-color: #fff;
  317. border-radius: 0 0 24rpx 24rpx;
  318. position: relative;
  319. z-index: 1;
  320. bottom: 24rpx;
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-around;
  324. padding-top: 48rpx;
  325. padding-bottom: 24rpx;
  326. .item {
  327. display: flex;
  328. flex-direction: column;
  329. align-items: center;
  330. justify-content: center;
  331. gap: 4rpx;
  332. image {
  333. width: 64rpx;
  334. height: 64rpx;
  335. }
  336. text {
  337. font-size: 26rpx;
  338. color: #202020;
  339. }
  340. }
  341. }
  342. }
  343. // 名片内容区域
  344. .card-content {
  345. margin: 0 24rpx;
  346. padding: 0 24rpx;
  347. border-radius: 24rpx;
  348. background: #ffffff;
  349. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  350. position: relative;
  351. z-index: 2;
  352. }
  353. // Tab 切换区域
  354. .tab-section {
  355. border-radius: 24rpx 24rpx 0 0;
  356. padding: 0 40rpx;
  357. .tab-wrapper {
  358. display: flex;
  359. border-bottom: 1rpx solid #f0f0f0;
  360. .tab-item {
  361. flex: 1;
  362. display: flex;
  363. flex-direction: column;
  364. align-items: center;
  365. padding: 32rpx 0;
  366. position: relative;
  367. .tab-text {
  368. font-size: 28rpx;
  369. color: #999999;
  370. font-weight: 500;
  371. }
  372. &.active .tab-text {
  373. color: #333333;
  374. font-weight: 600;
  375. }
  376. .tab-indicator {
  377. position: absolute;
  378. bottom: 0;
  379. width: 60rpx;
  380. height: 4rpx;
  381. background: linear-gradient(90deg, #4A90E2 0%, #6FB3F2 100%);
  382. border-radius: 2rpx;
  383. }
  384. }
  385. }
  386. }
  387. // 产品列表
  388. .product-list {
  389. padding: 24rpx 40rpx;
  390. .product-item {
  391. display: flex;
  392. padding: 24rpx 0;
  393. border-bottom: 1rpx solid #f0f0f0;
  394. &:last-child {
  395. border-bottom: none;
  396. }
  397. .product-image {
  398. width: 160rpx;
  399. height: 160rpx;
  400. border-radius: 12rpx;
  401. background: #f5f5f5;
  402. flex-shrink: 0;
  403. margin-right: 24rpx;
  404. }
  405. .product-info {
  406. flex: 1;
  407. display: flex;
  408. flex-direction: column;
  409. justify-content: center;
  410. .product-title {
  411. font-size: 28rpx;
  412. color: #333333;
  413. margin-bottom: 12rpx;
  414. line-height: 1.5;
  415. }
  416. .product-desc {
  417. font-size: 24rpx;
  418. color: #999999;
  419. }
  420. }
  421. }
  422. }
  423. // 企业简介
  424. .company-section {
  425. background: #ffffff;
  426. padding: 40rpx;
  427. .company-content {
  428. .company-text {
  429. display: block;
  430. font-size: 28rpx;
  431. color: #666666;
  432. line-height: 1.8;
  433. margin-bottom: 24rpx;
  434. ::v-deep img {
  435. max-width: 100% !important;
  436. }
  437. &:last-child {
  438. margin-bottom: 0;
  439. }
  440. }
  441. }
  442. }
  443. </style>