apiConfig.js 643 B

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