index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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.postName || '职位' }}</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. companyInfo
  154. } = storeToRefs(userStore)
  155. // 统计数据
  156. const statisticsData = ref({
  157. clueTotal: 0,
  158. clueNewThisMonth: 0,
  159. clueMine: 0,
  160. customerTotal: 0,
  161. customerNewThisMonth: 0,
  162. customerMine: 0,
  163. opportunityTotal: 0,
  164. opportunityNewThisMonth: 0,
  165. opportunityMine: 0
  166. })
  167. onMounted(async () => {
  168. // 如果没有数据,重新获取
  169. if (!cardInfo.value.nickName) {
  170. await userStore.queryCardInfo()
  171. }
  172. if (!companyInfo.value.name) {
  173. await userStore.queryCompanyInfo()
  174. }
  175. // 加载统计数据
  176. loadStatisticsData()
  177. })
  178. // 加载统计数据(后续对接真实 API)
  179. const loadStatisticsData = () => {
  180. // TODO: 调用统计 API 获取真实数据
  181. statisticsData.value = {
  182. clueTotal: 1266,
  183. clueNewThisMonth: 65,
  184. clueMine: 126,
  185. customerTotal: 1088,
  186. customerNewThisMonth: 123,
  187. customerMine: 235,
  188. opportunityTotal: 1366,
  189. opportunityNewThisMonth: 63,
  190. opportunityMine: 86
  191. }
  192. }
  193. const navigateTo = (page) => {
  194. uni.showToast({
  195. title: `功能开发中:${page}`,
  196. icon: 'none'
  197. })
  198. }
  199. // 显示名片
  200. const showCard = () => {
  201. uni.navigateTo({
  202. url: '/pages/mine/card'
  203. })
  204. }
  205. // 退出登录
  206. const logout = () => {
  207. uni.showModal({
  208. title: '提示',
  209. content: '确定要退出登录吗?',
  210. success: (res) => {
  211. if (res.confirm) {
  212. console.log('用户确认退出登录')
  213. // 1. 清除 token(使用统一工具函数)
  214. clearUserInfo()
  215. // 2. 清除 store 中的用户数据
  216. userStore.$reset()
  217. // 3. 清除其他缓存数据
  218. try {
  219. uni.removeStorageSync('userInfo')
  220. uni.removeStorageSync('companyInfo')
  221. } catch (e) {
  222. console.warn('清除额外缓存失败:', e)
  223. }
  224. console.log('已清除所有登录数据')
  225. // 4. 跳转到登录页(先 Toast 再跳转)
  226. uni.showToast({
  227. title: '已退出登录',
  228. icon: 'success'
  229. })
  230. setTimeout(() => {
  231. uni.reLaunch({
  232. url: '/pages/login/login'
  233. })
  234. }, 300)
  235. }
  236. }
  237. })
  238. }
  239. </script>
  240. <style lang="scss" scoped>
  241. .mine-container {
  242. background: #f5f6f8;
  243. }
  244. .top-bg {
  245. width: 750rpx;
  246. height: 634rpx;
  247. position: fixed;
  248. top: 0;
  249. left: 0;
  250. z-index: 1;
  251. }
  252. // 顶部背景区域
  253. .header-bg {
  254. padding: 0 40rpx;
  255. padding-bottom: 200rpx;
  256. position: relative;
  257. overflow: hidden;
  258. // 背景光效
  259. .bg-light {
  260. position: absolute;
  261. border-radius: 50%;
  262. background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
  263. }
  264. .bg-light-1 {
  265. top: -150rpx;
  266. right: -100rpx;
  267. width: 500rpx;
  268. height: 500rpx;
  269. }
  270. .bg-light-2 {
  271. top: 200rpx;
  272. left: -200rpx;
  273. width: 400rpx;
  274. height: 400rpx;
  275. }
  276. // 顶部状态栏
  277. .header-top {
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. margin-bottom: 60rpx;
  282. position: relative;
  283. z-index: 10;
  284. .header-left {
  285. width: 100rpx;
  286. }
  287. .header-right {
  288. display: flex;
  289. align-items: center;
  290. .more-btn,
  291. .refresh-btn {
  292. width: 64rpx;
  293. height: 64rpx;
  294. border-radius: 50%;
  295. background: rgba(255, 255, 255, 0.15);
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. margin-left: 16rpx;
  300. }
  301. }
  302. }
  303. // 用户信息区域
  304. .user-info-section {
  305. display: flex;
  306. align-items: center;
  307. position: relative;
  308. z-index: 10;
  309. .avatar-wrapper {
  310. position: relative;
  311. margin-right: 24rpx;
  312. flex-shrink: 0;
  313. }
  314. .user-details {
  315. flex: 1;
  316. .name-row {
  317. display: flex;
  318. align-items: center;
  319. margin-bottom: 12rpx;
  320. .user-name {
  321. font-size: 36rpx;
  322. font-weight: 600;
  323. color: #ffffff;
  324. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  325. }
  326. .user-role {
  327. font-size: 22rpx;
  328. color: #ffffff;
  329. background: rgba(255, 255, 255, 0.25);
  330. padding: 4rpx 16rpx;
  331. border-radius: 20rpx;
  332. margin-left: 16rpx;
  333. font-weight: 500;
  334. }
  335. }
  336. .company-name {
  337. font-size: 24rpx;
  338. color: rgba(255, 255, 255, 0.85);
  339. display: block;
  340. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  341. }
  342. }
  343. .qr-btn {
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. justify-content: center;
  348. .qr-icon {
  349. width: 48rpx;
  350. height: 48rpx;
  351. }
  352. .qr-text {
  353. font-size: 20rpx;
  354. color: #ffffff;
  355. margin-top: 4rpx;
  356. }
  357. }
  358. }
  359. }
  360. // 内容区域
  361. .content-section {
  362. margin-top: -160rpx;
  363. position: relative;
  364. z-index: 20;
  365. padding: 0 40rpx;
  366. }
  367. // 数据卡片
  368. .data-card {
  369. background: #ffffff;
  370. margin-bottom: 24rpx;
  371. padding: 32rpx;
  372. border-radius: 24rpx;
  373. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  374. .card-header {
  375. display: flex;
  376. justify-content: space-between;
  377. align-items: center;
  378. margin-bottom: 24rpx;
  379. }
  380. .card-title {
  381. font-size: 28rpx;
  382. font-weight: 600;
  383. color: #333333;
  384. }
  385. .data-row {
  386. display: flex;
  387. justify-content: space-between;
  388. .data-item {
  389. display: flex;
  390. flex-direction: column;
  391. align-items: center;
  392. flex: 1;
  393. position: relative;
  394. .data-value {
  395. font-size: 40rpx;
  396. font-weight: 600;
  397. color: #333333;
  398. margin-bottom: 12rpx;
  399. font-family: DIN, 'DIN Alternate', sans-serif;
  400. }
  401. .data-label {
  402. font-size: 24rpx;
  403. color: #999999;
  404. }
  405. &.highlight .data-value {
  406. color: #ff6b35;
  407. }
  408. &:not(:last-child)::after {
  409. content: '';
  410. position: absolute;
  411. right: 0;
  412. top: 50%;
  413. transform: translateY(-50%);
  414. width: 1rpx;
  415. height: 60rpx;
  416. background: #f0f0f0;
  417. }
  418. }
  419. }
  420. }
  421. // 功能菜单卡片
  422. .menu-card {
  423. background: #ffffff;
  424. padding: 0 32rpx;
  425. border-radius: 24rpx;
  426. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  427. .menu-item {
  428. display: flex;
  429. align-items: center;
  430. padding: 32rpx 0;
  431. .menu-icon-wrapper {
  432. width: 64rpx;
  433. height: 64rpx;
  434. border-radius: 16rpx;
  435. display: flex;
  436. align-items: center;
  437. justify-content: center;
  438. margin-right: 20rpx;
  439. &.icon-blue {
  440. background: rgba(74, 144, 226, 0.1);
  441. }
  442. &.icon-red {
  443. background: rgba(255, 77, 79, 0.1);
  444. }
  445. }
  446. .menu-text {
  447. flex: 1;
  448. font-size: 28rpx;
  449. color: #333333;
  450. }
  451. }
  452. .menu-divider {
  453. height: 1rpx;
  454. background: #f0f0f0;
  455. }
  456. }
  457. // 底部占位
  458. .bottom-spacer {
  459. height: 40rpx;
  460. }
  461. </style>