Merge branch 'ymf' of https://e.coding.net/g-cphe0354/cashier_front/cashier_admin_app into dwb
This commit is contained in:
commit
200ecaea29
|
|
@ -19,6 +19,17 @@ let baseUrl = 'https://admintestpapi.sxczgkj.cn'
|
|||
// 多少 ms 以内, 不提示loading
|
||||
const loadingShowTime = 200
|
||||
|
||||
|
||||
function getHeader(){
|
||||
const headerObject={}
|
||||
headerObject["Authorization"] = storageManage.token()
|
||||
headerObject["Content-Type"] = 'application/json'
|
||||
headerObject["loginname"] = 'admin'
|
||||
headerObject["token"] = 'eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyVHlwZSI6Ik1HIiwiZXhwIjoxNjkwMTgwNzE2LCJ1c2VySWQiOiIyNDQiLCJpYXQiOjE2ODg3MDk0ODcsImxvZ2luTmFtZSI6ImFkbWluIn0.lqxxvv2-FcecQngMBorz4MpkB3mIJQDG-IUULQyV-KQ'
|
||||
headerObject["userId"] = '244'
|
||||
return headerObject
|
||||
}
|
||||
|
||||
// 通用处理逻辑
|
||||
function commonsProcess(showLoading, httpReqCallback) {
|
||||
|
||||
|
|
@ -141,18 +152,14 @@ function commonsProcess(showLoading, httpReqCallback) {
|
|||
|
||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["authorization"] = storageManage.token()
|
||||
headerObject["content-type"] = 'application/json'
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({
|
||||
url: baseUrl + uri,
|
||||
data: data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
header: getHeader()
|
||||
}, extParams)
|
||||
)
|
||||
})
|
||||
|
|
@ -171,8 +178,6 @@ function request(args) {
|
|||
} = args
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
headerObject["content-type"] = 'application/json'
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
|
|
@ -180,7 +185,7 @@ function request(args) {
|
|||
url: baseUrl + url,
|
||||
data: params||data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
header: getHeader()
|
||||
}, extParams)
|
||||
)
|
||||
})
|
||||
|
|
@ -193,7 +198,6 @@ function upload(uri, data, file, showLoading = true, extParams = {}) {
|
|||
// 放置token
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.uploadFile(
|
||||
|
|
@ -202,7 +206,7 @@ function upload(uri, data, file, showLoading = true, extParams = {}) {
|
|||
formData: data,
|
||||
name: "file",
|
||||
filePath: file.path,
|
||||
header: headerObject
|
||||
header: getHeader()
|
||||
}, extParams)
|
||||
).then((httpData) => {
|
||||
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||
|
|
|
|||
Loading…
Reference in New Issue