sc
This commit is contained in:
@@ -14,7 +14,15 @@ const { start, done } = useNProgress()
|
|||||||
|
|
||||||
const { loadStart, loadDone } = usePageLoading()
|
const { loadStart, loadDone } = usePageLoading()
|
||||||
// 路由不重定向白名单
|
// 路由不重定向白名单
|
||||||
const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/swagger']
|
const whiteList = [
|
||||||
|
'/login',
|
||||||
|
'/mp-login',
|
||||||
|
'/social-login',
|
||||||
|
'/auth-redirect',
|
||||||
|
'/bind',
|
||||||
|
'/register',
|
||||||
|
'/swagger'
|
||||||
|
]
|
||||||
|
|
||||||
// 路由加载前
|
// 路由加载前
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
|
|||||||
@@ -161,6 +161,16 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
noTagsView: true
|
noTagsView: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/mp-login',
|
||||||
|
component: () => import('@/views/Login/MPLogin.vue'),
|
||||||
|
name: 'MPLogin',
|
||||||
|
meta: {
|
||||||
|
hidden: true,
|
||||||
|
title: '用户绑定',
|
||||||
|
noTagsView: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/sso',
|
path: '/sso',
|
||||||
component: () => import('@/views/Login/Login.vue'),
|
component: () => import('@/views/Login/Login.vue'),
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="pl-20px pr-20px">
|
<div class="pl-20px pr-20px">
|
||||||
<el-form :model="form" ref="formRef" :rules="rules" label-width="auto" v-loading="formLoading">
|
<el-form :model="form" ref="formRef" :rules="rules" label-width="auto" v-loading="formLoading">
|
||||||
|
<el-form-item label="开启通知">
|
||||||
|
<el-radio-group v-model="form.kaiqitongzhi">
|
||||||
|
<el-radio :label="1"> 开启 </el-radio>
|
||||||
|
<el-radio :label="0"> 关闭 </el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="发送途径">
|
<el-form-item label="发送途径">
|
||||||
<el-checkbox-group v-model="form.fasongtujing">
|
<el-checkbox-group v-model="form.fasongtujing">
|
||||||
<el-checkbox :label="1">系统通知</el-checkbox>
|
<el-checkbox :label="1">系统通知</el-checkbox>
|
||||||
@@ -96,6 +103,7 @@ async function getReportInfo() {
|
|||||||
try {
|
try {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
form.value = {
|
form.value = {
|
||||||
|
kaiqitongzhi: 1,
|
||||||
fasongtujing: [1, 2],
|
fasongtujing: [1, 2],
|
||||||
sendTime: '21:00:00',
|
sendTime: '21:00:00',
|
||||||
sendContent: [21, 22, 23]
|
sendContent: [21, 22, 23]
|
||||||
|
|||||||
65
src/views/Login/MPLogin.vue
Normal file
65
src/views/Login/MPLogin.vue
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-20px">
|
||||||
|
<p class="mb-30px font-bold text-20px">微信授权登陆</p>
|
||||||
|
<el-form :model="form" ref="formRef" :rules="rules" label-width="auto">
|
||||||
|
<el-form-item label="用户名" prop="username">
|
||||||
|
<el-input v-model="form.username" placeholder="请输入用户名" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="密码" prop="password">
|
||||||
|
<el-input v-model="form.password" placeholder="请输入密码" show-password type="password" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-button type="primary" class="w-full" @click="onSubmit">授权登陆</el-button>
|
||||||
|
<div v-if="form.code">code: {{ form.code }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="MPLogin">
|
||||||
|
const form = ref({
|
||||||
|
code: undefined,
|
||||||
|
username: undefined,
|
||||||
|
password: undefined
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
const rules = {
|
||||||
|
username: { required: true, message: '用户名不可为空', trigger: 'blur' },
|
||||||
|
password: { required: true, message: '密码不可为空', trigger: 'blur' }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信授权登陆地址
|
||||||
|
const WX_AUTH_URL = 'https://open.weixin.qq.com/connect/oauth2/authorize?'
|
||||||
|
// 重定向参数-固定写法
|
||||||
|
const REDIRECT = '#wechat_redirect'
|
||||||
|
|
||||||
|
const params = ref({
|
||||||
|
appid: 'wxf87aa1f474c0494f', // 公众号 APP ID
|
||||||
|
redirect_uri: ``, // 授权后重定向的回调链接地址, 请使用 urlEncode 对链接进行处理
|
||||||
|
response_type: 'code', // 固定写法
|
||||||
|
scope: 'snsapi_base' // snsapi_base 静默授权获取 open id ;snsapi_userinfo 需要用户授权,获取详细信息
|
||||||
|
// state:'code', // a-zA-Z0-9的参数值,最多128字节
|
||||||
|
})
|
||||||
|
function onSubmit() {
|
||||||
|
// 这些需要判断没有 code 情况拉起授权登陆,有就结束放在重复拉起授权登陆
|
||||||
|
if (!form.value.code) {
|
||||||
|
const access_url = WX_AUTH_URL + `${new URLSearchParams(params.value)}` + REDIRECT
|
||||||
|
location.href = access_url
|
||||||
|
} else {
|
||||||
|
alert(`授权成功!`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const uri = location.origin + location.pathname
|
||||||
|
params.value.redirect_uri = encodeURI(uri)
|
||||||
|
// 获取地址参数
|
||||||
|
const param = new URLSearchParams(location.search)
|
||||||
|
form.value.code = param.get('code')
|
||||||
|
|
||||||
|
if (!form.value.code) {
|
||||||
|
const access_url = WX_AUTH_URL + `${new URLSearchParams(params.value)}` + REDIRECT
|
||||||
|
location.href = access_url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
Reference in New Issue
Block a user