Files
im/api/login.js
T

165 lines
4.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
// 验证是否升级
2026-01-09 09:15:59 +08:00
export const checkUpgrade = (params) =>{
const _this = this;
return new Promise((resolve,reject)=>{
let system = uni.getSystemInfoSync()
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
uni.$u?.http.post("/common/checkUpgrade", JSON.stringify({
version:system.appVersion,
platform:system.platform,
version_wgt:inf.versionCode,
})).then(res=>{
console.log(res);
if(!res || !res.version){
return reject(true);
}
let skip_version = uni.getStorageSync('skip_version')
//console.log(res.version,skip_version);
if(res && res.version!=skip_version){
uni.$emit('closeWebview')
uni.setStorageSync('upgrade_model',res)
uni.navigateTo({
url: '/pages/common/upgrade',
animationType:"fade-in",
complete(res1) {
//console.log(res1);
return resolve();
}
});
}
reject();
}).catch(e=>{
reject(e);
})
});
});
};
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-24 04:12:56 +08:00
"/user/profile",
2025-12-02 03:05:52 +08:00
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-12-24 04:12:56 +08:00
export const getSpage = (name) => uni.$u?.http.get(`/article/singpage?name=${name}`);
export const getArticle = (id) => uni.$u?.http.get(`/article/detail?id=${id}`);
2025-11-25 05:36:02 +08:00
export const getFriendCircle = (page=1,limit=10) =>{
2025-12-24 04:12:56 +08:00
return uni.$u?.http.get(`/friendcircle/list?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");
}
2025-12-08 02:29:46 +08:00
export const upload = (files,data,onProgress) =>{
if(typeof data == 'function'){
onProgress = data;
data = {};
}
console.log(typeof files);
2025-11-27 07:40:32 +08:00
return new Promise((resolve,reject)=>{
var u = uni.uploadFile({
url: config.getRegisterUrl()+"/user/upload", // 仅为示例,非真实的接口地址
2025-12-08 02:29:46 +08:00
filePath: files,
//files:files.length > 1 ? files : files[0],
2025-11-27 07:40:32 +08:00
name: "file",
2025-12-08 02:29:46 +08:00
formData:data,
2025-11-27 07:40:32 +08:00
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
}