(options, method)
| 670 | } |
| 671 | ///////////////////////////////////////////////////////////////////////////////////// |
| 672 | function httpRequest(options, method) { |
| 673 | method = options.method |
| 674 | ? options.method.toLowerCase() |
| 675 | : options.body |
| 676 | ? "post" |
| 677 | : "get"; |
| 678 | return new Promise((resolve) => { |
| 679 | $[method](options, (err, resp, data) => { |
| 680 | try { |
| 681 | if (err) { |
| 682 | console.log(`${method}请求失败`); |
| 683 | $.logErr(err); |
| 684 | } else { |
| 685 | if (data) { |
| 686 | typeof JSON.parse(data) == "object" |
| 687 | ? (data = JSON.parse(data)) |
| 688 | : (data = data); |
| 689 | resolve(data); |
| 690 | } else { |
| 691 | console.log(`请求api返回数据为空,请检查自身原因`); |
| 692 | } |
| 693 | } |
| 694 | } catch (e) { |
| 695 | $.logErr(e, resp); |
| 696 | } finally { |
| 697 | resolve(); |
| 698 | } |
| 699 | }); |
| 700 | }); |
| 701 | } |
| 702 | /** |
| 703 | * 判断版本号是否小于 V2.15.0 小于返回true |
| 704 | * @param {*} version |
no test coverage detected