You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
const COMPANY_BASE = 'https://api-dsb.dingtax.cn/dsb/tax-appoint/api/dx/third'
|
|
|
|
const isCompanyOk = (body) => {
|
|
if (!body || typeof body !== 'object') return false
|
|
if (body.respCode !== undefined && Number(body.respCode) !== 0) return false
|
|
const code = body.code
|
|
if (code === undefined || code === null || code === '') return true
|
|
return code === 0 || code === '0' || code === 200 || code === '200'
|
|
}
|
|
|
|
const companyPost = (path, payload) => {
|
|
const token = uni.getStorageSync('token') || ''
|
|
const header = {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
if (token) {
|
|
header.token = token
|
|
header.Authorization = `Bearer ${token}`
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
uni.request({
|
|
url: `${COMPANY_BASE}${path}`,
|
|
method: 'POST',
|
|
data: payload,
|
|
header,
|
|
timeout: 20000,
|
|
success: (res) => {
|
|
let body = res.data
|
|
if (typeof body === 'string') {
|
|
try {
|
|
body = JSON.parse(body)
|
|
} catch (error) {
|
|
reject(error)
|
|
return
|
|
}
|
|
}
|
|
if (Number(res.statusCode) !== 200 || !isCompanyOk(body)) {
|
|
reject(body || res)
|
|
return
|
|
}
|
|
resolve(body)
|
|
},
|
|
fail: (err) => reject(err),
|
|
})
|
|
})
|
|
}
|
|
|
|
export const searchCompanyPage = (params = {}) => {
|
|
return companyPost('/company/info/page', {
|
|
zjhm: params.zjhm,
|
|
pageNum: params.pageNum || 1,
|
|
pageSize: params.pageSize || 50,
|
|
})
|
|
}
|
|
|
|
export const getCompanyRisk = (params = {}) => {
|
|
return companyPost('/company/risk/info', {
|
|
zjhm: params.zjhm,
|
|
djxh: params.djxh,
|
|
})
|
|
}
|