set.vue 5.1 KB

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