card.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="card-container">
  3. <!-- 顶部背景 -->
  4. <image class="top-bg" src="/static/image/home/top-bg.png" />
  5. <NavBar :title="'我的名片'" color="#fff" :fixed="true" :bgImg="'/static/image/home/top-bg.png'" :bg="'transparent'">
  6. <template #left>
  7. <!-- <view class="left-title">{{appName}}</view> -->
  8. </template>
  9. </NavBar>
  10. <!-- 名片卡片 -->
  11. <view class="page-top">
  12. <UserCard :info="cardInfo" @call="makeCall" />
  13. <ShareButton />
  14. </view>
  15. <view class="card-content" >
  16. <!-- 企业简介 -->
  17. <CompanyIntroduce></CompanyIntroduce>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup>
  22. import {
  23. ref,
  24. onMounted
  25. } from 'vue'
  26. import NavBar from '@/components/nav-bar/index.vue'
  27. import UserAvatar from '@/components/user-avatar/index.vue'
  28. import EmptyState from '@/components/empty-state/index.vue'
  29. import ShareButton from '@/components/shareButton/index.vue'
  30. import CompanyIntroduce from '@/components/companyIntroduce/index.vue'
  31. import UserCard from '@/components/user-card/index.vue'
  32. import {
  33. useUserStore
  34. } from '@/store/modules/user.js'
  35. import {
  36. storeToRefs
  37. } from 'pinia'
  38. import {
  39. onShareAppMessage
  40. } from '@dcloudio/uni-app';
  41. // 使用 Pinia 管理用户状态
  42. const userStore = useUserStore()
  43. const {
  44. cardInfo,
  45. companyInfo,
  46. cardImage
  47. } = storeToRefs(userStore)
  48. onShareAppMessage(() => {
  49. return {
  50. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  51. imageUrl: cardImage.value,
  52. title:`${cardInfo.value.nickName} 向你分享了名片`
  53. };
  54. });
  55. let appName = ref('')
  56. // 入场动画
  57. const pageIn = ref(false)
  58. onMounted(() => {
  59. pageIn.value = true
  60. })
  61. const makeCall = () => {
  62. if (cardInfo.value.phonenumber) {
  63. uni.makePhoneCall({
  64. phoneNumber: cardInfo.value.phonenumber
  65. })
  66. } else {
  67. uni.showToast({
  68. title: '暂无电话号码',
  69. icon: 'none'
  70. })
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .card-container {
  76. background: #f5f6f8;
  77. }
  78. .left-title {
  79. font-size: 44rpx;
  80. font-weight: bold;
  81. color: #ffffff;
  82. text-shadow: 2px 2px 0 black;
  83. }
  84. .top-bg {
  85. width: 100%;
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. z-index: 1;
  90. }
  91. // 顶部背景区域
  92. .header-bg {
  93. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  94. padding: 0 40rpx;
  95. padding-top: calc(var(--status-bar-height) + 20rpx);
  96. padding-bottom: 60rpx;
  97. position: relative;
  98. overflow: hidden;
  99. // 背景光效
  100. &::before {
  101. content: '';
  102. position: absolute;
  103. top: -100rpx;
  104. right: -100rpx;
  105. width: 500rpx;
  106. height: 500rpx;
  107. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  108. border-radius: 50%;
  109. }
  110. // 导航栏
  111. .nav-bar {
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. height: 88rpx;
  116. position: relative;
  117. z-index: 10;
  118. .nav-back {
  119. width: 60rpx;
  120. height: 60rpx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: center;
  124. }
  125. .nav-title {
  126. font-size: 32rpx;
  127. font-weight: 600;
  128. color: #ffffff;
  129. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  130. }
  131. .nav-right {
  132. display: flex;
  133. align-items: center;
  134. .more-btn,
  135. .refresh-btn {
  136. width: 64rpx;
  137. height: 64rpx;
  138. border-radius: 50%;
  139. background: rgba(255, 255, 255, 0.15);
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. margin-left: 16rpx;
  144. }
  145. }
  146. }
  147. }
  148. .page-top {
  149. margin: 0 24rpx 24rpx;
  150. position: relative;
  151. z-index: 2;
  152. }
  153. // 名片内容区域
  154. .card-content {
  155. margin: 0 24rpx;
  156. padding: 20rpx 40rpx;
  157. border-radius: 24rpx;
  158. background: #ffffff;
  159. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  160. position: relative;
  161. bottom: 24rpx;
  162. z-index: 2;
  163. }
  164. </style>