|
@@ -1,384 +1,219 @@
|
|
|
-import * as WxJsApi from '@/utils/wxJsApi.js'
|
|
|
import * as API from '@/apis/buytickets.js'
|
|
|
-import * as Pay from '@/apis/weixin.js'
|
|
|
-import {
|
|
|
- wxPayJs
|
|
|
-} from '@/utils/wxpay'
|
|
|
-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: [{}, {}],
|
|
|
- //车的位置
|
|
|
- car: {
|
|
|
- obj: null,
|
|
|
- longitude: '',
|
|
|
- latitude: '',
|
|
|
- },
|
|
|
- stationList: [],
|
|
|
- //个人
|
|
|
- info: {
|
|
|
- obj: null,
|
|
|
- init: false,
|
|
|
- longitude: '',
|
|
|
- latitude: '',
|
|
|
- },
|
|
|
- myinterval: '',
|
|
|
- downId: '',
|
|
|
- downName: '',
|
|
|
- passengerInfo: {
|
|
|
- totalAmount: 0,
|
|
|
- id: '',
|
|
|
- list: []
|
|
|
+ return {
|
|
|
+ noback:false,
|
|
|
+ id: '',
|
|
|
+ num: 0,
|
|
|
+ pic: '',
|
|
|
+ list: [],
|
|
|
+ selectList: [],
|
|
|
+ subForm: {
|
|
|
+ pageIndex: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ totalPage: 1
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
- components: {
|
|
|
- Carmap
|
|
|
- },
|
|
|
-
|
|
|
methods: {
|
|
|
- confirmBtn() {
|
|
|
- var route_path = window.location.href.split("#")[1];
|
|
|
- this.carhelp.set("back_url", route_path);
|
|
|
- uni.redirectTo({
|
|
|
- url: '/pages/car/login?back=true'
|
|
|
- })
|
|
|
- },
|
|
|
- downBtn(item) {
|
|
|
- if (item.status == 2) {
|
|
|
- this.downId = item.id
|
|
|
- this.downName = item.stationName
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
- select(op) {
|
|
|
- //passengerInfo
|
|
|
- var obj = this.carhelp.get("form");
|
|
|
- if (this.passengerInfo.id) {
|
|
|
- obj.mergeOrderId = this.passengerInfo.id;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (op) {
|
|
|
- obj.op = op;
|
|
|
- this.carhelp.set("form", obj);
|
|
|
-
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/buytickets/site?id=' + this.id + '&uid=' + op.id
|
|
|
- })
|
|
|
- } else {
|
|
|
- obj.op = null;
|
|
|
- this.carhelp.set("form", obj);
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/buytickets/confirm?id=' + this.id
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ gotoHome(){
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/index/index'
|
|
|
+ });
|
|
|
},
|
|
|
-
|
|
|
- selectSiteBtn() {
|
|
|
-
|
|
|
+
|
|
|
+ submit() {
|
|
|
var obj = this.carhelp.get("form");
|
|
|
- var 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
|
|
|
+ obj.oplist = []
|
|
|
+ for (var i in this.list) {
|
|
|
+ if (this.list[i].ck) {
|
|
|
+ obj.oplist.push(this.list[i]);
|
|
|
+ }
|
|
|
}
|
|
|
- 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;
|
|
|
- this.carhelp.set("form", obj);
|
|
|
- //uni.navigateBack()
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/buytickets/site?id=' + this.id
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- }).catch(error => {
|
|
|
- this.$refs.common.showLoading(false, error);
|
|
|
+ this.carhelp.set("form", obj);
|
|
|
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/buytickets/selectSite?id=' + this.id
|
|
|
})
|
|
|
-
|
|
|
},
|
|
|
- submit() {
|
|
|
- this.$refs.common.showLoading();
|
|
|
-
|
|
|
-
|
|
|
- Pay.wxpay(this.passengerInfo.id).then((response) => {
|
|
|
- if(!response.result){
|
|
|
- this.$refs.common.showLoading(false, response.message);
|
|
|
- return
|
|
|
- }
|
|
|
- var data = response.data
|
|
|
- var url = window.location.href.split("#")[0] + "/#/pages/buytickets/success";
|
|
|
-
|
|
|
- var obj = {
|
|
|
- ...data,
|
|
|
- url: url
|
|
|
+ ckBtn(item) {
|
|
|
+ item.ck = !item.ck;
|
|
|
+
|
|
|
+ if (item.ck) {
|
|
|
+ var bl=true
|
|
|
+ for (var i = 0; i < this.selectList.length; i++) {
|
|
|
+ if (this.selectList[i].upStationId != item.upStationId) {
|
|
|
+ bl=false;
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(!bl){
|
|
|
+ item.ck = !item.ck;
|
|
|
+ this.$refs.common.alert("所选乘客上车站点不一致,请重新选择。");
|
|
|
+ return;
|
|
|
}
|
|
|
- wxPayJs(obj);
|
|
|
-
|
|
|
- }).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]
|
|
|
+ this.num++;
|
|
|
+ this.selectList.push(item);
|
|
|
+ } else {
|
|
|
+ this.num--;
|
|
|
+ for (var i = 0; i < this.selectList.length; i++) {
|
|
|
+ if (this.selectList[i].id == item.id) {
|
|
|
+ this.selectList.splice(i, 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()
|
|
|
-
|
|
|
- },
|
|
|
- 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
|
|
|
- }
|
|
|
- API.getVehicleStationInfo(this.id).then((response2) => {
|
|
|
- this.getShiftInfoResponse(response, response2);
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- }).catch(error => {
|
|
|
- this.$refs.common.showLoading(false, error);
|
|
|
-
|
|
|
- })
|
|
|
- },
|
|
|
+ console.log(this.selectList)
|
|
|
+ },
|
|
|
getPassengerInfo() {
|
|
|
|
|
|
-
|
|
|
- var thisform = {
|
|
|
- id: this.id,
|
|
|
- openId: this.carhelp.getOpenId()
|
|
|
- }
|
|
|
- this.$refs.common.showLoading()
|
|
|
-
|
|
|
- API.getPassengerInfo(thisform).then((response) => {
|
|
|
- if (!response.result) {
|
|
|
- this.$refs.common.goError(response.message)
|
|
|
- return
|
|
|
- }
|
|
|
- this.passengerInfo = response.data
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ var thisform = {
|
|
|
+ id: this.id,
|
|
|
+ openId: this.carhelp.getOpenId()
|
|
|
+ }
|
|
|
+ this.$refs.common.showLoading()
|
|
|
+
|
|
|
+ API.getPassengerInfo(thisform).then((response) => {
|
|
|
+ if (!response.result) {
|
|
|
+ this.$refs.common.goError(response.message)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.passengerInfo = response.data
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
var obj = this.carhelp.get("form");
|
|
|
if(!obj){
|
|
|
obj={}
|
|
|
- }
|
|
|
+ }
|
|
|
obj.list = this.passengerInfo.list;
|
|
|
obj.name= 'buytickets';
|
|
|
- obj.id= this.id;
|
|
|
- this.carhelp.set("form", obj);
|
|
|
-
|
|
|
- if (!response.data.id) {
|
|
|
- uni.redirectTo({
|
|
|
- url: '/pages/buytickets/confirm?id=' + this.id+'&back=true'
|
|
|
- })
|
|
|
- } else {
|
|
|
+ obj.id= this.id;
|
|
|
+ this.carhelp.set("form", obj);
|
|
|
|
|
|
- this.getShiftInfo()
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
-
|
|
|
- if (error) {
|
|
|
- this.$refs.common.goError(error)
|
|
|
- return
|
|
|
- }
|
|
|
- //this.$refs.common.showLoading(false,error)
|
|
|
- })
|
|
|
+ if (response.data.supply) {
|
|
|
+ this.$refs.common.alert('存在需要补票的订单。')
|
|
|
+
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/news/index'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ //this.$refs.common.goError(response.message)
|
|
|
+ this.$refs.common.setFnc(()=>{
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/news/index'
|
|
|
+ });
|
|
|
+ },()=>{
|
|
|
+ if (!response.data.id) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/buytickets/index?id=' + this.id+'&back=true'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this.getShiftInfo()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.$refs.common.confirm('存在需要补票的订单,是否前去查看?')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (response.data.id) {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/buytickets/home?id=' + this.id
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.upBusNoTicketList(true);
|
|
|
+ //this.getShiftInfo()
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+
|
|
|
+ if (error) {
|
|
|
+ this.$refs.common.goError(error)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //this.$refs.common.showLoading(false,error)
|
|
|
+ })
|
|
|
},
|
|
|
- getPoint() {
|
|
|
-
|
|
|
+ upBusNoTicketList(bl) {
|
|
|
+
|
|
|
+ this.$refs.common.showLoading();
|
|
|
+ this.subForm.id = this.id;
|
|
|
+ var obj = this.carhelp.get("form")
|
|
|
+ this.list = [];
|
|
|
+ API.upBusNoTicketList(this.subForm).then((res) => {
|
|
|
|
|
|
- if (!this.initBl) {
|
|
|
- this.$refs.common.showLoading();
|
|
|
- }
|
|
|
- API.getVehicleInfo(this.id).then((response) => {
|
|
|
- this.car = response.data;
|
|
|
- this.$refs.amap.setCar(this.car);
|
|
|
- var bl = false;
|
|
|
- for (var i in this.stationList) {
|
|
|
- var stat = this.stationList[i];
|
|
|
- stat.status = 0
|
|
|
- if (bl) {
|
|
|
- stat.status = 2;
|
|
|
+ var list = res.data.data;
|
|
|
+ if(!list.length){
|
|
|
+ this.$refs.common.alert2("无照片,请上车刷脸或联系司机");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i in list) {
|
|
|
+ list[i].show = true;
|
|
|
+ list[i].ck = false;
|
|
|
+ for (var j in obj.list) {
|
|
|
+ if (obj.list[j].id == list[i].id) {
|
|
|
+ list[i].show = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- if (stat.id == this.car.currentStationId) {
|
|
|
- stat.status = 1;
|
|
|
- bl = true;
|
|
|
+ if (list[i].show) {
|
|
|
+ this.list.push(list[i]);
|
|
|
}
|
|
|
- }
|
|
|
- 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;
|
|
|
- }
|
|
|
- this.$refs.common.showLoading(false);
|
|
|
- }).exec();
|
|
|
- });
|
|
|
+ }
|
|
|
+ this.selectList=[];//清空选中
|
|
|
+ if (this.list.length != 0&&!bl) {
|
|
|
+ this.$refs.common.showLoading(false, "刷新成功");
|
|
|
} else {
|
|
|
this.$refs.common.showLoading(false);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
}).catch(error => {
|
|
|
this.$refs.common.showLoading(false, error);
|
|
|
|
|
|
- })
|
|
|
- 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/buytickets/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) {
|
|
|
-
|
|
|
+ onLoad(op) {
|
|
|
+ if(op.back){
|
|
|
+ this.noback=op.back
|
|
|
+ }
|
|
|
this.id = op.id
|
|
|
},
|
|
|
- onUnload() {
|
|
|
- if (this.myinterval) {
|
|
|
- clearInterval(this.myinterval)
|
|
|
+ onReady() {
|
|
|
+
|
|
|
+ if (!this.id) {
|
|
|
+ this.$refs.common.goError()
|
|
|
}
|
|
|
- },
|
|
|
- onReady() {
|
|
|
- if (!this.carhelp.getPersonInfo()) {
|
|
|
- this.$refs.common.setFnc(this.confirmBtn)
|
|
|
- this.$refs.common.alert2('您还不是车信达用户,注册后再购买车票。', '前往注册', '尚未注册')
|
|
|
- } else{
|
|
|
+ var obj = this.carhelp.get("form")
|
|
|
+
|
|
|
+ if (obj && obj.name == 'buytickets' && obj.id == this.id) {
|
|
|
+ //不创建新订单
|
|
|
+ } else {
|
|
|
+ this.carhelp.set("form", {
|
|
|
+ name: 'buytickets',
|
|
|
+ id: this.id,
|
|
|
+ oplist: [], //当前添加的2人
|
|
|
+ list: [] // 一共添加的人
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (false&&!this.carhelp.getPersonInfo()) {
|
|
|
+ this.$refs.common.setFnc(this.confirmBtn)
|
|
|
+ this.$refs.common.alert2('您还不是车信达用户,注册后再购买车票。', '前往注册', '尚未注册')
|
|
|
+ } else {
|
|
|
+ }
|
|
|
+ if (this.noback) {
|
|
|
+ this.upBusNoTicketList(true);
|
|
|
+ } else {
|
|
|
this.getPassengerInfo()
|
|
|
}
|
|
|
+ //this.upBusNoTicketList();
|
|
|
|
|
|
+
|
|
|
}
|
|
|
}
|