2020-09-17 20:03:25 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="page">
|
|
|
|
|
<view class="cu-item height">
|
|
|
|
|
<view class="action">
|
|
|
|
|
<text class="text-black">文章名称:</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-item title">
|
|
|
|
|
<textarea placeholder="请输入文章名称"
|
|
|
|
|
v-model="noticeInfo.title"
|
|
|
|
|
maxlength=50
|
|
|
|
|
></textarea>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-item height">
|
|
|
|
|
<view class="action">
|
|
|
|
|
<text class="text-black">文章标签:</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-item label">
|
|
|
|
|
<textarea placeholder="请输入文章标签"
|
|
|
|
|
v-model="noticeInfo.label"
|
|
|
|
|
maxlength=4
|
|
|
|
|
></textarea>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-item">
|
|
|
|
|
<view class="action">
|
|
|
|
|
<text class="text-black">文章内容:</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="cu-item content">
|
|
|
|
|
<textarea placeholder="请输入文章内容"
|
|
|
|
|
v-model="noticeInfo.content"
|
|
|
|
|
auto-height="true"
|
|
|
|
|
maxlength=2000
|
|
|
|
|
></textarea>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="button">
|
|
|
|
|
<button type="default" @tap="preservation">保存</button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import request from '@/util/request.js';
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
let noticeInfo = uni.getStorageSync('notice');
|
|
|
|
|
noticeInfo.fabulous = true;
|
|
|
|
|
noticeInfo.messageFabulous = true;
|
|
|
|
|
return {
|
|
|
|
|
//文章信息
|
|
|
|
|
noticeInfo: noticeInfo,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* @param {Object} e
|
|
|
|
|
*/
|
|
|
|
|
onNavigationBarButtonTap(e) {
|
|
|
|
|
let _this = this;
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '删除',
|
|
|
|
|
content: '确认删除这篇文章?',
|
|
|
|
|
success(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
request.post('/hs/deleteOne',{
|
|
|
|
|
id: _this.noticeInfo.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log("删除这篇文章",res);
|
|
|
|
|
if (res.data === 1) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'loading',
|
|
|
|
|
title: '删除成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack({
|
|
|
|
|
delta: 1
|
|
|
|
|
})
|
|
|
|
|
},1000)
|
|
|
|
|
}
|
|
|
|
|
},err=>{
|
|
|
|
|
console.log("err",err);
|
|
|
|
|
})
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
console.log('用户点击取消');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* 保存
|
|
|
|
|
*/
|
|
|
|
|
preservation() {
|
2020-12-19 12:13:27 +08:00
|
|
|
|
if (this.noticeInfo.title === '') {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请输入文章标题'
|
|
|
|
|
})
|
|
|
|
|
} else if (this.noticeInfo.label.length !== 4) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '文章标签只能4个字符哦'
|
|
|
|
|
})
|
|
|
|
|
} else if (this.noticeInfo.content === '') {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请输入文章内容'
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
request.post('/hs/updateOneContent',{
|
|
|
|
|
id: this.noticeInfo.id,
|
|
|
|
|
label: this.noticeInfo.label,
|
|
|
|
|
title: this.noticeInfo.title,
|
|
|
|
|
content: this.noticeInfo.content,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log("保存文章",res);
|
|
|
|
|
if (res.data === 1) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
icon: 'loading',
|
|
|
|
|
title: '保存成功'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
uni.navigateBack({
|
|
|
|
|
delta: 1
|
|
|
|
|
})
|
|
|
|
|
},1000)
|
|
|
|
|
}
|
|
|
|
|
},err=>{
|
|
|
|
|
console.log("err",err);
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-09-17 20:03:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.button{
|
|
|
|
|
padding: 40rpx 100rpx;
|
|
|
|
|
}
|
|
|
|
|
.cu-item{
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
.title{
|
|
|
|
|
padding-top: 0;
|
|
|
|
|
}
|
2020-09-27 15:39:35 +08:00
|
|
|
|
.title, .label, .content{
|
2020-09-17 20:03:25 +08:00
|
|
|
|
background-color: #F1F1F1;
|
2020-09-27 15:39:35 +08:00
|
|
|
|
border-radius: 10rpx;
|
2020-09-17 20:03:25 +08:00
|
|
|
|
padding: 20rpx;
|
2020-09-27 15:39:35 +08:00
|
|
|
|
margin: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
.title textarea, .label textarea, .content textarea{
|
2020-09-17 20:03:25 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
.title textarea{
|
|
|
|
|
height: 128rpx;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
.label textarea{
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
}
|
2020-09-23 18:53:25 +08:00
|
|
|
|
.page{
|
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
|
}
|
2020-09-17 20:03:25 +08:00
|
|
|
|
</style>
|