set.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="set-box">
  3. <en-nav title="设置" title-color="#333333" ></en-nav>
  4. <view class="set-list">
  5. <view class="set-item">
  6. <view class="item-text sys-height-44 sys-color-black">清理缓存</view>
  7. <view class="item-icon" @click="clearStorage()">
  8. <text class=" sys-height-44 sys-color-gray-9"> {{storageSize}}</text>
  9. <text class="iconfont sys-height-44 sys-color-gray-9"> &#xe62b;</text>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="set-list">
  14. <view class="set-item" @click="goToUrl(setItem.url)" v-for="setItem in setList">
  15. <view class="item-text sys-height-44 sys-color-black">{{setItem.text}}</view>
  16. <view class="item-icon">
  17. <text class="iconfont sys-height-44 sys-color-gray-9"> &#xe62b;</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="set-list">
  22. <view class="set-item" @click="goToUrl(sysItem.url)" v-for="sysItem in sysList">
  23. <view class="item-text sys-height-44 sys-color-black">{{sysItem.text}}</view>
  24. <view class="item-icon">
  25. <text class="iconfont sys-height-44 sys-color-gray-9"> &#xe62b;</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="set-list">
  30. <view class="set-item" @click="goToUrl('./set/conversion')">
  31. <view class="item-text sys-height-44 sys-color-black">兑换码</view>
  32. <view class="item-icon">
  33. <text class="iconfont sys-height-44 sys-color-gray-9"> &#xe62b;</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="set-id sys-color-gray-9">ID:87999890</view>
  38. <view class="set-quit sys-color-black" @click="logOut">退出账号</view>
  39. </view>
  40. </template>
  41. <script>
  42. import EnNav from "@/components/en-utils/en-nav/en-nav";
  43. export default {
  44. components: {EnNav},
  45. data() {
  46. return {
  47. storageSize:'',
  48. setList:[
  49. {'text':'实名认证(未认证)','url':'./set/autonym'},
  50. {'text':'修改密码','url':'./set/change-pass'},
  51. {'text':'修改绑定手机','url':'./set/chang-phone'},
  52. {'text':'更多设置','url':'./set/more-set'},
  53. ],
  54. sysList:[
  55. {'text':'意见与反馈','url':''},
  56. {'text':'关于我们','url':'./agreement/about-us'},
  57. {'text':'用户协议','url':'./agreement/agreement'},
  58. {'text':'隐私政策','url':'./agreement/privacy'},
  59. // {'text':'第三方信息共享清单','url':''},
  60. {'text':'个人信息清单','url':'./agreement/personage'},
  61. {'text':'相关许可证','url':'./agreement/all-permission'},
  62. // {'text':'ICOCO权限及用途说明','url':''},
  63. // {'text':'隐私中心','url':''},
  64. ],
  65. }
  66. },
  67. mounted() {
  68. this.getStorageSize()
  69. },
  70. methods: {
  71. logOut(){
  72. uni.showModal({
  73. title: '提示',
  74. content: '是否退出当前账户?',
  75. success: function (res) {
  76. if (res.confirm) {
  77. uni.clearStorageSync();
  78. uni.reLaunch({
  79. url:'/pages/login/index'
  80. })
  81. } else if (res.cancel) {
  82. console.log('用户点击取消');
  83. }
  84. }
  85. });
  86. },
  87. goToUrl(url){
  88. if(url===''){
  89. return;
  90. }
  91. uni.navigateTo({
  92. 'url':url
  93. })
  94. },
  95. getStorageSize:function(){
  96. let that = this;
  97. uni.getStorageInfo({
  98. success(res) {
  99. console.log(res)
  100. console.log(res.keys);
  101. console.log(res.limitSize);
  102. let size = res.currentSize;
  103. if (size < 1024) {
  104. that.storageSize = (size).toFixed(2) + ' B';
  105. } else if (size/1024>=1 && size/1024/1024<1) {
  106. that.storageSize = (Math.floor(size/1024*100)/100).toFixed(2) + ' KB';
  107. } else if (size/1024/1024>=1) {
  108. that.storageSize = (Math.floor(size/1024/1024*100)/100).toFixed(2) + ' M';
  109. }
  110. }
  111. })
  112. },
  113. clearStorage:function (){
  114. let that = this;
  115. uni.showModal({
  116. title:'提示',
  117. content:'确定清除缓存吗?',
  118. confirmText:'立即清除',
  119. success(res) {
  120. if(res.confirm){
  121. let token=uni.getStorageSync('token')
  122. uni.clearStorageSync();
  123. if(token){
  124. uni.setStorageSync('token',token)
  125. }
  126. //重新获取并显示清除后的缓存大小
  127. that.getStorageSize();
  128. uni.showToast({
  129. title:'清除成功'
  130. })
  131. }
  132. }
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .set-box{
  140. background-color: #F9F9F9;
  141. min-height: 100vh;
  142. padding-bottom: 50rpx;
  143. .set-list{
  144. margin: 20rpx 32rpx 0 32rpx;
  145. background-color: #fff;
  146. border-radius: 20rpx;
  147. padding: 0 32rpx;
  148. .set-item{
  149. padding: 32rpx 0;
  150. display: flex;
  151. justify-content: space-between;
  152. border-bottom: 1rpx solid #F2F2F2;
  153. .item-text{
  154. font-size: 28rpx;
  155. }
  156. .item-icon{
  157. .iconfont{
  158. font-size: 28rpx;
  159. }
  160. }
  161. }
  162. .set-item:last-child{
  163. border-bottom: none;
  164. }
  165. }
  166. .set-id{
  167. text-align: center;
  168. margin-top: 40rpx;
  169. font-size: 24rpx;
  170. }
  171. .set-quit{
  172. margin: 40rpx 32rpx;
  173. font-size: 32rpx;
  174. height: 88rpx;
  175. line-height: 88rpx;
  176. border-radius: 16rpx;
  177. background: #E0E0E0;
  178. text-align: center;
  179. }
  180. }
  181. </style>