123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- import * as WxJsApi from '@/utils/wxJsApi.js'
- import * as API from '@/apis/buytickets.js'
- import Carmap from '@/components/Carmap.vue'
- export default {
- data() {
- return {
- caritemBl:false,
- show1: false,
- show2: false,
- buy:"",
- look:false,
- initBl: false,
- title: '乘车人',
- show: false,
- id: 0, // 使用 marker点击事件 需要填写id
- k:0,
- //地图居中后的位置
- longitude: 112.276527,
- latitude: 30.306427,
- upid:'',
- shiftInfo: {
- },
- mapopen:false,
- list: [{}, {}],
- //车的位置
- car: {
- obj: null,
- longitude: '',
- latitude: '',
- },
- stationList: [],
- //个人
- info: {
- obj: null,
- init: false,
- longitude: '',
- latitude: '',
- },
- showInfo:{
- driver:{}
- },
- myinterval: '',
- downId: '',
- downName: '',
- passengerInfo:{
- totalAmount:0,
- id:'',
- list:[]
- }
-
- }
- },
- components: {
- Carmap
- },
- methods: {
- makePhoneCall(tel){
- uni.makePhoneCall({
- phoneNumber: tel //仅为示例
- });
- },
- 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) {
-
- if (!this.look&&item.id==this.car.currentStationId&&this.upid!=item.id) {
- this.downId = item.id
- this.downName = item.stationName
- this.$refs.amap.setDown(item);
- }
- if (!this.look&&item.status != 0) {
- this.downId = item.id
- this.downName = item.stationName
- this.$refs.amap.setDown(item);
- }
- this.$refs.amap.setCenter(item);
- },
-
-
- selectSiteBtn(){
-
- var obj=this.carhelp.get("form");
- var upid='';
-
-
- upid=obj.oplist[0].upStationId;
-
- var downid=this.downId;
-
- this.$refs.common.showLoading();
-
- var thisform={
- ticketUpStationId:upid,
- ticketDownStationId:downid ,
- ticketDownStationName:this.downName,
- price1:0,
- price2:0
- }
- thisform.ticketType=1;
-
- API.ticketAmount(thisform).then((response) => {
- thisform.price1=response.data.price
- thisform.ticketType=2;
- API.ticketAmount(thisform).then((response2) => {
- thisform.price2=response2.data.price
- obj.ticket=thisform;
- if(obj.op){
- obj.op.ticketDownStationId=this.downId;
- obj.op.ticketDownStationName=this.downName;
- }
-
- this.carhelp.set("form",obj);
- //uni.navigateBack()
- uni.redirectTo({
- url: '/pages/buytickets/site?id='+this.id
- })
- })
-
-
- }).catch(error => {
- this.$refs.common.showLoading(false, error);
-
- })
-
- },
-
- drawing(point, startend) {
- if(this.$refs.amap){
- this.$refs.amap.initMap(point, this.stationList, startend);
- }
- },
- getShiftInfoResponse(response, response2) {
- this.$refs.common.showLoading();
- var res = response.data
- this.title = res.routeName;
- this.shiftInfo = res;
- this.car.latitude = res.latitude;
- this.car.longitude = res.longitude;
- var point = [];
- res.mapPath.split("|").forEach((item) => {
- var sz = item.split(",");
- point.push({
- longitude: sz[0],
- latitude: sz[1],
- })
- if (!process.car.SIMPLE_RUN) {
- this.longitude = sz[0]
- this.latitude = sz[1]
- }
- })
- var obj = this.carhelp.get("form")
- obj.getShiftInfo = response;
- obj.getVehicleStationInfo = response2;
- var list = obj.getVehicleStationInfo.data;
- for (var i in list) {
- list[i].status = 0;
- }
- this.stationList = list
- obj = this.carhelp.set("form", obj)
- var sz1 = response.data.startStationCoordinate.split("|")
- var sz2 = response.data.endStationCoordinate.split("|")
- var startend = [{
- longitude: sz1[0],
- latitude: sz1[1],
- name: response.data.startStation
- }, {
- longitude: sz2[0],
- latitude: sz2[1],
- name: response.data.endStation
- }];
- this.drawing(point, startend);
- //this.$refs.common.showLoading(false);
- this.getPoint()
-
- },
- showname(name){
- if(!name){
- return "";
- }
-
- return name.substring(0,1)+'师傅';
- },
- carShow(){
- this.caritemBl=true;
- },
- getShiftInfo() {
-
- this.$refs.common.showLoading();
-
- var obj = this.carhelp.get("form")
- if (false&&obj.getShiftInfo && obj.getVehicleStationInfo) {
- this.stationList = obj.getVehicleStationInfo.data
- this.getShiftInfoResponse(obj.getShiftInfo, obj.getVehicleStationInfo);
- return;
- }
- API.getShiftInfo(this.id).then((response) => {
- if (!response.result) {
- this.$refs.common.goError(response.message)
- return
- }
- this.showInfo={
- driver:response.data.driver,
- licensePlateNumber:response.data.licensePlateNumber
- }
-
- API.getVehicleStationInfo(this.id).then((response2) => {
-
- this.getShiftInfoResponse(response, response2);
- })
- }).catch(error => {
- this.$refs.common.showLoading(false, error);
- })
- },
- carShow2(item){
- console.log(item)
- if(item.type=="car"){
- setTimeout(()=>{
- this.carShow()
- }, 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);
- }
-
- },
- getPoint() {
- if (!this.initBl) {
- this.$refs.common.showLoading();
- }
- //this.k=0
- API.getVehicleInfo(this.id).then((response) => {
- this.car = response.data;
-
- //this.car.currentStationId=this.stationList[this.k].id
- //this.car.currentStationStatus="2"
- //this.car.currentStationId=this.stationList[2].id
- //this.car.currentStationStatus="2";
-
- this.$refs.amap.setCar(this.car);
- var bl = false;
- var bl2 = false;
- for (var i in this.stationList) {
- var stat = this.stationList[i];
- stat.status = 0
- if (bl2) {
- stat.status = 2;
- }
- if (bl) {
- stat.status = 1;
- bl = false;
- bl2 = true;
- }
-
- if (stat.id == this.car.currentStationId) {
- if(this.car.currentStationStatus=="3"){
- if(eval(i+"+"+1)!=this.stationList.length){
- this.car.currentStationId2=this.stationList[eval(i+"+"+1)].id;
-
- }
- }
- bl = true;
- if(i==this.stationList.length-1){
- stat.status = 1;
- }
- if(this.buy){
- this.downBtn(stat)
- }
- }
- }
- if (!this.initBl) {
- this.initBl = true
-
- this.$nextTick(function() {
- const query = uni.createSelectorQuery().in(this);
- query.select('#map-now').boundingClientRect(data => {
- if(data){
- document.getElementById('map-route-main').scrollLeft = data.left-100;
- }
- this.$refs.common.showLoading(false);
- }).exec();
- });
- }else{
- this.$refs.common.showLoading(false);
- }
- }).catch(error => {
- this.$refs.common.showLoading(false, error);
- })
- WxJsApi.getLocation().then((res) => {
- 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 => {
- })
-
- var pages = getCurrentPages();
- var page = (pages[pages.length - 1]).route;
- if(page=="pages/buytickets/selectSite"){
- setTimeout(this.getPoint, 10000);
-
- }
- },
- },
- onLoad(op) {
- if(op.select){
- this.look=false;
- }else{
- this.look=true;// 只读界面
- }
- this.id = op.id
- var obj=this.carhelp.get("form");
- if(obj.oplist&&obj.oplist.length){
- this.upid=obj.oplist[0].upStationId;
- }
-
- },
- onUnload() {
- if (this.myinterval) {
- clearInterval(this.myinterval)
- }
- },onShow(){
- console.log("onShowonShowonShowonShow")
- this.$nextTick(function() {
- try{
- const query = uni.createSelectorQuery().in(this);
- query.select('#map-now').boundingClientRect(data => {
- if(data){
- document.getElementById('map-route-main').scrollLeft = data.left-100;
- }
- this.$refs.common.showLoading(false);
- }).exec();
- }catch(err){
- console.log("err")
-
- }
-
- });
- },
- onReady() {
- this.$refs.common.showLoading()
- WxJsApi.getWxConfig(['getLocation']).then(()=>{
- this.$refs.common.showLoading(false)
- });
- var obj = this.carhelp.get("form");
- this.buy=obj.buy;
-
- this.getShiftInfo()
- var pages = getCurrentPages();
- var page = (pages[pages.length - 1]).route;
-
- }
- }
|