Files

194 lines
4.9 KiB
Vue
Raw Normal View History

<template>
2020-06-02 02:34:01 +08:00
<view class="container">
2020-09-03 02:58:31 +08:00
<!-- #ifdef MP-WEIXIN -->
<view v-if="!token" class="force-login-wrap">
2020-09-10 18:35:29 +08:00
<!-- <image class="logo-bg" src="@/static/images/logo_bg.png" mode="aspectFill"></image> -->
2020-09-03 02:58:31 +08:00
<view class="force-login__content y-f">
<open-data class="user-avatar" type="userAvatarUrl"></open-data>
<open-data class="user-name" type="userNickName"></open-data>
<view class="login-notice">为了提供更优质的服务需要获取您的头像昵称</view>
<button class="cu-btn author-btn" @getuserinfo="getUserInfo" open-type="getUserInfo">授权并查看</button>
<button class="cu-btn close-btn" @tap="back">暂不授权</button>
2020-06-02 02:34:01 +08:00
</view>
2020-09-03 02:58:31 +08:00
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
2020-09-03 03:02:18 +08:00
<view class="force-login-wrap">
<image class="logo-bg" src="@/static/images/logo_bg.png" mode="aspectFill"></image>
<view class="force-login__content y-f">
<view class="login-notice">为了提供更优质的服务请先登录</view>
<button class="cu-btn author-btn" @tap="toLogin">去登录</button>
2020-06-02 02:34:01 +08:00
</view>
</view>
2020-09-03 02:58:31 +08:00
<!-- #endif -->
2020-06-02 02:34:01 +08:00
</view>
</template>
<script>
2020-09-03 02:58:31 +08:00
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";
export default {
data() {
return {
authorize: false,
};
},
computed: {
...mapState(["isAuthorization", "$deviceType", "token"]),
},
onShow() {
// // 先校验用户是否授权,如果没有授权,显示授权按钮
},
onHide() {
this.updateAuthorizationPage(false);
this.changeAuthorization(false);
2020-08-15 20:07:33 +08:00
},
2020-09-03 02:58:31 +08:00
onUnload() {
this.updateAuthorizationPage(false);
this.changeAuthorization(false);
2020-06-02 02:34:01 +08:00
},
2020-09-03 02:58:31 +08:00
methods: {
...mapActions(["changeAuthorization", "setUserInfo"]),
...mapMutations(["updateAuthorizationPage"]),
toLogin() {
this.$yrouter.push({
path: "/pages/user/Login/index",
query: {},
2020-06-02 02:34:01 +08:00
});
2020-09-03 02:58:31 +08:00
},
back() {
this.$yrouter.switchTab({
path: "/pages/home/index",
query: {},
});
},
getUserInfo(data) {
if (data.detail.errMsg == "getUserInfo:fail auth deny") {
2020-06-02 02:34:01 +08:00
uni.showToast({
2020-09-03 02:58:31 +08:00
title: "取消授权",
2020-06-02 02:34:01 +08:00
icon: "none",
2020-08-15 20:07:33 +08:00
duration: 2000,
2020-06-02 02:34:01 +08:00
});
2020-09-03 02:58:31 +08:00
return;
}
uni.showLoading({
title: "登录中",
2020-06-02 02:34:01 +08:00
});
2020-09-03 02:58:31 +08:00
login()
.then((res) => {
this.$yrouter.replace({
path: cookie.get("redirect")
});
})
.catch((error) => {
console.log(error);
uni.showToast({
title: error,
icon: "none",
duration: 2000,
});
});
},
2020-06-02 02:34:01 +08:00
},
2020-09-03 02:58:31 +08:00
mounted() {},
};
</script>
<style lang="less">
2020-09-03 02:58:31 +08:00
.container {
2020-06-02 02:34:01 +08:00
flex: 1;
display: flex;
flex-direction: column;
2020-09-03 02:58:31 +08:00
justify-content: flex-start;
position: relative;
}
2020-06-02 02:34:01 +08:00
2020-09-03 02:58:31 +08:00
.force-login-wrap {
position: fixed;
width: 100vw;
height: 100vh;
overflow: hidden;
z-index: 11111;
top: 0;
2020-09-10 18:35:29 +08:00
background: #fff;
2020-09-03 02:58:31 +08:00
.logo-bg {
width: 640rpx;
height: 300rpx;
}
2020-06-02 02:34:01 +08:00
2020-09-03 02:58:31 +08:00
.force-login__content {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
.user-avatar {
width: 160rpx;
height: 160rpx;
border-radius: 50%;
overflow: hidden;
margin-bottom: 40rpx;
2020-06-02 02:34:01 +08:00
}
2020-09-03 02:58:31 +08:00
.user-name {
font-size: 35rpx;
font-family: PingFang SC;
font-weight: bold;
2020-09-10 18:35:29 +08:00
color: #000;
2020-09-03 02:58:31 +08:00
margin-bottom: 30rpx;
}
2020-06-02 02:34:01 +08:00
2020-09-03 02:58:31 +08:00
.login-notice {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
2020-09-10 18:35:29 +08:00
color: #000;
2020-09-03 02:58:31 +08:00
line-height: 44rpx;
2020-09-03 03:02:18 +08:00
width: 500rpx;
2020-09-03 02:58:31 +08:00
text-align: center;
margin-bottom: 80rpx;
2020-06-02 02:34:01 +08:00
}
2020-09-03 02:58:31 +08:00
.author-btn {
width: 630rpx;
height: 80rpx;
2020-09-10 18:35:29 +08:00
background: linear-gradient(90deg, #eb3729, #eb3729);
// box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
2020-09-03 02:58:31 +08:00
border-radius: 40rpx;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: rgba(255, 255, 255, 1);
}
2020-06-02 02:34:01 +08:00
2020-09-03 02:58:31 +08:00
.close-btn {
width: 630rpx;
height: 80rpx;
margin-top: 30rpx;
border-radius: 40rpx;
2020-09-10 18:35:29 +08:00
border: 2rpx solid #eb3729;
2020-09-03 02:58:31 +08:00
background: none;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
2020-09-10 18:35:29 +08:00
color: #eb3729;
2020-09-03 02:58:31 +08:00
}
2020-06-02 02:34:01 +08:00
}
}
2020-04-23 19:55:05 +08:00
</style>