|
@@ -1,22 +1,12 @@
|
|
|
<template>
|
|
<template>
|
|
|
<view class="container">
|
|
<view class="container">
|
|
|
<view class="form-card">
|
|
<view class="form-card">
|
|
|
- <view class="form-title">{{ isNew ? '创建活动' : '编辑活动' }}</view>
|
|
|
|
|
-
|
|
|
|
|
<!-- 活动标题 -->
|
|
<!-- 活动标题 -->
|
|
|
<view class="form-item">
|
|
<view class="form-item">
|
|
|
<text class="form-label">活动标题 *</text>
|
|
<text class="form-label">活动标题 *</text>
|
|
|
<input class="form-input" v-model="form.title" placeholder="请输入活动标题" maxlength="50" />
|
|
<input class="form-input" v-model="form.title" placeholder="请输入活动标题" maxlength="50" />
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- 活动维度 -->
|
|
|
|
|
- <view class="form-item">
|
|
|
|
|
- <text class="form-label">所属维度 *</text>
|
|
|
|
|
- <picker class="form-picker" :value="dimIdx" :range="dimensionOptions" range-key="label" @change="onDimChange">
|
|
|
|
|
- <text class="picker-text">{{ form.dimensionCode ? dimLabel(form.dimensionCode) : '请选择维度' }}</text>
|
|
|
|
|
- </picker>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
<!-- 活动类型 -->
|
|
<!-- 活动类型 -->
|
|
|
<view class="form-item">
|
|
<view class="form-item">
|
|
|
<text class="form-label">活动类型 *</text>
|
|
<text class="form-label">活动类型 *</text>
|
|
@@ -95,9 +85,16 @@
|
|
|
<!-- 封面图片 -->
|
|
<!-- 封面图片 -->
|
|
|
<view class="form-item">
|
|
<view class="form-item">
|
|
|
<text class="form-label">封面图片</text>
|
|
<text class="form-label">封面图片</text>
|
|
|
- <input class="form-input" v-model="form.coverImage" placeholder="输入图片URL(可选)" />
|
|
|
|
|
- <view class="cover-preview" v-if="form.coverImage">
|
|
|
|
|
- <image class="preview-img" :src="form.coverImage" mode="aspectFill" @error="onImgError" />
|
|
|
|
|
|
|
+ <view class="cover-upload" @click="chooseImage">
|
|
|
|
|
+ <image v-if="form.coverImage" class="preview-img" :src="getCoverUrl(form.coverImage)" mode="aspectFill" @click.stop />
|
|
|
|
|
+ <view v-else class="upload-placeholder">
|
|
|
|
|
+ <text class="upload-icon">📷</text>
|
|
|
|
|
+ <text class="upload-text">点击上传封面图</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="cover-actions" v-if="form.coverImage">
|
|
|
|
|
+ <text class="cover-action" @click="chooseImage">重新选择</text>
|
|
|
|
|
+ <text class="cover-action-danger" @click="removeCover">移除</text>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -180,15 +177,7 @@ export default {
|
|
|
endTimePart: '',
|
|
endTimePart: '',
|
|
|
regDatePart: '',
|
|
regDatePart: '',
|
|
|
regTimePart: '',
|
|
regTimePart: '',
|
|
|
- dimIdx: 0,
|
|
|
|
|
typeIdx: 0,
|
|
typeIdx: 0,
|
|
|
- dimensionOptions: [
|
|
|
|
|
- { key: 'body', label: '身 · 主动健康' },
|
|
|
|
|
- { key: 'mind', label: '心 · 情感丰盈' },
|
|
|
|
|
- { key: 'wisdom', label: '智 · 赋能未来' },
|
|
|
|
|
- { key: 'action', label: '行 · 知行合一' },
|
|
|
|
|
- { key: 'wealth', label: '富 · 物质精神' }
|
|
|
|
|
- ],
|
|
|
|
|
typeOptions: [
|
|
typeOptions: [
|
|
|
{ key: 'offline', label: '线下活动' },
|
|
{ key: 'offline', label: '线下活动' },
|
|
|
{ key: 'online', label: '线上活动' },
|
|
{ key: 'online', label: '线上活动' },
|
|
@@ -256,20 +245,13 @@ export default {
|
|
|
self.form.registrationDeadline = rd.toISOString()
|
|
self.form.registrationDeadline = rd.toISOString()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // sync pickers
|
|
|
|
|
- for (var i = 0; i < self.dimensionOptions.length; i++) {
|
|
|
|
|
- if (self.dimensionOptions[i].key === self.form.dimensionCode) self.dimIdx = i
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // sync type picker
|
|
|
for (var j = 0; j < self.typeOptions.length; j++) {
|
|
for (var j = 0; j < self.typeOptions.length; j++) {
|
|
|
if (self.typeOptions[j].key === self.form.activityType) self.typeIdx = j
|
|
if (self.typeOptions[j].key === self.form.activityType) self.typeIdx = j
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}).catch(function() { self.loading = false })
|
|
}).catch(function() { self.loading = false })
|
|
|
},
|
|
},
|
|
|
- onDimChange(e) {
|
|
|
|
|
- this.dimIdx = e.detail.value
|
|
|
|
|
- this.form.dimensionCode = this.dimensionOptions[this.dimIdx].key
|
|
|
|
|
- },
|
|
|
|
|
onTypeChange(e) {
|
|
onTypeChange(e) {
|
|
|
this.typeIdx = e.detail.value
|
|
this.typeIdx = e.detail.value
|
|
|
this.form.activityType = this.typeOptions[this.typeIdx].key
|
|
this.form.activityType = this.typeOptions[this.typeIdx].key
|
|
@@ -354,15 +336,21 @@ export default {
|
|
|
onImgError() {
|
|
onImgError() {
|
|
|
this.form.coverImage = ''
|
|
this.form.coverImage = ''
|
|
|
},
|
|
},
|
|
|
|
|
+ getCoverUrl(path) {
|
|
|
|
|
+ if (!path) return ''
|
|
|
|
|
+ var s = String(path).trim()
|
|
|
|
|
+ if (!s || s === 'null' || s === '/null') return ''
|
|
|
|
|
+ if (s.indexOf('http://') === 0 || s.indexOf('https://') === 0) return s
|
|
|
|
|
+ return BASE_URL + (s.charAt(0) === '/' ? s : '/' + s)
|
|
|
|
|
+ },
|
|
|
|
|
+ removeCover() {
|
|
|
|
|
+ this.form.coverImage = ''
|
|
|
|
|
+ },
|
|
|
validate() {
|
|
validate() {
|
|
|
if (!this.form.title) {
|
|
if (!this.form.title) {
|
|
|
uni.showToast({ title: '请输入活动标题', icon: 'none' })
|
|
uni.showToast({ title: '请输入活动标题', icon: 'none' })
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- if (!this.form.dimensionCode) {
|
|
|
|
|
- uni.showToast({ title: '请选择所属维度', icon: 'none' })
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
if (!this.form.activityType) {
|
|
if (!this.form.activityType) {
|
|
|
uni.showToast({ title: '请选择活动类型', icon: 'none' })
|
|
uni.showToast({ title: '请选择活动类型', icon: 'none' })
|
|
|
return false
|
|
return false
|
|
@@ -381,6 +369,8 @@ export default {
|
|
|
payload.parentFee = Math.round((parseFloat(this.parentFeeYuan) || 0) * 100)
|
|
payload.parentFee = Math.round((parseFloat(this.parentFeeYuan) || 0) * 100)
|
|
|
payload.parentMemberFee = Math.round((parseFloat(this.parentMemberFeeYuan) || 0) * 100)
|
|
payload.parentMemberFee = Math.round((parseFloat(this.parentMemberFeeYuan) || 0) * 100)
|
|
|
if (this.activityId) payload.id = this.activityId
|
|
if (this.activityId) payload.id = this.activityId
|
|
|
|
|
+ // 维度由审核时设置,创建/编辑不提交空维度,避免误清空已有维度
|
|
|
|
|
+ if (!payload.dimensionCode) delete payload.dimensionCode
|
|
|
return payload
|
|
return payload
|
|
|
},
|
|
},
|
|
|
handleSave() {
|
|
handleSave() {
|
|
@@ -470,12 +460,6 @@ export default {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- dimLabel(key) {
|
|
|
|
|
- for (var i = 0; i < this.dimensionOptions.length; i++) {
|
|
|
|
|
- if (this.dimensionOptions[i].key === key) return this.dimensionOptions[i].label
|
|
|
|
|
- }
|
|
|
|
|
- return '请选择维度'
|
|
|
|
|
- },
|
|
|
|
|
typeLabel(key) {
|
|
typeLabel(key) {
|
|
|
for (var i = 0; i < this.typeOptions.length; i++) {
|
|
for (var i = 0; i < this.typeOptions.length; i++) {
|
|
|
if (this.typeOptions[i].key === key) return this.typeOptions[i].label
|
|
if (this.typeOptions[i].key === key) return this.typeOptions[i].label
|
|
@@ -614,6 +598,25 @@ export default {
|
|
|
margin-top: 8rpx;
|
|
margin-top: 8rpx;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.cover-actions {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: row;
|
|
|
|
|
+ gap: 24rpx;
|
|
|
|
|
+ margin-top: 12rpx;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.cover-action {
|
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
|
+ color: #475569;
|
|
|
|
|
+ text-decoration: underline;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.cover-action-danger {
|
|
|
|
|
+ font-size: 24rpx;
|
|
|
|
|
+ color: #ef4444;
|
|
|
|
|
+ text-decoration: underline;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.form-actions {
|
|
.form-actions {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: row;
|
|
flex-direction: row;
|