This commit is contained in:
zoujiandong 2025-08-27 15:57:36 +08:00
parent 42ef4d312e
commit cc0ddd0bc9
3 changed files with 59 additions and 20 deletions

View File

@ -678,6 +678,8 @@
const getHomeData = async () => { const getHomeData = async () => {
try { try {
uni.showLoading({ title: '加载中...' }); uni.showLoading({ title: '加载中...' });
const res = await api.getHomeData(); const res = await api.getHomeData();
console.log('首页数据:', res); console.log('首页数据:', res);
@ -776,7 +778,6 @@
defineExpose({ defineExpose({
testTabbar, testTabbar,
getTabbarStatus, getTabbarStatus,
updateTabbarData,
goToCourseHome goToCourseHome
}); });
</script> </script>

View File

@ -190,8 +190,8 @@
const result = await api.getCode(postData,{ const result = await api.getCode(postData,{
sign:sign sign:sign
}); });
console.log(result);
if (result.data.code === 200) { if (result.code === 200) {
uni.showToast({ uni.showToast({
title: '验证码已发送', title: '验证码已发送',
icon: 'none' icon: 'none'
@ -313,16 +313,41 @@
}); });
uni.hideLoading(); uni.hideLoading();
console.log(result)
if (result.data.code == 1) { if (result.code == 1) {
// //
if (result.data.data && result.data.data.token) { if (process.env.UNI_PLATFORM == "h5") {
uni.setStorageSync('AUTH_TOKEN_App', result.data.data.token); if (window.location.href.indexOf('dev') > -1) {
if (result.data.data) { uni.setStorageSync('AUTH_TOKEN_App',result.access_token);
uni.setStorageSync('USER_INFO', result.data.data); uni.setStorageSync('AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
} else {
uni.setStorageSync('DEV_AUTH_TOKEN_App', result.access_token);
uni.setStorageSync('DEV_AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('DEV_AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
}
} else if(process.env.UNI_PLATFORM == "mp-weixin") {
const {
envVersion
} = uni.getAccountInfoSync().miniProgram;
if (envVersion == "release") {
uni.setStorageSync('AUTH_TOKEN_App',result.access_token);
uni.setStorageSync('AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
} else {
uni.setStorageSync('DEV_AUTH_TOKEN_App', result.access_token);
uni.setStorageSync('DEV_AUTH_YX_ACCID_App', result.YX_accid);
uni.setStorageSync('DEV_AUTH_YX_TOKEN_App', result.YX_token);
uni.setStorageSync('userInfo', result.data);
} }
} }
uni.showToast({ uni.showToast({
title: '登录成功', title: '登录成功',
icon: 'none' icon: 'none'
@ -330,7 +355,7 @@
// //
setTimeout(() => { setTimeout(() => {
uni.switchTab({ uni.redirectTo({
url: '/pages/index/index' url: '/pages/index/index'
}); });
},0); },0);

View File

@ -19,7 +19,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
}; };
let token = ''; let token = '';
if (process.env.UNI_PLATFORM == "h5") { if (process.env.UNI_PLATFORM == "h5") {
if (window.location.href.indexOf('//App.igandan.com') > -1) { if (window.location.href.indexOf('//.igandan.com') > -1) {
token = uni.getStorageSync('AUTH_TOKEN_App'); token = uni.getStorageSync('AUTH_TOKEN_App');
} else { } else {
token = uni.getStorageSync('DEV_AUTH_TOKEN_App'); token = uni.getStorageSync('DEV_AUTH_TOKEN_App');
@ -38,20 +38,33 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
'content-type': contentType, 'content-type': contentType,
} }
let defaultData={} let defaultData={}
if(token){
header['Authorization']='Bearer ' + token
} let freeList=['/manager/getSystemTimeStamp','/expertAPI/smsLogin','/login/mobile','/expertAPI/login','/expertAPI/index']
defaultData = {
version: '4.0.0', if(freeList.indexOf(url)!=-1){
user_uuid: 'Rj3zuTY6zP6YTjHsYEz', if(freeList[4].indexOf(url)!=-1){
client_type: 'A', //client_type, if(!token){
header['Authorization']='Bearer ' + ''
}else{
header['Authorization']='Bearer ' + token
}
} }
}else{
if(token){
header['Authorization']='Bearer ' +token
}
}
// defaultData = {
// version: '4.0.0',
// user_uuid: 'Rj3zuTY6zP6YTjHsYEz',
// client_type: 'A', //client_type,
// }
return new Promise(function(e, n) { return new Promise(function(e, n) {
let timestamp = Date.now(); let timestamp = Date.now();
uni.request({ uni.request({
data: {...data,...defaultData,timestamp:new Date().getTime().toString()}, data: {...data},
url: url.indexOf('http') != -1 ? url : encodeURI(BASE_URL + url), url: url.indexOf('http') != -1 ? url : encodeURI(BASE_URL + url),
method: method, method: method,
sslVerify: false, sslVerify: false,