feat: 接口调试
This commit is contained in:
@@ -4,13 +4,15 @@ import { getWeChatAuthCode } from "./AuthManager";
|
|||||||
|
|
||||||
export async function loginAuth() {
|
export async function loginAuth() {
|
||||||
try {
|
try {
|
||||||
const openIdCode = '0f1XVM100D5JCU1BP6400WQQFD2XVM1T'// await getWeChatAuthCode();
|
const openIdCode = 'brother7'// await getWeChatAuthCode();
|
||||||
console.log('获取到的微信授权code:', openIdCode);
|
console.log('获取到的微信授权code:', openIdCode);
|
||||||
const response = await login({
|
const response = await login({
|
||||||
openIdCode,
|
openIdCode: [openIdCode],
|
||||||
grant_type: 'wechat',
|
grant_type: 'password',
|
||||||
scope: 'server',
|
scope: 'server',
|
||||||
clientId: '1'
|
//clientId: '1',
|
||||||
|
username: 'admin',
|
||||||
|
password: 'YehdBPev'
|
||||||
});
|
});
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
"vueVersion" : "3",
|
"vueVersion" : "3",
|
||||||
"h5" : {
|
"h5" : {
|
||||||
"router" : {
|
"router" : {
|
||||||
"base" : "",
|
"base" : "./",
|
||||||
"mode" : "hash"
|
"mode" : "hash"
|
||||||
},
|
},
|
||||||
"devServer" : {
|
"devServer" : {
|
||||||
|
|||||||
2
node_modules/.package-lock.json
generated
vendored
2
node_modules/.package-lock.json
generated
vendored
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "YGTianmuCS",
|
"name": "YGChatCS",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "YGTianmuCS",
|
"name": "YGChatCS",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appid": "wxb71a18420dee6fdc",
|
"appid": "wx6d8bb61f9480d79f",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "3.8.10",
|
"libVersion": "3.8.10",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import request from "../base/request";
|
import request from "../base/request";
|
||||||
|
|
||||||
function login(args) {
|
function login(args) {
|
||||||
return request.post('/auth/oauth2/token', args, {
|
return request.post('/auth/oauth2/token', args);
|
||||||
noToken: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { login }
|
export { login }
|
||||||
@@ -2,7 +2,7 @@ import { BASE_URL } from "../../constant/base";
|
|||||||
|
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
header: {
|
header: {
|
||||||
Authorization: '', // 可在此动态设置 token
|
Authorization: 'Basic Y3VzdG9tOmN1c3RvbQ==', // 可在此动态设置 token
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -21,24 +21,34 @@ function request(url, args = {}, method = 'POST', customConfig = {}) {
|
|||||||
// 判断是否需要 token
|
// 判断是否需要 token
|
||||||
if (customConfig.noToken) {
|
if (customConfig.noToken) {
|
||||||
delete header.Authorization;
|
delete header.Authorization;
|
||||||
} else if (token) {
|
|
||||||
header.Authorization = `Basic ${token}`;
|
|
||||||
} else {
|
} else {
|
||||||
delete header.Authorization;
|
if (token) {
|
||||||
}
|
header.Authorization = `Basic ${token}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
const config = {
|
const config = {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
...customConfig,
|
...customConfig,
|
||||||
header
|
header
|
||||||
};
|
};
|
||||||
|
console.log("请求接口:" + url)
|
||||||
|
console.log("请求头:" + JSON.stringify(config))
|
||||||
|
console.log("请求参数:" + JSON.stringify(args))
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
url,
|
url,
|
||||||
data: args,
|
data: args,
|
||||||
method,
|
method,
|
||||||
...config,
|
...config,
|
||||||
success: (res) => resolve(res.data),
|
success: (res) => {
|
||||||
fail: (err) => reject(err)
|
console.log("请求响应:" + JSON.stringify(res))
|
||||||
|
resolve(res.data)
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error("请求失败:", err);
|
||||||
|
reject(err)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user