| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view class="settings-page">
- <view class="menu-list">
- <view class="cell-group">
- <view class="cell-item" @click="onTodo">
- <text class="cell-title">个人信息</text>
- <uni-icons type="right" size="14" color="#ccc"></uni-icons>
- </view>
- <view class="cell-item" @click="goTo('/pages/my/settings/change-password/index')">
- <text class="cell-title">修改密码</text>
- <uni-icons type="right" size="14" color="#ccc"></uni-icons>
- </view>
- <view class="cell-item" @click="onClearCache">
- <text class="cell-title">清除缓存</text>
- <text class="cell-value">{{ cacheSize }}</text>
- <uni-icons type="right" size="14" color="#ccc"></uni-icons>
- </view>
- </view>
- <view class="cell-group danger-group">
- <view class="cell-item" @click="goTo('/pages/my/settings/account-delete/index')">
- <text class="cell-title danger">账号注销</text>
- <uni-icons type="right" size="14" color="#ccc"></uni-icons>
- </view>
- </view>
- </view>
- <view class="logout-btn-wrapper">
- <button class="logout-btn" @click="onLogout">退出登录</button>
- </view>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue'
- import { onShow } from '@dcloudio/uni-app'
- const cacheSize = ref('0 KB')
- const calculateCacheSize = () => {
- try {
- const res = uni.getStorageInfoSync()
- const size = res.currentSize
- if (size < 1024) {
- cacheSize.value = size + ' KB'
- } else {
- cacheSize.value = (size / 1024).toFixed(2) + ' MB'
- }
- } catch (e) {
- cacheSize.value = '0 KB'
- }
- }
- onShow(() => {
- calculateCacheSize()
- })
- const goTo = (url) => uni.navigateTo({ url })
- const onTodo = () => uni.showToast({ title: '演示功能,暂未开放', icon: 'none' })
- const onClearCache = () => {
- uni.showModal({
- title: '清理缓存',
- content: '确定要清理本地缓存吗?',
- success: (res) => {
- if (res.confirm) {
- try {
- // 清理前保留 token 等可能需要的核心认证信息
- const token = uni.getStorageSync('token')
- uni.clearStorageSync()
- if (token) {
- uni.setStorageSync('token', token)
- }
-
- calculateCacheSize()
- uni.showToast({ title: '清理成功', icon: 'success' })
- } catch (e) {
- uni.showToast({ title: '清理失败', icon: 'none' })
- }
- }
- }
- })
- }
- const onLogout = () => {
- uni.showModal({
- title: '提示',
- content: '确定要退出当前账号吗?',
- success: (res) => {
- if (res.confirm) {
- uni.showToast({ title: '已安全退出', icon: 'success' })
- setTimeout(() => uni.reLaunch({ url: '/pages/login/index' }), 1000)
- }
- }
- })
- }
- </script>
- <style lang="scss" scoped>
- .settings-page {
- min-height: 100vh;
- background: #f7f8fa;
- }
- .menu-list {
- padding-top: 24rpx;
- }
- .cell-group {
- background: #fff;
- margin: 0 24rpx 24rpx;
- border-radius: 24rpx;
- overflow: hidden;
- }
- .cell-item {
- display: flex;
- align-items: center;
- padding: 32rpx;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .cell-item:last-child {
- border-bottom: none;
- }
- .cell-title {
- flex: 1;
- font-size: 28rpx;
- color: #333;
- }
- .cell-title.danger {
- color: #ee0a24;
- }
- .cell-value {
- font-size: 26rpx;
- color: #999;
- margin-right: 8rpx;
- }
- .danger-group {
- margin-top: 40rpx;
- }
- .logout-btn-wrapper {
- padding: 80rpx 32rpx;
- }
- .logout-btn {
- width: 100%;
- height: 88rpx;
- background: #fff;
- color: #333;
- border: none;
- border-radius: 44rpx;
- font-size: 30rpx;
- line-height: 88rpx;
- }
- </style>
|