setting.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 cacheManager from '@/utils/cacheManager.js';
  12. function quitClick(){
  13. uni.showModal({
  14. title: '提示',
  15. content: '你确定要执行这个操作吗?',
  16. success: (res) => {
  17. if (res.confirm) {
  18. // 用户点击了确定按钮,执行你的操作
  19. console.log('用户点击了确定');
  20. quit()
  21. } else if (res.cancel) {
  22. // 用户点击了取消按钮
  23. console.log('用户点击了取消');
  24. }
  25. }
  26. });
  27. }
  28. function quit (){
  29. logout().then(res=>{
  30. console.log('logout')
  31. toast('退出登录成功')
  32. cacheManager.clearAll();
  33. }).catch(err => {
  34. toast('退出登录失败,请稍后重试')
  35. })
  36. }
  37. </script>
  38. <style>
  39. </style>