鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

357 lines
9.5 KiB

<template>
<view>
<uv-popup ref="popup" mode="bottom" bgColor="none" :zIndex="1000000" @change="onPopupChange">
<view class="popup__view" v-if="isShow">
<view class="flex header">
<view class="title">新增记录</view>
<button class="btn" @click="close">关闭</button>
</view>
<view class="form">
<uv-form
ref="form"
:model="form"
:rules="rules"
errorType="toast"
>
<view class="form-item">
<uv-form-item prop="project" :customStyle="formItemStyle">
<view class="form-item-label">
<image class="icon" src="@/pages_order/static/icon-require.png" mode="widthFix"></image>
关联项目
</view>
<view class="form-item-content">
<view class="flex row" @click="openRelatePojectPicker">
<view v-if="form.project" class="text">{{ projectDesc }}</view>
<view v-else class="text placeholder">请选择关联项目</view>
<uv-icon name="arrow-right" color="#C6C6C6" size="32rpx"></uv-icon>
</view>
<reloateProjectPopup ref="reloateProjectPopup" :options="projects" @confirm="onRelateProjectChange"></reloateProjectPopup>
</view>
</uv-form-item>
</view>
<view class="form-item">
<uv-form-item prop="tripNum" :customStyle="formItemStyle">
<view class="flex row">
<view class="form-item-label">行程</view>
<view class="form-item-content">
<formRate v-model="form.tripNum"></formRate>
</view>
</view>
</uv-form-item>
</view>
<view class="form-item">
<uv-form-item prop="spotNum" :customStyle="formItemStyle">
<view class="flex row">
<view class="form-item-label">景点</view>
<view class="form-item-content">
<formRate v-model="form.spotNum"></formRate>
</view>
</view>
</uv-form-item>
</view>
<view class="form-item">
<uv-form-item prop="mentorNum" :customStyle="formItemStyle">
<view class="flex row">
<view class="form-item-label">导师</view>
<view class="form-item-content">
<formRate v-model="form.mentorNum"></formRate>
</view>
</view>
</uv-form-item>
</view>
<view class="form-item">
<uv-form-item prop="images" :customStyle="formItemStyle">
<view class="form-item-label">上传图片</view>
<view class="form-item-content">
<formUpload v-model="form.images"></formUpload>
</view>
</uv-form-item>
</view>
<view class="form-item" v-for="(item, index) in questions" :key="item.id">
<uv-form-item :prop="`texts[${index}]`" :customStyle="formItemStyle">
<view class="form-item-label">
<image class="icon" src="@/pages_order/static/icon-require.png" mode="widthFix"></image>
{{ item.label }}
</view>
<view class="form-item-content">
<formTextarea v-model="form.texts[index]"></formTextarea>
</view>
</uv-form-item>
</view>
</uv-form>
</view>
<view class="footer">
<button class="flex btn" @click="onPublish">发布</button>
</view>
</view>
</uv-popup>
</view>
</template>
<script>
import reloateProjectPopup from '@/pages_order/components/reloateProjectPopup.vue'
import formTextarea from '@/pages_order/components/formTextarea.vue'
import formUpload from '@/pages_order/components/formUpload.vue'
import formRate from '@/pages_order/components/formRate.vue'
export default {
components: {
reloateProjectPopup,
formTextarea,
formUpload,
formRate,
},
data() {
return {
isShow: false,
form: {
project: null,
tripNum: null,
spotNum: null,
mentorNum: null,
images: [],
texts: [],
},
rules: {
// todo
},
projects: [],
questions: [],
}
},
computed: {
projectDesc() {
const { project } = this.form
const target = this.projects?.find?.(item => item.id === project)
return target?.name || ''
},
},
methods: {
getData() {
// todo
this.projects = [
{
id: '001',
name: '亲子•坝上双草原6日 |乌兰布统+锡林郭勒+长城',
},
{
id: '002',
name: '青青草原•云中岭 |5-10公里AB线强度可选',
},
{
id: '003',
name: '新疆天山行7/9日丨醉美伊犁&吐鲁番双套餐',
},
{
id: '004',
name: '九色甘南|人间净土6日/7日深度游',
},
{
id: '005',
name: '北疆全景12日| 入疆首推!阿勒泰+伊犁+吐鲁番',
},
{
id: '006',
name: '塞上江南•神奇宁夏5日|穿越大漠与历史对话',
},
{
id: '007',
name: '尊享•天山环线9日| 伊犁全景+独库,头等舱大巴',
},
]
this.questions = [
{
id: '001',
label: '这次研学之旅,整体给你留下了怎样的印象?用几个词或几句话简单概括一下',
},
{
id: '002',
label: '在整个行程中,你最喜欢的部分是哪里?为什么?',
},
{
id: '003',
label: '你觉得这次研学的行程安排是否合理?有没有哪些地方让你觉得特别满意或需要改进的?',
},
]
},
async open() {
await this.getData()
const texts = this.questions.map(() => '')
this.form = {
project: null,
tripNum: null,
spotNum: null,
mentorNum: null,
images: [],
texts,
}
this.$refs.popup.open()
},
close() {
this.$refs.popup.close()
},
onPopupChange(e) {
this.isShow = e.show
},
openRelatePojectPicker() {
this.$refs.reloateProjectPopup.open(this.form.project?.id || null)
},
onRelateProjectChange(id) {
this.form.project = id
},
async onPublish() {
try {
await this.$refs.form.validate()
const {
} = this.form
const params = {
}
// todo: fetch
// await this.$fetch('updateAddress', params)
uni.showToast({
icon: 'success',
title: '发布成功',
});
this.$emit('submitted')
this.close()
} catch (err) {
console.log('onSave err', err)
}
},
},
}
</script>
<style lang="scss" scoped>
.popup__view {
width: 100vw;
display: flex;
flex-direction: column;
box-sizing: border-box;
background: #FFFFFF;
border-top-left-radius: 32rpx;
border-top-right-radius: 32rpx;
}
.header {
position: relative;
width: 100%;
padding: 24rpx 0;
box-sizing: border-box;
border-bottom: 2rpx solid #EEEEEE;
.title {
font-family: PingFang SC;
font-weight: 500;
font-size: 34rpx;
line-height: 1.4;
color: #181818;
}
.btn {
font-family: PingFang SC;
font-weight: 500;
font-size: 32rpx;
line-height: 1.4;
color: #8B8B8B;
position: absolute;
top: 26rpx;
left: 40rpx;
}
}
.form {
max-height: 75vh;
padding: 32rpx 40rpx;
box-sizing: border-box;
overflow-y: auto;
&-item {
padding: 8rpx 0 6rpx 0;
& + & {
padding-top: 24rpx;
border-top: 2rpx solid #EEEEEE;
}
&-label {
margin-bottom: 14rpx;
display: flex;
align-items: center;
font-family: PingFang SC;
font-weight: 400;
font-size: 26rpx;
line-height: 1.4;
color: #181818;
.icon {
margin-right: 8rpx;
width: 16rpx;
height: auto;
}
}
&-content {
.text {
padding: 2rpx 0;
font-family: PingFang SC;
font-weight: 400;
font-size: 32rpx;
line-height: 1.4;
&.placeholder {
color: #C6C6C6;
}
}
}
}
}
.row {
justify-content: space-between;
.form-label {
margin: 0;
}
}
.footer {
width: 100%;
padding: 32rpx 40rpx;
box-sizing: border-box;
border-top: 2rpx solid #F1F1F1;
.btn {
width: 100%;
padding: 14rpx 0;
box-sizing: border-box;
font-family: PingFang SC;
font-weight: 500;
font-size: 36rpx;
line-height: 1.4;
color: #FFFFFF;
background-image: linear-gradient(to right, #21FEEC, #019AF9);
border: 2rpx solid #00A9FF;
border-radius: 41rpx;
}
}
</style>