| | |
| | | /** |
| | | * Http 请求 |
| | | * * 小程序请使用增强编译 |
| | | * |
| | | * |
| | | * 调用例子 |
| | | * Req.http.post({ |
| | | * url: '', |
| | |
| | | import Axios from '../libs/axios' |
| | | |
| | | /* json转formdata(序列化),仅支持一级字面量和字面量数组 */ |
| | | function jsonToFormData (json) { |
| | | var arr = [] |
| | | var e = encodeURIComponent |
| | | for (var key in json) { |
| | | var item = json[key] |
| | | var res |
| | | if (item instanceof Array) { |
| | | res = []; |
| | | item.map(function (o, i) { |
| | | res.push(e(key) + '=' + e(o)) |
| | | }); |
| | | res = res.join('&') |
| | | } else { |
| | | res = e(key) + '=' + e(item) |
| | | } |
| | | arr.push(res) |
| | | function jsonToFormData(json) { |
| | | var arr = [] |
| | | var e = encodeURIComponent |
| | | for (var key in json) { |
| | | var item = json[key] |
| | | var res |
| | | if (item instanceof Array) { |
| | | res = [] |
| | | item.map(function(o) { |
| | | res.push(e(key) + '=' + e(o)) |
| | | }) |
| | | res = res.join('&') |
| | | } else { |
| | | res = e(key) + '=' + e(item) |
| | | } |
| | | return arr.join('&') |
| | | arr.push(res) |
| | | } |
| | | return arr.join('&') |
| | | } |
| | | |
| | | /** |