userCard.vue 10 KB

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