index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <view class="mine-container">
  3. <image class="top-bg" src="/static/image/home/top-bg.png" />
  4. <!-- 顶部背景区域 -->
  5. <view class="header-bg">
  6. <NavBar title="" color="#020202" :fixed="true" :bg="'transparent'">
  7. <template #left>
  8. <view class="left-title"></view>
  9. </template>
  10. </NavBar>
  11. <!-- 用户信息 -->
  12. <view class="user-info-section">
  13. <view class="avatar-wrapper">
  14. <UserAvatar :src="cardInfo.avatar" :name="cardInfo.nickName" :size="136"
  15. :badge-src="'/static/image/public/badge-icon.png'" :badge-size="52" />
  16. </view>
  17. <view class="user-details">
  18. <view class="name-row">
  19. <text class="user-name">{{ cardInfo.nickName || '用户' }}</text>
  20. <text class="user-role">{{ cardInfo.jobTitle || '职位' }}</text>
  21. </view>
  22. <text class="company-name">{{ cardInfo.companyName || '公司名称' }}</text>
  23. </view>
  24. <view class="qr-btn" @click="showCard">
  25. <image class="qr-icon" src="/static/image/public/qr-icon.png" />
  26. <text class="qr-text">我的名片</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 内容区域 -->
  31. <view class="content-section">
  32. <!-- 线索数据卡片 -->
  33. <view class="data-card" v-if="false">
  34. <view class="card-header">
  35. <text class="card-title">线索数据</text>
  36. </view>
  37. <view class="data-row">
  38. <view class="data-item">
  39. <text class="data-value">{{ statisticsData.clueTotal.toLocaleString() }}</text>
  40. <text class="data-label">线索总数</text>
  41. </view>
  42. <view class="data-item highlight">
  43. <text class="data-value orange">{{ statisticsData.clueNewThisMonth.toLocaleString() }}</text>
  44. <text class="data-label">本月新增</text>
  45. </view>
  46. <view class="data-item">
  47. <text class="data-value">{{ statisticsData.clueMine.toLocaleString() }}</text>
  48. <text class="data-label">我的线索</text>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 客户数据卡片 -->
  53. <view class="data-card" v-if="false">
  54. <view class="card-header">
  55. <text class="card-title">客户数据</text>
  56. <uni-icons type="eye" size="20" color="#999999"></uni-icons>
  57. </view>
  58. <view class="data-row">
  59. <view class="data-item">
  60. <text class="data-value">{{ statisticsData.customerTotal.toLocaleString() }}</text>
  61. <text class="data-label">客户总数</text>
  62. </view>
  63. <view class="data-item highlight">
  64. <text class="data-value orange">{{ statisticsData.customerNewThisMonth.toLocaleString()
  65. }}</text>
  66. <text class="data-label">本月新增</text>
  67. </view>
  68. <view class="data-item">
  69. <text class="data-value">{{ statisticsData.customerMine.toLocaleString() }}</text>
  70. <text class="data-label">我的客户</text>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 商机数据卡片 -->
  75. <view class="data-card" v-if="false">
  76. <view class="card-header">
  77. <text class="card-title">商机数据</text>
  78. <uni-icons type="eye" size="20" color="#999999"></uni-icons>
  79. </view>
  80. <view class="data-row">
  81. <view class="data-item">
  82. <text class="data-value">{{ statisticsData.opportunityTotal.toLocaleString() }}</text>
  83. <text class="data-label">商机总数</text>
  84. </view>
  85. <view class="data-item highlight">
  86. <text class="data-value orange">{{ statisticsData.opportunityNewThisMonth.toLocaleString()
  87. }}</text>
  88. <text class="data-label">本月新增</text>
  89. </view>
  90. <view class="data-item">
  91. <text class="data-value">{{ statisticsData.opportunityMine.toLocaleString() }}</text>
  92. <text class="data-label">我的商机</text>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 功能菜单卡片 -->
  97. <view class="menu-card">
  98. <view class="menu-item" @click="navigateTo('guide')">
  99. <view class="menu-icon-wrapper icon-blue">
  100. <uni-icons type="help" size="24" color="#4A90E2"></uni-icons>
  101. </view>
  102. <text class="menu-text">使用指南</text>
  103. <uni-icons type="right" size="16" color="#cccccc"></uni-icons>
  104. </view>
  105. <view class="menu-divider"></view>
  106. <view class="menu-item" @click="navigateTo('service')">
  107. <view class="menu-icon-wrapper icon-blue">
  108. <uni-icons type="paperclip" size="24" color="#4A90E2"></uni-icons>
  109. </view>
  110. <text class="menu-text">联系客服</text>
  111. <uni-icons type="right" size="16" color="#cccccc"></uni-icons>
  112. </view>
  113. <view class="menu-divider"></view>
  114. <view class="menu-item" @click="navigateTo('about')">
  115. <view class="menu-icon-wrapper icon-blue">
  116. <uni-icons type="gear" size="24" color="#4A90E2"></uni-icons>
  117. </view>
  118. <text class="menu-text">关于我们</text>
  119. <uni-icons type="right" size="16" color="#cccccc"></uni-icons>
  120. </view>
  121. <view class="menu-divider"></view>
  122. <view class="menu-item" @click="logout" style="color: #ff4d4f;">
  123. <view class="menu-icon-wrapper icon-red">
  124. <uni-icons type="close" size="24" color="#ff4d4f"></uni-icons>
  125. </view>
  126. <text class="menu-text">退出登录</text>
  127. <uni-icons type="right" size="16" color="#cccccc"></uni-icons>
  128. </view>
  129. </view>
  130. <!-- 底部占位 -->
  131. <view class="bottom-spacer"></view>
  132. </view>
  133. </view>
  134. </template>
  135. <script setup>
  136. import {
  137. ref,
  138. onMounted
  139. } from 'vue'
  140. import NavBar from '@/components/nav-bar/index.vue'
  141. import UserAvatar from '@/components/user-avatar/index.vue'
  142. import {
  143. useUserStore
  144. } from '@/store/modules/user.js'
  145. import {
  146. storeToRefs
  147. } from 'pinia'
  148. import { clearUserInfo } from '@/utils/userCache.js'
  149. // 使用 Pinia 管理用户状态
  150. const userStore = useUserStore()
  151. const {
  152. cardInfo
  153. } = storeToRefs(userStore)
  154. // 统计数据
  155. const statisticsData = ref({
  156. clueTotal: 0,
  157. clueNewThisMonth: 0,
  158. clueMine: 0,
  159. customerTotal: 0,
  160. customerNewThisMonth: 0,
  161. customerMine: 0,
  162. opportunityTotal: 0,
  163. opportunityNewThisMonth: 0,
  164. opportunityMine: 0
  165. })
  166. onMounted(async () => {
  167. // 如果没有数据,重新获取
  168. if (!cardInfo.value.nickName) {
  169. await userStore.queryCardInfo()
  170. }
  171. // 加载统计数据
  172. loadStatisticsData()
  173. })
  174. // 加载统计数据(后续对接真实 API)
  175. const loadStatisticsData = () => {
  176. // TODO: 调用统计 API 获取真实数据
  177. statisticsData.value = {
  178. clueTotal: 1266,
  179. clueNewThisMonth: 65,
  180. clueMine: 126,
  181. customerTotal: 1088,
  182. customerNewThisMonth: 123,
  183. customerMine: 235,
  184. opportunityTotal: 1366,
  185. opportunityNewThisMonth: 63,
  186. opportunityMine: 86
  187. }
  188. }
  189. const navigateTo = (page) => {
  190. uni.showToast({
  191. title: `功能开发中:${page}`,
  192. icon: 'none'
  193. })
  194. }
  195. // 显示名片
  196. const showCard = () => {
  197. uni.navigateTo({
  198. url: '/pages/mine/card'
  199. })
  200. }
  201. // 退出登录
  202. const logout = () => {
  203. uni.showModal({
  204. title: '提示',
  205. content: '确定要退出登录吗?',
  206. success: (res) => {
  207. if (res.confirm) {
  208. console.log('用户确认退出登录')
  209. // 1. 清除 token(使用统一工具函数)
  210. clearUserInfo()
  211. // 2. 清除 store 中的用户数据
  212. userStore.$reset()
  213. // 3. 清除其他缓存数据
  214. try {
  215. uni.removeStorageSync('userInfo')
  216. uni.removeStorageSync('companyInfo')
  217. } catch (e) {
  218. console.warn('清除额外缓存失败:', e)
  219. }
  220. console.log('已清除所有登录数据')
  221. // 4. 跳转到登录页(先 Toast 再跳转)
  222. uni.showToast({
  223. title: '已退出登录',
  224. icon: 'success'
  225. })
  226. setTimeout(() => {
  227. uni.reLaunch({
  228. url: '/pages/login/login'
  229. })
  230. }, 300)
  231. }
  232. }
  233. })
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .mine-container {
  238. background: #f5f6f8;
  239. }
  240. .top-bg {
  241. width: 750rpx;
  242. height: 634rpx;
  243. position: fixed;
  244. top: 0;
  245. left: 0;
  246. z-index: 1;
  247. }
  248. // 顶部背景区域
  249. .header-bg {
  250. padding: 0 40rpx;
  251. padding-bottom: 200rpx;
  252. position: relative;
  253. overflow: hidden;
  254. // 背景光效
  255. .bg-light {
  256. position: absolute;
  257. border-radius: 50%;
  258. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  259. }
  260. .bg-light-1 {
  261. top: -150rpx;
  262. right: -100rpx;
  263. width: 500rpx;
  264. height: 500rpx;
  265. }
  266. .bg-light-2 {
  267. top: 200rpx;
  268. left: -200rpx;
  269. width: 400rpx;
  270. height: 400rpx;
  271. }
  272. // 顶部状态栏
  273. .header-top {
  274. display: flex;
  275. justify-content: space-between;
  276. align-items: center;
  277. margin-bottom: 60rpx;
  278. position: relative;
  279. z-index: 10;
  280. .header-left {
  281. width: 100rpx;
  282. }
  283. .header-right {
  284. display: flex;
  285. align-items: center;
  286. .more-btn,
  287. .refresh-btn {
  288. width: 64rpx;
  289. height: 64rpx;
  290. border-radius: 50%;
  291. background: rgba(255, 255, 255, 0.15);
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. margin-left: 16rpx;
  296. }
  297. }
  298. }
  299. // 用户信息区域
  300. .user-info-section {
  301. display: flex;
  302. align-items: center;
  303. position: relative;
  304. z-index: 10;
  305. .avatar-wrapper {
  306. position: relative;
  307. margin-right: 24rpx;
  308. flex-shrink: 0;
  309. }
  310. .user-details {
  311. flex: 1;
  312. .name-row {
  313. display: flex;
  314. align-items: center;
  315. margin-bottom: 12rpx;
  316. .user-name {
  317. font-size: 36rpx;
  318. font-weight: 600;
  319. color: #ffffff;
  320. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  321. }
  322. .user-role {
  323. font-size: 22rpx;
  324. color: #ffffff;
  325. background: rgba(255, 255, 255, 0.25);
  326. padding: 4rpx 16rpx;
  327. border-radius: 20rpx;
  328. margin-left: 16rpx;
  329. font-weight: 500;
  330. }
  331. }
  332. .company-name {
  333. font-size: 24rpx;
  334. color: rgba(255, 255, 255, 0.85);
  335. display: block;
  336. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  337. }
  338. }
  339. .qr-btn {
  340. display: flex;
  341. flex-direction: column;
  342. align-items: center;
  343. justify-content: center;
  344. .qr-icon {
  345. width: 48rpx;
  346. height: 48rpx;
  347. }
  348. .qr-text {
  349. font-size: 20rpx;
  350. color: #ffffff;
  351. margin-top: 4rpx;
  352. }
  353. }
  354. }
  355. }
  356. // 内容区域
  357. .content-section {
  358. margin-top: -160rpx;
  359. position: relative;
  360. z-index: 20;
  361. padding: 0 40rpx;
  362. }
  363. // 数据卡片
  364. .data-card {
  365. background: #ffffff;
  366. margin-bottom: 24rpx;
  367. padding: 32rpx;
  368. border-radius: 24rpx;
  369. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  370. .card-header {
  371. display: flex;
  372. justify-content: space-between;
  373. align-items: center;
  374. margin-bottom: 24rpx;
  375. }
  376. .card-title {
  377. font-size: 28rpx;
  378. font-weight: 600;
  379. color: #333333;
  380. }
  381. .data-row {
  382. display: flex;
  383. justify-content: space-between;
  384. .data-item {
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. flex: 1;
  389. position: relative;
  390. .data-value {
  391. font-size: 40rpx;
  392. font-weight: 600;
  393. color: #333333;
  394. margin-bottom: 12rpx;
  395. font-family: DIN, 'DIN Alternate', sans-serif;
  396. }
  397. .data-label {
  398. font-size: 24rpx;
  399. color: #999999;
  400. }
  401. &.highlight .data-value {
  402. color: #ff6b35;
  403. }
  404. &:not(:last-child)::after {
  405. content: '';
  406. position: absolute;
  407. right: 0;
  408. top: 50%;
  409. transform: translateY(-50%);
  410. width: 1rpx;
  411. height: 60rpx;
  412. background: #f0f0f0;
  413. }
  414. }
  415. }
  416. }
  417. // 功能菜单卡片
  418. .menu-card {
  419. background: #ffffff;
  420. padding: 0 32rpx;
  421. border-radius: 24rpx;
  422. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  423. .menu-item {
  424. display: flex;
  425. align-items: center;
  426. padding: 32rpx 0;
  427. .menu-icon-wrapper {
  428. width: 64rpx;
  429. height: 64rpx;
  430. border-radius: 16rpx;
  431. display: flex;
  432. align-items: center;
  433. justify-content: center;
  434. margin-right: 20rpx;
  435. &.icon-blue {
  436. background: rgba(74, 144, 226, 0.1);
  437. }
  438. &.icon-red {
  439. background: rgba(255, 77, 79, 0.1);
  440. }
  441. }
  442. .menu-text {
  443. flex: 1;
  444. font-size: 28rpx;
  445. color: #333333;
  446. }
  447. }
  448. .menu-divider {
  449. height: 1rpx;
  450. background: #f0f0f0;
  451. }
  452. }
  453. // 底部占位
  454. .bottom-spacer {
  455. height: 40rpx;
  456. }
  457. </style>