From 8adf435446ac2d0dcad5aae2ea41d0c2a2240eeb Mon Sep 17 00:00:00 2001 From: 396316021 <396316021@qq.com> Date: Sat, 12 Oct 2024 22:40:57 +0800 Subject: [PATCH] 1 --- api/user.js | 2 +- config/config.js | 4 +--- pages/Login/index.vue | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/api/user.js b/api/user.js index 605c2a4..7971dcc 100644 --- a/api/user.js +++ b/api/user.js @@ -23,7 +23,7 @@ export function appletLogin(data) { } export function cloudLogin(data) { return request({ - url: `${cloud_host}/api/oauth/authorize`, + url: `${host}/tfsmy/auth`, method: "get", data }); diff --git a/config/config.js b/config/config.js index 5e9395c..d186b50 100644 --- a/config/config.js +++ b/config/config.js @@ -63,6 +63,4 @@ export const UPLOAD_PATH = '/common/upload'; export const CLOUD_CLIENT_ID = '2f42346b72'; -export const CLOUD_SECRET_KEY = '2615d5cdf6294f5db6166677'; - -export const CLOUD_LOGIN_PATH = 'https://nxr.smy.fanyiguanjia.com/'; +export const CLOUD_LOGIN_PATH = 'https://nxr.smy.fanyiguanjia.com/pages/Login/index'; diff --git a/pages/Login/index.vue b/pages/Login/index.vue index 566f109..e1fb092 100644 --- a/pages/Login/index.vue +++ b/pages/Login/index.vue @@ -137,7 +137,7 @@ import {imghost} from '@/config/host.js' import MzSubsection from '@/components/MzSubsection/Index.vue'; import api from '@/utils/functions.js'; -import {appletLogin, testLogin, userDetail} from "@/api/user"; +import {appletLogin, cloudLogin, testLogin, userDetail} from "@/api/user"; import {CLOUD_CLIENT_ID, CLOUD_LOGIN_PATH} from "../../config/config"; import {cloud_host} from "../../config/host"; @@ -161,8 +161,21 @@ export default { privateStatus:false } }, - onLoad() { - + onLoad(params) { + if(params.code){ + cloudLogin({code:params.code}).then(res => { + if(res.code === 200){ + uni.setStorageSync('token',res.data.token); + uni.setStorageSync('user',res.data); + this.$store.commit('userInfo', res.data); + uni.redirectTo({ + url:'/pages/Index/index' + }) + }else{ + uni.$u.toast('登录失败'); + } + }); + } }, computed: { api() { @@ -225,7 +238,7 @@ export default { this.$refs.popup.close(); }, peopleCloudLogin(){ - window.location.href = `${cloud_host}/oauth/?client_id=${CLOUD_CLIENT_ID}&response_type=code&redirect_uri=${CLOUD_LOGIN_PATH}&scope=read`; + window.location.href = `${cloud_host}/oauth/authorize?client_id=${CLOUD_CLIENT_ID}&response_type=code&redirect_uri=${CLOUD_LOGIN_PATH}&scope=read`; // console.log(url) // uni.redirectTo({ // url:url