123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- import * as API from '@/apis/buytickets.js'
- export default {
- data() {
- return {
- noback:true,
- id: '',
- num: 0,
- pic: '',
- list: [],
- selectList: [],
- subForm: {
- pageIndex: 1,
- pageSize: 20,
- totalPage: 1
- }
- }
- },
- methods: {
- gotoHome(){
- uni.switchTab({
- url: '/pages/index/index'
- });
- },
-
- submit() {
- var obj = this.carhelp.get("form");
- obj.oplist = []
- for (var i in this.list) {
- if (this.list[i].ck) {
- obj.oplist.push(this.list[i]);
- }
- }
- this.carhelp.set("form", obj);
- uni.navigateTo({
- url: '/pages/buytickets/selectSite?id=' + this.id
- })
- },
- 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;
- }
- 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);
- }
- }
- }
- 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 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.supply) {
- //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/index?id=' + this.id+'&back=true'
- })
- } else {
-
- this.upBusNoTicketList();
- }
- }).catch(error => {
-
- if (error) {
- this.$refs.common.goError(error)
- return
- }
- //this.$refs.common.showLoading(false,error)
- })
- },
- upBusNoTicketList() {
- this.$refs.common.showLoading();
- this.subForm.id = this.id;
- var obj = this.carhelp.get("form")
- this.list = [];
- API.upBusNoTicketList(this.subForm).then((res) => {
- 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 (list[i].show) {
- this.list.push(list[i]);
- }
- }
- this.selectList=[];//清空选中
- if (this.list.length != 0) {
- this.$refs.common.showLoading(false, "刷新成功");
- } else {
- this.$refs.common.showLoading(false);
- }
- }).catch(error => {
- this.$refs.common.showLoading(false, error);
- })
- }
- },
- onLoad(op) {
- if(op.back){
- this.noback=!op.back
- }
- this.id = op.id
- },
- onReady() {
- if (!this.id) {
- this.$refs.common.goError()
- }
- 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 {
- }
- this.getPassengerInfo()
-
- }
- }
|