setting.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <view>
  3. <view class="list-row" @click="quitClick">
  4. <icon class="list-icon login-out-icon"></icon>
  5. <text>退出登录</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script setup>
  10. import {logout} from '@/api/login.js'
  11. import {toast} from "@/utils/common";
  12. import cacheManager from '@/utils/cacheManager.js';
  13. function quitClick(){
  14. uni.showModal({
  15. title: '提示',
  16. content: '你确定要执行这个操作吗?',
  17. success: (res) => {
  18. if (res.confirm) {
  19. // 用户点击了确定按钮,执行你的操作
  20. console.log('用户点击了确定');
  21. quit()
  22. } else if (res.cancel) {
  23. // 用户点击了取消按钮
  24. console.log('用户点击了取消');
  25. }
  26. }
  27. });
  28. }
  29. function quit (){
  30. logout().then(res=>{
  31. console.log('logout')
  32. toast('退出登录成功')
  33. cacheManager.clearAll();
  34. }).catch(err => {
  35. toast('退出登录失败,请稍后重试')
  36. })
  37. }
  38. </script>
  39. <style>
  40. </style>