|
@@ -0,0 +1,582 @@
|
|
|
+ import * as API from '@/apis/route.js'
|
|
|
+ import * as API_index from '@/apis/index.js'
|
|
|
+ import * as WxJsApi from '@/utils/wxJsApi.js'
|
|
|
+
|
|
|
+import Carmap from '@/components/Carmap.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ wxinit:false,
|
|
|
+ mapopen:false,
|
|
|
+ initBl: false,
|
|
|
+ title: '乘车人',
|
|
|
+ show: false,
|
|
|
+ id: 0, // 使用 marker点击事件 需要填写id
|
|
|
+ upid:'',
|
|
|
+ downid:'',
|
|
|
+ downItem:{},
|
|
|
+ //地图居中后的位置
|
|
|
+ longitude: 112.276527,
|
|
|
+ latitude: 30.306427,
|
|
|
+ show1: false,
|
|
|
+ show2: false,
|
|
|
+ centerBl:false,
|
|
|
+ shiftInfo: {
|
|
|
+
|
|
|
+ },
|
|
|
+ remindList:[],
|
|
|
+ list: [{}, {}],
|
|
|
+ carList:[],
|
|
|
+ caritem:{
|
|
|
+ driverInfo:{}
|
|
|
+ },
|
|
|
+ caritemBl:false,
|
|
|
+ stationList: [],
|
|
|
+ routeTimeTableList:[],
|
|
|
+ dis:'',
|
|
|
+ //个人
|
|
|
+ info: {
|
|
|
+ obj: null,
|
|
|
+ init: true,
|
|
|
+ longitude: '',
|
|
|
+ latitude: '',
|
|
|
+ },
|
|
|
+ reverseInit:false,
|
|
|
+ myinterval: '',
|
|
|
+ routeInfo:{},
|
|
|
+ popid:0,
|
|
|
+ radiolist: [
|
|
|
+ {
|
|
|
+ name: '不提醒',
|
|
|
+ isRemind: "0",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '提前1站',
|
|
|
+ isRemind: "1",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '提前2站',
|
|
|
+ isRemind: "2",
|
|
|
+ }
|
|
|
+ ]
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ Carmap
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ selectBtn(i){
|
|
|
+
|
|
|
+ this.popid=i;
|
|
|
+
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ makePhoneCall(tel){
|
|
|
+ uni.makePhoneCall({
|
|
|
+ phoneNumber: tel //仅为示例
|
|
|
+ });
|
|
|
+ },
|
|
|
+ radioChange(e){
|
|
|
+ console.log(e)
|
|
|
+ },
|
|
|
+ vehicleStationDis(){
|
|
|
+
|
|
|
+ if(this.stationList[0].id==this.downItem.id&&this.routeTimeTableList&&this.routeTimeTableList.length){
|
|
|
+
|
|
|
+
|
|
|
+ var nowDate =new Date();
|
|
|
+ var curDay=nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate();
|
|
|
+ var startDate =null;
|
|
|
+
|
|
|
+ for(var i in this.routeTimeTableList){
|
|
|
+ var obj=this.routeTimeTableList[i]
|
|
|
+ var objDate =new Date(curDay+" "+obj.startTime+":00");
|
|
|
+
|
|
|
+ if(nowDate.getTime()<objDate.getTime()){
|
|
|
+ if(startDate==null){
|
|
|
+ startDate=objDate;
|
|
|
+ }
|
|
|
+ if(objDate<startDate){
|
|
|
+ startDate=objDate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(startDate==null){
|
|
|
+ this.dis="今日发车已经结束,明日发车时间"+this.routeInfo.startTime
|
|
|
+ }else{
|
|
|
+ console.log(startDate)
|
|
|
+ console.log(nowDate)
|
|
|
+ var d= parseInt((startDate.getTime()-nowDate.getTime())/1000/60)
|
|
|
+ this.dis="等待发车... 大约"+d+"分钟发车"
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ var obj={
|
|
|
+ startStationId:this.stationList[0].id,
|
|
|
+ currentStationId :this.downItem.id,
|
|
|
+ routeId:this.routeInfo.id,
|
|
|
+ }
|
|
|
+ //this.$refs.common.showLoading();
|
|
|
+ API.vehicleStationDis(obj).then((res) => {
|
|
|
+ this.dis=res.data;
|
|
|
+ //this.$refs.common.showLoading(false);
|
|
|
+ }).catch(error => {
|
|
|
+ this.$refs.common.showLoading(false,error);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ radioGroupChange(){
|
|
|
+
|
|
|
+ this.downItem.isRemind=this.popid;
|
|
|
+ var item= this.downItem
|
|
|
+
|
|
|
+ if(item.isRemind==0){
|
|
|
+ if(this.downItem.remindId){
|
|
|
+ this.del(item.remindId,item.isRemind!=0)
|
|
|
+ }else{
|
|
|
+ this.show1 = false
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(item.remindId){
|
|
|
+ this.del(item.remindId,item.isRemind!=0)
|
|
|
+ }else{
|
|
|
+ this.remindAdd()
|
|
|
+ }
|
|
|
+
|
|
|
+ },del(id,bl){
|
|
|
+ API_index.cancelRemind(id).then((res) => {
|
|
|
+ this.downItem.remindId=""
|
|
|
+ if(bl){
|
|
|
+ this.remindAdd()
|
|
|
+ }else{
|
|
|
+ this.show1 = false
|
|
|
+ this.$forceUpdate()
|
|
|
+ this.$refs.common.alert( "设置成功");
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$refs.common.alert( error);
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ remind(){
|
|
|
+ var myBtn = document.getElementById("subscribe-btn").tap();
|
|
|
+ myBtn.tap();
|
|
|
+ },
|
|
|
+ showCar(item){
|
|
|
+
|
|
|
+ for(var i in this.carList){
|
|
|
+ var car= this.carList[i]
|
|
|
+
|
|
|
+ if(car.currentStationStatus=="3"){
|
|
|
+ if(car.currentStationId==this.stationList[this.stationList.length-1].id&&car.currentStationId==item.id){
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }else if(car.currentStationId2==item.id){
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(car.currentStationId==item.id){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ showname(name){
|
|
|
+ if(!name){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ return name.substring(0,1)+'师傅';
|
|
|
+ },
|
|
|
+ getCar(){
|
|
|
+
|
|
|
+ if(this.stationList.length==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var obj={
|
|
|
+ routeId:this.id,
|
|
|
+ startStationId:this.stationList[0].id,
|
|
|
+ }
|
|
|
+
|
|
|
+ API.routeShiftList(obj).then((response) => {
|
|
|
+
|
|
|
+ this.carList=response.data;
|
|
|
+ this.$refs.amap.ifCenter(this.carList[0]);
|
|
|
+
|
|
|
+ if(!this.centerBl&&this.carList.length){
|
|
|
+ this.centerBl=this.$refs.amap.setCenter(this.carList[0]);
|
|
|
+
|
|
|
+ this.$refs.amap.ifCenter(this.carList[0]);
|
|
|
+
|
|
|
+ //this.centerBl=true;
|
|
|
+ if(this.centerBl){
|
|
|
+ document.getElementById('map-route-main').scrollLeft = 0
|
|
|
+ this.$nextTick(function() {
|
|
|
+ const query = uni.createSelectorQuery().in(this);
|
|
|
+ query.select('.map-route-car').boundingClientRect(data => {
|
|
|
+ if(data){
|
|
|
+ document.getElementById('map-route-main').scrollLeft = data.left-100;
|
|
|
+ }
|
|
|
+
|
|
|
+ //this.downBtn()
|
|
|
+ }).exec();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //car.currentStationId=this.stationList[this.stationList.length-1].id
|
|
|
+ //car.currentStationStatus="1";
|
|
|
+
|
|
|
+ // this.carList=[];
|
|
|
+ // this.carList.push({
|
|
|
+ // currentStationId:"9e5be927-178b-4163-a34b-49bba6460eec",
|
|
|
+ // currentStationStatus:"1"
|
|
|
+
|
|
|
+ // })
|
|
|
+ // this.carList.push({
|
|
|
+ // currentStationId:"ff2251e0-26ca-41ad-a4a0-43ece7ab3471",
|
|
|
+ // currentStationStatus:"2"
|
|
|
+
|
|
|
+ // })
|
|
|
+ for(var j in this.stationList){
|
|
|
+ var station =this.stationList[j];
|
|
|
+ station.currentStationStatus="1";
|
|
|
+ }
|
|
|
+ console.log("this.stationList")
|
|
|
+
|
|
|
+ console.log(this.stationList)
|
|
|
+ console.log("this.stationList")
|
|
|
+ for(var j in this.stationList){
|
|
|
+
|
|
|
+ var station =this.stationList[j];
|
|
|
+ // station.currentStationStatus="1";
|
|
|
+
|
|
|
+ for(var i in this.carList){
|
|
|
+ var car =this.carList[i];
|
|
|
+
|
|
|
+
|
|
|
+ if(car.currentStationId==station.id){
|
|
|
+ console.log(car.licensePlateNumber+"------"+station.name)
|
|
|
+ if(car.currentStationStatus==3){
|
|
|
+
|
|
|
+ if(eval(j+"+"+1)!=this.stationList.length){
|
|
|
+ console.log(this.stationList[eval(j+"+"+1)].id);
|
|
|
+ car.currentStationId2=this.stationList[eval(j+"+"+1)].id
|
|
|
+ this.stationList[eval(j+"+"+1)].currentStationStatus="2";
|
|
|
+
|
|
|
+ console.log("--------this.carList----A------"+car.licensePlateNumber)
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ car.currentStationStatus=1
|
|
|
+ this.stationList[j].currentStationStatus="1";
|
|
|
+ console.log("--------this.carList----B------"+car.licensePlateNumber)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ this.stationList[j].currentStationStatus=car.currentStationStatus;
|
|
|
+ console.log("--------this.carList----c------"+car.licensePlateNumber)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ console.log("--------this.carList----------")
|
|
|
+ console.log(this.carList)
|
|
|
+ console.log("--------this.carList----------")
|
|
|
+
|
|
|
+ this.$refs.amap.setCarList(this.carList);
|
|
|
+ this.vehicleStationDis();
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error);
|
|
|
+ this.$refs.common.showLoading(false,error)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ mapopenBtn(){
|
|
|
+ this.mapopen=!this.mapopen;
|
|
|
+ if(this.mapopen){
|
|
|
+ this.$refs.amap.setMyStyle("width: 100%; height: 340px;")
|
|
|
+ }else{
|
|
|
+ this.$refs.amap.setMyStyle("width: 100%; height: 140px;")
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ downBtn(item) {
|
|
|
+
|
|
|
+ this.$refs.amap.setSite(item);
|
|
|
+ this.$refs.amap.setCenter(item);
|
|
|
+ this.downid=item.id;
|
|
|
+ this.downItem=item;
|
|
|
+ this.vehicleStationDis();
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ remindAdd(){
|
|
|
+ if(this.downItem.id){
|
|
|
+
|
|
|
+ var obj={
|
|
|
+ startStationId:this.stationList[0].id,
|
|
|
+ endStationId:this.stationList[this.stationList.length-1].id,
|
|
|
+ remindStationId :this.downItem.id,
|
|
|
+ stopInAdvance:this.downItem.isRemind,
|
|
|
+ remindType:"1",
|
|
|
+ routeId:this.routeInfo.id,
|
|
|
+ openId:this.carhelp.getOpenId()
|
|
|
+ }
|
|
|
+ API_index.saveRemind(obj).then((res) => {
|
|
|
+ this.downItem.remindId=res.data.id
|
|
|
+ this.$refs.common.alert( "设置成功");
|
|
|
+ this.show1 = false
|
|
|
+ this.$forceUpdate()
|
|
|
+ }).catch(error => {
|
|
|
+ this.$refs.common.alert( error);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ drawing(point, startend) {
|
|
|
+ if (this.$refs.amap) {
|
|
|
+ this.$refs.amap.initMap(point, this.stationList,startend);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ carShow2(item){
|
|
|
+ console.log(item)
|
|
|
+ if(item.type=="car"){
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.carShow3(item.obj)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ if(item.type=="point"){
|
|
|
+
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.downBtn(item.obj)
|
|
|
+ document.getElementById('map-route-main').scrollLeft = 0
|
|
|
+
|
|
|
+ this.$nextTick(function() {
|
|
|
+ const query = uni.createSelectorQuery().in(this);
|
|
|
+ query.select('.map-down').boundingClientRect(data => {
|
|
|
+ if(data){
|
|
|
+ document.getElementById('map-route-main').scrollLeft = data.left-100;
|
|
|
+ }
|
|
|
+ this.$refs.common.showLoading(false);
|
|
|
+ //this.downBtn()
|
|
|
+ }).exec();
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ carShow3(item){
|
|
|
+
|
|
|
+ var caritem =item;
|
|
|
+
|
|
|
+ this.caritem=caritem;
|
|
|
+ this.caritemBl=true;
|
|
|
+
|
|
|
+ },
|
|
|
+ carShow(item){
|
|
|
+
|
|
|
+
|
|
|
+ this.$refs.amap.setCenter(item);
|
|
|
+
|
|
|
+ },
|
|
|
+ reverse(){
|
|
|
+ this.centerBl=false;
|
|
|
+ this.stationList.reverse();
|
|
|
+ this.getCar()
|
|
|
+ this.passengerShiftRemindList();
|
|
|
+
|
|
|
+ this.$refs.amap.setStartend(this.stationList);
|
|
|
+ document.getElementById('map-route-main').scrollLeft = 0
|
|
|
+ this.$nextTick(function() {
|
|
|
+ const query = uni.createSelectorQuery().in(this);
|
|
|
+ query.select('.map-down').boundingClientRect(data => {
|
|
|
+ if(data){
|
|
|
+ document.getElementById('map-route-main').scrollLeft = data.left-100;
|
|
|
+ }
|
|
|
+ this.$refs.common.showLoading(false);
|
|
|
+ //this.downBtn()
|
|
|
+ }).exec();
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ setRemind(){
|
|
|
+ for(var i in this.stationList){
|
|
|
+ var item=this.stationList[i];
|
|
|
+ item.isRemind=0;
|
|
|
+ item.remindId="";
|
|
|
+ for(var j in this.remindList){
|
|
|
+ var obj=this.remindList[j];
|
|
|
+ if(this.stationList[0].id==obj.startStationId&&obj.remindType==1){
|
|
|
+ if(obj.remindStationId==item.id){
|
|
|
+ item.remindId=obj.id;
|
|
|
+ item.isRemind=obj.stopInAdvance;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ passengerShiftRemindList(){
|
|
|
+ this.$refs.common.showLoading()
|
|
|
+ API.passengerShiftRemindList({
|
|
|
+ routeId:this.id,
|
|
|
+ openId:this.carhelp.getOpenId(),
|
|
|
+ }).then((response) => {
|
|
|
+ this.remindList=response.data;
|
|
|
+ this.setRemind();
|
|
|
+ this.$refs.common.showLoading(false)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getPassengerInfo() {
|
|
|
+
|
|
|
+ this.$refs.common.showLoading()
|
|
|
+
|
|
|
+ API.routeDetail(this.id).then((response) => {
|
|
|
+
|
|
|
+ var list=response.data.stationInfoList;
|
|
|
+ if(this.upid&&list.length){
|
|
|
+
|
|
|
+ if(this.upid==list[list.length-1].id){
|
|
|
+ list.reverse();
|
|
|
+ }
|
|
|
+ this.upid="";
|
|
|
+ }
|
|
|
+ this.stationList=list;
|
|
|
+ for(var i in list){
|
|
|
+ list[i].isRemind=0;
|
|
|
+ if(list[i].id==this.downid){
|
|
|
+ this.downItem=list[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.passengerShiftRemindList();
|
|
|
+
|
|
|
+ this.$refs.common.showLoading(false)
|
|
|
+
|
|
|
+ var point = [];
|
|
|
+ this.routeInfo=response.data.routeInfo;
|
|
|
+ this.routeTimeTableList=response.data.routeTimeTableList;
|
|
|
+ this.title=this.routeInfo.name;
|
|
|
+ if(!response.data.routeInfo.mapPath){
|
|
|
+ this.$refs.common.showLoading(false,"路线加载失败!")
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ mapdown(){
|
|
|
+ this.getPoint();
|
|
|
+
|
|
|
+ if(this.downid=="null"){
|
|
|
+ this.downid="";
|
|
|
+ }else{
|
|
|
+ this.centerBl=true;
|
|
|
+ }
|
|
|
+ if(this.downid){
|
|
|
+ this.downBtn(this.downItem)
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ getPoint() {
|
|
|
+
|
|
|
+ if (!this.info.init) {
|
|
|
+ WxJsApi.getWxConfig([ 'getLocation','getSetting']).then(() => {
|
|
|
+ // this.$refs.common.showLoading(false)
|
|
|
+ this.getLocation()
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this.getLocation()
|
|
|
+ }
|
|
|
+ this.getCar();
|
|
|
+ var pages = getCurrentPages();
|
|
|
+ var page = (pages[pages.length - 1]).route;
|
|
|
+ if (page == "pages/route2/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,true);
|
|
|
+
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ onLoad(op) {
|
|
|
+ this.upid=op.upid;
|
|
|
+ this.id = op.id
|
|
|
+ this.downid=op.downid;
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ if (this.myinterval) {
|
|
|
+ clearInterval(this.myinterval)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+ WxJsApi.getWxConfig([ 'getLocation','getSetting']).then(() => {
|
|
|
+ // this.$refs.common.showLoading(false)
|
|
|
+ this.wxinit=true;
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ this.getPassengerInfo()
|
|
|
+
|
|
|
+ }
|
|
|
+}
|