index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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="120"
  15. :badge-src="'/static/image/public/badge-icon.png'" :badge-size="40" />
  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. // 使用 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. flex-shrink: 0;
  306. }
  307. .user-details {
  308. flex: 1;
  309. .name-row {
  310. display: flex;
  311. align-items: center;
  312. margin-bottom: 12rpx;
  313. .user-name {
  314. font-size: 36rpx;
  315. font-weight: 600;
  316. color: #ffffff;
  317. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  318. }
  319. .user-role {
  320. font-size: 22rpx;
  321. color: #ffffff;
  322. background: rgba(255, 255, 255, 0.25);
  323. padding: 4rpx 16rpx;
  324. border-radius: 20rpx;
  325. margin-left: 16rpx;
  326. font-weight: 500;
  327. }
  328. }
  329. .company-name {
  330. font-size: 24rpx;
  331. color: rgba(255, 255, 255, 0.85);
  332. display: block;
  333. text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  334. }
  335. }
  336. .qr-btn {
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. justify-content: center;
  341. .qr-icon {
  342. width: 48rpx;
  343. height: 48rpx;
  344. }
  345. .qr-text {
  346. font-size: 20rpx;
  347. color: #ffffff;
  348. margin-top: 4rpx;
  349. }
  350. }
  351. }
  352. }
  353. // 内容区域
  354. .content-section {
  355. margin-top: -160rpx;
  356. position: relative;
  357. z-index: 20;
  358. padding: 0 40rpx;
  359. }
  360. // 数据卡片
  361. .data-card {
  362. background: #ffffff;
  363. margin-bottom: 24rpx;
  364. padding: 32rpx;
  365. border-radius: 24rpx;
  366. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  367. .card-header {
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. margin-bottom: 24rpx;
  372. }
  373. .card-title {
  374. font-size: 28rpx;
  375. font-weight: 600;
  376. color: #333333;
  377. }
  378. .data-row {
  379. display: flex;
  380. justify-content: space-between;
  381. .data-item {
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. flex: 1;
  386. position: relative;
  387. .data-value {
  388. font-size: 40rpx;
  389. font-weight: 600;
  390. color: #333333;
  391. margin-bottom: 12rpx;
  392. font-family: DIN, 'DIN Alternate', sans-serif;
  393. }
  394. .data-label {
  395. font-size: 24rpx;
  396. color: #999999;
  397. }
  398. &.highlight .data-value {
  399. color: #ff6b35;
  400. }
  401. &:not(:last-child)::after {
  402. content: '';
  403. position: absolute;
  404. right: 0;
  405. top: 50%;
  406. transform: translateY(-50%);
  407. width: 1rpx;
  408. height: 60rpx;
  409. background: #f0f0f0;
  410. }
  411. }
  412. }
  413. }
  414. // 功能菜单卡片
  415. .menu-card {
  416. background: #ffffff;
  417. padding: 0 32rpx;
  418. border-radius: 24rpx;
  419. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  420. .menu-item {
  421. display: flex;
  422. align-items: center;
  423. padding: 32rpx 0;
  424. .menu-icon-wrapper {
  425. width: 64rpx;
  426. height: 64rpx;
  427. border-radius: 16rpx;
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. margin-right: 20rpx;
  432. &.icon-blue {
  433. background: rgba(74, 144, 226, 0.1);
  434. }
  435. &.icon-red {
  436. background: rgba(255, 77, 79, 0.1);
  437. }
  438. }
  439. .menu-text {
  440. flex: 1;
  441. font-size: 28rpx;
  442. color: #333333;
  443. }
  444. }
  445. .menu-divider {
  446. height: 1rpx;
  447. background: #f0f0f0;
  448. }
  449. }
  450. // 底部占位
  451. .bottom-spacer {
  452. height: 40rpx;
  453. }
  454. </style>