|
@@ -107,7 +107,7 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import moment from 'moment';
|
|
|
- import { ref, toRefs, getCurrentInstance, defineExpose } from 'vue';
|
|
|
+ import { ref, toRefs, getCurrentInstance, defineExpose, watch } from 'vue';
|
|
|
//该依赖已内置不需要单独安装
|
|
|
import { onShow } from "@dcloudio/uni-app";
|
|
|
// 请求接口
|
|
@@ -141,18 +141,35 @@
|
|
|
});
|
|
|
const props = defineProps({
|
|
|
id: { type: String, default: () => '' },
|
|
|
+ gameId: { type: String, default: () => '' },
|
|
|
typeList: { type: Array, default: () => [] },
|
|
|
numberList: { type: Array, default: () => [] },
|
|
|
openList: { type: Array, default: () => [] },
|
|
|
durationList: { type: Array, default: () => [] },
|
|
|
});
|
|
|
- const { id, typeList, durationList, numberList, openList } = toRefs(props);
|
|
|
+ const { id, gameId, typeList, durationList, numberList, openList } = toRefs(props);
|
|
|
onShow(() => {
|
|
|
uni.$on('opponentInfo', function (item) {
|
|
|
form.value.opponent = item.id
|
|
|
opponent_name.value = item.name
|
|
|
})
|
|
|
})
|
|
|
+ watch(() => gameId.value, (newVal, oldVal) => { search(); })
|
|
|
+
|
|
|
+ // 查询
|
|
|
+ const search = async () => {
|
|
|
+ if (gameId.value) {
|
|
|
+ const res = await $api(`game/${gameId.value}`, 'GET', {});
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (res.data) form.value = res.data.matchInfo
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.msg || '',
|
|
|
+ icon: 'error',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
// 类型选择
|
|
|
const typeChange = (e) => {
|
|
|
const data = typeList.value[e.detail.value]
|
|
@@ -252,8 +269,11 @@
|
|
|
form.value.maxPerson = maxPerson.value
|
|
|
form.value.title = title.value
|
|
|
form.value.brief = brief.value
|
|
|
- const arr = await $api(`friendship`, 'POST', form.value);
|
|
|
+ let arr;
|
|
|
+ if (form.value.id) arr = await $api(`friendship`, 'PUT', form.value);
|
|
|
+ else arr = await $api(`friendship`, 'POST', form.value);
|
|
|
if (arr.code === 200) {
|
|
|
+ if (form.value.id && gameId.value) await $api(`game/${gameId.value}`, 'DELETE', {})
|
|
|
const data = {
|
|
|
matchId: arr.id,
|
|
|
type: '0',
|
|
@@ -313,6 +333,10 @@
|
|
|
align-items: center;
|
|
|
background-color: var(--mainColor);
|
|
|
|
|
|
+ .title {
|
|
|
+ width: 26vw;
|
|
|
+ }
|
|
|
+
|
|
|
.label {
|
|
|
.input {
|
|
|
text-align: right;
|