token已存入Storage, 认证厂家详情接口初步完成

This commit is contained in:
clay
2023-01-04 20:58:04 +08:00
parent 27787d3300
commit 2417d8fe28
4 changed files with 67 additions and 97 deletions

View File

@@ -17,7 +17,8 @@ function isOutTime(res) {
const service = {
get(url, data) {
const header = {}
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
// header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['token'] = uni.getStorageSync('token')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
@@ -42,15 +43,8 @@ const service = {
},
post(url, data, isLogin) {
const header = {}
if (isLogin) {
// header['content-type'] = 'application/x-www-form-urlencoded';
console.log(isLogin)
header['Authorization'] = ''
} else {
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['content-type'] = 'application/json'
}
header['token'] = uni.getStorageSync('token')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
method: 'post',
@@ -59,7 +53,6 @@ const service = {
header: header,
timeout: 30000,
success: res => {
console.log(1111, res)
uni.hideLoading()
// if (res.data.exception === 'UnAuthorizedException') {
// let pages = getCurrentPages()
@@ -99,14 +92,8 @@ const service = {
},
put(url, data, isLogin) {
const header = {}
if (isLogin) {
header['content-type'] = 'application/x-www-form-urlencoded'
} else {
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['content-type'] = 'application/json'
}
header['token'] = uni.getStorageSync('token')
header['content-type'] = 'application/json'
return new Promise((resolve, reject) => {
uni.request({
method: 'put',
@@ -117,7 +104,6 @@ const service = {
isOutTime(res)
reject(res)
}
resolve(res)
},
data: data,
@@ -174,11 +160,18 @@ const toast = {
const apiService = {
uploadImgUrl: serverHost,
imgUrl: serverHost,
login: data => {
data = Object.assign(data || {}, {})
const url = `/api`
// login: data => {
// data = Object.assign(data || {}, {})
// const url = `/api`
// return new Promise((resolve, reject) => {
// resolve(service.post(url, data, true))
// })
// },
//登录接口
login(data) {
const url = `/login/mnpLogin`
return new Promise((resolve, reject) => {
resolve(service.post(url, data, true))
resolve(service.post(url, data))
})
},
// 获取首页轮播图
@@ -230,13 +223,7 @@ const apiService = {
resolve(service.get(url, id))
})
},
login: data => {
data = Object.assign(data || {}, {})
const url = `/api`
return new Promise((resolve, reject) => {
resolve(service.post(url, data, true))
})
},
// 获取首页分类Tag
getTags(data) {
const url = `/home/tags`