card.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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" :bg="'transparent'">
  6. <template #left>
  7. <!-- <view class="left-title">{{appName}}</view> -->
  8. </template>
  9. </NavBar>
  10. <!-- 名片卡片 -->
  11. <view class="page-top">
  12. <view class="user-card" id="user-card">
  13. <!-- 背景图 -->
  14. <image class="user-card-bg" src="/static/image/home/usecard-bg.png" />
  15. <!-- 左上:姓名 + 职位 -->
  16. <view class="user-header">
  17. <view class="name-row">
  18. <text class="user-name">{{ cardInfo.nickName || '用户' }}</text>
  19. <text class="user-role">{{ cardInfo.postName || '职位' }}</text>
  20. </view>
  21. <text class="company-name">{{ cardInfo.companyName || '公司名称' }}</text>
  22. </view>
  23. <!-- 右上:头像 -->
  24. <view class="avatar-wrapper">
  25. <UserAvatar :src="cardInfo.avatar" :name="cardInfo.nickName" :size="142"
  26. :badge-src="'/static/image/public/badge-icon.png'" :badge-size="56" />
  27. </view>
  28. <!-- 左下:联系方式 -->
  29. <view class="user-contact">
  30. <view class="contact-row" @click="makeCall">
  31. <uni-icons type="phone" :size="18" color="#666666"></uni-icons>
  32. <text class="contact-text">{{ cardInfo.phonenumber || '暂无电话' }}</text>
  33. </view>
  34. <view class="contact-row">
  35. <uni-icons type="email" :size="18" color="#666666"></uni-icons>
  36. <text class="contact-text">{{ cardInfo.email || '暂无邮箱' }}</text>
  37. </view>
  38. <view class="contact-row">
  39. <uni-icons type="location" :size="18" color="#666666"></uni-icons>
  40. <text class="contact-text">{{ cardInfo.companyAddress || '暂无地址' }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <ShareButton />
  45. </view>
  46. <view class="card-content">
  47. <!-- 企业简介 -->
  48. <CompanyIntroduce></CompanyIntroduce>
  49. </view>
  50. </view>
  51. </template>
  52. <script setup>
  53. import {
  54. ref,
  55. onMounted
  56. } from 'vue'
  57. import NavBar from '@/components/nav-bar/index.vue'
  58. import UserAvatar from '@/components/user-avatar/index.vue'
  59. import EmptyState from '@/components/empty-state/index.vue'
  60. import ShareButton from '@/components/shareButton/index.vue'
  61. import CompanyIntroduce from '@/components/companyIntroduce/index.vue'
  62. import {
  63. useUserStore
  64. } from '@/store/modules/user.js'
  65. import {
  66. storeToRefs
  67. } from 'pinia'
  68. import {
  69. onShareAppMessage
  70. } from '@dcloudio/uni-app';
  71. // 使用 Pinia 管理用户状态
  72. const userStore = useUserStore()
  73. const {
  74. cardInfo,
  75. companyInfo,
  76. cardImage
  77. } = storeToRefs(userStore)
  78. onShareAppMessage(() => {
  79. return {
  80. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  81. imageUrl: cardImage.value,
  82. title:`${cardInfo.value.nickName} 向你分享了名片`
  83. };
  84. });
  85. let appName = ref('')
  86. const makeCall = () => {
  87. if (cardInfo.value.phonenumber) {
  88. uni.makePhoneCall({
  89. phoneNumber: cardInfo.value.phonenumber
  90. })
  91. } else {
  92. uni.showToast({
  93. title: '暂无电话号码',
  94. icon: 'none'
  95. })
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .card-container {
  101. background: #f5f6f8;
  102. }
  103. .left-title {
  104. font-size: 44rpx;
  105. font-weight: bold;
  106. color: #ffffff;
  107. text-shadow: 2px 2px 0 black;
  108. }
  109. .top-bg {
  110. width: 750rpx;
  111. height: 634rpx;
  112. position: fixed;
  113. top: 0;
  114. left: 0;
  115. z-index: 1;
  116. }
  117. // 顶部背景区域
  118. .header-bg {
  119. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  120. padding: 0 40rpx;
  121. padding-top: calc(var(--status-bar-height) + 20rpx);
  122. padding-bottom: 60rpx;
  123. position: relative;
  124. overflow: hidden;
  125. // 背景光效
  126. &::before {
  127. content: '';
  128. position: absolute;
  129. top: -100rpx;
  130. right: -100rpx;
  131. width: 500rpx;
  132. height: 500rpx;
  133. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  134. border-radius: 50%;
  135. }
  136. // 导航栏
  137. .nav-bar {
  138. display: flex;
  139. align-items: center;
  140. justify-content: space-between;
  141. height: 88rpx;
  142. position: relative;
  143. z-index: 10;
  144. .nav-back {
  145. width: 60rpx;
  146. height: 60rpx;
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. }
  151. .nav-title {
  152. font-size: 32rpx;
  153. font-weight: 600;
  154. color: #ffffff;
  155. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  156. }
  157. .nav-right {
  158. display: flex;
  159. align-items: center;
  160. .more-btn,
  161. .refresh-btn {
  162. width: 64rpx;
  163. height: 64rpx;
  164. border-radius: 50%;
  165. background: rgba(255, 255, 255, 0.15);
  166. display: flex;
  167. align-items: center;
  168. justify-content: center;
  169. margin-left: 16rpx;
  170. }
  171. }
  172. }
  173. }
  174. .page-top {
  175. margin: 0 24rpx 24rpx;
  176. .user-card {
  177. position: relative;
  178. z-index: 2;
  179. width: 100%;
  180. height: 400rpx;
  181. box-sizing: border-box;
  182. padding: 80rpx 40rpx 32rpx;
  183. position: relative;
  184. .user-card-bg {
  185. position: absolute;
  186. top: 0;
  187. left: 0;
  188. width: 100%;
  189. height: 100%;
  190. z-index: 0;
  191. }
  192. view,
  193. text {
  194. position: relative;
  195. z-index: 1;
  196. }
  197. .user-header {
  198. .name-row {
  199. display: flex;
  200. align-items: center;
  201. margin-bottom: 16rpx;
  202. .user-name {
  203. font-size: 44rpx;
  204. font-weight: 700;
  205. color: #202020;
  206. line-height: 1.2;
  207. }
  208. .user-role {
  209. margin-left: 16rpx;
  210. padding: 6rpx 16rpx;
  211. background: rgba(68, 110, 255, 0.10);
  212. border-radius: 8rpx;
  213. font-size: 24rpx;
  214. font-weight: 500;
  215. color: #446eff;
  216. }
  217. }
  218. .company-name {
  219. font-size: 28rpx;
  220. font-weight: 500;
  221. color: #666666;
  222. line-height: 1.4;
  223. }
  224. }
  225. .avatar-wrapper {
  226. position: absolute;
  227. top: 74rpx;
  228. right: 36rpx;
  229. z-index: 2;
  230. }
  231. .user-contact {
  232. margin-top: 32rpx;
  233. .contact-row {
  234. display: flex;
  235. align-items: center;
  236. margin-bottom: 16rpx;
  237. uni-icons {
  238. margin-right: 12rpx;
  239. flex-shrink: 0;
  240. }
  241. .contact-text {
  242. font-size: 26rpx;
  243. color: #666666;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. // 名片内容区域
  250. .card-content {
  251. margin: 0 24rpx;
  252. padding: 20rpx 40rpx;
  253. border-radius: 24rpx;
  254. background: #ffffff;
  255. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  256. position: relative;
  257. bottom: 24rpx;
  258. z-index: 2;
  259. }
  260. </style>