diff --git a/common/request.js b/common/request.js index 7ba3476..39a0637 100644 --- a/common/request.js +++ b/common/request.js @@ -4,6 +4,11 @@ import { host } from "./api" import { getSessionXToken } from "@/session" const coreRequestBase = (url, reqParams, options = {}, methodType = "POST", coreParams = {}) => { + // get请求 需要转成query参 + if(methodType.toLocaleLowerCase() == 'get') { + url = url + (url.indexOf('?') == -1 ? '?': '') + tansGetParamsToQuery(reqParams) + reqParams = {} + } return new Promise((resolve, reject) => { uni.request({ url, @@ -23,6 +28,32 @@ const coreRequestBase = (url, reqParams, options = {}, methodType = "POST", core const baseParam = {} +/** +* 参数处理 +* @param {*} params 参数 +*/ +export function tansGetParamsToQuery(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName]; + var part = encodeURIComponent(propName) + "="; + if (value !== null && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']'; + var subPart = encodeURIComponent(params) + "="; + result += subPart + encodeURIComponent(value[key]) + "&"; + } + } + } else { + result += part + encodeURIComponent(value) + "&"; + } + } + } + return result +} + // 请求处理 let coreRequest = function(url, params = {}, options = {}, methodType, coreParams = {}) { let comReqData = getCommonReqData() diff --git a/pages/print/courierNote.vue b/pages/print/courierNote.vue index d931cec..fcb7a6f 100644 --- a/pages/print/courierNote.vue +++ b/pages/print/courierNote.vue @@ -169,6 +169,7 @@ printFlag: '0', billCode: '', _date: [], + params: {} }, resData: { list: [] } } @@ -186,8 +187,8 @@ methods: { async getListFun(param){ let cpParam = JSON.parse(JSON.stringify(param)) - cpParam['params.beginSendDate'] = cpParam._date[0] - cpParam['params.endSendDate'] = cpParam._date[1] + cpParam.params.beginSendDate = cpParam._date[0] + cpParam.params.endSendDate = cpParam._date[1] let res = await apiService.queryPrintListSimple(cpParam) // list增加新字段 res.rows.map(t=> { diff --git a/pages/tabBar/order/order.vue b/pages/tabBar/order/order.vue index 3358995..ac7a5cc 100644 --- a/pages/tabBar/order/order.vue +++ b/pages/tabBar/order/order.vue @@ -36,7 +36,7 @@ - @@ -123,7 +123,9 @@ searchParam: { billCode: '', _date: [], - waybillStatType: dicData?.emis_waybill_stat_type?.[0]?.val, + params: { + waybillStatType: dicData?.emis_waybill_stat_type?.[0]?.val, + } }, queryOption: { @@ -156,9 +158,8 @@ methods: { transSearchPm(param){ let cpParam = JSON.parse(JSON.stringify(param)) - cpParam['params.beginDate'] = cpParam._date[0] - cpParam['params.endDate'] = cpParam._date[1] - cpParam['params.waybillStatType'] = param.waybillStatType + cpParam.params.beginDate = cpParam._date[0] + cpParam.params.endDate = cpParam._date[1] return cpParam }, async getListFun(param){