apiConfig.js 568 B

12345678910111213141516171819202122232425262728
  1. let v = wx.getAccountInfoSync();
  2. let { envVersion } = v.miniProgram;
  3. let apiUrl = `${
  4. envVersion == "release"
  5. ? "https://interface.huihenduo.cc/hhd-ship/"
  6. : "https://interface.huihenduo.com.cn/hhd-ship-dev/"
  7. }`;
  8. function api(url, data, method) {
  9. return new Promise((resolve, reject) => {
  10. wx.request({
  11. url: `${apiUrl}/${url}`,
  12. method,
  13. data,
  14. dataType: "json",
  15. header: {
  16. "content-type": "application/json",
  17. },
  18. success: resolve,
  19. fail: reject,
  20. });
  21. });
  22. }
  23. module.exports = {
  24. apiUrl,
  25. api,
  26. };