wepy-relogin

    0.0.5 • Public • Published

    wepy-reload

    安装

    npm install --save wepy-reload

    使用

    import wepy from 'wepy'
    import Relogin from 'wepy-reload'
     
    //传入 wepy
    Relogin.login(wepy)
    .then(e => {
      wepy.showToast({
        title: '登录成功',
        icon: 'success',
        duration: 1000
      })
      console.log(e)
    })
    .catch(e => {
      console.log(e)
    })

    or

        //app.wpy
        globalData = {
          userInfo: null,
        }
     
        async getUserInfo() {
          let userInfo = this.globalData.userInfo
          if (!userInfo) {
            userInfo = await Relogin.login(wepy, false)
            this.globalData.userInfo = userInfo
            return userInfo
          } else {
            return new Promise(userInfo)
          }
        }
     
        //page/index.wpy
        getUserInfo() {
          this.$parent.getUserInfo()
              .then(e => {
                this.userInfo = e.userInfo
                this.$apply()
                console.log('授权成功', this.userInfo)
              })
              .catch(e => {
                console.log('授权失败',e)
              })
        }

    依赖

    wepy

    async-await

    Install

    npm i wepy-relogin

    DownloadsWeekly Downloads

    3

    Version

    0.0.5

    License

    ISC

    Unpacked Size

    5.01 kB

    Total Files

    3

    Last publish

    Collaborators

    • avatar