userCard.vue 10 KB

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