uniapp登录授权

摘要:
1、 第一阶段(微信、QQ、微博)˂viewclass=”“”

一、第一阶段(微信,QQ,微博)

<template>
    <view class="content">
        <view class="box">
            <view class="item">
                <image :src="http://t.zoukankan.com/qqimg" data-loginType="qq" mode="" @tap="auth" class="imagestyle"></image>
                <view class="">{{qqname}}
                </view>
            </view>
            <view class="item">
                <image :src="http://t.zoukankan.com/weixinimg" data-loginType="weixin" mode="" @tap="auth" class="imagestyle"></image>
                <view class="">{{weixinname}}
                </view>
            </view>
            <view class="item">
                <image :src="http://t.zoukankan.com/weiboimg" data-loginType="sinaweibo" mode="" @tap="auth" class="imagestyle"></image>
                <view class="">{{weiboname}}
                </view>
            </view>
        </view>
        <view class="" @tap='goauthentication()'>指纹认证
        </view>
        <view class="" @tap='gooldauthentication()'>旧指纹认证
        </view>
        
        <view class="input">
            <input type="text" value="" @input="onChange" />
        </view>
    </view>
</template>

<script>export default{
        data() {
            return{
                qqname: "qq_name",
                weixinname: "weixin_name",
                weiboname:'weibo_name',
                qqimg: require('@/static/images/QQ.png'),
                weixinimg: require('@/static/images/Weixin.png'),
                weiboimg:require('@/static/images/Weibo.png')
            }
        },
        onLoad() {

        },
        methods: {
            
            //获取数据
onChange(){
                uni.onKeyboardHeightChange(res =>{
                  console.log(res.height)
                })
            },
            
            
            //跳转到指纹认证
            goauthentication:function(){
                uni.navigateTo({
                    url:"/pages/authentication/authentication"})
            },
            
            //跳转到旧指纹认证
            gooldauthentication:function(){
                uni.navigateTo({
                    url:"/pages/oldauthentication/oldauthentication"})
            },
            
            auth(e) {
                var that = this;
                let loginType =e.currentTarget.dataset.logintype
                console.log("loginType", loginType)
                uni.login({
                    provider: loginType,
                    success(res) {
                        console.log(res)
                        //登录成功后, 获取用户数据
uni.getUserInfo({
                            provider: loginType,
                            success(info) {
                                var userInfo =info.userInfo
                                console.log("userInfo", userInfo)
                                var nickName = ""
                                var avatarUrl = ""
                                var openId = ""
                                if (loginType == "weixin") {
                                    nickName =userInfo.nickName
                                    that.weixinname =nickName
                                    that.weixinimg =userInfo.avatarUrl
                                    avatarUrl =userInfo.avatarUrl
                                    openId =userInfo.openId
                                } else if (loginType == "qq") {
                                    nickName =userInfo.nickname
                                    that.qqimg =userInfo.figureurl_qq
                                    that.qqname =nickName;
                                    avatarUrl =userInfo.figureurl_qq_2
                                    //qq返回了多个尺寸的头像, 按需选择
                                    openId =userInfo.openId
                                } else if (loginType == "sinaweibo") {
                                    console.log("userInfo",userInfo)
                                    that.weiboname =userInfo.nickName
                                    that.weiboimg =userInfo.avatar_large
                                    nickName =userInfo.nickname
                                    avatarUrl =userInfo.avatar_large
                                    openId =userInfo.id
                                }
                            }
                        })
                    }
                })
            }
        }
    }
</script>

<style lang="scss">.content {
        .box {
             100%;
            padding: 20rpx;
            box-sizing: border-box;
            display: flex;

            .item {
                 33.33%;
                text-align: center;
                border-right: 1rpx solid #C0C0C0;

                .imagestyle {
                     50%;
                    height: 120rpx;
                }
            }
        }
    }
</style>

免责声明:文章转载自《uniapp登录授权》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇IAR添加debug和release选项linux下安装ping命令下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

ArcGIS Pro 中文(简体)语言包-指定路径为空

在电脑上安装了ArcGISPro2.5,在安装中文(简体)语言包的时候,报错:指定路径为空。因此,新建立一个Chinese_CN项即可。经过上述修改,就可以成功安装中文(简体)语言包了。...

HTML5表单之input 类型- Date Pickers(日期选择器)

HTML5有几种新的输入类型用于选择日期和时间:日期:选择日期、月份、年份月份:选择月份、年份星期:选择星期和年份时间:选择时间datetime local:选择时间、日期、月份和年份datetime:选择时间、,年示例1:日期示例2:月示例3:周示例4:时间˂inputtype=“time”name=“tart_time”value=“”//示例5:dat...

WPF 制作圆角按钮

在程序对应坐置插入以下代码,或是先拖一个按钮控件到窗体中,再替换对应的代码。...

如何在Android模拟器上安装apk文件

如本实例的“mishop_2.0.20130911_1.1.1.apk”3.执行控制台命令,进行安装。切换到D盘,输入D:,然后点击Enter,即切换到D盘,输入cd,找到platform-tools的文件地址,即adb.exe的文件路径。,粘贴在控制台中。...

CentOS7 复制文件夹和移动文件夹

CentOS7在Linux中复制、移动和删除文件的命令有:cp、mv、rm I。文件复制命令cp命令格式:cp[-adfilprsu]源文件(source)目标文件(destination)cp[option]source1source2source3…directory参数描述:-a:指存档,即复制所有目录-d:如果源文件是连接文件(linkfile...

ORACLE无法删除当前连接用户

今天在做Oracle数据库是遇到ORACLE无法删除当前连接用户,经查找可用如下方法解决。SQL˃dropuseracascade;//删除用户以及用户表空间下所有对象用户已丢弃。...