Files
hejiu/pages/event-create/event-create.vue
T
cg fabbb167cf feat(circle): 添加酒友圈社交模块
- 新增酒友圈、圈子详情、发布动态、好友列表、活动创建等页面配置
- 添加酒友圈相关API接口,包括动态、评论、好友、活动等功能
- 实现模拟数据用于前端开发和测试
- 创建评论项、空状态、活动卡片、动态卡片、好友项等组件
- 编写酒友圈模块详细的接口文档,定义数据结构和业务规则
2026-07-20 22:53:04 +08:00

341 lines
7.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view :class="themeClass" class="page-container create-page">
<!-- 顶部导航 -->
<view class="create-nav" :style="{ paddingTop: navPaddingTop }">
<view class="create-nav-inner">
<view class="create-back" @click="goBack">
<text class="create-back-icon"></text>
</view>
<text class="create-nav-title">发起酒局</text>
<view class="create-nav-ph"></view>
</view>
</view>
<scroll-view class="create-scroll" scroll-y>
<view class="create-body">
<!-- 标题 -->
<view class="form-group">
<text class="form-label">酒局名称</text>
<input
class="form-input"
v-model="form.title"
placeholder="例如:周五夜·老地方火锅局"
placeholder-class="form-placeholder"
:maxlength="30"
/>
</view>
<!-- 时间 -->
<view class="form-group">
<text class="form-label">时间</text>
<picker mode="date" :value="form.date" @change="onDateChange">
<view class="form-picker">
<text :class="form.date ? 'form-picker-text' : 'form-picker-ph'">{{ form.date || '选择日期' }}</text>
<text class="form-picker-arrow"></text>
</view>
</picker>
<picker mode="time" :value="form.time" @change="onTimeChange">
<view class="form-picker" style="margin-top: 16rpx;">
<text :class="form.time ? 'form-picker-text' : 'form-picker-ph'">{{ form.time || '选择时间' }}</text>
<text class="form-picker-arrow"></text>
</view>
</picker>
</view>
<!-- 地点 -->
<view class="form-group">
<text class="form-label">地点</text>
<input
class="form-input"
v-model="form.location"
placeholder="输入聚会地点"
placeholder-class="form-placeholder"
:maxlength="50"
/>
</view>
<!-- 人数 -->
<view class="form-group">
<text class="form-label">人数上限</text>
<view class="form-stepper">
<view class="stepper-btn" @click="changePeople(-1)">
<text class="stepper-btn-text"></text>
</view>
<text class="stepper-value">{{ form.maxPeople }}</text>
<view class="stepper-btn" @click="changePeople(1)">
<text class="stepper-btn-text">+</text>
</view>
</view>
</view>
<!-- 备注 -->
<view class="form-group">
<text class="form-label">备注选填</text>
<textarea
class="form-textarea"
v-model="form.note"
placeholder="例如:自带酒水,AA制餐费"
placeholder-class="form-placeholder"
:maxlength="200"
/>
</view>
<!-- 发布按钮 -->
<button class="create-submit" :class="{ disabled: !canSubmit }" @click="handleSubmit">
发布酒局
</button>
</view>
</scroll-view>
</view>
</template>
<script>
import { CreateEvent } from '../../common/api'
import themeMixin from '../../common/theme-mixin'
export default {
mixins: [themeMixin],
data() {
const menuBtn = uni.getMenuButtonBoundingClientRect()
return {
navPaddingTop: menuBtn.top + 'px',
form: {
title: '',
date: '',
time: '',
location: '',
maxPeople: 6,
note: ''
},
submitting: false
}
},
computed: {
canSubmit() {
return this.form.title.trim() && this.form.date && this.form.time && this.form.location.trim() && !this.submitting
}
},
methods: {
goBack() {
uni.navigateBack()
},
onDateChange(e) {
this.form.date = e.detail.value
},
onTimeChange(e) {
this.form.time = e.detail.value
},
changePeople(delta) {
const val = this.form.maxPeople + delta
if (val >= 2 && val <= 50) {
this.form.maxPeople = val
}
},
async handleSubmit() {
if (!this.canSubmit) return
this.submitting = true
try {
await CreateEvent({
title: this.form.title,
time: `${this.form.date} ${this.form.time}`,
location: this.form.location,
maxPeople: this.form.maxPeople,
note: this.form.note
})
uni.showToast({ title: '酒局已发布 🎉', icon: 'none' })
setTimeout(() => uni.navigateBack(), 800)
} catch (e) {
uni.showToast({ title: '发布失败', icon: 'none' })
}
this.submitting = false
}
}
}
</script>
<style lang="scss" scoped>
.create-page {
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
.create-nav {
background: $bg-base;
padding-left: $sp-lg;
padding-right: $sp-lg;
}
.create-nav-inner {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
}
.create-back {
width: 64rpx;
height: 64rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: $bg-card;
&:active { background: $bg-card-alt; }
}
.create-back-icon {
font-size: $fs-xl;
color: $text-primary;
font-weight: $fw-bold;
}
.create-nav-title {
font-size: $fs-base;
font-weight: $fw-bold;
color: $text-primary;
}
.create-nav-ph {
width: 64rpx;
}
.create-scroll {
flex: 1;
height: 0;
}
.create-body {
padding: $sp-lg;
padding-bottom: calc(env(safe-area-inset-bottom) + #{$sp-2xl});
}
.form-group {
margin-bottom: $sp-xl;
}
.form-label {
display: block;
font-size: $fs-sm;
font-weight: $fw-medium;
color: $text-secondary;
margin-bottom: $sp-md;
}
.form-input {
width: 100%;
height: 88rpx;
padding: 0 $sp-lg;
background: $bg-card;
border-radius: $radius-lg;
border: 1rpx solid var(--border-faint, rgba(255,255,255,0.08));
font-size: $fs-base;
color: $text-primary;
box-sizing: border-box;
}
.form-placeholder {
color: $text-tertiary;
}
.form-picker {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
padding: 0 $sp-lg;
background: $bg-card;
border-radius: $radius-lg;
border: 1rpx solid var(--border-faint, rgba(255,255,255,0.08));
}
.form-picker-text {
font-size: $fs-base;
color: $text-primary;
}
.form-picker-ph {
font-size: $fs-base;
color: $text-tertiary;
}
.form-picker-arrow {
font-size: $fs-xl;
color: $text-tertiary;
}
.form-textarea {
width: 100%;
min-height: 160rpx;
padding: $sp-lg;
background: $bg-card;
border-radius: $radius-lg;
border: 1rpx solid var(--border-faint, rgba(255,255,255,0.08));
font-size: $fs-base;
color: $text-primary;
line-height: $lh-normal;
box-sizing: border-box;
}
/* 人数步进器 */
.form-stepper {
display: flex;
align-items: center;
gap: $sp-xl;
}
.stepper-btn {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background: $bg-card;
border: 1rpx solid var(--border-faint, rgba(255,255,255,0.08));
display: flex;
align-items: center;
justify-content: center;
&:active { background: $bg-card-alt; }
}
.stepper-btn-text {
font-size: $fs-xl;
color: $text-primary;
font-weight: $fw-bold;
}
.stepper-value {
font-size: $fs-xl;
font-weight: $fw-black;
color: $amber;
min-width: 60rpx;
text-align: center;
}
/* 提交 */
.create-submit {
width: 100%;
height: 96rpx;
line-height: 96rpx;
text-align: center;
background: linear-gradient(135deg, $amber, $amber-deep);
color: $text-on-amber;
font-size: $fs-lg;
font-weight: $fw-bold;
border-radius: $radius-full;
border: none;
margin-top: $sp-xl;
&::after { border: none; }
&.disabled {
opacity: 0.4;
}
&:active {
transform: scale(0.98);
}
}
</style>