14 changed files with 788 additions and 141 deletions
@ -1,8 +1,256 @@ |
|||
<template> |
|||
<view class="activityPage"> |
|||
<view class="title"> |
|||
<view class="label">活动标题(必填项)</view> |
|||
<input type="text" v-model="activityInfo.title" placeholder="请输入活动标题" class="title-inp"> |
|||
</view> |
|||
<view class="category"> |
|||
<view class="label">活动分类(必填项)</view> |
|||
<picker @change="categoryChange" class="dataPicker" :value="cc_index" range-key="name" :range="category_list"> |
|||
<view class="uni-input" v-if="cc_index==-1" style="color: #999;">请选择</view> |
|||
<view class="uni-input" v-else>{{category_list[cc_index].name}}</view> |
|||
</picker> |
|||
</view> |
|||
<view class="content"> |
|||
<view class="label">活动内容(必填项)</view> |
|||
<jinEdit placeholder="请输入内容" @editOk="editOk" uploadFileUrl="/#" :html="activityInfo.describe"></jinEdit> |
|||
</view> |
|||
<view class="promotional"> |
|||
<view class="label">活动宣传图(必填项)</view> |
|||
<view class="" v-if="activityInfo.promotional_img" style="position: relative;"> |
|||
<image :src="activityInfo.promotional_img" mode="widthFix" style="width: 100%;height: auto;"></image> |
|||
<image :src="imgfixUrls + 'merchant/close.png'" class="close" @click.stop="closePreview()" /> |
|||
</view> |
|||
<image v-else :src="imageRootNew+'mb-plus.png'" @click="uploadFiles()" class="plus"></image> |
|||
</view> |
|||
<view class=""> |
|||
<view class="release-btn" @click="saveActivit">确认发布</view> |
|||
</view> |
|||
<!-- <view style="font-size: 14px;color: #509DFD;margin-top: 20upx;" v-if="id===0"> |
|||
<navigator url="./myActivities">我的发布</navigator> |
|||
</view> --> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import App from '@/common/js/app.js'; |
|||
import jinEdit from '@/components/jin-edit/jin-edit.vue'; |
|||
export default { |
|||
data() { |
|||
return { |
|||
id: 0, |
|||
activityInfo: { |
|||
title: '', |
|||
describe: '', |
|||
promotional_img: '', |
|||
cc_id: '', |
|||
}, |
|||
category_list: [], |
|||
cc_index: -1, |
|||
} |
|||
}, |
|||
components: { |
|||
jinEdit |
|||
}, |
|||
onLoad(e) { |
|||
if(e.id){ |
|||
this.id = e.id; |
|||
} |
|||
this.getDetail(); |
|||
}, |
|||
methods: { |
|||
getDetail(){ |
|||
let _this = this; |
|||
App._post_form('&p=student&do=getCampusActivities', {id:this.id||0}, res => { |
|||
// _this.setData({ |
|||
// activitiesInfo: res.data.data |
|||
// }) |
|||
this.category_list = res.data.category_list; |
|||
if(res.data.list!=[]){ |
|||
this.activityInfo = res.data.list; |
|||
for(let i=0;i<this.category_list.length;i++){ |
|||
if(this.category_list[i].id == res.data.list.cc_id){ |
|||
this.cc_index = i; |
|||
} |
|||
} |
|||
|
|||
} |
|||
}); |
|||
}, |
|||
categoryChange(e){ |
|||
console.log(e); |
|||
this.cc_index = e.detail.value; |
|||
this.activityInfo.cc_id = this.category_list[this.cc_index].id; |
|||
}, |
|||
editOk(res) { |
|||
console.log('-------',res.html); |
|||
this.activityInfo.describe = res.html; |
|||
uni.showToast({ |
|||
title: '保存成功' |
|||
}) |
|||
}, |
|||
saveActivit(){ |
|||
if(this.activityInfo.title.replace(/(^\s*)|(\s*$)/g, "")==""){ |
|||
uni.showToast({ |
|||
icon:'none', |
|||
title: '标题不能为空', |
|||
duration: 2000 |
|||
}); |
|||
return ; |
|||
} |
|||
if(this.cc_index==-1){ |
|||
uni.showToast({ |
|||
icon:'none', |
|||
title: '分类不能为空', |
|||
duration: 2000 |
|||
}); |
|||
return ; |
|||
} |
|||
if(this.activityInfo.describe.replace(/(^\s*)|(\s*$)/g, "")==""){ |
|||
uni.showToast({ |
|||
icon:'none', |
|||
title: '未保存内容', |
|||
duration: 2000 |
|||
}); |
|||
return ; |
|||
} |
|||
if(this.activityInfo.promotional_img==""){ |
|||
uni.showToast({ |
|||
icon:'none', |
|||
title: '宣传图不能为空', |
|||
duration: 2000 |
|||
}); |
|||
return ; |
|||
} |
|||
App._post_form('&p=student&do=publishCampusActivities', this.activityInfo, res => { |
|||
uni.showToast({ |
|||
title: res.message |
|||
}) |
|||
setTimeout(()=>{ |
|||
uni.navigateBack({ |
|||
delta: 1 |
|||
}) |
|||
}, 2000) |
|||
}); |
|||
}, |
|||
// 文件上传接口 |
|||
async uploadFiles() { |
|||
let _this = this; |
|||
// #ifndef H5 |
|||
wx.chooseImage({ |
|||
count: 1, |
|||
sourceType: ['album', 'camera'], |
|||
success: async function(res) { |
|||
for (let i = 0; i < res.tempFilePaths.length; i++) { |
|||
let result = await App._MYupLoad(res.tempFilePaths[i]); |
|||
console.log(result.data.img, result); |
|||
|
|||
_this.activityInfo.promotional_img = result.data.img; |
|||
|
|||
uni.showToast({ |
|||
title: result.message |
|||
}) |
|||
} |
|||
} |
|||
}); |
|||
// #endif |
|||
}, |
|||
closePreview(){ |
|||
this.activityInfo.promotional_img = ''; |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style> |
|||
<style lang="scss" scoped> |
|||
.activityPage{ |
|||
padding: 20upx 30upx 80upx; |
|||
background: #f8f8f8; |
|||
|
|||
.title, .category, .content, .promotional{ |
|||
background-color: #fff; |
|||
padding: 10upx 20upx; |
|||
border-radius: 20upx; |
|||
margin-bottom: 30upx; |
|||
} |
|||
.category{ |
|||
} |
|||
.content{ |
|||
} |
|||
.promotional{ |
|||
} |
|||
.label{ |
|||
height: 16px; |
|||
line-height: 16px; |
|||
padding-left: 10upx; |
|||
margin: 20upx 0px; |
|||
border-left: 4px solid #509DFD; |
|||
} |
|||
.title-inp{ |
|||
font-size: 14px; |
|||
border: 1px solid #e6e6e6; |
|||
padding: 0px 10px; |
|||
height: 30px; |
|||
border-radius: 6px; |
|||
line-height: 30px; |
|||
margin: 20upx 0px; |
|||
} |
|||
.dataPicker{ |
|||
font-size: 14px; |
|||
border: 1px solid #e6e6e6; |
|||
padding: 0px 10px; |
|||
height: 30px; |
|||
border-radius: 6px; |
|||
line-height: 30px; |
|||
margin: 20upx 0px; |
|||
} |
|||
.close{ |
|||
position: absolute; |
|||
width: 20px; |
|||
height: 20px; |
|||
right: 10px; |
|||
top: 10px; |
|||
} |
|||
.plus{ |
|||
width: 50px; |
|||
height: 50px; |
|||
border: 1px solid #e6e6e6; |
|||
border-radius: 4px; |
|||
padding: 15px; |
|||
margin: 20upx 0px; |
|||
background-color: #f8f8f8; |
|||
} |
|||
.release-btn{ |
|||
margin: 20upx auto 0 auto; |
|||
width: 690upx; |
|||
height: 83upx; |
|||
// background: rgba(255, 68, 68, 1); |
|||
color: #fff; |
|||
background-color: #509DFD; |
|||
text-align: center; |
|||
padding: 0; |
|||
position: relative; |
|||
display: block; |
|||
box-sizing: border-box; |
|||
font-size: 35upx; |
|||
text-decoration: none; |
|||
line-height: 2.55555556; |
|||
border-radius: 50px; |
|||
overflow: hidden; |
|||
} |
|||
} |
|||
/deep/ .tool-view{ |
|||
position: absolute !important; |
|||
width: calc(100vw - 100upx - 2px) !important; |
|||
background-color: #fff; |
|||
} |
|||
/deep/ .container{ |
|||
border: 1px solid #e6e6e6; |
|||
border-radius: 6px; |
|||
margin: 20upx 0px; |
|||
position: relative; |
|||
} |
|||
/deep/ .ql-container{ |
|||
font-size: 14px !important; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,8 @@ |
|||
<template> |
|||
</template> |
|||
|
|||
<script> |
|||
</script> |
|||
|
|||
<style> |
|||
</style> |
|||
|
Before Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in new issue