|
|
@@ -53,12 +53,7 @@
|
|
|
<div class="player-item">
|
|
|
<div class="title">客队</div>
|
|
|
<template v-if="info.maxPlayerNum === 2">
|
|
|
- <div
|
|
|
- class="list1 not"
|
|
|
- @click="choosePerson(item)"
|
|
|
- v-for="(item, index) in guests"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
+ <div class="list1 not" v-for="(item, index) in guests" :key="index">
|
|
|
<van-image
|
|
|
width="58"
|
|
|
height="58"
|
|
|
@@ -70,12 +65,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="list" v-else>
|
|
|
- <div
|
|
|
- class="person"
|
|
|
- @click="choosePerson(item)"
|
|
|
- v-for="(item, index) in guests"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
+ <div class="person" v-for="(item, index) in guests" :key="index">
|
|
|
<van-image
|
|
|
width="24"
|
|
|
height="24"
|
|
|
@@ -105,6 +95,14 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="help">
|
|
|
+ <div class="help-btn" v-if="isJoin" @click="back">
|
|
|
+ <img src="@assets/png-tuichu.png" alt="" />
|
|
|
+ <span>退出</span>
|
|
|
+ </div>
|
|
|
+ <div class="help-btn" v-if="isHost" @click="$refs.failed.init()">
|
|
|
+ <img src="@assets/png-liuju.png" alt="" />
|
|
|
+ <span>流局</span>
|
|
|
+ </div>
|
|
|
<div class="help-btn" @click="$refs.description.init()">
|
|
|
<img src="@assets/png-shuoming.png" alt="" />
|
|
|
<span>说明</span>
|
|
|
@@ -112,17 +110,33 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="bottom" v-if="isJoin">
|
|
|
- <div class="btn" @click="changeUrl" v-if="isHost">
|
|
|
- <img src="@assets/png-xiugaidizhi.png" alt="" />
|
|
|
- <span>修改地址</span>
|
|
|
+ <div class="join-btn" v-if="isFull">
|
|
|
+ <van-button type="primary" v-if="info.status == 'WAITING'" block @click="start">开始比赛</van-button>
|
|
|
+ <van-button type="primary" v-else-if="info.status == 'GAMING'" block @click="$refs.joinGame.init()"
|
|
|
+ >进入比赛</van-button
|
|
|
+ >
|
|
|
</div>
|
|
|
- <div class="btn" @click="$router.push('/exceptionLogAdd?roomId=' + roomId)">
|
|
|
- <img src="@assets/png-yicangshenbao.png" alt="" />
|
|
|
- <span>异常申报</span>
|
|
|
- </div>
|
|
|
- <div class="btn">
|
|
|
- <img src="@assets/png-quxiaosaishi.png" alt="" />
|
|
|
- <span>取消赛事</span>
|
|
|
+ <div class="btns">
|
|
|
+ <div class="btn" v-if="!isHost" @click="quit">
|
|
|
+ <img src="@assets/png-quxiaobaoming.png" alt="" />
|
|
|
+ <span>取消报名</span>
|
|
|
+ </div>
|
|
|
+ <div class="btn" @click="changeUrl" v-if="isHost">
|
|
|
+ <img src="@assets/png-xiugaidizhi.png" alt="" />
|
|
|
+ <span>修改地址</span>
|
|
|
+ </div>
|
|
|
+ <div class="btn" @click="$router.push('/exceptionLogAdd?roomId=' + roomId)">
|
|
|
+ <img src="@assets/png-yicangshenbao.png" alt="" />
|
|
|
+ <span>异常申报</span>
|
|
|
+ </div>
|
|
|
+ <div class="btn" v-if="isHost && info.status == 'WAITING'">
|
|
|
+ <img src="@assets/png-quxiaosaishi.png" alt="" />
|
|
|
+ <span>取消赛事</span>
|
|
|
+ </div>
|
|
|
+ <div class="btn" v-if="info.status == 'GAMING'" @click="$refs.result.init()">
|
|
|
+ <img src="@assets/png-jieshubisai.png" alt="" />
|
|
|
+ <span>结束比赛</span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<change-url ref="url" :roomId="roomId"></change-url>
|
|
|
@@ -130,6 +144,8 @@
|
|
|
<description ref="description"></description>
|
|
|
<failed ref="failed"></failed>
|
|
|
<player-info ref="player" :roomInfo="info"></player-info>
|
|
|
+ <join-game ref="joinGame" :roomInfo="info"></join-game>
|
|
|
+ <result ref="result" :roomId="roomId" @update="getInfo"></result>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -137,9 +153,11 @@
|
|
|
import room from '../mixins/room.js';
|
|
|
import changeUrl from '../components/room/changeUrl.vue';
|
|
|
import joinRoom from '../components/room/joinRoom.vue';
|
|
|
+import joinGame from '../components/room/joinGame.vue';
|
|
|
import description from '../components/room/description.vue';
|
|
|
import failed from '../components/room/failed.vue';
|
|
|
import playerInfo from '../components/room/playerInfo.vue';
|
|
|
+import result from '../components/room/result.vue';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -188,7 +206,7 @@ export default {
|
|
|
return list;
|
|
|
},
|
|
|
isHost() {
|
|
|
- return this.host.id === this.$store.state.userInfo.id;
|
|
|
+ return this.host.userId === this.$store.state.userInfo.id;
|
|
|
},
|
|
|
isJoin() {
|
|
|
if (this.isHost) {
|
|
|
@@ -207,7 +225,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mixins: [room],
|
|
|
- components: { changeUrl, joinRoom, description, failed, playerInfo },
|
|
|
+ components: { changeUrl, joinRoom, description, failed, playerInfo, joinGame, result },
|
|
|
mounted() {
|
|
|
if (this.$route.query.id) {
|
|
|
this.roomId = this.$route.query.id;
|
|
|
@@ -220,13 +238,20 @@ export default {
|
|
|
message: '加载中...',
|
|
|
forbidClick: true
|
|
|
});
|
|
|
- this.$http.get('/room/detail/' + this.roomId).then(res => {
|
|
|
- this.$toast.clear();
|
|
|
- this.info = res;
|
|
|
- if (!this.isFull && !this.isJoin && res.status === 'WAITING') {
|
|
|
- this.$refs.join.init();
|
|
|
- }
|
|
|
- });
|
|
|
+ this.$http
|
|
|
+ .get('/room/detail/' + this.roomId)
|
|
|
+ .then(res => {
|
|
|
+ this.$toast.clear();
|
|
|
+ this.info = res;
|
|
|
+ if (!this.isFull && !this.isJoin && res.status === 'WAITING') {
|
|
|
+ this.$refs.join.init();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e && e.error) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
changeUrl() {
|
|
|
this.$refs.url.init(this.info.url);
|
|
|
@@ -235,8 +260,70 @@ export default {
|
|
|
this.$router.back();
|
|
|
},
|
|
|
choosePerson(info) {
|
|
|
- console.log(info);
|
|
|
+ if (this.isHost) {
|
|
|
+ this.$refs.player.init();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ quit() {
|
|
|
+ this.$dialog
|
|
|
+ .confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '确认要取消报名吗?',
|
|
|
+ confirmButtonText: '立即取消'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ return this.$http.post('/room/quit', {
|
|
|
+ roomId: this.roomId
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$toast.success('取消成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.back();
|
|
|
+ }, 1000);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e && e.error) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ start() {
|
|
|
+ this.$dialog
|
|
|
+ .confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '确认要开始比赛吗?',
|
|
|
+ confirmButtonText: '立即开始'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ return this.$http.post('/room/startGame', {
|
|
|
+ roomId: this.roomId
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.getInfo();
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e && e.error) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ beforeRouteLeave(to, from, next) {
|
|
|
+ if (this && this.emitter) {
|
|
|
+ this.emitter.emit('updateList', this.info);
|
|
|
}
|
|
|
+ next();
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
@@ -444,12 +531,15 @@ export default {
|
|
|
bottom: 0;
|
|
|
left: 0;
|
|
|
right: 0;
|
|
|
- height: 56px;
|
|
|
.bottom(0px);
|
|
|
- .flex();
|
|
|
+ .btns {
|
|
|
+ .flex();
|
|
|
+ height: 56px;
|
|
|
+ padding: 0 32px;
|
|
|
+ justify-content: space-between;
|
|
|
+ }
|
|
|
|
|
|
.btn {
|
|
|
- flex-grow: 1;
|
|
|
.flex();
|
|
|
justify-content: center;
|
|
|
img {
|
|
|
@@ -464,6 +554,9 @@ export default {
|
|
|
margin-left: 4px;
|
|
|
}
|
|
|
}
|
|
|
+ .join-btn {
|
|
|
+ padding: 16px 32px 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.help {
|
|
|
@@ -492,6 +585,9 @@ export default {
|
|
|
line-height: 10px;
|
|
|
}
|
|
|
}
|
|
|
+ .help-btn + .help-btn {
|
|
|
+ margin-top: 24px;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.person {
|