Commit 8c42825e authored by zuoliyuan's avatar zuoliyuan

授权

parent c73f2bbb
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title" style="font-size: 12px;padding: 100px;" @click="copy">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: this.$route.query.code
}
},
onLoad() {
// localStorage.removeItem("hasLogin")
// console.log("code:"+this.$route.query.code);
debugger
if (!localStorage.getItem("hasLogin")) {
uni.redirectTo({
url: '/pages/login/index'
});
}
if (this.$route.query.code) {
// 从静模授权进入首页
localStorage.setItem("auth_code", this.$route.query.code)
// alert("code:" + this.$route.query.code);
// this.getuserinfo3rd()
}
},
methods: {
// 获取敏感信息
getuserinfo3rd: function() {
uni.request({
url: 'http://127.0.0.1:4523/m1/2230462-1135055-default/getData?code=' + this.$route.query
.code,
method: 'get',
success: function(res) {
// alert(res.data.hasChildren, this.$route.query.code)
console.log("res:" + res);
}
})
},
copy: function() {
uni.setClipboardData({
data: this.$route.query.code,
success: () => {
uni.showToast({
title: '复制成功',
duration: 2000,
icon: 'success'
});
}
});
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
\ No newline at end of file
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: this.$route.query.code
}
},
onLoad() {
if(localStorage.getItem("hasLogin")=='false'){
uni.redirectTo({
url: '../login/login'
});
}
if(this.$route.query.code){
// 从静模授权进入首页
localStorage.setItem("auth_code",this.$route.query.code)
this.getuserinfo3rd()
}
},
methods: {
// 获取敏感信息
getuserinfo3rd:function(){
uni.request({
url: 'http://tantan.vaiwan.com/login/getuserinfo3rd.do?code='+this.$route.query.code,
method:'POST',
success: function (res) {
console.log("res:"+res);
}
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
\ No newline at end of file
<template>
<view class="launch-v">
<!-- #ifdef APP-PLUS -->
<view class="launch-box">
<view class="title">全新模式 为你而来</view>
<view class="version">VERSION3.7</view>
<view class="launch-img">
<image :src="startup" mode="widthFix"></image>
</view>
<!-- <view class="copyright">Copyright © 2024 华中师范大学出品</view> -->
</view>
<!-- #endif -->
</view>
</template>
<script>
import resources from '@/libs/resources.js'
import {
useUserStore
} from '@/store/modules/user'
export default {
data() {
return {
startup: resources.startup.main
}
},
onLoad() {
if (uni.getStorageSync('isUpdate')) return
const launchFlag = uni.getStorageSync('launchFlag');
const token = uni.getStorageSync("token") || '';
console.log(launchFlag, 999)
if (launchFlag) {
alert(1)
if (token) {
uni.switchTab({
url: '/pages/index/index'
})
} else {
uni.redirectTo({
url: '/pages/login/index'
})
}
} else {
alert(2)
// #ifdef APP-PLUS
uni.redirectTo({
url: '/pages/launch/policy'
})
// #endif
// #ifndef APP-PLUS
if (token) {
alert(3)
uni.switchTab({
url: '/pages/index/index'
})
} else {
// uni.redirectTo({
// url: '/pages/login/qywxLogin'
// })
if (!localStorage.getItem("hasLogin")) {
alert(4)
uni.redirectTo({
url: '/pages/login/qywxLogin'
})
}
if (this.$route.query.code) {
alert(5)
// 从静模授权进入首页
localStorage.setItem("auth_code", this.$route.query.code)
this.getToken()
}
}
// #endif
}
},
methods: {
// 获取敏感信息
getToken: function() {
const userStore = useUserStore()
const data = {
nonPassword: 'nonPassword',
grant_type: 'password',
code: this.$route.query.code
}
uni.request({
url: 'https://dj.ccnu.edu.cn/api/oauth/wechat/getToken',
data: JSON.stringify(data),
method: 'POST',
success: function(res) {
alert("res:" + res.data.token+';'+this.$route.query.code);
let token = res.data.token
userStore.setToken(token)
// this.rememberAccount()
userStore.getCurrentUser().then(res => {
// this.loading = false
uni.switchTab({
url: '/pages/index/index'
});
}).catch(() => {
// this.loading = false
})
}
})
}
}
}
</script>
<style lang="scss">
.launch-v {
.launch-box {
padding-top: 170rpx;
.title {
font-size: 50rpx;
line-height: 70rpx;
color: #5098FA;
text-align: center;
margin-bottom: 10rpx;
}
.version {
width: 250rpx;
margin: 0 auto;
text-align: center;
height: 50rpx;
border: 1px solid #5098FA;
border-radius: 25rpx;
line-height: 48rpx;
color: #5098FA;
letter-spacing: 2rpx;
}
.launch-img {
margin: 0 auto;
width: 680rpx;
image {
width: 100%;
}
}
.copyright {
position: fixed;
bottom: 120rpx;
right: 0;
left: 0;
text-align: center;
color: #999999;
font-size: 24rpx;
}
}
}
</style>
\ No newline at end of file
<template>
<view style="width: 96%;margin: 0 auto;">
<view>
<form @submit="doLogin">
<button plain="true" class="loginBtn" lang="zh_CN" form-type="submit">登录</button>
</form>
</view>
</view>
</template>
<script>
export default {
data() {
return {
usercode: '',
password: '',
passwordHidden: true
}
},
onLoad: function() {
localStorage.removeItem("hasLogin")
},
methods: {
doLogin() {
let _this = this
localStorage.setItem("hasLogin", true)
// 这里放自己的域名
let redirect_uri = encodeURI("https://dj.ccnu.edu.cn/app")
let authorUrl =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7219d601c7041b7a&redirect_uri=' +
redirect_uri + '&response_type=code&scope=snsapi_base&state=STATE&agentid=1000396#wechat_redirect'
console.log(authorUrl, 898)
window.location.href = authorUrl
}
}
}
</script>
<style>
.loginBtn {
color: #337bd4 !important;
border: 1rpx solid #337bd4 !important;
font-size: 30rpx;
border-radius: 50rpx;
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment