Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 必须单击按钮两次才能调用该函数_Javascript_Vue.js_Button - Fatal编程技术网

Javascript 必须单击按钮两次才能调用该函数

Javascript 必须单击按钮两次才能调用该函数,javascript,vue.js,button,Javascript,Vue.js,Button,单击该按钮将调用joinQueue(),joinQueue()将调用getArrivalTime()。但是,需要单击按钮两次才能调用该函数。单击按钮一次后,如何更改以调用该函数 <form @submit.prevent="joinQueue()"> joinQueue: function () { var paxGroup = this.getPaxGroup(this.numAdult, this.numChildren);

单击该按钮将调用joinQueue(),joinQueue()将调用getArrivalTime()。但是,需要单击按钮两次才能调用该函数。单击按钮一次后,如何更改以调用该函数

<form @submit.prevent="joinQueue()">

joinQueue: function () {
            var paxGroup = this.getPaxGroup(this.numAdult, this.numChildren);
            var restName = this.restaurantSelected.restaurantName;
            var mallName = this.mallSelected;
            this.getArrivalTime(paxGroup, restName, mallName);
        },

getArrivalTime(paxGroup, restName, mallName) {
            let counter = 0;
            database
            .collection("bookings")
            .get()
            .then((snapshot) => {
                snapshot.docs.forEach((doc) => {
                    var booking = doc.data();
                    if (((booking.paxGroup === paxGroup) && (booking.restaurantName === restName)) 
                    && ((booking.mallName === mallName) && (booking.queueStatus === "waiting"))) {
                        counter += 1;
                    }
                })
            }).then(() => {
                var bookTime = this.getCurrentTime();
                var parsed = (Date.parse(bookTime) + (counter * 2700000));
                var arrTime = (new Date(parsed)).toString();
                database.collection("bookings").add({
                    customerID: this.customerID,
                    mallName: mallName,
                    restaurantName: restName,
                    restaurantMall: restName + " @ " + mallName,
                    numAdult: this.numAdult,
                    numChildren: this.numChildren,
                    paxGroup: paxGroup,
                    queueNumber: this.getQueueNumber(this.numAdult, this.numChildren),
                    babyChair: this.babyChair,
                    wheelChair: this.wheelChair,
                    additionalMessage: this.additionalMessage,
                    queueStatus: "waiting",
                    bookedTiming: bookTime,
                    restaurantId: this.restaurantSelected.id,
                    arrivalTime: arrTime,
                });
                alert(
                    "Successfully joined queue. Please arrive at " + restName + " @ "
                    + mallName + " by " + arrTime + "."
                );
                this.$router.push("/myprofile");
            });
        },

joinQueue:函数(){
var paxGroup=this.getPaxGroup(this.numAdult,this.numChildren);
var restName=this.restaurantSelected.restaurantName;
var mallName=this.mallSelected;
this.getArrivalTime(paxGroup、restName、mallName);
},
getArrivalTime(paxGroup、restName、mallName){
设计数器=0;
数据库
.收款(“预订”)
.get()
。然后((快照)=>{
snapshot.docs.forEach((doc)=>{
var booking=doc.data();
如果((booking.paxGroup==paxGroup)和&(booking.restaurantName==restName))
&&((booking.mallName==mallName)和&(booking.queueStatus==waiting”)){
计数器+=1;
}
})
}).然后(()=>{
var bookTime=this.getCurrentTime();
var parsed=(Date.parse(bookTime)+(计数器*2700000));
var arrTime=(新日期(已解析)).toString();
数据库。收藏(“预订”)。添加({
customerID:this.customerID,
mallName:mallName,
restaurantName:restName,
restaurantMall:restName+“@”+mallName,
numAdult:这个,numAdult,
孩子们:这个,孩子们,
paxGroup:paxGroup,
queueNumber:this.getQueueNumber(this.numDult,this.numChildren),
宝贝头发:这个,宝贝头发,
轮椅:这个,轮椅,
additionalMessage:this.additionalMessage,
队列状态:“正在等待”,
预定时间:预定时间,
restaurantId:this.restaurantSelected.id,
到达时间:到达时间,
});
警觉的(
已成功加入队列。请到达“+restName+”@”
+mallName+“由“+arrTime+”替换”
);
这个。$router.push(“/myprofile”);
});
},