litian
2024-07-09 86cbb2a45a153a704bcc0d63697f83d2832caa71
pages/personalCenter/index.js
@@ -47,7 +47,7 @@
  {
    title: '出书申请',
    icon: '/static/images/personal/chushu.png',
    url: '/packagePersonal/pages/publishBooks/index',
    url: '',
    type: 'publishBooks',
  }
];
@@ -102,6 +102,7 @@
  data: {
    barHeight: '',
    navBarHeight: '',
    scoll: false,
    isWhite: false,
    userInfo: {},
    currAuthStep: 1,
@@ -120,7 +121,7 @@
      value: false
    },
    loadingProps: {
      size: '50rpx',
      size: '10rpx',
    },
    scrollTop: 0,
  },
@@ -135,6 +136,14 @@
      barHeight: systInfo.statusBarHeight,
      navBarHeight: navBarHeight,
    });
  },
  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        active: 4
      })
    }
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
@@ -148,16 +157,9 @@
      })
    } else {
      this.setData({
        currAuthStep: 1,
        currAuthStep: 3,
      });
      this.getUserInfo()
    }
  },
  onShow() {
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        active: 4
      })
    }
  },
  /**
@@ -185,7 +187,7 @@
          this.setData({
            userTypeActive: JSON.parse(userTypeData.data).userType,
          });
          type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
          type = this.data.userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable;
        } else {
          type = ''
        }
@@ -194,11 +196,12 @@
        let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
        let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
        let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
        let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
        if (teacherRole && teacherInfos) {
          defaultUser = {
            ...teacherInfos,
            nickName: teacherInfos.name,
            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo ? WeChatInfo.name : '',
            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo ? WeChatInfo.icon : '',
            userId: res.userId,
            role: 'Teacher',
            roleId: teacherRole.role.id,
@@ -211,11 +214,22 @@
        } else if (WeChatInfo) {
          defaultUser = {
            ...WeChatInfo,
            nickName: nickNameData ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
            icon: nickNameData ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : WeChatInfo.name,
            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : WeChatInfo.icon,
            userId: res.userId,
            userType: type,
            role: 'Student',
          }
          this.setData({
            currAuthStep: 3,
          });
        } else if (secretData) {
          defaultUser = {
            nickName: nickNameData && JSON.parse(nickNameData.data).nickName ? JSON.parse(nickNameData.data).nickName : secretData.credential,
            icon: nickNameData && JSON.parse(nickNameData.data).icon != "" ? JSON.parse(nickNameData.data).icon : "",
            userId: res.userId,
            role: "Student",
            userType: type,
          }
          this.setData({
            currAuthStep: 3,
@@ -333,15 +347,23 @@
  },
  onScroll(e) {
    if (this.data.scoll) {
      if (e.detail.scrollTop < 20) {
        this.data.scoll = false
        this.isChange(false);
      }
    } else {
      if (e.detail.scrollTop > 20) {
        this.data.scoll = true
        this.isChange(true);
      }
    }
  },
  isChange(data) {
    this.setData({
      isWhite: e.detail.scrollTop > 10 ? true : false
      isWhite: data
    })
    const {
      scrollTop
    } = e.detail;
    this.setData({
      scrollTop
    });
  },