You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.3 KiB
Vue

1 year ago
<template>
1 year ago
<view class="main">
<image src="@/static/image/logo.png" mode="scaleToFill" class="logo" />
1 year ago
<view class="btn">
<u-button
v-if="isShow"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
color="transparent"
>点击登录</u-button>
</view>
<!-- <view class="btn">
<u-button v-if="isLogoutShow" @click="login" color="transparent"></u-button>
</view>-->
1 year ago
</view>
1 year ago
</template>
<script>
1 year ago
export default {
data() {
return {
code: "",
openId: "",
1 year ago
isShow: true,
isLogoutShow: true
1 year ago
};
},
methods: {
async getPhoneNumber(e) {
1 year ago
console.log(e);
1 year ago
if (e.detail.errMsg == "getPhoneNumber:ok") {
// 用户允许或去手机号
1 year ago
let res = await this.$api.login.getTel({ code: e.detail.code });
1 year ago
if (res.status == 0) {
1 year ago
uni.setStorageSync("telNum", res.data.telNum);
1 year ago
uni.redirectTo({
1 year ago
url: "/pages/realName/realName"
1 year ago
});
1 year ago
} else {
this.$common.msgToast(res.msg);
1 year ago
}
} else {
this.$common.msgToast("请不要拒绝哟~重新点击登录");
}
1 year ago
}
1 year ago
// async login() {
// // 获取code
// uni.login({
// provider: "weixin",
// success: async res => {
// console.log(res);
// this.code = res.code;
// let res1 = await this.$api.login.login({ code: res.code });
// if (res1.status == 0) {
// this.isShow = true;
// this.openId = res1.data.accountInfo.openId;
// uni.setStorageSync("token", res1.data.token);
// uni.redirectTo({
// url: "/pages/register/register"
// });
// } else {
// this.$common.msgToast(res1.msg);
// }
// }
// });
// }
1 year ago
},
onLoad() {
1 year ago
uni.login({
provider: "weixin",
success: async res => {
console.log("res.code", res.code);
this.code = res.code;
let res1 = await this.$api.login.login({ code: res.code });
if (res1.status == 0) {
if (res1.data.accountInfo.isNew) {
this.isShow = true;
this.openId = res1.data.accountInfo.openId;
uni.setStorageSync("token", res1.data.token);
1 year ago
} else {
1 year ago
uni.setStorageSync("token", res1.data.token);
uni.redirectTo({
url: "/pages/home/index"
});
1 year ago
}
1 year ago
} else {
this.$common.msgToast(res1.msg);
1 year ago
}
1 year ago
}
});
1 year ago
}
};
1 year ago
</script>
<style lang="scss" scoped>
1 year ago
/deep/.u-button {
background: red;
}
1 year ago
.main {
1 year ago
background: url("https://cdns.fontree.cn/fonchain-main/prod/image/1381bd18-2f0c-49f1-84f6-d3eceb94f7a7/artwork/6ef00a09-f663-451d-ae0c-0d00cf4068c5.png");
height: 100vh;
1 year ago
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
.logo {
width: 237rpx;
height: 390rpx;
}
1 year ago
uni-button:after {
border: 0px;
}
1 year ago
.btn {
background: transparent;
width: 200rpx;
position: fixed;
bottom: 15%;
1 year ago
color: #fff;
1 year ago
left: 50%;
transform: translateX(-50%);
font-size: 30rpx;
transition: all 1s;
animation: jump 1s ease-in-out infinite alternate;
}
@keyframes jump {
from {
bottom: 16%;
}
to {
bottom: 15%;
}
}
}
1 year ago
</style>