view

          <view class="container">
                    <view class="btn">
                        <button open-type="getUserInfo" @getuserinfo="getUserInfo"></button>
                        微信一键登录
                    </view>
                </view>

JavaScript

复制代码
       getUserInfo() {
                uni.login({
                    provider:'weixin',
                    success(logRes) {
                        console.log(logRes)
                        uni.getUserInfo({
                            provider:'weixin',
                            success(infoRes) {
                                console.log(infoRes)
                            }
                        })
                    }
                })
            }
复制代码

css

复制代码
            .btn{
                        width: 200rpx;
                        height: 80rpx;
                        color: #5AA8A6;
                        background-color: #fff;
                        font-size: 28rpx;
                        position: relative;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        button{
                            position: absolute;
                            width: 100%;
                            height: 100%;
                            opacity: 0;
                        }
                    }
复制代码