Files

473 lines
13 KiB
Vue
Raw Permalink Normal View History

2022-05-31 10:04:46 +08:00
<template>
<section class="AppMessageNotification">
<div class="header">
2022-06-07 17:43:51 +08:00
<p>注意</p>
2022-05-31 10:04:46 +08:00
<p>每个用户每天可以接受10条群发消息不限企业发布的群发还是个人发布的群发</p>
<p>个人群发每天可以给用户发送10条群发消息</p>
</div>
<div class="select-user">
2022-06-07 09:11:47 +08:00
<div class="label color-666">用户选择</div>
2022-06-06 12:03:55 +08:00
<div class="right" @click="toSelect">
<span>
2022-06-14 11:07:50 +08:00
<span v-if="!areaIdList.length && !tagIdList.length && !deptList.length && !userList.length">全部</span>
2022-06-07 09:11:47 +08:00
<span v-else>已选择<!-- <span class="color-1365DD">10</span> --></span>
2022-05-31 10:04:46 +08:00
</span>
<img src="./components/img/right-icon.png" alt="">
</div>
</div>
<div class="content">
2022-06-06 12:03:55 +08:00
<p class="title fw500 mar-b32">群发消息设置</p>
<div class="select-user pad-lr0">
<div class="label color-666"><span class="tips">*</span>群发方式</div>
<div class="right">
<u-radio-group v-model="form.sendType">
<u-radio v-for="(item, index) in sendTypeList" :key="index" :label="item.name" :name="item.type">{{item.name}}</u-radio>
</u-radio-group>
</div>
<u-picker mode="time" v-model="timeShow" :params="timeParams" @confirm="timeSelect"></u-picker>
</div>
<div class="select-user pad-lr0" v-if="form.sendType == 1">
<div class="label color-666"><span class="tips">*</span>群发时间</div>
<div class="right" @click="timeShow=true">
<span v-if="form.sendTime">{{form.sendTime}}</span>
<span class="color-999" v-else>请选择</span>
</div>
<u-picker mode="time" v-model="timeShow" :params="timeParams" @confirm="timeSelect"></u-picker>
</div>
<div class="mini-title color-666"><span class="tips">*</span>文本内容</div>
2022-05-31 10:04:46 +08:00
<div class="textarea">
2022-06-07 17:43:51 +08:00
<u-input v-model="form.content" type="textarea" :height="400" auto-height maxlength="1000" placeholder="请输入文本内容" />
<div class="hint">{{ form.content.length }}/1000</div>
2022-05-31 10:04:46 +08:00
</div>
2022-06-14 11:07:50 +08:00
<!-- <div class="type">
2022-05-31 10:04:46 +08:00
<p class="color-666">其它类型</p>
2022-06-06 12:03:55 +08:00
<u-radio-group v-model="form.contentType">
2022-06-07 19:07:38 +08:00
<u-radio v-for="(item, index) in typeList" :key="index" :name="item.type" @change="radioChange" > {{item.name}}</u-radio>
2022-05-31 10:04:46 +08:00
</u-radio-group>
2022-06-14 11:07:50 +08:00
</div> -->
2022-05-31 10:04:46 +08:00
<div class="type-content">
2022-06-14 11:07:50 +08:00
<div class="flex">
2022-05-31 10:04:46 +08:00
<p class="label" style="width:40px;">图片</p>
2022-06-15 15:46:31 +08:00
<AiUploader type="image" :limit="9" multiple :def.sync="fileListImg" @data="changeImg"></AiUploader>
2022-06-08 14:32:51 +08:00
</div>
2022-06-14 11:07:50 +08:00
<div class="flex" >
2022-06-08 14:32:51 +08:00
<p class="label" style="width:40px;">视频</p>
2022-06-15 15:46:31 +08:00
<AiUploader type="video" :limit="9" multiple placeholder="上传视频" :def.sync="fileListVideo" @data="changeVideo"></AiUploader>
2022-06-08 14:32:51 +08:00
</div>
2022-06-14 11:07:50 +08:00
<div class="flex">
2022-06-08 14:32:51 +08:00
<p class="label" style="width:40px;">附件</p>
2022-06-15 15:46:31 +08:00
<AiUploader type="file" :limit="9" multiple placeholder="上传附件" :def.sync="fileListFile" @data="changeFile"></AiUploader>
2022-05-31 10:04:46 +08:00
</div>
2022-06-06 12:03:55 +08:00
<div v-if="form.contentType == 'link'">
2022-05-31 10:04:46 +08:00
<div class="flex border-b">
<p class="label">链接地址</p>
<div class="value">
2022-06-06 12:03:55 +08:00
<u-input v-model="formData.accessUrl" type="text" input-align="right" placeholder="请输入链接地址" height="44" />
2022-05-31 10:04:46 +08:00
</div>
</div>
<div class="flex border-b">
<p class="label">链接图片</p>
2022-06-07 19:07:38 +08:00
<AiUploader multiple :def.sync="formData.imgList" :limit="1" action="/admin/file/add2"></AiUploader>
2022-05-31 10:04:46 +08:00
</div>
<div class="flex">
<p class="label">链接标题</p>
<div class="value">
2022-06-06 12:03:55 +08:00
<u-input v-model="formData.accessTitle" type="text" input-align="right" placeholder="请输入链接标题" height="44" />
2022-05-31 10:04:46 +08:00
</div>
</div>
</div>
2022-06-06 12:03:55 +08:00
<div v-if="form.contentType == 'miniapp'" class="flex-label">
2022-05-31 10:04:46 +08:00
<div class="flex border-b">
<p class="label">小程序标题</p>
<div class="value">
2022-06-06 12:03:55 +08:00
<u-input v-model="formData.accessTitle" type="text" input-align="right" placeholder="请输入小程序标题" height="44" />
2022-05-31 10:04:46 +08:00
</div>
</div>
<div class="flex border-b">
<p class="label">小程序APPID</p>
<div class="value">
2022-06-06 12:03:55 +08:00
<u-input v-model="formData.accessAppid" type="text" input-align="right" placeholder="请输入小程序APPID" height="44" />
2022-05-31 10:04:46 +08:00
</div>
</div>
<div class="flex border-b">
<p class="label">小程序跳转页面</p>
<div class="value">
2022-06-06 12:03:55 +08:00
<u-input v-model="formData.accessUrl" type="text" input-align="right" placeholder="如pages/home/home" height="44" />
2022-05-31 10:04:46 +08:00
</div>
</div>
<div class="flex">
<p class="label" style="width:80px;">小程序图片</p>
2022-06-07 19:07:38 +08:00
<AiUploader multiple :def.sync="formData.imgList" :limit="1" action="/admin/file/add2"></AiUploader>
2022-05-31 10:04:46 +08:00
</div>
</div>
</div>
<!-- <div class="upload"><u-icon name="plus-circle-fill" color="#1365DD" size="32"></u-icon>添加附件</div> -->
</div>
<div class="bg-144"></div>
<div class="footer">
2022-06-07 09:27:51 +08:00
<div @click="back">取消</div>
2022-06-06 12:03:55 +08:00
<div class="confirm" @click="confirm">确认发送</div>
2022-05-31 10:04:46 +08:00
</div>
<!-- <u-popup v-model="show" mode="bottom">
<div class="popup">
<div class="item" v-for="(item, index) in popupList" :key="index">
<div class="icon-bg">
<u-icon :name="item.icon" size="56" color="#333"></u-icon>
</div>
<p>{{item.text}}</p>
</div>
</div>
</u-popup> -->
</section>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: "AppMessageNotification",
appName: "消息通知",
data() {
return {
2022-06-06 12:03:55 +08:00
typeList: [
{name: '图片', type: 'image'},
{name: '视频', type: 'video'},
2022-06-07 09:11:47 +08:00
{name: '文件', type: 'file'}
2022-06-06 12:03:55 +08:00
],
sendTypeList: [
{name: '立即发送', type: '0'},
{name: '定时发送', type: '1'}
],
form: {
content: '',
sendType: '0',
sendTime: ''
},
2022-06-15 15:46:31 +08:00
formData: {},
fileList: [],
fileListImg: [],
fileListVideo: [],
fileListFile: [],
2022-06-06 12:03:55 +08:00
areaIdList: [],
tagIdList: [],
2022-06-14 11:07:50 +08:00
deptList: [],
userList: [],
2022-06-06 12:03:55 +08:00
timeShow: false,
timeParams: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true
2022-06-08 14:32:51 +08:00
},
2022-05-31 10:04:46 +08:00
}
},
computed: {...mapState(['user'])},
methods: {
2022-06-15 15:46:31 +08:00
changeImg(e) {
this.$nextTick(() => {
this.fileListImg.map((item) => {
if(item.id == e.file.id) {
item.mediaId = e.media.mediaId
item.contentType = 'image'
}
})
})
},
changeVideo(e) {
this.$nextTick(() => {
this.fileListVideo.map((item) => {
if(item.id == e.file.id) {
item.mediaId = e.media.mediaId
item.contentType = 'video'
}
})
})
},
changeFile(e) {
this.$nextTick(() => {
this.fileListFile.map((item) => {
if(item.id == e.file.id) {
item.mediaId = e.media.mediaId
item.contentType = 'file'
}
})
})
},
2022-05-31 10:04:46 +08:00
toSelect() {
2022-06-14 11:07:50 +08:00
uni.navigateTo({url: `./chooseUser?tagIdList=${this.tagIdList}&areaList=${this.areaIdList}&deptList=${this.deptList}&userList=${this.userList}`})
2022-06-06 12:03:55 +08:00
},
timeSelect(e) {
2022-06-07 09:11:47 +08:00
var nowTime = new Date().getTime() * 1
var beginTimes = new Date(e.year + '/' + e.month + '/' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second).getTime() * 1
if (nowTime > beginTimes) {
// this.form.sendTime = ''
return this.$u.toast('群发时间应大于当前时间')
} else {
this.form.sendTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`
}
2022-06-06 12:03:55 +08:00
},
confirm() {
2022-06-14 11:07:50 +08:00
this.$loading()
2022-06-06 12:03:55 +08:00
if(this.form.sendType == 1 && !this.form.sendTime) {
return this.$u.toast('请选择群发时间')
}
if(!this.form.content) {
return this.$u.toast('请输入文本内容')
}
2022-06-15 15:46:31 +08:00
this.fileList = []
2022-06-14 11:07:50 +08:00
var contentFile = {
content: this.form.content,
contentType: 'text'
}
2022-06-15 15:46:31 +08:00
this.fileList = [...this.fileListImg, ...this.fileListVideo, ...this.fileListFile]
this.fileList.unshift(contentFile)
2022-06-06 12:03:55 +08:00
var params = {
...this.form,
areaId: this.areaIdList.join(','),
2022-06-07 09:11:47 +08:00
tag: this.tagIdList.join(','),
2022-06-14 11:07:50 +08:00
deptList: this.deptList,
2022-06-15 15:46:31 +08:00
userList: this.userList,
fileList: this.fileList
2022-06-06 12:03:55 +08:00
}
this.$http.post("/app/pushmessage/addOrUpdate", params).then(res => {
if (res?.code == 0) {
2022-06-07 19:07:38 +08:00
this.$u.toast('发送成功')
2022-06-16 11:23:56 +08:00
setTimeout(() => {
this.back()
}, 500)
2022-06-15 17:26:00 +08:00
// this.form = {
// content: '',
// contentType: 'text',
// sendType: '0',
// sendTime: ''
// }
// this.areaIdList = []
// this.tagIdList = []
// this.formDataInit()
2022-06-08 09:43:32 +08:00
}else {
this.$u.toast(res.msg)
2022-06-06 12:03:55 +08:00
}
2022-06-08 09:43:32 +08:00
}).catch((err) => {
this.$u.toast(err)
2022-06-06 12:03:55 +08:00
})
2022-06-07 09:27:51 +08:00
},
2022-06-07 19:07:38 +08:00
formDataInit() {
2022-06-15 15:46:31 +08:00
for(let key in this.form) {
this.form[key] = ''
2022-06-07 19:07:38 +08:00
}
2022-06-15 15:46:31 +08:00
this.form.sendType = '0'
this.fileListImg = []
this.fileListVideo = []
this.fileListFile = []
2022-06-15 14:26:38 +08:00
this.areaIdList = []
this.tagIdList = []
this.deptList = []
this.userList = []
2022-06-07 19:07:38 +08:00
},
2022-06-07 09:27:51 +08:00
back() {
uni.navigateBack()
2022-05-31 10:04:46 +08:00
}
},
created() {
this.areaId = this.user.areaId
this.areaName = this.user.areaName
2022-06-06 12:03:55 +08:00
uni.$on('selectTag', res => {
this.tagIdList = res.tagIdList
this.areaIdList = res.areaIdList
2022-06-14 11:07:50 +08:00
this.deptList = res.deptList
this.userList = res.userList
2022-06-06 12:03:55 +08:00
})
2022-05-31 10:04:46 +08:00
},
}
</script>
<style lang="scss" scoped>
.AppMessageNotification {
height: 100%;
background-color: #f3f6f9;
.fw500{
font-weight: 500;
font-size: 32px!important;
}
.color-666{
color: #666;
font-size: 30px;
}
2022-06-06 12:03:55 +08:00
.tips{
font-size: 34px;
color: #f46!important;
vertical-align: middle;
}
.mar-b32{
margin-bottom: 32px;
}
2022-05-31 10:04:46 +08:00
.header{
2022-06-07 17:43:51 +08:00
// background-color: #fff;
padding: 32px 32px 20px 32px;
2022-05-31 10:04:46 +08:00
box-sizing: border-box;
margin-bottom: 16px;
p{
line-height: 44px;
margin-bottom: 8px;
word-break: break-all;
font-size: 28px;
2022-06-07 17:43:51 +08:00
color: #666;
2022-05-31 10:04:46 +08:00
}
}
.select-user{
background-color: #fff;
padding: 34px 32px;
display: flex;
justify-content: space-between;
margin-bottom: 16px;
font-size: 30px;
img{
width: 44px;
height: 44px;
vertical-align: middle;
}
.color-999{
color: #999;
}
.color-1365DD{
color: #1365DD;
}
2022-06-06 12:03:55 +08:00
.label{
width: 160px;
}
.right{
width: calc(100% - 160px);
text-align: right;
}
}
.pad-lr0{
padding: 0;
margin-bottom: 32px;
2022-05-31 10:04:46 +08:00
}
.content{
padding: 32px;
box-sizing: border-box;
background-color: #fff;
.title{
line-height: 44px;
margin-bottom: 24px;
}
.mini-title{
line-height: 44px;
margin-bottom: 24px;
}
.textarea{
padding: 16px 32px;
box-sizing: border-box;
border: 1px solid #ddd;
.hint {
padding: 4px 0 8px 0;
text-align: right;
color: #999;
}
}
// .upload{
// padding: 16px 32px;
// line-height: 44px;
// border: 1px solid #ddd;
// border-top: 0;
// .u-icon{
// margin-right: 8px;
// }
// }
.type{
margin-top: 32px;
p{
display: inline-block;
margin-right: 16px;
}
}
.type-content{
margin-top: 32px;
.label{
display: inline-block;
margin-right: 16px;
vertical-align: top;
font-size: 30px;
color: #666;
width: 130px;
}
.value{
width: calc(100% - 130px);
}
.ai-uploader{
display: inline-block;
width: calc(100% - 130px);
}
.flex{
padding: 34px 0;
line-height: 44px;
display: flex;
}
.border-b{
border-bottom: 1px solid #ddd;
}
.flex-label{
.label{
width: 260px;
}
}
}
}
.bg-144{
height: 144px;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 112px;
line-height: 112px;
background: #fff;
display: flex;
font-size: 36px;
font-family: PingFangSC-Regular, PingFang SC;
.confirm {
color: #fff;
background: #1365dd;
}
div {
flex: 1;
text-align: center;
color: #333;
}
}
.popup{
padding-top: 32px;
background-color: #f3f6f9;
.item{
display: inline-block;
width: 25%;
text-align: center;
padding: 32px 0;
.icon-bg{
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: #fff;
margin: 0 auto;
border-radius: 8px;
margin-bottom: 16px;
.u-icon{
margin-top: 20px;
}
}
p{
line-height: 44px;
font-size: 30px;
font-weight: 500;
color: #333;
}
}
}
}
</style>