api.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import axios from 'axios'
  2. // let apiPath = 'http://commontest.yiguanjia.me/index.php?r='
  3. let apiPath = ''
  4. let uri = location.href
  5. let test = true
  6. var userId = ''
  7. var formData = new FormData()
  8. if (uri.indexOf('common.yiguanjia.me') > -1) {
  9. test = false
  10. }
  11. // 正式开发判断test还是pro
  12. if (test) {
  13. apiPath = 'http://commontest.yiguanjia.me/index.php?r='
  14. userId = localStorage.getItem('wxUserID')
  15. } else {
  16. apiPath = 'http://common.yiguanjia.me/index.php?r='
  17. userId = localStorage.getItem('wxUserID')
  18. }
  19. // 判断是否为dev开发
  20. if (uri.indexOf('http://localhost:8080/') > -1) {
  21. apiPath = ''
  22. userId = '57e238929f5160d6048b456d'
  23. } else if (uri.indexOf('common.yiguanjiadev.me') > -1) {
  24. apiPath = 'http://common.yiguanjiadev.me/index.php?r='
  25. userId = '57e238929f5160d6048b456d'
  26. }
  27. formData.append('user_id', userId) // 获取
  28. export default({
  29. // 获取用户信息
  30. getO2oUserInfo: function (cb) {
  31. axios.post(apiPath + 'o2o/user/info', formData).then(function (res) {
  32. cb(res.data)
  33. })
  34. },
  35. getProductList: function (cb) {
  36. axios.get(apiPath + 'o2o/product/list').then(function (res) {
  37. cb(res.data)
  38. })
  39. }
  40. })