123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712 |
- <template>
- <view class="create_active">
- <view class="img" v-if="!uploadImage">
- <u-upload ref="uUpload" :action="action" :auto-upload="true" :form-data='imageDate' :file-list="fileList"
- @on-success='uploadSuccess' :custom-btn="true" max-count="1">
- <view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
- <u-icon name="plus" size="50" color="#79573D"></u-icon>
- </view>
- </u-upload>
- <text>添加活动海报</text>
- <text style="font-size: 12px;">(最佳尺寸比例:215*74)</text>
- </view>
- <view class="img" v-else>
- <u-image height="100%" :src="uploadImage"></u-image>
- </view>
- <view class="title title1">
- <view class="line"></view>
- <text>基本信息</text>
- </view>
- <u-form :model="form" ref="uForm" class="form">
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动标题" prop="title" :label-width="150">
- <u-input v-model="form.title" input-align="right" />
- </u-form-item>
- </view>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动类型" prop="type_id" :label-width="160">
- <view class="right" @click="choose_type">
- <text>{{current_type?current_type.label:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- <!-- <view class="warning" v-if="is_warning">
- 请选择活动类型
- </view> -->
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="type" mode="selector" :range="selector_type" @confirm="choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动开始时间" prop="start_time" :label-width="180">
- <view class="right" @click="actice_start_time = true">
- <text>{{form.start_time?form.start_time:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="actice_start_time" mode="time" @confirm="time_choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动结束时间" prop="end_time" :label-width="180">
- <view class="right" @click="actice_end_time = true">
- <text>{{form.end_time?form.end_time:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="actice_end_time" mode="time" @confirm="end_time_choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动形式" prop="shape" :label-width="150">
- <view class="right" @click="choose_shape">
- <text>{{current_shape?current_shape.label:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- <view class="warning" v-if="is_shape_show">
- 请选择活动形式
- </view>
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="is_shape" mode="selector" :range="selector" @confirm="shape_choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="联系人姓名" prop="contact_name" :label-width="150">
- <u-input v-model="form.contact_name" input-align="right" />
- </u-form-item>
- </view>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="联系人手机号" prop="contact_mobile" :label-width="180">
- <u-input v-model="form.contact_mobile" input-align="right" />
- </u-form-item>
- </view>
- <view class="posotion">
- <view class="star p_star">
- *
- </view>
- <view class="label">
- 地址
- </view>
- <u-form-item label="" prop="intro" :label-width="150">
- <u-input v-model="form.address" type="text" />
- </u-form-item>
- </view>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动详情" prop="body" :label-width="150">
- <view class="right" @click="goEdit">
- <!-- <VueEditor v-model="form.body" /> -->
- <text>{{form.body?'重新输入':'请点击跳转输入'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- </view>
- </u-form-item>
- </view>
- <view class="title">
- <view class="line"></view>
- <text>报名设置</text>
- </view>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="报名开始时间" prop="sign_up_start_time" :label-width="180">
- <view class="right" @click="actice_sign_up_start_time = true">
- <text>{{form.sign_up_start_time?form.sign_up_start_time:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="actice_sign_up_start_time" mode="time" @confirm="sus_time_choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="报名结束时间" prop="sign_up_end_time" :label-width="180">
- <view class="right" @click="actice_sign_up_end_time = true">
- <text>{{form.sign_up_end_time?form.sign_up_end_time:'请选择'}}</text>
- <u-icon name="arrow-right" size="20" color="#C8C9CC"></u-icon>
- </view>
- </u-form-item>
- </view>
- <u-picker v-model="actice_sign_up_end_time" mode="time" @confirm="sue_time_choose"></u-picker>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="报名总人数" prop="total_nums" :label-width="180">
- <u-input v-model="form.total_nums" type="number" input-align="right" />
- </u-form-item>
- </view>
- <view class="posotion">
- <view class="star">
- *
- </view>
- <u-form-item label="活动状态" prop="status" :label-width="180">
- <u-radio-group v-model="form.status" @change="radioGroupChange">
- <u-radio name="1">
- 正常
- </u-radio>
- <u-radio name="0">
- 暂停
- </u-radio>
- </u-radio-group>
- </u-form-item>
- </view>
- </u-form>
- <view class="btn">
- <button type="default" @click="submit">提交</button>
- </view>
- <!-- <view class="pic">
- <view class="top">
- <text>活动相册</text>
- <u-switch v-model="switchVal"></u-switch>
- </view>
- <text>*开启后,活动详情显示相册板块</text>
- </view>
- <view class="pic">
- <view class="top">
- <text>活动评论</text>
- <u-switch v-model="switchVal"></u-switch>
- </view>
- <text>*开启后,活动详情显示评论板块</text>
- </view> -->
- <!-- <view class="pic">
- <view class="top">
- <text>活动互动</text>
- <u-switch v-model="switchVal"></u-switch>
- </view>
- <text>*开启后,活动详情显示互动板块</text>
- </view> -->
- <u-popup v-model="show" mode="bottom" height="100%">
- <view class="form">
- <view class="back" @click="show=!show">
- <u-icon name="arrow-left" color="#2979ff" size="28"></u-icon>
- </view>
- <u-navbar :is-back="false" title="填写信息"></u-navbar>
- <jinEdit placeholder="请输入内容..." @editOk="editOk" uploadFileUrl="/api/common/upload" :html="form.body">
- </jinEdit>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import jinEdit from '../../components/jin-edit/jin-edit.vue';
- export default {
- components: {
- jinEdit
- },
- data() {
- return {
- form: {
- status: 1
- },
- is_warning: false,
- is_shape_show: false,
- type: false,
- actice_start_time: false,
- actice_end_time: false,
- is_shape: false,
- actice_sign_up_end_time: false,
- actice_sign_up_start_time: false,
- switchVal: false,
- selector: [],
- selector_type: [],
- show: false,
- rules: {
- title: [{
- required: true,
- message: '请输入活动标题',
- trigger: ['change', 'blur'],
- }],
- type_id: [{
- required: true,
- message: '请选择活动类型',
- trigger: ['change', 'blur'],
- }],
- start_time: [{
- required: true,
- message: '请选择活动开始时间',
- trigger: ['change', 'blur'],
- }],
- end_time: [{
- required: true,
- message: '请选择活动结束时间',
- trigger: ['change', 'blur'],
- }],
- sign_up_start_time: [{
- required: true,
- message: '请选择报名开始时间',
- trigger: ['change', 'blur'],
- }],
- sign_up_end_time: [{
- required: true,
- message: '请选择报名结束时间',
- trigger: ['change', 'blur'],
- }],
- total_nums: [{
- required: true,
- type: 'number',
- message: '请输入报名总人数',
- trigger: ['change', 'blur'],
- }],
- // shape: [{
- // required: true,
- // message: '请选择活动形式',
- // trigger: ['change', 'blur'],
- // }],
- contact_name: [{
- required: true,
- message: '请输入联系人姓名',
- trigger: ['change', 'blur'],
- }],
- contact_mobile: [{
- required: true,
- len: 11,
- message: '请输入联系人手机号',
- trigger: ['change', 'blur'],
- }],
- status: [{
- required: true,
- message: '请选择活动状态',
- trigger: ['change', 'blur'],
- }],
- address: [{
- required: true,
- message: '请输入活动地址',
- // 可以单个或者同时写两个触发验证方式
- trigger: ['change', 'blur'],
- }],
- body: [{
- required: true,
- message: '请输入活动内容',
- // 可以单个或者同时写两个触发验证方式
- trigger: ['change', 'blur'],
- }],
- },
- action: 'http://www.example.com/upload',
- fileList: [],
- imageDate: {
- file_type: 'img',
- type: 'course'
- }, //上传图片携带参数
- active_type: [],
- shape_list: [],
- current_type: '',
- current_shape: '',
- uploadImage: ''
- }
- },
- onShow() {
- this.action = '/api/common/upload'
- },
- methods: {
- goEdit() {
- this.show = true
- },
- // 点击发布
- editOk(res) {
- this.form.body = res.html
- console.log(this.form,'form')
- this.show = false
- },
- //上传图片成功
- uploadSuccess(data) {
- this.form.cover = data.data.id
- // this.form.headimg = data.data[0].url
- this.uploadImage = data.data.url
- // this.image_edit = 1
- },
- choose_type() {
- this.type = true
- this.active_type = uni.getStorageSync('type')
- this.selector_type = this.active_type.filter(item => {
- // if(item.label!='全部') {
- return item.label!='全部'
- // }
- })
- this.selector_type = this.selector_type.map(item=>{
- return item.label
- })
- console.log(this.active_type, 'active_type')
- console.log(this.selector_type, 'selector_type')
- },
- // picker选择的值
- choose(e) {
- this.current_type = this.active_type[e]
- // if(this.current_type.value == ""){
- // this.form.type_id = 0
- // return
- // }
- this.form.type_id = this.current_type.value
-
- // if (this.form.type_id || this.form.type_id == '') {
- // this.is_warning = false
- // }
- console.log(this.form.type_id, 'this.form.type_id')
- },
- //活动开始时间选择
- time_choose(e) {
- this.form.start_time = e.year + '-' + e.month + '-' + e.day
- },
- //活动结束时间选择
- end_time_choose(e) {
- this.form.end_time = e.year + '-' + e.month + '-' + e.day
- },
- choose_shape() {
- this.is_shape = true
- this.shape_list = uni.getStorageSync('shape')
- this.selector = this.shape_list.filter(item => {
- // if(item.label!='全部') {
- return item.label!='全部'
- // }
- })
- this.selector = this.selector.map(item => {
- return item.label
- })
- console.log(this.selector, 'selector')
- },
- //选择picker中的值
- shape_choose(e) {
- this.current_shape = this.shape_list[e]
- console.log(this.current_shape.value,'this.current_shape.value')
- // if(this.current_shape.value == ""){
- // this.form.shape = 0
- // }
- this.form.shape = this.current_shape.value
- },
- sus_time_choose(e) {
- this.form.sign_up_start_time = e.year + '-' + e.month + '-' + e.day
- },
- sue_time_choose(e) {
- this.form.sign_up_end_time = e.year + '-' + e.month + '-' + e.day
- },
- submit() {
- var reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
- // if (!this.form.type_id) {
- // this.is_warning = true
- // } else {
- // this.is_warning = false
- // }
- // if (!this.form.shape) {
- // this.is_shape_show = true
- // } else {
- // this.is_shape_show = false
- // }
- // this.$refs.uForm.validate(valid => {
- // if (valid) {
- // this.form.organization_id = this.vuex_user.organization_id
- // this.$u.post('/page/organization-activity', this.form).then(res => {
- // if (res.code == 200) {
- // uni.showToast({
- // title: '添加成功',
- // icon: 'none'
- // })
- // setTimeout(function() {
- // uni.reLaunch({
- // url: 'index'
- // })
- // }, 1500)
- // }
- // })
- // } else {
- // console.log('验证失败');
- // }
- // });
- if(!this.form.cover){
- uni.showToast({
- title: '请上传活动海报',
- icon: 'none'
- })
- return
- }
- else if (!this.form.title) {
- uni.showToast({
- title: '请填写活动标题',
- icon: 'none'
- })
- return
- }else if(this.form.type_id!=''&&!this.form.type_id){
- uni.showToast({
- title: '请选择活动类型',
- icon: 'none'
- })
- return
- }
- else if (!this.form.start_time) {
- uni.showToast({
- title: '请选择活动开始时间',
- icon: 'none'
- })
- return
- } else if (!this.form.end_time) {
- uni.showToast({
- title: '请选择活动结束时间',
- icon: 'none'
- })
- return
- } else if (this.form.shape!=''&&!this.form.shape) {
- uni.showToast({
- title: '请选择活动形式',
- icon: 'none'
- })
- return
- } else if (!this.form.contact_name) {
- uni.showToast({
- title: '请填写联系人姓名',
- icon: 'none'
- })
- return
- } else if(!this.form.contact_mobile){
- uni.showToast({
- title: '请正确填写联系人电话',
- icon: 'none'
- })
- return
- } else if(!reg_tel.test(this.form.contact_mobile)){
- uni.showToast({
- title: '请正确填写联系人电话',
- icon: 'none'
- })
- return
- }else if (!this.form.address) {
- uni.showToast({
- title: '请输入地址',
- icon: 'none'
- })
- return
- } else if (!this.form.body) {
- uni.showToast({
- title: '请输入活动详情',
- icon: 'none'
- })
- return
- } else if (!this.form.sign_up_start_time) {
- uni.showToast({
- title: '请选择报名开始时间',
- icon: 'none'
- })
- return
- } else if (!this.form.sign_up_end_time) {
- uni.showToast({
- title: '请选择报名结束时间',
- icon: 'none'
- })
- return
- }else if (!this.form.total_nums) {
- uni.showToast({
- title: '请输入报名总人数',
- icon: 'none'
- })
- return
- } else if (!this.form.status) {
- uni.showToast({
- title: '请选择活动状态',
- icon: 'none'
- })
- return
- }
- this.form.organization_id = this.vuex_user.organization_id
- this.$u.post('/page/organization-activity', this.form).then(res => {
- if (res.code == 200) {
- uni.showToast({
- title: '添加成功',
- icon: 'none'
- })
- setTimeout(function() {
- uni.reLaunch({
- url: 'index'
- })
- }, 1500)
- }
- })
- },
- radioGroupChange(e) {
- }
- },
- // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- }
- }
- </script>
- <style lang="scss" scoped>
- .create_active {
- // padding: 0 16px;
- background-color: rgba($color: #C8C9CC, $alpha: 0.2);
- padding-bottom: 30px;
- .img {
- width: 100%;
- height: 200px;
- background-color: #C8C9CC;
- background-color: rgba($color: #C8C9CC, $alpha: 0.2);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .slot-btn {
- border: 1px dashed #79573D;
- width: 70px;
- height: 70px;
- line-height: 70px;
- text-align: center;
- margin-bottom: 10px;
- }
- font-size: 14px;
- color: rgba($color: #C8C9CC, $alpha: 1.0);
- }
- .form {
- position: relative;
- .back {
- position: absolute;
- left: 10px;
- top: 0px;
- width: 30px;
- height: 44px;
- line-height: 44px;
- text-align: center;
- z-index: 9999;
- // background: #18B566;
- }
- }
- .title {
- display: flex;
- align-items: center;
- padding-top: 15px;
- padding-bottom: 10px;
- font-size: 14px;
- background-color: #fff;
- .line {
- width: 3px;
- height: 20px;
- background-color: #79573D;
- margin-right: 5px;
- }
- }
- .title1 {
- padding: 15px 16px 10px;
- }
- .form {
- padding: 0 16px;
- background-color: #fff;
- .posotion {
- position: relative;
- padding-left: 10px;
- .star {
- position: absolute;
- left: 0;
- top: 20px;
- color: red;
- }
- .label {
- margin-top: 10px;
- }
- .p_star {
- top: 0px;
- }
- }
- .right {
- width: 100%;
- text-align: right;
- color: #C8C9CC;
- }
- .warning {
- color: red;
- text-align: left;
- font-size: 12px;
- }
- }
- .pic {
- padding: 10px 16px;
- margin-top: 8px;
- background-color: #fff;
- color: #C8C9CC;
- font-size: 12px;
- .top {
- color: #333;
- font-size: 14px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- }
- .btn {
- button {
- z-index: 2;
- width: 90%;
- // position: fixed;
- // bottom: 0;
- margin-top: 15px;
- border-radius: 10px;
- background-color: #79573D;
- color: #fff;
- // border-radius: 0;
- &::after {
- border: none;
- }
- }
- }
- }
- </style>
|