Files
ClassContent/项目合集/电商App/shop_backend/header.md
2025-04-12 11:10:30 +08:00

31 lines
1.4 KiB
Markdown
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.

---
## 【注意】使用注意事项
1用户登录注册的时候发送接口请求头中不需要`jwt``token`字段。用户登录成功后,登录接口会返回`token`参数。请前端自己使用`localStorage.setItem`
方法进行本地保存`token`字段。后端的所有接口在数据请求的时候需要在请求头携带`token`字段通过身份验证。
2有些接口没有参数的话需要在调用`xxxService`的时候传入一个空的对象。例如请求首页接口
```
await this.$http.homeService.getHomeData({}); # getHomeData方法接口空对象: {}
```
4接口返回的数据格式如下
```
{
"status" : 200,
"message" : "请求成功"
"result" : "{}"
}
```
- 4.1status主要作用标志请求是否成功`200`表示接口请求成功无错误,`404`表示接口请求出现错误,`500`表示接口出现严重错误,`403`表示接口无权限或失效等
- 4.2message`status``200` 的时候值为:`请求成功`,当 `status``404` 的时候 `message`数值为具体的接口错误信息前端只需要在全局ajax拦截器中`Toast`弹出`message`的错误信息即可
- 4.3result: 请求的所有数据都会在本字段中,本字段的数据会使用私钥进行加密,需要前端公钥解密数据后使用
5Ajax的请求方式一律使用`POST`接口,注意是`POST`