酷炫小程序

request.js 492B

1234567891011121314151617181920
  1. var rootDocment = 'https://tbk.726p.com';//域名
  2. // var header = {'source':'3000'}
  3. var header = {}
  4. function req(url, method, userInfo, data, cb) {
  5. wx.request({
  6. url: rootDocment + url,
  7. data: data,
  8. method: method,
  9. header: Object.assign(userInfo,header),
  10. success: function (res) {
  11. return typeof cb == "function" && cb(res.data)
  12. },
  13. fail: function () {
  14. return typeof cb == "function" && cb("请求错误")
  15. }
  16. })
  17. }
  18. module.exports = {
  19. req: req
  20. }