setting.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="setting-container">
  3. <view class="setting-title">设置</view>
  4. <view class="setting-list">
  5. <view class="setting-item" v-for="item in settingList" :key="item.title" @click="onItem(item)">
  6. <image :src="item.icon" class="item-icon" />
  7. <view class="item-title">{{ item.title }}</view>
  8. <text class="arrow">›</text>
  9. </view>
  10. <view class="divider" v-for="(item,idx) in settingList" :key="'d'+idx" v-if="idx!==settingList.length-1"></view>
  11. </view>
  12. <button class="logout-btn" @click="logout">退出登录</button>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. settingList: [
  20. { title: '账号安全', icon: '/static/logo.png' },
  21. { title: '隐私设置', icon: '/static/2.png' },
  22. { title: '清除缓存', icon: '/static/login.png' },
  23. { title: '关于我们', icon: '/static/logo.png' }
  24. ]
  25. }
  26. },
  27. methods: {
  28. onItem(item) {
  29. if(item.title==='清除缓存'){
  30. uni.clearStorageSync();
  31. uni.showToast({ title: '缓存已清除', icon: 'success' })
  32. } else {
  33. uni.showToast({ title: item.title, icon: 'none' })
  34. }
  35. },
  36. logout() {
  37. uni.showModal({
  38. title: '提示',
  39. content: '确定要退出登录吗?',
  40. success: (res) => {
  41. if (res.confirm) {
  42. uni.clearStorageSync();
  43. uni.reLaunch({ url: '/pages/login/index' })
  44. }
  45. }
  46. })
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss">
  52. .setting-container {
  53. min-height: 100vh;
  54. background: #f7f8fa;
  55. padding-bottom: 120rpx;
  56. }
  57. .setting-title {
  58. text-align: center;
  59. font-size: 36rpx;
  60. font-weight: bold;
  61. color: #222;
  62. padding: 48rpx 0 32rpx 0;
  63. }
  64. .setting-list {
  65. background: #fff;
  66. border-radius: 20rpx;
  67. margin: 0 24rpx;
  68. box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
  69. overflow: hidden;
  70. }
  71. .setting-item {
  72. display: flex;
  73. align-items: center;
  74. padding: 0 32rpx;
  75. height: 96rpx;
  76. background: #fff;
  77. cursor: pointer;
  78. position: relative;
  79. }
  80. .item-icon {
  81. width: 40rpx;
  82. height: 40rpx;
  83. margin-right: 24rpx;
  84. }
  85. .item-title {
  86. flex: 1;
  87. font-size: 28rpx;
  88. color: #333;
  89. }
  90. .arrow {
  91. color: #bbb;
  92. font-size: 36rpx;
  93. margin-left: 8rpx;
  94. }
  95. .divider {
  96. height: 1rpx;
  97. background: #f0f0f0;
  98. margin: 0 32rpx;
  99. }
  100. .logout-btn {
  101. width: 80%;
  102. margin: 48rpx 10% 0 10%;
  103. background: #ff4d4f;
  104. color: #fff;
  105. border-radius: 12rpx;
  106. font-size: 32rpx;
  107. }
  108. </style>