jiaju/pages/index/login.vue

110 lines
2.8 KiB
Vue

<template>
<view>
<view class="logo">
<image class="img" src="../../static/23.png" mode="aspectFill"></image>
</view>
<view class="name">
家具
</view>
<button open-type="getUserInfo" @click="getUserProfile()" type="default" class="button">
微信授权
</button>
<view class="text">
登录代表您已同意 <navigator class="on" url="">用户服务协议</navigator>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
getUserProfile(e) {
let that = this
wx.getUserProfile({
desc: '用于完善会员资料',
success: (userRes) => {
console.log(userRes)
wx.login({
success(res) {
that.request({
url: that.host + "/api/user/login",
type:"POST",
data: {
code: res.code,
nickname: userRes.userInfo.nickName,
headimgurl: userRes.userInfo.avatarUrl
},
success:function(data){
uni.setStorageSync('userData',data.data.data);
uni.redirectTo({
url: '/pages/personalCenter/personalCenter'
});
}
})
}
})
},
fail: (err) => {
}
})
},
}
}
</script>
<style>
.logo {
width: 200rpx;
margin: auto;
height: 200rpx;
margin-top: 350rpx;
border-radius: 50rpx;
box-shadow: 2rpx 2rpx 10rpx rgba(0, 0, 0, 0.5);
}
.img {
width: 200rpx;
height: 200rpx;
border-radius: 50rpx;
}
.name {
text-align: center;
font-size: 26rpx;
font-weight: bold;
margin-top: 10rpx;
}
.button {
color: #FFFFFF !important;
width: 630rpx;
background-color: #1aad19 !important;
margin: auto;
margin-top: 10vh;
}
.text {
text-align: center;
font-size: 28rpx;
display: flex;
justify-content: center;
margin-top: 20rpx;
}
.text .on {
color: #007AFF;
}
</style>