index.vue 12 KB

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