uni-Identify-quality/pages/login/login.vue
xingyy 5df9de86b2 1.修复登录状态过期时的提示和跳转逻辑 - 在接口请求中增加401 错误的处理,显示登录过期提示并跳转到登录页面
2. 添加游客访问功能
   - 在登录页面添加游客访问按钮,点击后跳转到首页
3.优化支付成功页面的数据加载 - 增加多个数据加载方法以适应不同的支付场景
4. 修复委托绘画页面的加载逻辑
   - 修复了委托绘画页面的加载问题,增加了错误提示
2024-10-18 15:18:56 +08:00

162 lines
3.8 KiB
Vue

<template>
<view class="main">
<view class="ykfw" @click="goRouter">游客访问</view>
<image src="@/static/image/logo.png" mode="scaleToFill" class="logo" />
<view class="btn">
<u-button v-if="isShow" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" color="transparent"
text="点击登录"></u-button>
</view>
<!-- <view class="btn">
<u-button v-if="isLogoutShow" @click="login" color="transparent">点击登录</u-button>
</view>-->
</view>
</template>
<script>
export default {
data() {
return {
code: "",
openId: "",
isShow: false,
isNew: false
};
},
methods: {
goRouter(){
uni.switchTab({
url: '/pages/home/index'
});
},
async getPhoneNumber(e) {
if (e.detail.errMsg == "getPhoneNumber:ok") {
// 用户允许或去手机号
let res = await this.$api.login.getTel({ code: e.detail.code });
if (res.status == 0) {
uni.setStorageSync("telNum", res.data.telNum);
if (this.isNew) {
uni.reLaunch({
url: "/pages/realName/realName"
});
} else {
uni.reLaunch({
url: "/pages/home/index"
});
}
} else {
this.$common.msgToast(res.msg);
}
} else {
this.$common.msgToast("请不要拒绝哟~重新点击登录");
}
},
//获取openId
async getOpenId() {
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 || !uni.getStorageSync("telNum")) {
this.isShow = true;
this.isNew = res1.data.accountInfo.isNew;
} else {
uni.reLaunch({
url: "/pages/home/index"
});
}
uni.setStorageSync("token", res1.data.token);
} else {
this.$common.msgToast(res1.msg);
}
}
});
},
// info判断用户是401就让他获取openId
// async info() {
// const res = await this.$api.mine.info();
// if (res.status === 0) {
// if (res.data.isNew) {
// //登录未注册
// uni.reLaunch({
// url: "/pages/realName/realName"
// });
// } else {
// //登录已注册
// uni.reLaunch({
// url: "/pages/home/index"
// });
// }
// } else if (res.status === 401) {
// this.getOpenId();
// } else {
// this.$common.msgToast(res.msg);
// }
// }
},
onLoad() {
// if (!uni.getStorageSync("telNum")) {
// this.getOpenId();
// }
// this.info();
this.getOpenId();
}
};
</script>
<style lang="scss" scoped>
/deep/.u-button {
background: red;
}
.main {
background: url("https://cdns.fontree.cn/fonchain-main/prod/image/1381bd18-2f0c-49f1-84f6-d3eceb94f7a7/artwork/6ef00a09-f663-451d-ae0c-0d00cf4068c5.png");
height: 100vh;
display: flex;
align-items: center;
flex-direction: column;
position: relative;
.ykfw{
height: 50rpx;
position:absolute;
top: 20rpx;
right: 40rpx;
color: #fff;
}
.logo {
margin-top: 250rpx;
width: 398rpx;
height: 744rpx;
}
uni-button:after {
border: 0px;
}
.btn {
background: transparent;
width: 200rpx;
position: fixed;
bottom: 15%;
color: #fff;
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%;
}
}
}
</style>