setting.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="container">
  3. <view id="topnav" class="topnav flex-between" :style="{'height':`${topbarOffsetHeight-statusBarHeight}px`,'padding-top':`${statusBarHeight}px`}">
  4. <view class="nav-item flex-center" @click="back">
  5. <image :src="`${assetsUrl}back.png`" mode="widthFix" class="nav-img"></image>
  6. </view>
  7. <view class="nav-text font32 fw600">
  8. {{topbarTitle}}
  9. </view>
  10. <view class="nav-item"></view>
  11. </view>
  12. <view class="setting-box flex-between" :style="{'margin-top':`${topNavHeight+15}px`}">
  13. <view class="setting-item flex-between" @click="loginOut">
  14. <view class="setting-text font28 fw600">
  15. 退出登录
  16. </view>
  17. <image :src="`${assetsUrl}setting-more.png`" mode="widthFix" class="setting-icon"></image>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. topbarIcon:'back',
  27. topbarTitle:'设置',
  28. assetsUrl:this.$util.assetsUrl,
  29. topNavHeight:0,
  30. };
  31. },
  32. mounted() {
  33. this.computedScollviewHeight();
  34. },
  35. computed: {
  36. statusBarHeight() {
  37. return this.$store.state.statusBarHeight;
  38. },
  39. topbarOffsetHeight() {
  40. return this.$store.state.topbarOffsetHeight;
  41. },
  42. userInfo(){
  43. return this.$store.state.userInfo||JSON.parse(uni.getStorageSync('userInfo'))
  44. }
  45. },
  46. methods:{
  47. back(){
  48. uni.navigateBack({
  49. delta:1
  50. })
  51. },
  52. /**
  53. * 计算scroll高度
  54. */
  55. computedScollviewHeight() {
  56. let query = uni.createSelectorQuery().in(this);
  57. let heightLeaf =0;
  58. query.select('#topnav').boundingClientRect(data => {
  59. this.topNavHeight=data.height;
  60. heightLeaf += data.height;
  61. }).exec(() => {
  62. let sysInfo = uni.getSystemInfoSync();
  63. this.scrollHeight = sysInfo.windowHeight - heightLeaf;
  64. });
  65. },
  66. loginOut(){
  67. uni.showModal({
  68. title:'退出登录',
  69. content:'退出登录后将清除所有本机数据,下次登录自动登录,是否继续?',
  70. confirmColor:'#6C52F4',
  71. confirmText:'继续',
  72. success:(res)=>{
  73. if(res.confirm){
  74. uni.$TUIKit.logout();
  75. uni.$TUIKit.destroy();
  76. uni.setStorageSync('token','');
  77. uni.setStorageSync('LL_Ukn','');
  78. uni.setStorageSync('autoLogin','false');
  79. uni.reLaunch({
  80. url:'/pages/login/login'
  81. })
  82. }
  83. }
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. .container{
  91. width: 100vw;
  92. height: 100vh;
  93. background-color: $bgcolor1;
  94. overflow: hidden;
  95. .topnav {
  96. padding: 0 10rpx;
  97. position: fixed;
  98. top: 0;
  99. left: 0;
  100. width: 100vw;
  101. z-index: 100;
  102. background-color: $bgcolor1;
  103. .nav-item{
  104. width: 40rpx;
  105. height: 40rpx;
  106. margin-left: 16rpx;
  107. .nav-img{
  108. width: 40rpx;
  109. height: 40rpx;
  110. }
  111. }
  112. .nav-text{
  113. flex: 1;
  114. color: $fontcolor5;
  115. height: 40rpx;
  116. text-align: center;
  117. }
  118. }
  119. .setting-box{
  120. margin: 16rpx;
  121. border-radius: 8rpx;
  122. background-color: $bgcolor3;
  123. flex-direction: column;
  124. .setting-item{
  125. width: 100%;
  126. height: 112rpx;
  127. padding: 0rpx 32rpx;
  128. box-sizing: border-box;
  129. .setting-text{
  130. color: $fontcolor5;
  131. }
  132. .setting-icon{
  133. width: 24rpx;
  134. height: 24rpx;
  135. }
  136. }
  137. }
  138. }
  139. </style>