188 lines
4.4 KiB
Vue
188 lines
4.4 KiB
Vue
<template>
|
|
<view class="page">
|
|
<u-navbar title="公告协议" :border-bottom="false" :background="bgc" back-icon-color="#262B37" title-color='#262B37'
|
|
title-size='36' height='36' id="navbar">
|
|
</u-navbar>
|
|
<view class="form">
|
|
<view class="form-item">
|
|
<text class="label">标题</text>
|
|
<input class="input" v-model="obj.title" placeholder="请输入标题" placeholder-class="ph" />
|
|
</view>
|
|
<view class="form-item">
|
|
<text class="label">展示秒数</text>
|
|
<view class="input-with-unit">
|
|
<input class="input" type="number" v-model.number="obj.duration" placeholder="请输入展示秒数" placeholder-class="ph" />
|
|
<text class="unit">秒</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="richtext">
|
|
<piaoyiEditor :values="values" :maxlength="3000" @changes="saveContens" :readOnly="readOnly" :photoUrl="photoUrl" :token="token" :api="api" :name="name"/>
|
|
<!-- <view class="">
|
|
{{txt}}
|
|
</view> -->
|
|
</view>
|
|
<button class="bc" @click="btnbc">保存</button>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import piaoyiEditor from '@/uni_modules/piaoyi-editor/components/piaoyi-editor/piaoyi-editor.vue';
|
|
export default {
|
|
data() {
|
|
return {
|
|
readOnly: false, //是否只读
|
|
photoUrl: 'https://up-z2.qiniup.com', //服务器图片域名或者ip
|
|
api: '', //上传图片接口地址
|
|
txt: '',
|
|
name: 'file',
|
|
values: '',
|
|
bgc: {
|
|
backgroundColor: "#FFFFFF",
|
|
},
|
|
areaId:'',
|
|
token:'',
|
|
obj:{},
|
|
id:''
|
|
};
|
|
},
|
|
components: {
|
|
piaoyiEditor
|
|
},
|
|
onLoad(option) {
|
|
this.id = option.id
|
|
this.getqiniuyun()
|
|
this.getxieyi()
|
|
},
|
|
methods: {
|
|
saveContens(e) {
|
|
this.txt = e.html
|
|
},
|
|
// 获取公告协议
|
|
getxieyi(){
|
|
this.$u.get(`/bst/agreement/${this.id}`).then((res) => {
|
|
if (res.code == 200) {
|
|
this.values = res.data.content
|
|
this.obj = res.data
|
|
}
|
|
})
|
|
},
|
|
// 获取七牛云上传token
|
|
getqiniuyun(){
|
|
this.$u.get("/common/qiniuToken").then((res) => {
|
|
if (res.code == 200) {
|
|
this.token = res.data
|
|
}
|
|
})
|
|
},
|
|
// 点击保存
|
|
btnbc(){
|
|
let data = {
|
|
id:this.id,
|
|
title:this.obj.title,
|
|
duration:Number(this.obj.duration) || 0,
|
|
content:this.txt || this.values
|
|
}
|
|
this.$u.put(`/bst/agreement`,data).then((res) => {
|
|
if (res.code == 200) {
|
|
uni.showToast({
|
|
title: '保存成功',
|
|
icon: 'success',
|
|
duration:3000
|
|
})
|
|
setTimeout(()=>{
|
|
uni.navigateBack()
|
|
},1500)
|
|
}else{
|
|
uni.showToast({
|
|
title: res.msg,
|
|
icon: 'none',
|
|
duration:3000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
},
|
|
onShareAppMessage(res) {
|
|
if (res.from === 'button') { // 来自页面内分享按钮
|
|
console.log(res.target)
|
|
}
|
|
return {
|
|
title: '多功能富文本编辑器!',
|
|
path: '/pages/editor/editor'
|
|
}
|
|
},
|
|
onShareTimeline(res) {
|
|
if (res.from === 'button') { // 来自页面内分享按钮
|
|
console.log(res.target)
|
|
}
|
|
return {
|
|
title: '多功能富文本编辑器!'
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page {
|
|
background-color: #fff;
|
|
}
|
|
/deep/ .editor{
|
|
height: 43vh;
|
|
overflow: scroll;
|
|
}
|
|
.form{
|
|
padding: 24rpx 32rpx 0;
|
|
}
|
|
.form-item{
|
|
margin-bottom: 28rpx;
|
|
}
|
|
.label{
|
|
display: inline-block;
|
|
font-size: 28rpx;
|
|
color: #222;
|
|
margin-bottom: 12rpx;
|
|
}
|
|
.input{
|
|
width: 84%;
|
|
height: 88rpx;
|
|
padding: 0 24rpx;
|
|
border-radius: 16rpx;
|
|
background: #ffffff;
|
|
border: 2rpx solid #ececec;
|
|
color: #222;
|
|
font-size: 28rpx;
|
|
}
|
|
.input:focus{
|
|
border-color: #ff5fa2;
|
|
box-shadow: 0 0 0 4rpx rgba(255,95,162,0.1);
|
|
}
|
|
.ph{
|
|
color: #9a9a9a;
|
|
}
|
|
.input-with-unit{
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12rpx;
|
|
}
|
|
.unit{
|
|
color: #ff5fa2; /* 粉色点缀 */
|
|
font-size: 28rpx;
|
|
padding: 0 8rpx;
|
|
}
|
|
.bc{
|
|
width: 680rpx;
|
|
position: fixed;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
bottom: 50rpx;
|
|
height: 90rpx;
|
|
line-height: 90rpx;
|
|
background-color: #4297F3;
|
|
color: #fff;
|
|
text-align: center;
|
|
line-height: 90rpx;
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
}
|
|
</style> |