🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ class HTTP { request(param) { //param是一个对象,包含url,data,method,success if (!param.method) { param.method = "GET"; } wx.request({ url: param.url, data: param.data, method: param.method, header: { 'Content-Type': 'application/json', "appkey": config.appkey }, success: function (res) { let code = res.statusCode.toString(); if (code.startsWith("2")) { param.success(res.data); } else { wx.showToast({ title: '网络错误', icon: 'none' }) } }, fail: function () { wx.showToast({ title: '网络错误', icon: 'none' }) } }) } } ~~~