system.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <!-- 系统设置 -->
  3. <view>
  4. <u-navbar title="系统设置" autoBack placeholder></u-navbar>
  5. <view class="card_system">
  6. <view class="space_between card_mine_option" @click="logOut">
  7. <view class="option_title">退出登录</view>
  8. <u-icon name="arrow-right" size="20"></u-icon>
  9. </view>
  10. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  11. @confirm="confirm"></u-modal>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. logoutShow: false,
  20. title: '确定退出?',
  21. content: '退出登录后将无法查看订单,重新登录后即可查看'
  22. }
  23. },
  24. methods: {
  25. // 退出登录
  26. logOut() {
  27. this.logoutShow = true
  28. },
  29. // 确定退出登录
  30. confirm() {
  31. this.$api.post('/api/logout').then(res => {
  32. if (res.code == 200) {
  33. this.logoutShow = false
  34. this.$cache.removeToken()
  35. this.$cache.removeCache('userInfo')
  36. uni.redirectTo({
  37. url: '/pages/login'
  38. })
  39. } else if (res.code == 401) {
  40. console.log(13)
  41. this.logoutShow = false
  42. this.$cache.removeToken()
  43. this.$cache.removeCache('userInfo')
  44. }
  45. })
  46. },
  47. // 取消
  48. cancel() {
  49. this.logoutShow = false
  50. },
  51. }
  52. }
  53. </script>
  54. <style lang="scss">
  55. .card_system {
  56. margin: 30rpx 30rpx 30rpx 30rpx;
  57. }
  58. .card_mine_option {
  59. margin: 40rpx 0rpx;
  60. border-bottom: 2rpx solid #E4E7ED;
  61. padding-bottom: 30rpx;
  62. }
  63. .option_title {
  64. font-size: 32rpx;
  65. font-weight: bold;
  66. }
  67. </style>