|
|
@@ -5,8 +5,8 @@
|
|
|
<van-field name="游戏区" label="游戏区" :border="false">
|
|
|
<template #input>
|
|
|
<div class="tabs">
|
|
|
- <div class="tab" :class="{ prim: form.type === 'QQ' }" @click="form.type = 'QQ'">QQ区</div>
|
|
|
- <div class="tab" :class="{ prim: form.type === 'wechat' }" @click="form.type = 'wechat'">
|
|
|
+ <div class="tab" :class="{ prim: form.zone === 'QQ' }" @click="form.zone = 'QQ'">QQ区</div>
|
|
|
+ <div class="tab" :class="{ prim: form.zone === 'wechat' }" @click="form.zone = 'wechat'">
|
|
|
微信区
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -25,6 +25,17 @@
|
|
|
@click="picker('modeId')"
|
|
|
>
|
|
|
</van-field>
|
|
|
+ <van-field
|
|
|
+ v-model="form.requireTicketLabel"
|
|
|
+ is-link
|
|
|
+ readonly
|
|
|
+ :border="false"
|
|
|
+ name="通行证类型"
|
|
|
+ label="通行证类型"
|
|
|
+ placeholder="点击选择通行证类型"
|
|
|
+ @click="picker('requireTicket')"
|
|
|
+ >
|
|
|
+ </van-field>
|
|
|
</van-cell-group>
|
|
|
<van-cell-group :border="false">
|
|
|
<van-field
|
|
|
@@ -46,10 +57,9 @@
|
|
|
</template>
|
|
|
</van-field>
|
|
|
<van-field
|
|
|
- v-model="form.psd"
|
|
|
- is-link
|
|
|
+ v-model="form.password"
|
|
|
:border="false"
|
|
|
- v-if="form.password"
|
|
|
+ v-if="form.usedPsd"
|
|
|
name="房间密码"
|
|
|
label="房间密码"
|
|
|
placeholder="请输入房间密码"
|
|
|
@@ -78,7 +88,7 @@
|
|
|
<van-button round block type="primary" native-type="submit">确认创建</van-button>
|
|
|
</div>
|
|
|
</van-form>
|
|
|
- <van-overlay :show="showPicker" @click="showPicker = false">
|
|
|
+ <van-overlay :show="showPicker" z-index="99" @click="showPicker = false">
|
|
|
<div class="picker" @click.stop>
|
|
|
<div class="picker-title">{{ pickerTitle }}</div>
|
|
|
<div class="selects" :class="{ selectOnly: pickerOptions.length === 1 }">
|
|
|
@@ -98,19 +108,25 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import room from '../mixins/room.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
- type: 'QQ',
|
|
|
+ type: 'USER',
|
|
|
+ zone: 'QQ',
|
|
|
usedPsd: false,
|
|
|
- map: '王者荣耀',
|
|
|
- message: '',
|
|
|
+ url: '',
|
|
|
modeId: '',
|
|
|
mode: '',
|
|
|
+ requireTicket: '',
|
|
|
+ requireTicketLabel: '',
|
|
|
+ gameId: '',
|
|
|
gameMapId: '',
|
|
|
gameMap: '',
|
|
|
- password: ''
|
|
|
+ password: '',
|
|
|
+ maxPlayerNum: '',
|
|
|
+ minPlayerNum: ''
|
|
|
},
|
|
|
showPicker: false,
|
|
|
pickerType: 'modeId',
|
|
|
@@ -118,11 +134,15 @@ export default {
|
|
|
gameMapIdOptions: []
|
|
|
};
|
|
|
},
|
|
|
+ mixins: [room],
|
|
|
computed: {
|
|
|
pickerOptions() {
|
|
|
if (this.pickerType === 'modeId') {
|
|
|
return [...this.modeIdOptions];
|
|
|
}
|
|
|
+ if (this.pickerType === 'requireTicket') {
|
|
|
+ return [...this.requireTicketOptions];
|
|
|
+ }
|
|
|
if (this.pickerType === 'gameMapId') {
|
|
|
return [...this.gameMapIdOptions];
|
|
|
}
|
|
|
@@ -132,12 +152,18 @@ export default {
|
|
|
if (this.pickerType === 'gameMapId') {
|
|
|
return Number(this.form.gameMapId || 0);
|
|
|
}
|
|
|
+ if (this.pickerType === 'requireTicket') {
|
|
|
+ return this.form.requireTicket;
|
|
|
+ }
|
|
|
return Number(this.form.modeId || 0);
|
|
|
},
|
|
|
pickerTitle() {
|
|
|
if (this.pickerType === 'gameMapId') {
|
|
|
return '选择赛事地图';
|
|
|
}
|
|
|
+ if (this.pickerType === 'requireTicket') {
|
|
|
+ return '选择通行证类型';
|
|
|
+ }
|
|
|
return '选择对战模式';
|
|
|
}
|
|
|
},
|
|
|
@@ -148,7 +174,10 @@ export default {
|
|
|
this.modeIdOptions = res.content.map(item => {
|
|
|
return {
|
|
|
label: item.name,
|
|
|
- value: item.id
|
|
|
+ value: item.id,
|
|
|
+ minPlayerNum: item.minPlayerNum,
|
|
|
+ maxPlayerNum: item.maxPlayerNum,
|
|
|
+ gameId: item.gameId
|
|
|
};
|
|
|
});
|
|
|
})
|
|
|
@@ -158,11 +187,114 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
- submit() {},
|
|
|
+ submit() {
|
|
|
+ if (!this.form.url) {
|
|
|
+ this.$toast('游戏地址必须填写,这样才能开始游戏');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.modeId) {
|
|
|
+ this.$toast('请选择对战模式');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.requireTicket) {
|
|
|
+ this.$toast('请选择通行证类型');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.gameMapId) {
|
|
|
+ this.$toast('请选择赛事地图');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.checkTicket().then(ticketId => {
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ let form = { ...this.form };
|
|
|
+ form.userId = this.$store.state.userInfo.id;
|
|
|
+ delete form.usedPsd;
|
|
|
+ delete form.mode;
|
|
|
+ delete form.gameMap;
|
|
|
+ delete form.requireTicketLabel;
|
|
|
+ console.log(form);
|
|
|
+
|
|
|
+ this.$http
|
|
|
+ .post('/room/createRoom', {
|
|
|
+ gameId: this.form.gameId,
|
|
|
+ modeId: this.form.modeId,
|
|
|
+ mapId: this.form.gameMapId,
|
|
|
+ ticketId: ticketId,
|
|
|
+ url: this.form.url,
|
|
|
+ password: this.form.password,
|
|
|
+ zone: this.form.zone
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.$toast.clear();
|
|
|
+ this.$toast.success('创建成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.replace({
|
|
|
+ path: '/room',
|
|
|
+ query: {
|
|
|
+ id: res.id
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 1000);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ console.log(e);
|
|
|
+ this.$toast(e.error);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ checkTicket() {
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ return this.$http
|
|
|
+ .post(
|
|
|
+ '/userTicket/all',
|
|
|
+ {
|
|
|
+ query: {
|
|
|
+ userId: this.$store.state.userInfo.id,
|
|
|
+ type: this.form.requireTicket,
|
|
|
+ used: false,
|
|
|
+ expired: false
|
|
|
+ },
|
|
|
+ sort: 'id,asc'
|
|
|
+ },
|
|
|
+ { body: 'json' }
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ let info = res;
|
|
|
+ this.$toast.clear();
|
|
|
+ if (res.empty) {
|
|
|
+ return this.$dialog
|
|
|
+ .confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '您没有可用的' + this.form.requireTicketLabel,
|
|
|
+ confirmButtonText: '立即购买'
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.$router.push('/shop');
|
|
|
+ return Promise.reject();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ return this.$dialog
|
|
|
+ .confirm({
|
|
|
+ title: '门票确认',
|
|
|
+ message: '此操作将扣除您【' + this.form.requireTicketLabel + '】门票一张'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return Promise.resolve(info.content[0].id);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
picker(type = 'modeId') {
|
|
|
if (type === 'gameMapId') {
|
|
|
if (!this.form.modeId) {
|
|
|
- this.$toast('请选择对战模式');
|
|
|
+ this.$toast('请先选择对战模式');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -187,12 +319,22 @@ export default {
|
|
|
},
|
|
|
choosePicker(id) {
|
|
|
if (this.pickerType == 'modeId') {
|
|
|
+ let info = [...this.modeIdOptions].find(item => {
|
|
|
+ return item.value === id;
|
|
|
+ });
|
|
|
this.form.modeId = id;
|
|
|
- this.form.mode = this.getLabelName(this.form.modeId, this.modeIdOptions);
|
|
|
+ this.form.mode = info.label;
|
|
|
+ this.form.minPlayerNum = info.minPlayerNum;
|
|
|
+ this.form.maxPlayerNum = info.maxPlayerNum;
|
|
|
+ this.form.gameId = info.gameId;
|
|
|
this.form.gameMapId = '';
|
|
|
this.form.gameMap = '';
|
|
|
this.getMap();
|
|
|
}
|
|
|
+ if (this.pickerType == 'requireTicket') {
|
|
|
+ this.form.requireTicket = id;
|
|
|
+ this.form.requireTicketLabel = this.getLabelName(this.form.requireTicket, this.requireTicketOptions);
|
|
|
+ }
|
|
|
if (this.pickerType == 'gameMapId') {
|
|
|
this.form.gameMapId = id;
|
|
|
this.form.gameMap = this.getLabelName(this.form.gameMapId, this.gameMapIdOptions);
|
|
|
@@ -210,7 +352,6 @@ export default {
|
|
|
@bg: #08080d;
|
|
|
.picker {
|
|
|
width: 272px;
|
|
|
- height: 194px;
|
|
|
background-color: @bg;
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
@@ -219,6 +360,7 @@ export default {
|
|
|
margin-top: -97px;
|
|
|
.flex-col();
|
|
|
justify-content: center;
|
|
|
+ z-index: 20;
|
|
|
&::after {
|
|
|
content: '';
|
|
|
background: linear-gradient(-225deg, #f6abf0 0%, #10f7ee 100%);
|
|
|
@@ -252,6 +394,7 @@ export default {
|
|
|
color: #fff;
|
|
|
font-weight: bold;
|
|
|
text-align: center;
|
|
|
+ padding-top: 20px;
|
|
|
}
|
|
|
.selects {
|
|
|
.flex();
|