api.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // let BASE_URL = 'http://114.115.147.140:8002'
  2. // const BASE_URL='http://8.136.98.49:8002'
  3. // let BASE_URL = 'http://192.168.0.36:8003'
  4. // let BASE_URL = 'https://wx.hnyfwlw.com'
  5. let BASE_URL = 'https://wx.hnyfwlw.com'
  6. // let BASE_URL = 'http://192.168.2.110:8003'
  7. export const myRequest=(options)=>{
  8. // BASE_URL=uni.getStorageSync('http')
  9. // if(BASE_URL==''){
  10. // BASE_URL = 'https://wx.hnyfwlw.com/'
  11. // }
  12. // console.log(BASE_URL)
  13. var session_key=""
  14. session_key=uni.getStorageSync('session_key')
  15. let url=options.url
  16. let data=options.data||{}
  17. if (url != 'user.login.login_user' && url != 'pest.pests.insect_discern' &&
  18. url != 'pest.pests.plant_discern' &&
  19. url != 'pest.pests.pests_contrast' && url != 'pest.pests.pests_expert_img' &&
  20. url != 'pest.pests.pests_img' && url != 'recognizationSys' &&
  21. url != 'base.bases.base_photo' && url != 'pest.warning_record.rolemanage_img' &&
  22. url != 'home.homes.personal_photo' && url != 'ascend.ascend_manage.product_info' &&
  23. url != 'ascend.ascend_manage.quality_info' && url != 'ascend.ascend_manage.grow_info' &&
  24. url != 'ascend.ascend_manage.all_ascend' && url != 'after_sale.after_sale_manage.device_check' &&
  25. url != 'after_sale.after_sale_manage.aftersale_apply') {
  26. data.token=session_key
  27. }
  28. return new Promise((resolve,reject)=>{
  29. uni.request({
  30. url:BASE_URL+options.url,
  31. method:options.method||'POST',
  32. header:{
  33. "Content-Type": "application/x-www-form-urlencoded",
  34. },
  35. data:data,
  36. success:(res)=>{
  37. if (res.data.message) {
  38. if(res.data.message !== "识别无结果" && res.data.message !== "该设备未绑定SIM"){
  39. return uni.showToast({
  40. title: res.data.message,
  41. icon: "none"
  42. })
  43. }else{
  44. resolve(res.data.data)
  45. }
  46. }
  47. resolve(res.data.data)
  48. },
  49. fail:(err)=>{
  50. uni.showToast({
  51. title:'请求接口失败'
  52. })
  53. reject(err)
  54. }
  55. })
  56. })
  57. }