case-data/api/api.js
zoujiandong db955ff4f3 6.9
2025-06-09 08:38:59 +08:00

221 lines
6.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {request} from '@/utils/request.js'
const loadingTime = 500;
const showLog = false;
const api = {
wxLogin(data) {
return request('/login/wechat/mobile', data, 'post', true);
},
mobileLogin(data) {
return request('/login/mobile_login', data, 'post', true);
},
getCode(data) {
return request('/code/phone', data, 'post', true);
},
getHomeData(data) { //首页数据
return request('/index/clinical', data, 'get', true);
},
getHomeStatics(data) { //首页统计数据
return request('/clinical/stats', data, 'get', true);
},
getArticleDetail(id) { //获取详情
return request('/clinical/article/'+id,{}, 'get', false);
},
getVideoDetail(id) { //获取详情
return request('/clinical/video/'+id,{}, 'get', false);
},
collectArticle(id){
return request('/clinical/article/collect/'+id, {}, 'post',false);
},
cancelCollectArticle(id){
return request('/clinical/article/collect/'+id, {}, 'delete',false);
},
collectVideo(id){
return request('/clinical/video/collect/'+id, {}, 'post',false);
},
cancelCollectVideo(id){
return request('/clinical/video/collect/'+id,{}, 'delete',false);
},
addVideoComment(id,data){
return request('/clinical/video/comment/'+id,data, 'post',false,'application/json');
},
delVideoComment(id){
return request('/clinical/video/comment/'+id, {}, 'delete',false);
},
topVideoComment(id){
return request('/clinical/video/comment/top/'+id, {}, 'put',false);
},
cancelTopVideoComment(id){
return request('/clinical/video/comment/top/'+id, {}, 'delete',false);
},
addArticleComment(id,data){
return request('/clinical/article/comment/'+id, data, 'post',false,'application/json');
},
delArticleComment(id){
return request('/clinical/article/comment/'+id, {}, 'delete',false);
},
topArticleComment(id){
return request('/clinical/article/comment/top/'+id, {}, 'put',false);
},
cancelTopArticleComment(id){
return request('/clinical/article/comment/top/'+id, {}, 'delete',false);
},
getArticleComment(data){
return request('/clinical/article/comment/page',data, 'post', false,'application/json');
},
getVideoComment(data){
return request('/clinical/video/comment/page',data, 'post', false,'application/json');
},
searchArticle(data){
return request('/clinical/article/search', data, 'post',true,'application/json');
},
searchVideo(data){
return request('/clinical/video/search', data, 'post',true,'application/json');
},
searchDoctor(data){
return request('/clinical/doctor/search', data, 'post',true,'application/json');
},
searchHospital(data){
return request('/clinical/hospital/search', data, 'post',true,'application/json');
},
getStaticDoctor(id){
return request('/clinical/stats/doctor/'+id,{}, 'get',false);
},
getStaticHospital(id){
return request('/clinical/stats/hospital/'+id, {}, 'get',false);
},
getUserInfo(){
return request('/user',{}, 'get', false);
},
getExchangeStatic(){
return request('/exchange/stats',{}, 'get', false);
},
getExchangeStaticUser(id){
return request('/exchange/stats/user/'+id,{}, 'get', false);
},
searchExchage(){
return request('/exchange/search', data, 'post',true,'application/json');
},
getExchangeDetail(id){
return request('/exchange/'+id,{}, 'get', false);
},
getExchangeVote(id){
return request('/exchange/vote/'+id,{}, 'get', false);
},
exchangeCollect(id){
return request('/exchange/collect/'+id, {}, 'post',false);
},
cancelExchangeCollect(id){
return request('/exchange/collect/'+id, {}, 'delete',false);
},
addExchangeComment(id,data){
return request('/exchange/comment/'+id, data, 'post',false);
},
delExchangeComment(id){
return request('/exchange/comment/'+id, {}, 'delete',false);
},
topExchangeComment(id){
return request('/exchange/comment/top/'+id, {}, 'put',false);
},
cancleTopExchangeComment(id){
return request('/exchange/comment/top/'+id, {}, 'delete',false);
},
getExchangeComment(data){
return request('/exchange/comment/page', data, 'post',false);
},
getExchangeCommentUser(data){
return request('/exchange/user/comment/page', data, 'post',false);
},
getMyCollect(data){
return request('/user/collect/search',data, 'post',false,'application/json');
},
getMyRead(data){
return request('/user/case/read/search',data, 'post',false,'application/json');
},
queryList(data) {
const listCount = 24;
return _queryList(data, listCount);
}
};
function _queryList(data, listCount, showNews = false ,random = false, showChat = false) {
if (!data.pageNo || !data.pageSize) {
return _callQueryResult([]);
}
let pageNo = parseInt(data.pageNo);
let pageSize = parseInt(data.pageSize);
let type = data.type || 0;
if (pageNo < 0 || pageSize <= 0) {
return _callQueryResult([]);
}
if (showLog) {
console.log('%c\n----------请求开始--------', 'color:green;');
console.info(`请求参数【pageNo:${pageNo},pageSize:${pageSize}`)
console.log('%c----------请求结束--------\n', 'color:green;');
}
uni.showLoading({
title: '加载中...'
})
if (pageNo == 0) {
pageNo = 1;
}
var totalPagingList = [];
for (let i = 0; i < listCount; i++) {
if (!showChat) {
const item = {
'title': (i + 1).toString(),
'detail': '测试信息' + type
};
if (showNews) {
item.detail = getNews(random);
}
totalPagingList.push(item);
} else {
const item = {
'name': '哆啦A梦',
'icon': '/static/duola.jpg',
'content': getNews(true),
'isMe': false
};
totalPagingList.push(item);
}
}
let pageNoIndex = (pageNo - 1) * pageSize;
if (pageNoIndex + pageSize <= totalPagingList.length) {
return _callQueryResult(totalPagingList.splice(pageNoIndex, pageSize));
} else if (pageNoIndex < totalPagingList.length) {
return _callQueryResult(totalPagingList.splice(pageNoIndex, totalPagingList.length - pageNoIndex));
} else {
return _callQueryResult([]);
}
}
function _callQueryResult(arg) {
return new Promise((resolve, reject) => {
setTimeout(() => {
uni.hideLoading();
if (showLog) {
console.log('%c\n----------响应开始--------', 'color:#0113fa;');
// #ifdef H5
console.table(arg);
// #endif
// #ifndef H5
console.log(arg);
// #endif
console.log('%c----------响应结束--------\n', 'color:#0113fa;');
}
resolve({
data: {
list: arg
}
});
}, loadingTime)
})
}
export default api