user.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. wx.switchTab({
  23. url: '/pages/mine/mine'
  24. })
  25. },
  26. logOff() {
  27. wx.showModal({
  28. title: '确认注销账号?',
  29. content: '注销账号后xxxxx',
  30. success: (res) => {
  31. if (res.confirm) {
  32. console.log('用户点击确定')
  33. logOffApi().then(res => {
  34. wx.removeStorageSync('userInfo')
  35. wx.removeStorageSync('userId')
  36. wx.removeStorageSync('token')
  37. getApp().globalData.hasLogin = false;
  38. wx.switchTab({
  39. url: '/pages/mine/mine'
  40. })
  41. })
  42. } else if (res.cancel) {
  43. console.log('用户点击取消')
  44. }
  45. }
  46. })
  47. }
  48. }
  49. }
  50. </script>
  51. <style>
  52. </style>