zoukankan      html  css  js  c++  java
  • uniapp 开发微信小程序总结(四)mixin

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

     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 }
  • 相关阅读:
    012 spring retry重试原理的解析
    011 @Retryable的使用
    010 @ControllerAdvice
    009 SpringBoot+Swagger的使用
    008 @Import作用
    007 SpringBoot的@EnableAutoConfiguration注解
    001 品牌管理案例
    000 vue各种基本指令
    013 JS
    002 docker基本的命令
  • 原文地址:https://www.cnblogs.com/kitty-blog/p/14043471.html
Copyright © 2011-2022 走看看