set.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="container">
  3. <view class="list_cell m_t b_b" @click="navTo('/pages/user/info')" hover-class="cell_hover" :hover-stay-time="50">
  4. <text class="cell_tit">{{$L('个人信息')}}</text>
  5. <text class="cell_more iconfont iconziyuan11"></text>
  6. </view>
  7. <view class="list_cell m_t b_b" @click="navTo('/pages/member/collect')" hover-class="cell_hover" :hover-stay-time="50">
  8. <text class="cell_tit">{{$L('我的收藏')}}</text>
  9. <text class="cell_more iconfont iconziyuan11"></text>
  10. </view>
  11. <view class="list_cell b_b" @click="navTo('/pages/member/history')" hover-class="cell_hover" :hover-stay-time="50">
  12. <text class="cell_tit">{{$L('我的足迹')}}</text>
  13. <text class="cell_more iconfont iconziyuan11"></text>
  14. </view>
  15. <view class="list_cell" @click="navTo('/pages/address/list')" hover-class="cell_hover" :hover-stay-time="50">
  16. <text class="cell_tit">{{$L('收货地址')}}</text>
  17. <text class="cell_more iconfont iconziyuan11"></text>
  18. </view>
  19. <view class="list_cell m_t" @click="navTo('/pages/account/account')" hover-class="cell_hover" :hover-stay-time="50">
  20. <text class="cell_tit">{{$L('账号安全')}}</text>
  21. <text class="cell_more iconfont iconziyuan11"></text>
  22. </view>
  23. <!-- #ifdef APP-PLUS -->
  24. <view class="list_cell b_b m_t" @click="navTo('/pages/set/aboutUs')" hover-class="cell_hover" :hover-stay-time="50">
  25. <text class="cell_tit">{{$L('关于我们')}}</text>
  26. <text class="cell_more iconfont iconziyuan11"></text>
  27. </view>
  28. <view class="list_cell b_b" @click="navTo('/pages/privacyPolicy/privacyPolicy')" hover-class="cell_hover" :hover-stay-time="50">
  29. <text class="cell_tit">{{$L('用户协议和隐私政策')}}</text>
  30. <text class="cell_more iconfont iconziyuan11"></text>
  31. </view>
  32. <view class="list_cell" @click="clearCache()" hover-class="cell_hover" :hover-stay-time="50">
  33. <text class="cell_tit">{{$L('清除缓存')}}</text>
  34. <text class="size_cache">{{fileSizeString}}</text>
  35. <text class="cell_more iconfont iconziyuan11"></text>
  36. </view>
  37. <!-- #endif -->
  38. <view class="log_out_btn flex_row_center_center" @click="loginOutDialog(true)">
  39. {{$L('退出登录')}}
  40. </view>
  41. <uni-popup ref="popup" type="dialog">
  42. <uni-popup-dialog type="input" title ="提示" content="确定要退出登录吗?" :duration="2000" @close="loginOutDialog(false)" @confirm="confirmLoginOut"></uni-popup-dialog>
  43. </uni-popup>
  44. </view>
  45. </template>
  46. <script>
  47. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  48. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  49. import {
  50. mapMutations,mapState
  51. } from 'vuex';
  52. export default {
  53. components: {
  54. uniPopup,
  55. uniPopupDialog
  56. },
  57. data() {
  58. return {
  59. fileSizeString:'', //app文件缓存大小
  60. };
  61. },
  62. computed: {
  63. ...mapState(['hasLogin', 'userCenterData']),
  64. userInfo:{
  65. get(){
  66. return this.$store.state.userInfo
  67. },
  68. set(){}
  69. }
  70. },
  71. onLoad() {
  72. // #ifdef APP-PLUS
  73. this.formatSize(); //获取文件缓存
  74. // #endif
  75. },
  76. methods:{
  77. ...mapMutations(['login','logout', 'setUserCenterData', 'userInfo']),
  78. navTo(url){
  79. uni.navigateTo({
  80. url: url
  81. })
  82. },
  83. //退出登录
  84. confirmLoginOut(){
  85. this.$request({
  86. url:'v3/frontLogin/oauth/logout',
  87. method:'POST',
  88. data:{
  89. refresh_token:this.userInfo.refresh_token
  90. }
  91. }).then(res => {
  92. this.logout();
  93. uni.redirectTo({
  94. url:`/pages/public/login?source=loginOut`
  95. });
  96. }).catch((e) => {})
  97. },
  98. //退出登录提示
  99. loginOutDialog(type){
  100. if(type){
  101. this.$refs.popup.open();
  102. }else{
  103. this.$refs.popup.close();
  104. }
  105. },
  106. //获取文件缓存
  107. formatSize(){
  108. let that = this;
  109. plus.cache.calculate(function(size){
  110. let sizeCache = parseInt(size);
  111. if(sizeCache == 0){
  112. that.fileSizeString = "0B";
  113. }else if(sizeCache < 1024){
  114. that.fileSizeString = sizeCache + "B";
  115. }else if(sizeCache < 1048576){
  116. that.fileSizeString = (sizeCache / 1024).toFixed(2) + "KB";
  117. } else if (sizeCache < 1073741824) {
  118. that.fileSizeString = (sizeCache / 1048576).toFixed(2) + "MB";
  119. } else {
  120. that.fileSizeString = (sizeCache / 1073741824).toFixed(2) + "GB";
  121. }
  122. })
  123. },
  124. //清除文件缓存
  125. clearCache(){
  126. let that = this;
  127. uni.showModal({
  128. title:'提示',
  129. content:'确定清除缓存?',
  130. success: (res) => {
  131. if(res.confirm){
  132. let os = plus.os.name;
  133. if (os == 'Android') {
  134. let main = plus.android.runtimeMainActivity();
  135. let sdRoot = main.getCacheDir();
  136. let files = plus.android.invoke(sdRoot, "listFiles");
  137. let len = files.length;
  138. for (let i = 0; i < len; i++) {
  139. let filePath = '' + files[i]; // 没有找到合适的方法获取路径,这样写可以转成文件路径
  140. plus.io.resolveLocalFileSystemURL(filePath, function(entry) {
  141. if (entry.isDirectory) {
  142. entry.removeRecursively(function(entry) { //递归删除其下的所有文件及子目录
  143. uni.showToast({
  144. title: '缓存清理完成',
  145. duration: 2000
  146. });
  147. that.formatSize(); // 重新计算缓存
  148. }, function(e) {
  149. });
  150. } else {
  151. entry.remove();
  152. }
  153. }, function(e) {
  154. });
  155. }
  156. } else { // ios
  157. plus.cache.clear(function() {
  158. uni.showToast({
  159. title: '缓存清理完成',
  160. duration: 2000
  161. });
  162. that.formatSize();
  163. });
  164. }
  165. }else if(res.cancel){
  166. }
  167. }
  168. })
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang='scss'>
  174. page{
  175. background: $bg-color-split;
  176. width: 750rpx;
  177. margin: 0 auto;
  178. }
  179. .list_cell{
  180. display:flex;
  181. align-items:center;
  182. padding: 0 20rpx;
  183. line-height:100rpx;
  184. height: 100rpx;
  185. position:relative;
  186. background: #fff;
  187. justify-content: center;
  188. &.cell_hover{
  189. background:#fafafa;
  190. }
  191. &.b_b:after{
  192. left: 20rpx;
  193. }
  194. &.m_t{
  195. margin-top: 20rpx;
  196. }
  197. .cell_more{
  198. color: $main-third-color;
  199. font-size: 18rpx;
  200. margin-left:10rpx;
  201. }
  202. .cell_tit{
  203. flex: 1;
  204. font-size: 28rpx;
  205. color: #2D2D2D;
  206. margin-right:10rpx;
  207. }
  208. .size_cache{
  209. font-size: 28rpx;
  210. color: #FC1C1C;
  211. }
  212. }
  213. .log_out_btn{
  214. position: fixed;
  215. width: 668rpx;
  216. margin: 0 41rpx;
  217. left: 50%;
  218. transform: translateX(-375rpx);
  219. /* left: 41rpx;
  220. right: 41rpx; */
  221. bottom: 80rpx;
  222. z-index: 95;
  223. font-size: 34rpx;
  224. color: $main-color;
  225. height: 88rpx;
  226. border:1px solid $main-color;
  227. border-radius:44px;
  228. letter-spacing: 1rpx;
  229. }
  230. </style>