Files
im/api/login.js
T

124 lines
3.1 KiB
JavaScript
Raw Normal View History

2025-11-27 07:40:32 +08:00
import config from "@/common/config";
2025-11-07 09:56:20 +08:00
// 登录
2025-11-27 07:40:32 +08:00
2025-11-23 01:01:52 +08:00
export const businessConfig = (params) =>
uni.$u?.http.post("/common/init", JSON.stringify(params));
2025-11-25 05:36:02 +08:00
// 验证是否升级
export const checkUpgrade = (params) =>
uni.$u?.http.post("/common/checkUpgrade", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessLogin = (params) =>
2025-11-23 01:01:52 +08:00
uni.$u?.http.post("/common/login", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessSendSms = (params) =>
2025-11-23 01:01:52 +08:00
uni.$u?.http.post("/common/captcha", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessVerifyCode = (params) =>
2025-11-23 01:01:52 +08:00
uni.$u?.http.post("/common/verify_captcha", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessRegister = (params) =>
2025-11-23 01:01:52 +08:00
uni.$u?.http.post("/common/register", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessReset = (params) =>
2025-11-23 01:01:52 +08:00
uni.$u?.http.post("/common/resetpwd", JSON.stringify(params));
2025-11-07 09:56:20 +08:00
export const businessModify = (params) =>
uni.$u?.http.post(
2025-11-23 01:01:52 +08:00
"/user/change_password",
2025-11-07 09:56:20 +08:00
JSON.stringify({
...params,
}), {
header: {
token: uni.getStorageSync("BusinessToken"),
},
}
);
// 用户信息
export const businessInfoUpdate = (params) =>
uni.$u?.http.post(
2025-12-02 03:05:52 +08:00
"/user/info",
JSON.stringify({...params}),
2025-11-25 05:36:02 +08:00
{
2025-11-07 09:56:20 +08:00
header: {
token: uni.getStorageSync("BusinessToken"),
},
}
);
export const businessGetUserInfo = (userID) =>
uni.$u?.http.post(
2025-11-23 01:01:52 +08:00
"/user/find",
2025-12-02 03:05:52 +08:00
JSON.stringify({userIDs: [userID],}),
2025-11-25 05:36:02 +08:00
{
2025-11-07 09:56:20 +08:00
header: {
token: uni.getStorageSync("BusinessToken"),
},
}
);
2025-11-23 07:58:47 +08:00
export const businessSearchUserInfo = (keyword,searchtype) =>
2025-11-07 09:56:20 +08:00
uni.$u?.http.post(
2025-11-23 01:01:52 +08:00
"/user/search",
2025-11-07 09:56:20 +08:00
JSON.stringify({
keyword,
2025-11-23 07:58:47 +08:00
searchtype:(searchtype? searchtype : 'id'),
page: 1,
limit: 10
2025-11-07 09:56:20 +08:00
}), {
header: {
token: uni.getStorageSync("BusinessToken"),
},
}
);
2025-11-23 07:58:47 +08:00
export const businessSearchUser = (keyword,searchtype) =>
2025-11-07 09:56:20 +08:00
uni.$u?.http.post(
"/friend/search",
JSON.stringify({
keyword,
2025-11-23 07:58:47 +08:00
searchtype:(searchtype? searchtype : 'id'),
page: 1,
limit: 99,
2025-11-07 09:56:20 +08:00
}), {
header: {
token: uni.getStorageSync("BusinessToken"),
},
}
2025-11-25 05:36:02 +08:00
);
2025-11-27 07:40:32 +08:00
export const getArticle = (id,type) => uni.$u?.http.post("/article/detail",JSON.stringify({id,type:(type? type : 'id')}));
2025-11-25 05:36:02 +08:00
export const getFriendCircle = (page=1,limit=10) =>{
2025-11-27 07:40:32 +08:00
return uni.$u?.http.get("/friendcircle/list",JSON.stringify({limit:limit,page:page}));
2025-11-25 05:36:02 +08:00
}
export const getFriendCircleNewcount = () =>{
2025-11-27 07:40:32 +08:00
return uni.$u?.http.get("/friendcircle/newcount");
}
export const getFriendCircleInfo = () =>{
return uni.$u?.http.get("/friendcircle/info");
}
export const upload = (url,onProgress) =>{
return new Promise((resolve,reject)=>{
var u = uni.uploadFile({
url: config.getRegisterUrl()+"/user/upload", // 仅为示例,非真实的接口地址
filePath: url,
name: "file",
header:{
token:uni.getStorageSync("BusinessToken"),
2025-11-25 05:36:02 +08:00
},
2025-11-27 07:40:32 +08:00
success({data,errMsg}){
console.log(data);
data = JSON.parse(data);
if(data.code == 0){
resolve(data);
}else{
reject(data.msg);
}
},
fail(res) {
console.log(e);
reject(e);
}
});
u.onProgressUpdate((e)=>{
var res = {
'code' : 99999,
'progress' : e.progress
}
onProgress && onProgress.call(this,res);
})
})
2025-11-25 05:36:02 +08:00
}