This commit is contained in:
shijingjing
2022-09-05 09:54:41 +08:00
parent c6b550a07a
commit 6cf725119f
2 changed files with 181 additions and 8 deletions

View File

@@ -27,8 +27,11 @@
<div class="content_fodder">
<!-- <div style="color: #8E8F91;">添加素材</div> -->
<div class="fodder_alls">
<div class="fodder_add" @click="showFodder"><u-icon name="plus" color="#CCD0D3" size="32"></u-icon></div>
<!-- <AiUploader :def.sync="files" placeholder="添加素材" type="file" :limit="9" multiple action="/admin/file/add2"></AiUploader> -->
<!-- <div class="fodder_add" @click="showUpload = true"><u-icon name="plus" color="#CCD0D3" size="32"></u-icon></div> -->
<AiUploader :def.sync="files" placeholder="添加素材" type="file" :limit="9" multiple action="/admin/file/add2"></AiUploader>
</div>
<div class="fodder_file">
<div class="item"></div>
</div>
</div>
</div>
@@ -78,10 +81,10 @@
<div class="file_content" v-for="item in files" :key="item.id">
<img class="text_left" src="https://cdn.cunwuyun.cn/dvcp/announce/avatar.png" />
<img class="only_pic" :src="item.url" alt="" v-if="getExtension(item.name) == '.jpg' || getExtension(item.name) == '.jpeg'">
<img class="only_pic" :src="item.url" alt="" v-if="['.jpg', '.jpeg','png'].indexOf(getExtension(item.name)) !== -1">
<video controls class="only_video" :src="item.url" v-if="getExtension(item.name) == '.mp4'"></video>
<div class="text_right file_right"
v-if="getExtension(item.name) != '.jpg' && getExtension(item.name) != '.jpeg' && getExtension(item.name) != '.mp4'">
v-if="['.jpg', '.jpeg','png','.mp4'].indexOf(getExtension(item.name)) === -1">
<div class="cont_left">
<h4>{{ item.name }}</h4>
<p>{{ item.fileSizeStr }}</p>
@@ -99,6 +102,21 @@
</div>
</div>
<u-popup v-model="showUpload" mode="bottom" border-radius="24">
<div class="uploadPopup">
<div class="upload_card" v-for="(item,index) in uploadList" :key="index">
<div class="upload_item">{{ item.title }}</div>
<div class="upload_list">
<div class="list_item" v-for="(e, i) in item.list" :key="i" @click="uploadBtn(e.msgType)">
<img :src="e.icon" alt="">
<span>{{ e.name }}</span>
</div>
</div>
</div>
<div class="btnCancel" @click="showUpload = false">取消</div>
</div>
</u-popup>
<div class="btn">
<div class="submitBtn" @click="confirm">通知成员发送</div>
@@ -134,6 +152,7 @@ export default {
userListIds: [],
showPopup: false,
showFodder: false,
showUpload: false,
params: {
year: true,
month: true,
@@ -144,6 +163,41 @@ export default {
timestamp: false,
},
flag: false,
uploadList: [
// {
// title: '从素材库上传',
// list: [
// {
// icon: '',
// name: ''
// },
// {
// icon: '',
// name: ''
// }
// ]
// },
{
title: '从本地上传',
list: [
{
icon: 'https://cdn.cunwuyun.cn/dvcp/announce/img.png',
name: '图片',
msgType: 'image'
},
{
icon: 'https://cdn.cunwuyun.cn/dvcp/announce/video.png',
name: '视频',
msgType: 'video'
},
{
icon: 'https://cdn.cunwuyun.cn/dvcp/announce/folder.png',
name: '文件',
msgType: 'file'
}
]
}
],
}
},
methods: {
@@ -186,6 +240,56 @@ export default {
return name.substring(name.lastIndexOf('.'))
},
uploadBtn(type) {
let count = 9 - (this.files?.length || 0)
if(count > 0){
let params = {
count,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
let count = this.files?.length + (res.tempFiles?.length || res.tempFile ? 1 : 0)
if (count > 9) {
return this.$u.toast(`不能超过9个`)
}
if (res.tempFiles) {
res.tempFiles?.map((item) => {
this.uploadFile(item)
})
} else if (res?.tempFile) {
this.uploadFile(res.tempFile)
}
},
}
if (type == 'image') {
uni.chooseImage(params)
} else if (type == 'video') {
uni.chooseVideo(params)
} else if(type == 'file') {
uni.chooseFile(params)
}
} else {
this.$u.toast(`不能超过9个`)
}
},
uploadFile(img) {
uni.showLoading({title: '上传中'})
let formData = new FormData()
formData.append('file', img)
this.$http.post('/admin/file/add2', formData).then((res) => {
uni.hideLoading()
if (res?.data) {
this.$u.toast('上传成功!')
this.showUpload = false
this.files.push(res.data)
}
}).catch(res => {
this.$u.toast(res)
uni.hideLoading()
})
},
choiceTime(e) {
this.form.choiceTime = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
},
@@ -201,10 +305,21 @@ export default {
]
this.form.contents.push(...firstContent)
const fileLists = this.files.map(item=> {
// if(this.getExtension(item.name)==)
const picUrl = this.files.map(e=> {
if(['.jpg','.jpeg','.png'].indexOf(this.getExtension(e.name)) !== -1) {
console.log({
imgPicUrl: e.url,
msgType: '1'
})
return {
imgPicUrl: e.url,
msgType: '1'
}
}
})
this.form.contents.push(...picUrl)
if(!this.form.taskTitle) {
return this.$u.toast('请输入任务名称')
}
@@ -228,6 +343,8 @@ export default {
if(this.isTimedTask) {
if(!this.form.choiceTime.length) {
return this.$u.toast("请选择发送时间")
} else if (new Date(this.form.choiceTime).getTime() < Date.now()) {
return this.$u.toast('定时发送时间不得早于当前时间')
}
}
this.flag = true
@@ -315,6 +432,12 @@ export default {
border-radius: 8px;
}
}
.fodder_file {
.item {
}
}
}
}
@@ -459,6 +582,49 @@ export default {
}
}
.uploadPopup {
background: #F7F7F7;
.upload_card {
padding: 32px 32px 0 32px;
box-sizing: border-box;
overflow-x: scroll;
.upload_item {
margin-bottom: 32px;
}
.upload_list {
overflow-x: scroll;
display: flex;
.list_item {
text-align: center;
width: 106px;
height: 130px;
margin-right: 48px;
img {
display: inline-block;
width: 84px;
height: 84px;
}
span {
// display: inline-block;
// line-height: 44px;
}
}
}
}
.btnCancel {
width: 100%;
height: 120px;
line-height: 120px;
text-align: center;
border-top: 2px solid #DDDDDD;
margin-top: 80px;
}
}
.btn {
position: fixed;

View File

@@ -90,7 +90,7 @@ export default {
this.userList = []
this.$http.post(`/app/appgirdmemberinfo/listByGirdIdByThree?girdId=${id}`).then((res) => {
if (res?.data) {
this.userList = res.data.map(e => ({...e, isChecked: e.id == this.selected.forEach(i => i.id)}))
this.userList = res.data.map(e => ({...e, isChecked: this.selected.find(i => i.id==e.id)}))
}
})
},
@@ -129,7 +129,14 @@ export default {
// })
// this.selected = {...row, kind: "user"}
// }
this.selected = this.userList.filter(v=> v.isChecked)
if(row.isChecked){
this.selected.push(row)
}else{
console.log(this.selected)
let index=this.selected.findIndex(item=>row.id===item.id)
index>=0&&this.selected.splice(index, 1)
}
// this.selected = this.userList.filter(v=> v.isChecked)
uni.setStorageSync('userSelect', this.selected)
},