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

220 lines
4.3 KiB

<template>
5 years ago
<view class="container">
<view v-if="!token">
<!-- #ifdef MP-WEIXIN -->
<view>
5 years ago
<view class="getUserInfo">
<text>您还未允许微信登录授权请点击下方按钮允许微信授权登录</text>
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
<view style="height:20rpx"></view>
<button @click="back">取消微信登录授权</button>
</view>
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<view>
5 years ago
<view class="getUserInfo">
<text>请先登录</text>
<button type="primary" @tap="toLogin">去登录</button>
5 years ago
</view>
</view>
<!-- #endif -->
5 years ago
</view>
</view>
</template>
<script>
5 years ago
import { mapState, mapMutations, mapActions } from "vuex";
import { wxappAuth, getUser } from "@/api/user";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import { login, authorize } from "@/utils";
5 years ago
export default {
5 years ago
data() {
return {
authorize: false,
};
5 years ago
},
computed: {
...mapState(["isAuthorization", "$deviceType", "token"]),
5 years ago
},
onShow() {
// // 先校验用户是否授权,如果没有授权,显示授权按钮
5 years ago
},
onHide() {
5 years ago
this.updateAuthorizationPage(false);
5 years ago
this.changeAuthorization(false);
},
onUnload() {
5 years ago
this.updateAuthorizationPage(false);
5 years ago
this.changeAuthorization(false);
},
methods: {
...mapActions(["changeAuthorization", "setUserInfo"]),
...mapMutations(["updateAuthorizationPage"]),
toLogin() {
this.$yrouter.push({
path: "/pages/user/Login/index",
query: {},
});
},
5 years ago
back() {
this.$yrouter.switchTab({
path: "/pages/home/index",
query: {},
5 years ago
});
},
getUserInfo(data) {
if (data.detail.errMsg == "getUserInfo:fail auth deny") {
uni.showToast({
title: "取消授权",
icon: "none",
duration: 2000,
5 years ago
});
return;
}
uni.showLoading({
title: "登录中",
5 years ago
});
login()
.then((res) => {
5 years ago
this.$yrouter.replace({ path: cookie.get("redirect") });
})
.catch((error) => {
5 years ago
console.log(error);
uni.showToast({
title: error,
5 years ago
icon: "none",
duration: 2000,
5 years ago
});
});
},
},
mounted() {},
5 years ago
};
</script>
<style lang="less">
5 years ago
.sp-cell {
5 years ago
height: 20rpx;
5 years ago
}
.getUserInfo {
5 years ago
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
text {
font-size: 30rpx;
text-align: center;
margin-bottom: 20px;
}
5 years ago
}
.container {
5 years ago
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
position: relative;
5 years ago
}
.tab-bar {
5 years ago
font-size: 0;
display: flex;
align-items: center;
background: rgba(255, 255, 255, 0.9);
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 99;
border-top: 1px solid rgba(248, 248, 248, 1);
.tab-bar-item {
flex: 1;
height: 49px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
&.active {
text {
color: #ee7559;
}
.tab-bar-pic {
display: none;
background: #f9f9f9;
&.active {
display: block;
}
}
}
.tab-bar-pic {
display: block;
background: #f9f9f9;
&.active {
display: none;
}
}
}
.tab-bar-pic {
width: 25px;
height: 25px;
background: #f9f9f9;
image {
width: 25px;
height: 25px;
}
}
.tab-bar-pic-active {
}
text {
font-size: 10px;
color: rgb(160, 160, 160);
line-height: 10px;
margin-top: 5px;
}
5 years ago
}
.tab-bar-bg {
5 years ago
padding-top: 46px;
width: 100%;
5 years ago
}
.view-item {
5 years ago
display: none;
width: 100%;
5 years ago
}
.view-item-active {
5 years ago
display: block;
5 years ago
}
.getUserInfo {
5 years ago
display: flex;
align-items: center;
flex-direction: column;
padding: 30px;
p {
margin-bottom: 20px;
}
5 years ago
}
5 years ago
._van-dialog {
5 years ago
z-index: 99999999999;
5 years ago
}
</style>