set.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="set">
  3. <view
  4. class="list-cell b-b"
  5. :class="{ 'm-t': item.class === 'mT' }"
  6. v-for="item in setList"
  7. :key="item.title"
  8. @tap="navTo(item.url)"
  9. hover-class="cell-hover"
  10. :hover-stay-time="50"
  11. >
  12. <text class="cell-tit">{{ item.title }}</text>
  13. <text class="cell-tip">{{ item.content }}</text>
  14. <text class="cell-more iconfont iconyou"></text>
  15. </view>
  16. <!-- #ifdef APP-PLUS -->
  17. <view class="list-cell m-t">
  18. <text class="cell-tit">消息推送</text>
  19. <switch :checked="notifyChecked" :color="themeColor.color" />
  20. </view>
  21. <!-- #endif -->
  22. <view class="cu-list menu sm-border card-menu" v-if="styleUserIsOpen">
  23. <view class="cu-item">
  24. <view class="content flex align-center">
  25. <text
  26. class="cuIcon-colorlens"
  27. :class="'text-' + themeColor.name"
  28. ></text>
  29. <view
  30. class="padding solid radius shadow-blur"
  31. :class="'bg-' + themeColor.name"
  32. ></view>
  33. <view class="title"
  34. >主题色:<text :class="'text-' + themeColor.name">{{
  35. themeColor.title
  36. }}</text></view
  37. >
  38. </view>
  39. <view class="action">
  40. <button
  41. class="cu-btn round shadow"
  42. @click="showColorModal"
  43. :class="'bg-' + themeColor.name"
  44. >
  45. <text class="cuIcon-colorlens"></text> 选择主题
  46. </button>
  47. </view>
  48. </view>
  49. </view>
  50. <view
  51. class="list-cell log-out-btn"
  52. :class="'text-' + themeColor.name"
  53. @tap="toLogout"
  54. >
  55. <text class="cell-tit">退出登录</text>
  56. </view>
  57. <!-- modal -->
  58. <!-- 选择颜色模态框 -->
  59. <view class="cu-modal" :class="{ show: colorModal }">
  60. <view class="cu-dialog">
  61. <view class="cu-bar justify-end solid-bottom">
  62. <view class="content">选择颜色</view>
  63. <view class="action" @tap="colorModal = false">
  64. <text class="cuIcon-close text-red"></text>
  65. </view>
  66. </view>
  67. <view class="grid col-5 padding">
  68. <view
  69. class="padding-xs"
  70. v-for="(item, index) in themeList"
  71. :key="index"
  72. @tap="SetColor(item)"
  73. :data-color="item.name"
  74. >
  75. <view class="padding-tb radius" :class="'bg-' + item.name">
  76. {{ item.title }}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import { logout } from '@/api/login';
  86. export default {
  87. data() {
  88. return {
  89. isVersionUpgradeShow: false,
  90. loadProgress: 0,
  91. CustomBar: this.CustomBar,
  92. user: {},
  93. setList: this.$mConstDataConfig.setList,
  94. styleUserIsOpen: this.$mSettingConfig.styleUserIsOpen,
  95. notifyChecked: false,
  96. isNewVersion: false,
  97. colorModal: false,
  98. themeList: this.$mConstDataConfig.themeList
  99. };
  100. },
  101. onLoad() {
  102. this.initData();
  103. // #ifdef APP-PLUS
  104. if (uni.getSystemInfoSync().platform === 'ios') {
  105. this.CustomBar = 0;
  106. }
  107. // #endif
  108. },
  109. methods: {
  110. // 初始化数据
  111. initData() {
  112. this.user = uni.getStorageSync('user');
  113. // 缓存大小
  114. this.setList[5].content = `${uni.getStorageInfoSync().currentSize} kb`;
  115. // #ifdef APP-PLUS
  116. // eslint-disable-next-line
  117. this.setList[8].content = `当前版本 ${plus.runtime.version}`;
  118. // #endif
  119. },
  120. // 通用跳转
  121. navTo(route) {
  122. if (!route) return;
  123. if (route === 'clearCache') {
  124. uni.showModal({
  125. content: '确定要清除缓存吗',
  126. success: e => {
  127. if (e.confirm) {
  128. uni.clearStorageSync();
  129. this.setList[5].content = '0 kb';
  130. this.$mStore.commit('login', this.user);
  131. this.$mHelper.toast('清除缓存成功');
  132. }
  133. }
  134. });
  135. return;
  136. } else if (route === 'versionUpgrade') {
  137. this.isVersionUpgradeShow = true;
  138. if (this.isNewVersion) {
  139. this.$mHelper.toast('已经是最新版本');
  140. }
  141. return;
  142. }
  143. this.$mRouter.push({ route });
  144. },
  145. // 退出登录
  146. toLogout() {
  147. uni.showModal({
  148. content: '确定要退出登录么',
  149. success: e => {
  150. if (e.confirm) {
  151. this.$http.post(`${logout}`).then(() => {
  152. this.$mStore.commit('logout');
  153. uni.reLaunch({
  154. url: '/pages/profile/profile'
  155. });
  156. });
  157. }
  158. }
  159. });
  160. },
  161. showColorModal() {
  162. this.colorModal = true;
  163. },
  164. SetColor(item) {
  165. this.colorModal = false;
  166. this.themeColor = item;
  167. this.$mStore.commit('setThemeColor', item);
  168. }
  169. }
  170. };
  171. </script>
  172. <style lang="scss">
  173. page {
  174. background: $page-color-base;
  175. }
  176. .set {
  177. padding: $spacing-base 0;
  178. }
  179. .cu-list.card-menu {
  180. margin: $spacing-base 0;
  181. .title {
  182. margin-left: $spacing-base;
  183. }
  184. }
  185. </style>