Commit a3f57396 authored by chenqikuai's avatar chenqikuai

完成建设银行excel文件选中监听解析并上传函数

parent 586c3181
import baseAxios from '../index'
export default class AddressService {
prefix: string
static instance: AddressService
max_len_gps: number
static getInstance() {
if (!AddressService.instance) {
AddressService.instance = new AddressService()
}
return AddressService.instance
}
constructor() {
this.prefix = '/address'
this.max_len_gps = 10
}
getGpses(data: { addrs: string[] }): Promise<string[]> {
return new Promise((resolve, reject) => {
const resultList = [] as string[]
if (data.addrs.length) {
for (
let i = 0;
i < Math.ceil(data.addrs.length / this.max_len_gps);
++i
) {
const reqList = data.addrs.slice(
i * this.max_len_gps,
i * this.max_len_gps + this.max_len_gps,
)
this.__getGpses(reqList).then((ret) => {
if (ret.code === 200) {
resultList.push(...ret.data.gps)
if (resultList.length === data.addrs.length) {
resolve(resultList)
}
} else {
reject('解析错误')
}
})
}
}
})
}
private __getGpses(addrs: string[]) {
if (addrs.length > 10) {
throw new Error('长度超过10')
} else {
return baseAxios<{ gps: string[] }>({
url: this.prefix + '/getGps',
method: 'post',
data: {
addrs: addrs,
},
})
}
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment