1. The login

1) Login in wechat environment 2) Login in enterprise wechat

Call wechat login interface -> return code -> use code request interface to get openId -> use mobile number (wechat return encryptedData) and openId to get token -> login success

2. Dynamic tabBar

It is a big pit of small program!! QSWL!!!!!! Note: wx.hideTabbar () and wx.showTabbar () are invalid if you use custom tabbars. You can hide tabbars by setting separate routes or control them by js

1) Handwritten and 2) official custom tab-bar

The second method I use. Create a custom tab-bar folder at the same level as pages (you can get demo on Github)

index.js

Component({
  data: {
    selected: 0.color: '#CECECE'.selectedColor: '# 476853'.backgroundColor: '#FFFFFF'.borderStyle: 'black'.list: [].studentTabList: [{pagePath: '/pages/home/index/index'.// Note that the path is different from that of app.config
        iconPath: '/assets/footer-bar/home.png'.// Note that the path is different from that of app.config
        selectedIconPath: '/assets/footer-bar/home_active.png'./ / same as above
        text: 'course'},].teacherTabList: [{pagePath: '/pages/home/index/index'.iconPath: '/assets/footer-bar/table.png'.selectedIconPath: '/assets/footer-bar/table_active.png'.text: 'Timetable'
      },
      {
        pagePath: '/pages/user/index/index'.iconPath: '/assets/footer-bar/user.png'.selectedIconPath: '/assets/footer-bar/user_active.png'.text: 'I'}},attached() {
    // When the component instance enters the page node tree
    let type = wx.getStorageSync('type') | |'teacher' // After login, get the identity of the login student or teacher
    if (type == 'student') {
      this.setData({
        list: this.data.studentTabList
      })
    } else {
      this.setData({
        list: this.data.teacherTabList
      })
    }
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({ url })
      this.setData({
        selected: data.index
      })
    }
  }
})

Copy the code

app.config.js


  tabBar: {
    custom: true.color: '#CECECE'.selectedColor: '# 476853'.backgroundColor: '#FFFFFF'.borderStyle: 'black'.list: [ // All possible tabbars
      {
        pagePath: 'pages/home/index/index'.iconPath: 'assets/footer-bar/table.png'.selectedIconPath: 'assets/footer-bar/table_active.png'.text: 'Timetable'
      },
      {
        pagePath: 'pages/home/index/index'.iconPath: 'assets/footer-bar/home.png'.selectedIconPath: 'assets/footer-bar/home_active.png'.text: 'course'
      },
      {
        pagePath: 'pages/user/index/index'.iconPath: 'assets/footer-bar/user.png'.selectedIconPath: 'assets/footer-bar/user_active.png'.text: 'I'}}}]Copy the code