请求类
This commit is contained in:
parent
883807298b
commit
4c1e56981b
@ -87,7 +87,7 @@ interface CenterCodeResult {
|
|||||||
keystr?: string
|
keystr?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCodeResult | undefined {
|
function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCodeResult {
|
||||||
if (isNewCenter) {
|
if (isNewCenter) {
|
||||||
const msg: object = JSON.parse(message);
|
const msg: object = JSON.parse(message);
|
||||||
const result: object = msg?.['data'][0]?.result;
|
const result: object = msg?.['data'][0]?.result;
|
||||||
@ -111,8 +111,23 @@ function dealCenterCode(message: string, isNewCenter: boolean = false): CenterCo
|
|||||||
return returnResult
|
return returnResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const result = [new RegExp('<code>(.*)<\/code>', 'i'), new RegExp('<message>(.*)<\/message>', 'i'), new RegExp('<keystr>(.*)<\/keystr>', 'i')].map(pattern => {
|
||||||
|
const patternArr = pattern.exec(message);
|
||||||
|
return patternArr && patternArr[1]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result[0] != '1') {
|
||||||
|
promptAction.showToast({
|
||||||
|
message: decodeURIComponent(message as string),
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
|
||||||
|
return { code: result[0], message: decodeURIComponent(result[1]) }
|
||||||
|
} else {
|
||||||
|
return { code: result[0], message: decodeURIComponent(result[1]), keystr: result[2], }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestResult = Object | object | string | CenterCodeResult
|
type RequestResult = Object | object | string | CenterCodeResult
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user