oilPrice.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // pages/oilPrice/oilPrice.js
  2. import { postApi } from "../../apis/api";
  3. Page({
  4. data: {
  5. oilPriceList: [],
  6. },
  7. async getOilPriceList() {
  8. let { data } = await postApi("/fuel/list", {});
  9. if (data.status === 0) {
  10. this.setData({
  11. oilPriceList: data.result.map((item, index) => {
  12. return {
  13. id: index,
  14. latitude: item.fuelShipLatitude,
  15. longitude: item.fuelShipLongitude,
  16. iconPath:
  17. "https://frontend-1255802371.cos.ap-shanghai.myqcloud.com/miniapp-static%2Fgas-station.png",
  18. width: 40,
  19. height: 40,
  20. ...item,
  21. callout: {
  22. content: item.vendorName,
  23. display: "ALWAYS",
  24. bgColor: "none",
  25. },
  26. };
  27. }),
  28. });
  29. } else {
  30. this.setData({
  31. oilPriceList: [],
  32. });
  33. wx.showToast({
  34. title: data.msg,
  35. icon: "none",
  36. });
  37. }
  38. },
  39. onLoad(options) {
  40. this.getOilPriceList();
  41. },
  42. onShow() {
  43. if (typeof this.getTabBar === "function" && this.getTabBar()) {
  44. this.getTabBar().setData({
  45. selected: 2,
  46. });
  47. }
  48. },
  49. });