card.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="130"
  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. <view class="company-section">
  49. <view class="company-title">
  50. 企业简介
  51. </view>
  52. <rich-text class="company-text" :nodes="companyInfo.introduce"></rich-text>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script setup>
  58. import {
  59. ref,
  60. onMounted
  61. } from 'vue'
  62. import NavBar from '@/components/nav-bar/index.vue'
  63. import UserAvatar from '@/components/user-avatar/index.vue'
  64. import EmptyState from '@/components/empty-state/index.vue'
  65. import ShareButton from '@/components/shareButton/index.vue'
  66. import {
  67. useUserStore
  68. } from '@/store/modules/user.js'
  69. import {
  70. storeToRefs
  71. } from 'pinia'
  72. import {
  73. onShareAppMessage
  74. } from '@dcloudio/uni-app';
  75. // 使用 Pinia 管理用户状态
  76. const userStore = useUserStore()
  77. const {
  78. cardInfo,
  79. companyInfo,
  80. cardImage
  81. } = storeToRefs(userStore)
  82. onShareAppMessage(() => {
  83. return {
  84. userName: '小程序',
  85. path: 'pages/splash/splash?userId=' + cardInfo.value.userId,
  86. imageUrl: cardImage.value
  87. };
  88. });
  89. let appName = ref('')
  90. const makeCall = () => {
  91. if (cardInfo.value.phonenumber) {
  92. uni.makePhoneCall({
  93. phoneNumber: cardInfo.value.phonenumber
  94. })
  95. } else {
  96. uni.showToast({
  97. title: '暂无电话号码',
  98. icon: 'none'
  99. })
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .card-container {
  105. background: #f5f6f8;
  106. }
  107. .left-title {
  108. font-size: 44rpx;
  109. font-weight: bold;
  110. color: #ffffff;
  111. text-shadow: 2px 2px 0 black;
  112. }
  113. .top-bg {
  114. width: 750rpx;
  115. height: 634rpx;
  116. position: fixed;
  117. top: 0;
  118. left: 0;
  119. z-index: 1;
  120. }
  121. // 顶部背景区域
  122. .header-bg {
  123. background: linear-gradient(135deg, #4A90E2 0%, #6FB3F2 50%, #87CEEB 100%);
  124. padding: 0 40rpx;
  125. padding-top: calc(var(--status-bar-height) + 20rpx);
  126. padding-bottom: 60rpx;
  127. position: relative;
  128. overflow: hidden;
  129. // 背景光效
  130. &::before {
  131. content: '';
  132. position: absolute;
  133. top: -100rpx;
  134. right: -100rpx;
  135. width: 500rpx;
  136. height: 500rpx;
  137. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  138. border-radius: 50%;
  139. }
  140. // 导航栏
  141. .nav-bar {
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. height: 88rpx;
  146. position: relative;
  147. z-index: 10;
  148. .nav-back {
  149. width: 60rpx;
  150. height: 60rpx;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. }
  155. .nav-title {
  156. font-size: 32rpx;
  157. font-weight: 600;
  158. color: #ffffff;
  159. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  160. }
  161. .nav-right {
  162. display: flex;
  163. align-items: center;
  164. .more-btn,
  165. .refresh-btn {
  166. width: 64rpx;
  167. height: 64rpx;
  168. border-radius: 50%;
  169. background: rgba(255, 255, 255, 0.15);
  170. display: flex;
  171. align-items: center;
  172. justify-content: center;
  173. margin-left: 16rpx;
  174. }
  175. }
  176. }
  177. }
  178. .page-top {
  179. margin: 0 24rpx 24rpx;
  180. .user-card {
  181. position: relative;
  182. z-index: 2;
  183. width: 100%;
  184. height: 400rpx;
  185. box-sizing: border-box;
  186. padding: 80rpx 40rpx 32rpx;
  187. position: relative;
  188. .user-card-bg {
  189. position: absolute;
  190. top: 0;
  191. left: 0;
  192. width: 100%;
  193. height: 100%;
  194. z-index: 0;
  195. }
  196. view,
  197. text {
  198. position: relative;
  199. z-index: 1;
  200. }
  201. .user-header {
  202. .name-row {
  203. display: flex;
  204. align-items: center;
  205. margin-bottom: 16rpx;
  206. .user-name {
  207. font-size: 44rpx;
  208. font-weight: 700;
  209. color: #202020;
  210. line-height: 1.2;
  211. }
  212. .user-role {
  213. margin-left: 16rpx;
  214. padding: 6rpx 16rpx;
  215. background: rgba(68, 110, 255, 0.10);
  216. border-radius: 8rpx;
  217. font-size: 24rpx;
  218. font-weight: 500;
  219. color: #446eff;
  220. }
  221. }
  222. .company-name {
  223. font-size: 28rpx;
  224. font-weight: 500;
  225. color: #666666;
  226. line-height: 1.4;
  227. }
  228. }
  229. .avatar-wrapper {
  230. position: absolute;
  231. top: 32rpx;
  232. right: 36rpx;
  233. z-index: 2;
  234. }
  235. .user-contact {
  236. margin-top: 32rpx;
  237. .contact-row {
  238. display: flex;
  239. align-items: center;
  240. margin-bottom: 16rpx;
  241. uni-icons {
  242. margin-right: 12rpx;
  243. flex-shrink: 0;
  244. }
  245. .contact-text {
  246. font-size: 26rpx;
  247. color: #666666;
  248. }
  249. }
  250. }
  251. }
  252. }
  253. // 名片内容区域
  254. .card-content {
  255. margin: 0 24rpx;
  256. padding: 20rpx 40rpx;
  257. border-radius: 24rpx;
  258. background: #ffffff;
  259. box-shadow: 0 -2rpx 12rpx rgba(0, 0, 0, 0.04);
  260. position: relative;
  261. bottom: 24rpx;
  262. z-index: 2;
  263. // 企业简介
  264. .company-section {
  265. background: #ffffff;
  266. .company-title {
  267. font-weight: bold;
  268. font-size: 32rpx;
  269. margin-bottom: 12rpx;
  270. }
  271. .company-text {
  272. display: block;
  273. font-size: 28rpx;
  274. color: #666666;
  275. line-height: 1.8;
  276. margin-bottom: 24rpx;
  277. ::v-deep img {
  278. max-width: 100% !important;
  279. height: auto !important;
  280. }
  281. &:last-child {
  282. margin-bottom: 0;
  283. }
  284. }
  285. }
  286. }
  287. </style>