// pages/settingss/settingss.js
const app = getApp();

Page({
  data: {
    menuButtonInfo: { height: 32, width: 32, top: 0 },
    statusBarHeight: 0
  },

  onLoad() {
    this.initSystemInfo();
  },

  initSystemInfo() {
    try {
      const systemInfo = wx.getSystemInfoSync();
      const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
      this.setData({
        statusBarHeight: systemInfo.statusBarHeight || 0,
        menuButtonInfo: menuButtonInfo || this.data.menuButtonInfo
      });
    } catch (e) {
      console.error('获取系统信息失败:', e);
    }
  },

  navigateBack() { 
    wx.navigateBack(); 
  },

  openFeedback() { 
    wx.navigateTo({ url: '/subpackages/settings/feedback/feedback' }); 
  },

  async logout() {
    wx.showModal({
      title: '退出登录',
      content: '确定要退出当前账号吗？',
      success: (res) => {
        if (res.confirm) {
          app.logout().then(() => {
            wx.reLaunch({
              url: '/pages/login/login'
            });
          });
        }
      }
    });
  }
});