mine.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Page({
  2. /**
  3. * 页面的初始数据
  4. */
  5. data: {
  6. booLogout: false,
  7. booLock: false
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad(options) {
  13. },
  14. /**
  15. * 生命周期函数--监听页面初次渲染完成
  16. */
  17. onReady() {
  18. },
  19. /**
  20. * 生命周期函数--监听页面显示
  21. */
  22. onShow() {
  23. this.getTabBar().init()
  24. },
  25. /**
  26. * 生命周期函数--监听页面隐藏
  27. */
  28. onHide() {
  29. },
  30. /**
  31. * 生命周期函数--监听页面卸载
  32. */
  33. onUnload() {
  34. },
  35. jump(e) {
  36. const { page } = e.currentTarget.dataset
  37. wx.navigateTo({
  38. url: `/pages/${page}/${page}`
  39. })
  40. },
  41. showLogout() {
  42. this.setData({
  43. booLogout: true
  44. })
  45. },
  46. hideLogout() {
  47. this.setData({
  48. booLogout: false
  49. })
  50. },
  51. async confirmLogout() {
  52. this.setData({
  53. booLock: true
  54. })
  55. try {
  56. const { status, msg } = await userLoginOut()
  57. if (status) {
  58. this.hideLogout()
  59. wx.removeStorageSync(sessionStorageKey)
  60. // 更新用户信息
  61. app.globalData.userInfo = {}
  62. wx.reLaunch({
  63. url: '/pages/mine/mine'
  64. })
  65. } else {
  66. wx.showToast({
  67. title: msg,
  68. icon: 'none'
  69. })
  70. }
  71. } catch (e) {}
  72. this.setData({
  73. booLock: false
  74. })
  75. }
  76. })