index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <view class="mine-container">
  3. <!-- 顶部渐变背景 -->
  4. <view class="top-gradient">
  5. <!-- 页面背景图 -->
  6. <view class="page-bg">
  7. <image src="/static/mine/minebg.png" class="bg-image" mode="aspectFit"></image>
  8. </view>
  9. </view>
  10. <!-- 自定义导航栏 -->
  11. <view class="custom-navbar" :style="{paddingTop: statusBarHeight + 'px'}">
  12. <view class="navbar-content">
  13. <text class="navbar-title">我的</text>
  14. </view>
  15. </view>
  16. <!-- 用户登录/注册卡片 -->
  17. <view class="login-card" :style="{marginTop: navbarHeight+50 + 'rpx'}" @click="handleLoginCardClick">
  18. <view class="login-card-content">
  19. <view class="avatar-section">
  20. <view v-if="!avatar" class="avatar-placeholder">
  21. <view class="iconfont icon-people avatar-icon"></view>
  22. </view>
  23. <image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill"></image>
  24. </view>
  25. <view class="login-info">
  26. <view v-if="!name" class="login-text">点击登录/注册</view>
  27. <view v-else class="user-name">{{ name }}</view>
  28. <view v-if="!name" class="login-desc">登录后获取更多功能信息</view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 第一个菜单卡片 -->
  33. <view class="menu-card">
  34. <view class="menu-item" @click="handleToInfo">
  35. <view class="menu-item-left">
  36. <view class="menu-icon-wrapper account-icon">
  37. <image src="/static/mine/account.png" class="menu-icon-image" mode="aspectFit"></image>
  38. </view>
  39. <text class="menu-text">账号信息</text>
  40. </view>
  41. <view class="iconfont icon-right arrow-icon"></view>
  42. </view>
  43. <view class="menu-divider"></view>
  44. <view class="menu-item" @click="handleToOrderRevenue">
  45. <view class="menu-item-left">
  46. <view class="menu-icon-wrapper revenue-icon">
  47. <image src="/static/mine/order.png" class="menu-icon-image" mode="aspectFit"></image>
  48. </view>
  49. <text class="menu-text">订单收益</text>
  50. </view>
  51. <view class="iconfont icon-right arrow-icon"></view>
  52. </view>
  53. </view>
  54. <!-- 第二个菜单卡片 -->
  55. <view class="menu-card">
  56. <view class="menu-item" @click="handleClearCache">
  57. <view class="menu-item-left">
  58. <view class="menu-icon-wrapper cache-icon">
  59. <image src="/static/mine/local.png" class="menu-icon-image" mode="aspectFit"></image>
  60. </view>
  61. <text class="menu-text">本地缓存</text>
  62. </view>
  63. </view>
  64. <view class="menu-divider"></view>
  65. <view class="menu-item" @click="handleAbout">
  66. <view class="menu-item-left">
  67. <view class="menu-icon-wrapper about-icon">
  68. <image src="/static/mine/about.png" class="menu-icon-image" mode="aspectFit"></image>
  69. </view>
  70. <text class="menu-text">关于我们</text>
  71. </view>
  72. <view class="iconfont icon-right arrow-icon"></view>
  73. </view>
  74. <view class="menu-divider"></view>
  75. <view class="menu-item" @click="handleLogout">
  76. <view class="menu-item-left">
  77. <view class="menu-icon-wrapper logout-icon">
  78. <image src="/static/mine/exit.png" class="menu-icon-image" mode="aspectFit"></image>
  79. </view>
  80. <text class="menu-text">退出登录</text>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 底部导航栏 -->
  85. <bar-navigasi-handap></bar-navigasi-handap>
  86. <!-- 退出登录确认对话框 -->
  87. <view v-if="showLogoutDialog" class="logout-dialog-mask" @click="closeLogoutDialog">
  88. <view class="logout-dialog" @click.stop>
  89. <view class="dialog-title">确认退出该账号吗?</view>
  90. <view class="dialog-buttons">
  91. <view class="dialog-btn logout-btn" @click="confirmLogout">退出登录</view>
  92. <view class="dialog-btn cancel-btn" @click="closeLogoutDialog">取消</view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 清理缓存确认对话框 -->
  97. <view v-if="showClearCacheDialog" class="clear-cache-dialog-mask" @click="closeClearCacheDialog">
  98. <view class="clear-cache-dialog" @click.stop>
  99. <view class="cache-dialog-content">{{ clearCacheContent }}</view>
  100. <view class="cache-dialog-buttons">
  101. <view class="cache-dialog-btn cancel-btn" @click="closeClearCacheDialog">取消</view>
  102. <view class="cache-dialog-btn confirm-btn" @click="confirmClearCache">确定</view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import BarNavigasiHandap from "@/components/barNavigasiHandap.vue"
  110. export default {
  111. components: {
  112. BarNavigasiHandap
  113. },
  114. data() {
  115. return {
  116. name: this.$store.state.user.name,
  117. statusBarHeight: 0,
  118. showLogoutDialog: false,
  119. showClearCacheDialog: false,
  120. clearCacheContent: ''
  121. }
  122. },
  123. onLoad() {
  124. // 获取状态栏高度
  125. const systemInfo = uni.getSystemInfoSync()
  126. this.statusBarHeight = systemInfo.statusBarHeight || 0
  127. },
  128. computed: {
  129. avatar() {
  130. return this.$store.state.user.avatar
  131. },
  132. navbarHeight() {
  133. // 状态栏高度(px转rpx) + 导航栏高度(88rpx) + 间距(30rpx)
  134. return (this.statusBarHeight * 2) + 88 + 30
  135. }
  136. },
  137. methods: {
  138. handleLoginCardClick() {
  139. if (!this.name) {
  140. this.$tab.reLaunch('/pages/login')
  141. } else {
  142. this.$tab.navigateTo('/pages/mine/info/index')
  143. }
  144. },
  145. handleToInfo() {
  146. if (!this.name) {
  147. this.$tab.reLaunch('/pages/login')
  148. return
  149. }
  150. this.$tab.navigateTo('/pages/mine/info/index')
  151. },
  152. handleToOrderRevenue() {
  153. if (!this.name) {
  154. this.$tab.reLaunch('/pages/login')
  155. return
  156. }
  157. this.$modal.showToast('模块建设中~')
  158. },
  159. handleClearCache() {
  160. // 计算当前缓存大小
  161. const getCacheSize = () => {
  162. try {
  163. const storageInfo = uni.getStorageInfoSync()
  164. let totalSize = 0
  165. if (storageInfo.keys && storageInfo.keys.length > 0) {
  166. storageInfo.keys.forEach(key => {
  167. try {
  168. const value = uni.getStorageSync(key)
  169. // 计算存储数据的大小(字节)
  170. const size = JSON.stringify(value).length
  171. totalSize += size
  172. } catch (e) {
  173. console.error('获取存储项失败:', key, e)
  174. }
  175. })
  176. }
  177. // 转换为KB,保留2位小数
  178. const sizeKB = (totalSize / 1024).toFixed(2)
  179. return parseFloat(sizeKB)
  180. } catch (e) {
  181. console.error('计算缓存大小失败:', e)
  182. return 0
  183. }
  184. }
  185. const cacheSize = getCacheSize()
  186. this.clearCacheContent = cacheSize > 0
  187. ? `当前缓存 ${cacheSize} KB,确定清除?`
  188. : '确定要清理本地缓存吗?'
  189. this.showClearCacheDialog = true
  190. },
  191. closeClearCacheDialog() {
  192. this.showClearCacheDialog = false
  193. },
  194. confirmClearCache() {
  195. // 清理缓存的逻辑
  196. uni.clearStorageSync()
  197. this.showClearCacheDialog = false
  198. uni.showToast({
  199. title: '缓存清理成功'
  200. })
  201. },
  202. handleAbout() {
  203. this.$tab.navigateTo('/pages/mine/about/index')
  204. },
  205. handleLogout() {
  206. if (!this.name) {
  207. this.$tab.reLaunch('/pages/login')
  208. return
  209. }
  210. this.showLogoutDialog = true
  211. },
  212. closeLogoutDialog() {
  213. this.showLogoutDialog = false
  214. },
  215. confirmLogout() {
  216. this.showLogoutDialog = false
  217. this.$store.dispatch('LogOut').then(() => {}).finally(() => {
  218. this.$tab.reLaunch('/pages/index')
  219. })
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. page {
  226. background-color: #f5f5f5;
  227. }
  228. .mine-container {
  229. width: 100%;
  230. min-height: 100vh;
  231. padding-bottom: 120rpx;
  232. background-color: #f5f5f5;
  233. position: relative;
  234. // 顶部渐变背景
  235. .top-gradient {
  236. position: fixed;
  237. top: 0;
  238. left: 0;
  239. right: 0;
  240. height: 800rpx;
  241. background: linear-gradient(180deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 197, 253, 0.05) 50%, transparent 100%);
  242. z-index: 0;
  243. pointer-events: none;
  244. }
  245. // 页面背景图
  246. .page-bg {
  247. position: fixed;
  248. right: -60rpx;
  249. pointer-events: none;
  250. width: 400rpx;
  251. height: 600rpx;
  252. z-index: 0;
  253. .bg-image {
  254. width: 100%;
  255. height: 100%;
  256. opacity: 0.6;
  257. }
  258. }
  259. // 自定义导航栏
  260. .custom-navbar {
  261. position: fixed;
  262. top: 0;
  263. left: 0;
  264. right: 0;
  265. z-index: 999;
  266. background-color: transparent;
  267. pointer-events: none;
  268. .navbar-content {
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. height: 88rpx;
  273. pointer-events: auto;
  274. .navbar-title {
  275. font-size: 36rpx;
  276. font-weight: 500;
  277. color: #000000;
  278. }
  279. }
  280. }
  281. // 登录卡片
  282. .login-card {
  283. min-height: 200rpx;
  284. position: relative;
  285. margin: 0 30rpx 40rpx 30rpx;
  286. padding: 30rpx 30rpx;
  287. background-color: rgba(255, 255, 255, 0.4);
  288. border-radius: 24rpx;
  289. overflow: visible;
  290. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  291. z-index: 10;
  292. .login-card-content {
  293. display: flex;
  294. position: relative;
  295. z-index: 2;
  296. .avatar-section {
  297. position: relative;
  298. width: 160rpx;
  299. height: 160rpx;
  300. flex-shrink: 0;
  301. .avatar-placeholder {
  302. width: 120rpx;
  303. height: 120rpx;
  304. border-radius: 50%;
  305. background-color: #e0e0e0;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. position: absolute;
  310. top: -100rpx;
  311. left: 0;
  312. .avatar-icon {
  313. font-size: 60rpx;
  314. color: #999999;
  315. }
  316. }
  317. .avatar-image {
  318. width: 160rpx;
  319. height: 160rpx;
  320. border-radius: 50%;
  321. position: absolute;
  322. top: -80rpx;
  323. left: 0;
  324. }
  325. }
  326. .login-info {
  327. margin-left: 30rpx;
  328. flex: 1;
  329. display: flex;
  330. flex-direction: column;
  331. .login-text {
  332. font-size: 36rpx;
  333. font-weight: 600;
  334. color: #000000;
  335. margin-bottom: 12rpx;
  336. }
  337. .user-name {
  338. font-size: 36rpx;
  339. font-weight: 600;
  340. color: #000000;
  341. margin-bottom: 12rpx;
  342. }
  343. .login-desc {
  344. font-size: 26rpx;
  345. color: #999999;
  346. }
  347. }
  348. }
  349. .login-card-bg {
  350. position: absolute;
  351. right: -60rpx;
  352. top: -60rpx;
  353. width:400rpx;
  354. height: 600rpx;
  355. opacity: 0.6;
  356. }
  357. }
  358. // 菜单卡片
  359. .menu-card {
  360. position: relative;
  361. margin: 0 30rpx 30rpx 30rpx;
  362. background-color: rgba(255, 255, 255, 0.4);
  363. border-radius: 24rpx;
  364. overflow: hidden;
  365. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  366. z-index: 10;
  367. .menu-item {
  368. display: flex;
  369. align-items: center;
  370. justify-content: space-between;
  371. padding: 32rpx 30rpx;
  372. background-color: rgba(255, 255, 255, 0.4);
  373. .menu-item-left {
  374. display: flex;
  375. align-items: center;
  376. flex: 1;
  377. .menu-icon-wrapper {
  378. width: 64rpx;
  379. height: 64rpx;
  380. border-radius: 16rpx;
  381. display: flex;
  382. align-items: center;
  383. justify-content: center;
  384. margin-right: 24rpx;
  385. background-color: transparent;
  386. .menu-icon-image {
  387. width: 40rpx;
  388. height: 40rpx;
  389. }
  390. }
  391. .menu-text {
  392. font-size: 32rpx;
  393. color: #000000;
  394. }
  395. }
  396. .arrow-icon {
  397. font-size: 28rpx;
  398. color: #cccccc;
  399. }
  400. }
  401. .menu-divider {
  402. height: 1rpx;
  403. background-color: #f0f0f0;
  404. margin: 0 30rpx;
  405. }
  406. }
  407. // 退出登录对话框
  408. .logout-dialog-mask {
  409. position: fixed;
  410. top: 0;
  411. left: 0;
  412. right: 0;
  413. bottom: 0;
  414. background-color: rgba(0, 0, 0, 0.5);
  415. z-index: 9999;
  416. display: flex;
  417. align-items: flex-end;
  418. justify-content: center;
  419. }
  420. .logout-dialog {
  421. width: 100%;
  422. background-color: #ffffff;
  423. border-radius: 32rpx 32rpx 0 0;
  424. padding: 40rpx 30rpx;
  425. padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
  426. box-sizing: border-box;
  427. .dialog-title {
  428. font-size: 24rpx;
  429. font-weight: 400;
  430. color: #666666;
  431. text-align: center;
  432. margin-bottom: 60rpx;
  433. line-height: 1.5;
  434. }
  435. .dialog-buttons {
  436. display: flex;
  437. flex-direction: column;
  438. align-items: center;
  439. .dialog-btn {
  440. width: 100%;
  441. height: 100rpx;
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. font-size: 34rpx;
  446. font-weight: 400;
  447. background-color: transparent;
  448. border: none;
  449. &.logout-btn {
  450. color: #EF2C54;
  451. margin-bottom: 40rpx;
  452. }
  453. &.cancel-btn {
  454. color: #333333;
  455. }
  456. }
  457. }
  458. }
  459. // 清理缓存对话框
  460. .clear-cache-dialog-mask {
  461. position: fixed;
  462. top: 0;
  463. left: 0;
  464. right: 0;
  465. bottom: 0;
  466. background-color: rgba(0, 0, 0, 0.5);
  467. z-index: 9999;
  468. display: flex;
  469. align-items: center;
  470. justify-content: center;
  471. }
  472. .clear-cache-dialog {
  473. width: 600rpx;
  474. background-color: #ffffff;
  475. border-radius: 24rpx;
  476. padding: 60rpx 40rpx 40rpx;
  477. box-sizing: border-box;
  478. min-height: 280rpx;
  479. display: flex;
  480. flex-direction: column;
  481. justify-content: space-between;
  482. .cache-dialog-content {
  483. font-size: 32rpx;
  484. font-weight: 400;
  485. color: #333333;
  486. text-align: center;
  487. line-height: 1.6;
  488. padding: 20rpx 0;
  489. min-height: 120rpx;
  490. display: flex;
  491. align-items: center;
  492. justify-content: center;
  493. }
  494. .cache-dialog-buttons {
  495. display: flex;
  496. flex-direction: row;
  497. align-items: center;
  498. justify-content: space-between;
  499. margin-top: 40rpx;
  500. gap: 20rpx;
  501. .cache-dialog-btn {
  502. flex: 1;
  503. height: 88rpx;
  504. display: flex;
  505. align-items: center;
  506. justify-content: center;
  507. font-size: 32rpx;
  508. font-weight: 400;
  509. background-color: transparent;
  510. border: none;
  511. &.cancel-btn {
  512. color: #666666;
  513. }
  514. &.confirm-btn {
  515. color: #2652C2;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. </style>