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){ // // 错了干点啥? // } // } // })