123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import * as API from '@/apis/route.js'
- import * as WxJsApi from '@/utils/wxJsApi.js'
-
- import Carmap from '@/components/Carmap.vue'
- export default {
- data() {
- return {
- initBl: false,
- title: '乘车人',
- show: false,
- id: 0, // 使用 marker点击事件 需要填写id
- //地图居中后的位置
- longitude: 112.276527,
- latitude: 30.306427,
- shiftInfo: {
- },
- list: [{}, {}],
-
- stationList: [],
- //个人
- info: {
- obj: null,
- init: false,
- longitude: '',
- latitude: '',
- },
- myinterval: '',
- routeInfo:{}
- }
- },
- components: {
- Carmap
- },
- methods: {
- downBtn(item) {
-
- this.$refs.amap.setCenter(item);
- },
-
-
- drawing(point, startend) {
- if (this.$refs.amap) {
- this.$refs.amap.initMap(point, this.stationList,startend);
- }
- },
- reverse(){
- this.stationList.reverse();
- this.$refs.amap.setStartend(this.stationList);
- },
-
- getPassengerInfo() {
-
- this.$refs.common.showLoading()
- API.routeDetail(this.id).then((response) => {
- this.stationList=response.data.stationInfoList;
- this.$refs.common.showLoading(false)
-
- var point = [];
- this.routeInfo=response.data.routeInfo;
- this.title=this.routeInfo.name;
- response.data.routeInfo.mapPath.split("|").forEach((item) => {
- var sz = item.split(",");
-
- point.push({
- longitude: sz[0],
- latitude: sz[1],
- })
- })
- var startend = [{
- longitude: this.stationList[0].longitude,
- latitude: this.stationList[0].latitude,
- name: this.stationList[0].name
- }, {
- longitude: this.stationList[this.stationList.length-1].longitude,
- latitude: this.stationList[this.stationList.length-1].latitude,
- name: this.stationList[this.stationList.length-1].name
- }];
-
- this.drawing(point,startend);
- this.$refs.common.showLoading(false)
-
- this.getPoint()
- }).catch(error => {
- this.$refs.common.showLoading(false,error)
- })
- },
- getPoint() {
-
-
- if (!this.info.init) {
- WxJsApi.getWxConfig(['getLocation']).then(() => {
- // this.$refs.common.showLoading(false)
- this.getLocation()
- });
- }else{
- this.getLocation()
- }
-
- var pages = getCurrentPages();
- var page = (pages[pages.length - 1]).route;
- if (page == "pages/route/index") {
- setTimeout(this.getPoint, 10000);
- }
- },
- getLocation(){
- WxJsApi.getLocation().then((res) => {
- console.log("----getLocation ok-----")
- var latitude = parseFloat(res.latitude);
- var longitude = parseFloat(res.longitude);
-
- if (!this.info.init) {
- this.latitude = latitude;
- this.longitude = longitude;
- }
- this.info.init = true
- this.info.latitude = latitude;
- this.info.longitude = longitude;
-
- this.$refs.amap.setPerson(this.info);
-
- }).catch(error => {
- console.log(error)
- })
- }
- },
- onLoad(op) {
- this.id = op.id
- },
- onUnload() {
- if (this.myinterval) {
- clearInterval(this.myinterval)
- }
- },
- onReady() {
- this.getPassengerInfo()
- }
- }
|