|
@@ -1,127 +1,129 @@
|
|
<template>
|
|
<template>
|
|
<view class="form">
|
|
<view class="form">
|
|
- <form @submit="formSubmit">
|
|
|
|
- <view class="value other">
|
|
|
|
- <view class="title">类型</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="type" @change="typeChange" :value="index" :range="typeList" range-key="dictLabel">
|
|
|
|
- <view class="picker">{{form.type||'请选择类型'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">类型</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="type" @change="typeChange" :value="index" :range="typeList" range-key="dictLabel">
|
|
|
|
+ <view class="picker">{{type_name||'请选择类型'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other margin">
|
|
|
|
- <view class="title">人数</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="number" @change="numberChange" :value="index" :range="numberList"
|
|
|
|
- range-key="dictLabel">
|
|
|
|
- <view class="picker">{{form.number||'请选择人数'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other margin">
|
|
|
|
+ <view class="title">人数</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="number" @change="numberChange" :value="index" :range="numberList" range-key="dictLabel">
|
|
|
|
+ <view class="picker">{{number_name||'请选择人数'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">对手</view>
|
|
|
|
- <view class="label" @tap="toOpponent">
|
|
|
|
- <text v-if="form.opponent">{{opponent_name}}</text>
|
|
|
|
- <text v-else>请选择</text>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">对手</view>
|
|
|
|
+ <view class="label" @tap="toOpponent">
|
|
|
|
+ <text v-if="form.opponent">{{opponent_name}}</text>
|
|
|
|
+ <text v-else>请选择</text>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">日期</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="date" mode="date" @change="dateChange" :value="index">
|
|
|
|
- <view class="picker">{{form.date||'请选择日期'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">日期</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="date" mode="date" @change="dateChange" :value="index">
|
|
|
|
+ <view class="picker">{{form.date||'请选择日期'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">时间</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="time" mode="time" @change="timeChange" :value="index">
|
|
|
|
- <view class="picker">{{form.time||'请选择时间'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">时间</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="time" mode="time" @change="timeChange" :value="index">
|
|
|
|
+ <view class="picker">{{form.time||'请选择时间'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">时长</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="duration" @change="durationChange" :value="index" :range="durationList"
|
|
|
|
- range-key="dictLabel">
|
|
|
|
- <view class="picker">{{form.duration||'请选择时长'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">时长</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="duration" @change="durationChange" :value="index" :range="durationList"
|
|
|
|
+ range-key="dictLabel">
|
|
|
|
+ <view class="picker">{{duration_name||'请选择时长'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">地点</view>
|
|
|
|
- <view class="label" @tap="toLocaltion">
|
|
|
|
- <text v-if="form.address">{{form.address}}</text>
|
|
|
|
- <text v-else>请选择</text>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other margin">
|
|
|
|
+ <view class="title">地点</view>
|
|
|
|
+ <view class="label" @tap="toLocaltion">
|
|
|
|
+ <text v-if="form.address">{{form.address}}</text>
|
|
|
|
+ <text v-else>请选择</text>
|
|
</view>
|
|
</view>
|
|
- <view class="value other margin">
|
|
|
|
- <view class="title">队服颜色</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <input name="color" class="input" :value="form.color" placeholder="请输入队服颜色" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">费用</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <input name="money" class="input" :value="form.money" placeholder="请输入费用" />
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">费用</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <input name="money" class="input" :value="form.money" placeholder="请输入费用" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">人数上限</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <input name="name" class="input" :value="form.max_person" placeholder="请输入人数上限" />
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">人数上限</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <input name="name" class="input" :value="form.max_person" placeholder="请输入人数上限" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">公开报名</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <picker name="is_open" @change="openChange" :value="index" :range="openList" range-key="dictLabel">
|
|
|
|
+ <view class="picker">{{open_name||'请选择'}}</view>
|
|
|
|
+ </picker>
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">公开报名</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <picker name="is_open" @change="openChange" :value="index" :range="openList" range-key="dictLabel">
|
|
|
|
- <view class="picker">{{form.is_open||'请选择'}}</view>
|
|
|
|
- </picker>
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other" v-if="form.date&&form.time">
|
|
|
|
+ <view class="title">报名截止时间</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <uni-datetime-picker :start="form.date" :border="false" v-model="form.end_time" />
|
|
</view>
|
|
</view>
|
|
- <view class="value other" v-if="form.date&&form.time">
|
|
|
|
- <view class="title">报名截止时间</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <uni-datetime-picker :start="form.date" :border="false" v-model="form.end_time" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="value other">
|
|
|
|
+ <view class="title">活动标题</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <input name="title" class="input" :value="form.title" placeholder="请输入活动标题" />
|
|
</view>
|
|
</view>
|
|
- <view class="value other">
|
|
|
|
- <view class="title">活动标题</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <input name="title" class="input" :value="form.title" placeholder="请输入活动标题" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="remark margin">
|
|
|
|
+ <view class="label">
|
|
|
|
+ <textarea name="brief" :value="form.brief" placeholder="请输入简介" />
|
|
</view>
|
|
</view>
|
|
- <view class="remark margin">
|
|
|
|
- <view class="label">
|
|
|
|
- <textarea name="brief" :value="form.brief" placeholder="请输入简介" />
|
|
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="remark">
|
|
|
|
+ <view class="title">上传图片</view>
|
|
|
|
+ <view class="label">
|
|
|
|
+ <uni-file-picker v-model="form.file" fileMediatype="image" :list-styles="imageStyles" limit="6"
|
|
|
|
+ title="最多选择6张图片" @select="toUpload" @delete="toDelete"></uni-file-picker>
|
|
</view>
|
|
</view>
|
|
- <view class="remark">
|
|
|
|
- <view class="title">上传图片</view>
|
|
|
|
- <view class="label">
|
|
|
|
- <uni-file-picker v-model="form.file" fileMediatype="image" :list-styles="imageStyles" limit="6"
|
|
|
|
- title="最多选择6张图片" @select="toUpload" @delete="toDelete"></uni-file-picker>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </form>
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="btn" style="display: none;">
|
|
|
|
+ <button form-type="submit">保存</button>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
- import { ref, toRefs, getCurrentInstance } from 'vue';
|
|
|
|
|
|
+ import { ref, toRefs, getCurrentInstance, defineExpose } from 'vue';
|
|
//该依赖已内置不需要单独安装
|
|
//该依赖已内置不需要单独安装
|
|
import { onShow } from "@dcloudio/uni-app";
|
|
import { onShow } from "@dcloudio/uni-app";
|
|
// 请求接口
|
|
// 请求接口
|
|
const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
|
|
const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
|
|
const $apifile = getCurrentInstance()?.appContext.config.globalProperties.$apifile;
|
|
const $apifile = getCurrentInstance()?.appContext.config.globalProperties.$apifile;
|
|
// 信息
|
|
// 信息
|
|
- const form = ref({ file: [] });
|
|
|
|
|
|
+ const form = ref({ file: [], number: '5', type: '0', duration: '3', is_open: 'Y' });
|
|
// 对手名称
|
|
// 对手名称
|
|
const opponent_name = ref('');
|
|
const opponent_name = ref('');
|
|
|
|
+ // 类型
|
|
|
|
+ const type_name = ref('足球');
|
|
|
|
+ // 人数
|
|
|
|
+ const number_name = ref('五人制');
|
|
|
|
+ // 是否公开
|
|
|
|
+ const open_name = ref('');
|
|
|
|
+ // 时长
|
|
|
|
+ const duration_name = ref('2.0小时');
|
|
const listStyles = ref({
|
|
const listStyles = ref({
|
|
width: 64,
|
|
width: 64,
|
|
height: 64,
|
|
height: 64,
|
|
@@ -133,12 +135,13 @@
|
|
}
|
|
}
|
|
});
|
|
});
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
|
+ id: { type: String, default: () => '' },
|
|
typeList: { type: Array, default: () => [] },
|
|
typeList: { type: Array, default: () => [] },
|
|
numberList: { type: Array, default: () => [] },
|
|
numberList: { type: Array, default: () => [] },
|
|
openList: { type: Array, default: () => [] },
|
|
openList: { type: Array, default: () => [] },
|
|
durationList: { type: Array, default: () => [] },
|
|
durationList: { type: Array, default: () => [] },
|
|
});
|
|
});
|
|
- const { typeList, durationList, numberList, openList } = toRefs(props);
|
|
|
|
|
|
+ const { id, typeList, durationList, numberList, openList } = toRefs(props);
|
|
onShow(() => {
|
|
onShow(() => {
|
|
uni.$on('opponentInfo', function (item) {
|
|
uni.$on('opponentInfo', function (item) {
|
|
form.value.opponent = item.id
|
|
form.value.opponent = item.id
|
|
@@ -148,12 +151,18 @@
|
|
// 类型选择
|
|
// 类型选择
|
|
const typeChange = (e) => {
|
|
const typeChange = (e) => {
|
|
const data = typeList.value[e.detail.value]
|
|
const data = typeList.value[e.detail.value]
|
|
- if (data) form.value.type = data.dictLabel
|
|
|
|
|
|
+ if (data) {
|
|
|
|
+ type_name.value = data.dictLabel
|
|
|
|
+ form.value.type = data.dictValue
|
|
|
|
+ }
|
|
};
|
|
};
|
|
// 人数选择
|
|
// 人数选择
|
|
const numberChange = (e) => {
|
|
const numberChange = (e) => {
|
|
const data = numberList.value[e.detail.value]
|
|
const data = numberList.value[e.detail.value]
|
|
- if (data) form.value.number = data.dictLabel
|
|
|
|
|
|
+ if (data) {
|
|
|
|
+ number_name.value = data.dictLabel
|
|
|
|
+ form.value.number = data.dictValue
|
|
|
|
+ }
|
|
};
|
|
};
|
|
// 日期选择器
|
|
// 日期选择器
|
|
const dateChange = (e) => {
|
|
const dateChange = (e) => {
|
|
@@ -166,11 +175,18 @@
|
|
// 时长选择选择
|
|
// 时长选择选择
|
|
const durationChange = (e) => {
|
|
const durationChange = (e) => {
|
|
const data = durationList.value[e.detail.value]
|
|
const data = durationList.value[e.detail.value]
|
|
- if (data) form.value.duration = data.dictLabel
|
|
|
|
|
|
+ if (data) {
|
|
|
|
+ duration_name.value = data.dictLabel
|
|
|
|
+ form.value.duration = data.dictValue
|
|
|
|
+ }
|
|
};
|
|
};
|
|
// 是否公开选择器
|
|
// 是否公开选择器
|
|
const openChange = (e) => {
|
|
const openChange = (e) => {
|
|
- form.value.is_open = e.detail.value
|
|
|
|
|
|
+ const data = numberList.value[e.detail.value]
|
|
|
|
+ if (data) {
|
|
|
|
+ open_name.value = data.dictLabel
|
|
|
|
+ form.value.is_open = data.dictValue
|
|
|
|
+ }
|
|
};
|
|
};
|
|
// 定位
|
|
// 定位
|
|
const toLocaltion = (e) => {
|
|
const toLocaltion = (e) => {
|
|
@@ -190,8 +206,7 @@
|
|
'file');
|
|
'file');
|
|
if (arr.code == 200) {
|
|
if (arr.code == 200) {
|
|
form.value.file.push({
|
|
form.value.file.push({
|
|
- newFileName: arr.newFileName,
|
|
|
|
- originalFilename: arr.originalFilename,
|
|
|
|
|
|
+ name: arr.originalFilename,
|
|
url: arr.url
|
|
url: arr.url
|
|
})
|
|
})
|
|
console.log(form.value.file);
|
|
console.log(form.value.file);
|
|
@@ -204,7 +219,7 @@
|
|
};
|
|
};
|
|
// 删除图片
|
|
// 删除图片
|
|
const toDelete = async (e) => {
|
|
const toDelete = async (e) => {
|
|
- form.value.file = form.value.file.filter(i => i.originalFilename != e.tempFile.name)
|
|
|
|
|
|
+ form.value.file = form.value.file.filter(i => i.name != e.tempFile.name)
|
|
console.log(form.value.file);
|
|
console.log(form.value.file);
|
|
};
|
|
};
|
|
// 对手选择
|
|
// 对手选择
|
|
@@ -213,6 +228,40 @@
|
|
url: `/pagesHome/create/person`,
|
|
url: `/pagesHome/create/person`,
|
|
})
|
|
})
|
|
};
|
|
};
|
|
|
|
+ // 创建
|
|
|
|
+ const formSubmit = async () => {
|
|
|
|
+ if (!form.value.opponent) {
|
|
|
|
+ uni.showToast({ title: '请选择比赛对手', icon: 'none' });
|
|
|
|
+ return
|
|
|
|
+ } else if (!form.value.date) {
|
|
|
|
+ uni.showToast({ title: '请选择活动日期', icon: 'none' });
|
|
|
|
+ return
|
|
|
|
+ } else if (!form.value.time) {
|
|
|
|
+ uni.showToast({ title: '请选择活动时间', icon: 'none' });
|
|
|
|
+ return
|
|
|
|
+ } else if (!form.value.address) {
|
|
|
|
+ uni.showToast({ title: '请选择活动场地', icon: 'none' });
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ if (form.value.file && form.value.file.length == 0) delete form.value.file
|
|
|
|
+ form.value.teamId = id.value
|
|
|
|
+ const arr = await $api(`friendship`, 'POST', form.value);
|
|
|
|
+ if (arr.code === 200) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: `/pagesHome/activity/info?id=${arr.data.id}`,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: arr.msg,
|
|
|
|
+ icon: 'error'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 第二部:暴露方法
|
|
|
|
+ defineExpose({
|
|
|
|
+ formSubmit
|
|
|
|
+ })
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.form {
|
|
.form {
|