This commit is contained in:
yanran200730
2022-06-10 16:13:01 +08:00
3 changed files with 384 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
<template>
<div class="AppTvMsg">
<AiTopFixed>
<div class="currentLeft-top">
<AiSelect @data="selectType" :list="typeList" v-model="type"></AiSelect>
</div>
</AiTopFixed>
<div class="record">
<div class="item" v-for="(item, index) in list" :key="index">
<p class="content">{{item.content}}</p>
<p :class="`type${item.type}`">{{item.type == '10' ? '主动报备提醒' : '核酸监测通知'}}</p>
<u-icon name="trash" color="#ff4466" size="40" class="del" @click="del(item)"></u-icon>
</div>
</div>
<AiEmpty v-if="!list.length"></AiEmpty>
<img src="./img/add-icon.png" alt="" class="add-img" @click="add">
</div>
</template>
<script>
export default {
name: "AppTvMsg",
appName: '极光推送',
data() {
return {
list: [],
current: 1,
type: '',
typeList: [{label: '全部', value: ''}, {label: '核酸监测通知', value: '15' }, {label: '主动报备提醒', value: '10' }]
}
},
onLoad() {
this.getList()
uni.$on('getList', () => {
this.list = []
this.current = 1
this.$nextTick(() => {
this.getList()
})
})
},
onShow() {
document.title = '极光推送'
},
methods: {
selectType(selecteds) {
this.type = selecteds?.[0]?.value
this.getListInit()
},
add() {
uni.navigateTo({
url: `./add`
})
},
getListInit() {
this.list = []
this.current = 1
this.getList()
},
getList() {
this.$http.post(`/app/appiptvjpush/list`, null, {
params: {
type: this.type,
current: this.current,
size: 10
}
}).then(res => {
if (res.code == 0) {
if (this.current > 1) {
this.list = [...this.list, ...res.data.records]
} else {
this.list = res.data.records
}
} else {
uni.hideLoading()
}
}).catch(() => {
uni.hideLoading()
})
},
del(item) {
this.$confirm(`是否要删除推送消息`).then(() => {
this.$http.post(`/app/appiptvjpush/delete?ids=${item.id}`).then((res) => {
if (res.code == 0) {
this.getListInit()
this.$u.toast('删除成功')
}
})
})
},
},
onReachBottom() {
this.current ++
this.getList()
}
}
</script>
<style lang="scss" scoped>
.AppTvMsg {
padding-bottom: 128px;
::v-deep .AiTopFixed{
.content{
padding: 0;
}
}
.record {
padding: 32px;
.item {
width: 100%;
padding: 32px 30px;
box-sizing: border-box;
background-color: #fff;
border-radius: 8px;
margin-bottom: 16px;
position: relative;
.del{
position: absolute;
top: 32px;
right: 32px;
}
.content{
width: 500px;
word-break: break-all;
margin-bottom: 8px;
}
.type10{
color:#4E8EEE;
}
.type15{
color:#42D784;
}
}
}
.add-img {
width: 120px;
position: fixed;
bottom: 120px;
right: 32px;
}
.currentLeft-top {
display: flex;
align-items: center;
padding: 32px 32px 0;
.left {
width: 200px;
display: flex;
align-items: center;
img {
width: 48px;
height: 48px;
}
}
}
::v-deep .u-search {
margin-bottom: 0 !important;
}
}
</style>

216
src/apps/AppTvMsg/add.vue Normal file
View File

@@ -0,0 +1,216 @@
<template>
<div class="add">
<div class="item">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">推送分类</span>
<span class="value">
<AiSelect :list="typeList" v-model="form.type" @data="selectType"></AiSelect>
</span>
</div>
</div>
<div class="item mar-b0">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">消息内容</span>
</div>
</div>
<div class="text-area">
<textarea placeholder="请输入" maxlength="200" v-model="form.msgContent"></textarea>
</div>
<div class="item" v-if="form.type == 15">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">时间</span>
<span class="value">
<input type="text" placeholder="请输入" v-model="form.msgTime" maxlength="30">
</span>
</div>
</div>
<div class="item" v-if="form.type == 15">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">地点</span>
<span class="value">
<input type="text" placeholder="请输入" v-model="form.msgPlace" maxlength="100">
</span>
</div>
</div>
<div class="item" v-if="form.type == 15">
<span class="tips">*</span>
<div class="border not-border">
<span class="label">按钮标题</span>
<span class="value">
<input type="text" placeholder="请输入" v-model="form.msgBtnText" maxlength="20">
</span>
</div>
</div>
<div class="add-btn" @click="submit">
<div>提交</div>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'add',
data() {
return {
form: {
type: '10',
msgContent: '',
msgTime: '',
msgPlace: '',
msgBtnText: '',
},
typeList: [{label: '核酸监测通知', value: '15' }, {label: '主动报备提醒', value: '10' }],
isFlag: true
}
},
onShow() {
document.title = '新增推送消息'
},
computed: {
...mapState(['user']),
},
methods: {
rules() {
return {
type: '请选择推送分类',
msgContent: '请输入消息内容',
msgTime: '请选择时间',
msgPlace: '请输入地点',
msgBtnText: '请输入按钮标题',
}
},
selectType(selecteds) {
this.form.type = selecteds?.[0]?.value
},
submit() {
if(this.form.type == 10) {
this.confirm()
return
}
const rules = this.rules()
for (let v of Object.keys(rules)) {
if (!this.form[v]) {
return this.$u.toast(rules[v])
}
}
this.confirm()
},
confirm() {
if(!this.isFlag) {
return
}
if(!this.form.msgContent) {
return this.$u.toast('请输入推送消息')
}
this.isFlag = false
this.$http.post('/app/appiptvjpush/addOrUpdate', this.form).then(res => {
if (res.code === 0) {
this.$u.toast('新增成功')
uni.$emit('getList')
uni.navigateBack({
delta: 1
})
}
}).catch((err) => {
this.$u.toast(err)
})
}
},
}
</script>
<style scoped lang="scss">
.add {
.item{
width: 100%;
padding-left: 14px;
background: #FFF;
box-sizing: border-box;
display: flex;
margin-bottom: 16px;
.tips{
width: 18px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #FF4466;
line-height: 44px;
padding: 34px 0 34px 0;
}
.border{
width: calc(100% - 18px);
padding: 34px 32px 34px 0;
line-height: 44px;
border-bottom: 1px solid #D8DDE6;
line-height: 44px;
font-size: 32px;
font-family: PingFangSC-Regular, PingFang SC;
color: #333;
display: flex;
box-sizing: border-box;
.label{
width: 170px;
}
.value{
width: calc(100% - 170px);
text-align: right;
img{
width: 32px;
height: 32px;
margin-left: 8px;
vertical-align: middle;
}
}
.color-999{
color: #999;
}
}
.not-border{
border-bottom: 0;
}
}
.mar-b0{
margin-bottom: 0;
}
.text-area{
width: 100%;
background-color: #fff;
padding: 0 32px;
margin-bottom: 16px;
box-sizing: border-box;
textarea{
width: 100%;
height: 88px;
padding-bottom: 32px;
}
}
.pad-b152{
width: 100%;
padding-bottom: 152px;
background-color: #f5f5f5;
}
.add-btn{
position: fixed;
bottom: 0;
left: 0;
z-index: 999;
width: 100%;
height: 112px;
line-height: 112px;
background: #3975C6;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
div{
text-align: center;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB