问星数据小程序

utils.js 766B

1234567891011121314151617181920212223242526
  1. // var rootDocment = 'https://sph.wenxingshuju.com/wx_sph';//域名
  2. var rootDocment = '/wx_sph';//域名
  3. function req(url, method, data, cb, fail_cb, selfHeader) {
  4. var dataes = {}
  5. var header = {'Content-type':'application/json'}
  6. uni.request({
  7. url: rootDocment + url,
  8. data: data ? Object.assign(data, dataes) : dataes,
  9. method: method,
  10. header: selfHeader ? Object.assign(selfHeader,header) : header,
  11. success: function (res) {
  12. if((res.data.errno == '4002' || res.data.errno == '4001')){
  13. }else{
  14. return typeof cb == "function" && cb(res.data)
  15. }
  16. },
  17. fail: function (err) {
  18. return typeof fail_cb == "function" && fail_cb(err)
  19. }
  20. })
  21. }
  22. module.exports = {
  23. req: req,
  24. rootDocment: rootDocment
  25. }