setting.vue 3.5 KB

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