userCard.vue 10 KB

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