Showing
1 changed file
with
24 additions
and
18 deletions
| 1 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; | 1 | import { Message } from 'wdJsBridge/src/main/ets/bean/Message'; |
| 2 | -import { H5ReceiveDataJsonBean, postBatchAttentionStatusResult } from 'wdBean'; | ||
| 3 | -import { ResponseDTO, WDHttp, HttpUrlUtils } from 'wdNetwork'; | 2 | +import { WDHttp, HttpUrlUtils } from 'wdNetwork'; |
| 4 | 3 | ||
| 5 | const TAG = 'JsCallAppService' | 4 | const TAG = 'JsCallAppService' |
| 6 | 5 | ||
| 7 | 6 | ||
| 8 | export function handleJsCallAppService(data: Message, callback: (res: string) => void) { | 7 | export function handleJsCallAppService(data: Message, callback: (res: string) => void) { |
| 9 | - let url: string = HttpUrlUtils.getHost() + data?.data?.url | 8 | + if (data?.data?.method === 'get') { |
| 9 | + let queryString: string = '' | ||
| 10 | + let parameters = data?.data?.parameters | ||
| 11 | + if (parameters) { | ||
| 12 | + queryString = Object.keys(parameters) | ||
| 13 | + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(parameters?.[key])}`) | ||
| 14 | + .join('&'); | ||
| 15 | + } | ||
| 10 | 16 | ||
| 11 | - let responseMap: ResponseDTO<postBatchAttentionStatusResult> = {} as ResponseDTO<postBatchAttentionStatusResult> | ||
| 12 | - | ||
| 13 | - let h5ReceiveDataJson: H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> = { | ||
| 14 | - netError: '0', | ||
| 15 | - responseMap | ||
| 16 | - } as H5ReceiveDataJsonBean<ResponseDTO<postBatchAttentionStatusResult>> | 17 | + let url: string = HttpUrlUtils.getHost() + data?.data?.url |
| 18 | + if(queryString){ | ||
| 19 | + url +`?${queryString}}` | ||
| 20 | + } | ||
| 21 | + WDHttp.get(url).then((res) => { | ||
| 22 | + callback(JSON.stringify(res)) | ||
| 23 | + }) | ||
| 24 | + } | ||
| 25 | + if (data?.data?.method === 'post') { | ||
| 26 | + let url: string = HttpUrlUtils.getHost() + data?.data?.url | ||
| 17 | 27 | ||
| 18 | - // if (data?.data?.method === 'get') { | ||
| 19 | - // WDHttp.get<ResponseDTO<postBatchAttentionStatusResult>>(url, headers).then((res: ResponseDTO<postBatchAttentionStatusResult>) => { | ||
| 20 | - // callback(JSON.stringify(res)) | ||
| 21 | - // }) | ||
| 22 | - // } | ||
| 23 | - if (data?.data?.method === 'post' && data?.data?.url === '/api/rmrb-interact/interact/zh/c/batchAttention/status') { | ||
| 24 | - WDHttp.post<ResponseDTO<postBatchAttentionStatusResult>>(url, data?.data?.parameters).then((res: ResponseDTO<postBatchAttentionStatusResult>) => { | ||
| 25 | - h5ReceiveDataJson.responseMap = res | ||
| 26 | - callback(JSON.stringify(h5ReceiveDataJson)) | 28 | + WDHttp.post(url, data?.data?.parameters).then((res) => { |
| 29 | + callback(JSON.stringify({ | ||
| 30 | + netError: '0', | ||
| 31 | + responseMap: res | ||
| 32 | + })) | ||
| 27 | }) | 33 | }) |
| 28 | } | 34 | } |
| 29 | } | 35 | } |
-
Please register or login to post a comment