• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

我的博客我做主

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

uniapp 开发微信小程序总结(四)mixin - login

在这个项目中,调用登录接口时,将页面参数传入,且登录完成后需要调用别的接口。

 1 import {mapState,mapActions,mapMutations,mapGetters} from 'vuex'
 2 export default {
 3     computed:{
 4         ...mapState('login',['userInfo','inviteUserId','guidecode']),
 5         ...mapGetters('login',['isLogin']),
 6         getBinding(){
 7             if(this.isLogin&&(this.inviteUserId||this.guidecode)){
 8                 console.log('bindWithGuid...')
 9                 this.bindWithGuid({})
10             }
11             return this.isLogin
12         }
13     },
14     onLoad(options){
15         console.log('mixin onload...')
16         let _this = this
17         let {inviteUserId} = options
18         if(inviteUserId){
19             console.log('inviteUserId:' + inviteUserId)
20             this.GETINVITEUSERID({inviteUserId})
21         }
22         if(!this.isLogin){
23             // 微信小程序登录
24              uni.getSetting({
25                 success: function(t) {
26                     if(t.authSetting["scope.userInfo"]){
27                         _this.onGetUserInfo()
28                     }
29                 }
30             })
31         }
32     },
33     methods:{
34         ...mapMutations('login', ['GETINVITEUSERID']),
35         ...mapActions('login',['bindWithGuid','onGetUserInfo']),
36     }
37 }

 

作者:kitty20180903suzhou
出处:https://www.cnblogs.com/kitty-blog/
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。

posted on 2020-12-28 14:11  kitty20180903suzhou  阅读(487)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3