123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- let Util = require('../../../utils/util');
- Page({
-
- data: {
- markers: []
- },
- goIndex(e) {
-
- let markerId = e.currentTarget.id;
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 3];
- this.data.markers.forEach((item, index) => {
- if (markerId && markerId == item.id) {
- let {
- latitude,
- longitude
- } = item;
- prevPage.setData({
- markerId,
- latitude,
- longitude,
- textData: item
- });
- wx.navigateBack({
- delta: 3
- });
- }
- });
- },
-
- onLoad: function(options) {
- let userInfo = wx.getStorageSync('userInfo');
- let isLogin = wx.getStorageSync('isLogin');
- let that = this;
-
- if (userInfo && isLogin) {
- wx.getLocation({
- success: function(res) {
-
- let {
- latitude,
- longitude,
- } = res;
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/userChargStations',
- data: {
- userId: userInfo.userId,
- lat: latitude,
- lon: longitude
- },
- method: 'POST',
- success(res) {
- console.log(res);
- let {
- data
- } = res;
- let markers = [];
- data.forEach((item, index) => {
-
-
-
-
-
-
- var marker = {
- name: item.chargStationName,
- address: item.address,
- width: "46rpx",
- height: "67rpx",
- iconPath: "/images/marker.png",
- id: item.id,
- callout: {},
- latitude: item.lat,
- longitude: item.lon,
- distance: Math.round(item.distance) / 1000,
-
- chargPileNum: item.fastCharg + item.slowCharg,
- fastCharg: item.fastCharg,
- slowCharg: item.slowCharg,
- freenum: item.freenum,
- fastfreenum: item.fastfreenum,
- slowfreenum: item.slowfreenum,
- breaknum: item.breaknum,
-
- chargprice: item.chargprice,
-
- serviceprice: item.serviceprice,
-
- stopprice: item.stopprice,
- operationState: item.operationState
- };
- markers[index] = marker;
- });
- that.setData({
- markers
- });
- }
- });
- }
- });
- }
- },
-
- onReady: function() {
- },
-
- onShow: function() {
- },
-
- onHide: function() {
- },
-
- onUnload: function() {
- },
-
- onPullDownRefresh: function() {
- },
-
- onReachBottom: function() {
- },
-
- onShareAppMessage: function() {
- }
- })
|