user.vue 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view>
  3. <button @click="loginOut">退出登录</button>
  4. <button @click="logOff">注销</button>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. logOffApi
  10. } from "@/api/user.js"
  11. export default {
  12. data() {
  13. return {
  14. }
  15. },
  16. methods: {
  17. loginOut() {
  18. wx.removeStorageSync('userInfo')
  19. wx.removeStorageSync('userId')
  20. wx.removeStorageSync('token')
  21. getApp().globalData.hasLogin = false;
  22. this.hasLogin = false
  23. },
  24. logOff() {
  25. wx.showModal({
  26. title: '确认注销账号?',
  27. content: '注销账号后xxxxx',
  28. success: (res) => {
  29. if (res.confirm) {
  30. console.log('用户点击确定')
  31. logOffApi().then(res => {
  32. wx.removeStorageSync('userInfo')
  33. wx.removeStorageSync('userId')
  34. wx.removeStorageSync('token')
  35. getApp().globalData.hasLogin = false;
  36. this.hasLogin = false
  37. })
  38. } else if (res.cancel) {
  39. console.log('用户点击取消')
  40. }
  41. }
  42. })
  43. }
  44. }
  45. }
  46. </script>
  47. <style>
  48. </style>