ts_aimz/net/api/testapi.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-03-21 09:02:29 +08:00
import {
request
} from "../http";
// 管理地址个人习惯喜欢的下载request参数中也行
const apiPath = {
login: "/api/v1/login"
}
class AuthService {
static login(data) {
// 按住ctrl点击wx.request进入ts声明看options的类型method是均大写的对应即可
return request(apiPath.login, "GET", data)
// 由于request的参数顺序第四个才是查询参数所以如果需要传递第三个传输传空对象即可
// return request(apiPath.login, "GET", {}, data)
}
}
export default AuthService;
// import AuthService from "../../service/AuthService";
// // 导入封装好的服务层
// // 其他代码省略
// page({
// // Promise语法
// submitForm(){
// AuthService.login({username:"a",password:"2"}).then(res=>{
// // 干点别的
// },err=>{
// // 出错了干点啥
// })
// },
// // async-await语法糖
// async asycsubmitForm(){
// try{
// const res = await AuthService.login({username:"abc",password:"123"});
// // 干点别的
// }catch(err){
// // 错了干点啥?
// }
// }
// })