index.vue 12 KB

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