litian
2024-07-10 81c23f9c2f5bdfbe962d0b19a5a80ea7c12f043d
pages/bibliographyList/index.js
@@ -1,7 +1,9 @@
// pages/bibliographyList/index.js
import Toast from 'tdesign-miniprogram/toast/index';
const app = getApp()
const config =
import {
  loginInfo
} from '../../assets/js/login';
  Page({
    /**
@@ -68,8 +70,6 @@
          });
        },
      })
      this.ceShi()
    },
    /**
@@ -84,7 +84,17 @@
     */
    onShow() {
      // console.log(this.data.value);
    // 检查登录状态
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.getUserInfo()
        }
      })
    } else {
      this.getUserInfo()
    }
    },
    /**
@@ -121,6 +131,32 @@
    onShareAppMessage() {
    },
  // 获取登录用户身份
  getUserInfo() {
    app.MG.identity.getCurrentAppUser().then(res => {
      // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认)
      if (res) {
        //获取用户类型
        let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
        let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
        let eMailData = res.secretList.find(i => i.type == 'EMail')
        if (eMailData) {
          this.setData({
            input: eMailData.credential
          })
        } else if (teacherRole && teacherInfos) {
          this.setData({
            input: JSON.parse(teacherInfos.data).email
          })
        } else {
          this.setData({
            input: ''
          })
        }
      }
    });
  },
    onTabsChange(event) {
      const value = event.detail.value
      this.setData({
@@ -472,25 +508,5 @@
        input: e.detail.value
      })
    },
    ceShi() {
      let that = this;
      // 获取Storage中的数据
      wx.getStorage({
        key: 'website-front-userInfo',
        success(res) {
          let datas = JSON.parse(res.data)
          console.log(datas.Email);
          let personalData = JSON.parse(datas.data)
          that.setData({
            input: datas.Email
          })
          console.log(that.data.value);
        },
        fail(err) {
          console.error(err);
        }
      });
    }
  })