// pages/oilPrice/oilPrice.js import { postApi } from "../../apis/api"; Page({ data: { oilPriceList: [], }, async getOilPriceList() { let { data } = await postApi("/fuel/list", {}); if (data.status === 0) { this.setData({ oilPriceList: data.result.map((item, index) => { return { id: index, latitude: item.fuelShipLatitude, longitude: item.fuelShipLongitude, iconPath: "https://frontend-1255802371.cos.ap-shanghai.myqcloud.com/miniapp-static%2Fgas-station.png", width: 40, height: 40, ...item, callout: { content: item.vendorName, display: "ALWAYS", bgColor: "none", }, }; }), }); } else { this.setData({ oilPriceList: [], }); wx.showToast({ title: data.msg, icon: "none", }); } }, onLoad(options) { this.getOilPriceList(); }, onShow() { if (typeof this.getTabBar === "function" && this.getTabBar()) { this.getTabBar().setData({ selected: 2, }); } }, });