This commit is contained in:
xiaofajia 2024-12-19 14:50:59 +08:00
parent 78106a56db
commit fbde96d076
4 changed files with 456 additions and 404 deletions

View File

@ -58,4 +58,4 @@ export function createApp() {
app
}
}
// #endif
// #endif

View File

@ -1,424 +1,463 @@
<!-- 发起订单 -->
<template>
<view class="content">
<view class="c-top">
<view class="" @click="getback()">
<uni-icons type="left" size="18"></uni-icons>
</view>
<view class="c-title">发布</view>
<view class=""></view>
</view>
<view class="dil">
<view class="content">
<view class="c-top">
<view class="" @click="getback()">
<uni-icons type="left" size="18"></uni-icons>
</view>
<view class="c-title">发布</view>
<view class=""></view>
</view>
<view class="dil">
<!-- 填空 -->
<view class="tinput">
<view class="text1"> <text class="hong1">*</text> 标题</view>
<view class="you">
<input type="text" placeholder="请输入标题" v-model="newsTitle">
</view>
</view>
<!-- 填空 -->
<!-- <view class="tinput">
<view class="text1"> <text class="hong1">*</text> 发布单位</view>
<view class="you">
<input type="text" placeholder="请发布单位 "v-model="publishUnit" >
</view>
</view> -->
<view class="tinput">
<view class="text1"> <text class="hong1">*</text> 封面图</view>
<view class="you">
<text>请上传封面图片</text>
<!-- <input type="text" placeholder="请上传封面图片"> -->
</view>
</view>
<!-- 上传图片 -->
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
multiple
:previewFullImage="true"
:maxCount="1"
></u-upload>
<view class="xinput">
<Rboy-editor ref="RboyEditor" @uploadFile="uploadFile" :count="6"></Rboy-editor>
</view>
<!-- 填空 -->
<view class="tinput">
<view class="text1">
<text class="hong1">*</text>
标题
</view>
<view class="you">
<input type="text" placeholder="请输入标题" v-model="newsTitle">
</view>
</view>
<!-- 填空 -->
<!-- <view class="tinput">
<view class="text1"> <text class="hong1">*</text> 发布单位</view>
<view class="you">
<input type="text" placeholder="请发布单位 "v-model="publishUnit" >
</view>
</view> -->
<view class="tinput">
<view class="text1">
<text class="hong1">*</text>
封面图
</view>
<view class="you">
<text>请上传封面图片</text>
<!-- <input type="text" placeholder="请上传封面图片"> -->
</view>
</view>
<!-- 上传图片 -->
<u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
multiple
:previewFullImage="true"
:maxCount="1"
></u-upload>
<view v-if="type === 'null'" class="tinput" style="display: flex;justify-content: space-between">
<text class="text1">设置可见</text>
<view>
<radio :checked="!ifShow" @click="changeShow(null)">全部可见</radio>
<radio :checked="ifShow === '01'" style="margin-left: 0.5rem" @click="changeShow('01')">员工可见</radio>
<radio :checked="ifShow === '02'" style="margin-left: 0.5rem" @click="changeShow('02')">用户可见</radio>
</view>
</view>
<view class="xinput">
<Rboy-editor ref="RboyEditor" @uploadFile="uploadFile" :count="6"></Rboy-editor>
</view>
<view class="xinput" v-if="type == 'hygg'">
<view class="text1"> <text class="hong1">*</text> 分类</view>
<view class="xz">
<view :class="{'xlan':maneizhi == index}" class="kuang" v-for="(item,index) in taplist" :key="index" @click="getzhi2(index,item.value)">
<view class="">{{item.label}}</view>
</view>
</view>
</view>
<view class="xinput" v-if="type == 'hygg'">
<view class="text1">
<text class="hong1">*</text>
分类
</view>
<view class="xz">
<view :class="{'xlan':maneizhi == index}" class="kuang" v-for="(item,index) in taplist" :key="index"
@click="getzhi2(index,item.value)">
<view class="">{{ item.label }}</view>
</view>
</view>
</view>
<view class="tinput">
<view class="text1"> 上传视频</view>
<view class="you">
<text>请上传视频</text>
<!-- <input type="text" placeholder="请上传视频"> -->
</view>
</view>
<!-- 上传视频 -->
<u-upload
:fileList="fileList2"
@afterRead="afterRead1"
@delete="deletePic1"
name="2"
multiple
:maxCount="1"
accept="video"
:previewFullImage="true"
></u-upload>
<view class="anniu" @click="getnewsadd()">
<text>发布文章</text>
</view>
<view style="width: 100%; height: 60px;"></view>
</view>
<view class="tinput">
<view class="text1"> 上传视频</view>
<view class="you">
<text>请上传视频</text>
<!-- <input type="text" placeholder="请上传视频"> -->
</view>
</view>
<!-- 上传视频 -->
<u-upload
:fileList="fileList2"
@afterRead="afterRead1"
@delete="deletePic1"
name="2"
multiple
:maxCount="1"
accept="video"
:previewFullImage="true"
></u-upload>
<view class="anniu" @click="getnewsadd()">
<text>发布文章</text>
</view>
<view style="width: 100%; height: 60px;"></view>
</view>
</view>
</view>
</template>
<script>
import RboyEditor from "@/components/Rboy-editor/Rboy-editor"
import request from '../../utils/request'
import config from '@/config'
import upload from '@/utils/upload.js'
export default{
data(){
return{
baseUrl:this.$baseUrl,
fileList1: [],
fileList2: [],
newsCover:'',
videoUrl:'',
newsTitle:'',
publishUnit:'',
newsContent:'',
value:'',
type:'hmzc',
id:1,
carzhi:0,
maneizhi:0,
taplist:[],
import RboyEditor from "@/components/Rboy-editor/Rboy-editor"
import request from '../../utils/request'
import config from '@/config'
import upload from '@/utils/upload.js'
}
},
onLoad(option) {
this.id = option.id
this.type = option.type
},
mounted() {
this.gettap()
},
components:{
RboyEditor,
},
methods:{
async set_content() {
this.$refs.RboyEditor.editor_setContents(this.detail)
},
//
async get_content() {
this.newsContent = await this.$refs.RboyEditor.editor_getcontents()
},
//
async uploadFile(event) {
let that = this
// event
for (var item in event.tempFilePaths) {
// uploadFileApi count1 使 await
upload({
url:'/common/upload',
filePath: event.tempFilePaths[item],
}).then((res)=>{
that.$refs.RboyEditor.editor_insertImage({
src: this.baseUrl + res.fileName,
alt: "图像",
})
})
}
},
async gettap(){
//
let ress = await request({
url: '/appInspection/news/editType',
method: 'get',
})
this.taplist = ress.data
this.value = ress.data[0].value
},
export default {
data() {
return {
baseUrl: this.$baseUrl,
fileList1: [],
fileList2: [],
newsCover: '',
videoUrl: '',
newsTitle: '',
publishUnit: '',
newsContent: '',
value: '',
type: 'hmzc',
id: 1,
carzhi: 0,
maneizhi: 0,
taplist: [],
ifShow: null,
}
},
onLoad(option) {
this.id = option.id
this.type = option.type
},
mounted() {
this.gettap()
},
components: {
RboyEditor,
},
methods: {
changeShow(value) {
this.ifShow = value
},
async set_content() {
this.$refs.RboyEditor.editor_setContents(this.detail)
},
//
async get_content() {
this.newsContent = await this.$refs.RboyEditor.editor_getcontents()
},
//
async uploadFile(event) {
let that = this
// event
for (var item in event.tempFilePaths) {
// uploadFileApi count1 使 await
upload({
url: '/common/upload',
filePath: event.tempFilePaths[item],
}).then((res) => {
that.$refs.RboyEditor.editor_insertImage({
src: this.baseUrl + res.fileName,
alt: "图像",
})
})
}
},
async gettap() {
//
let ress = await request({
url: '/appInspection/news/editType',
method: 'get',
})
this.taplist = ress.data
this.value = ress.data[0].value
},
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
upload({
url:'/common/upload',
filePath: url,
}).then((res)=>{
this.newsCover = res.fileName
})
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
upload({
url: '/common/upload',
filePath: url,
}).then((res) => {
this.newsCover = res.data.url
})
},
deletePic1(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead1(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
},
deletePic1(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead1(event) {
// multiple true , file
let lists = [].concat(event.file)
let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise1(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise1(url) {
upload({
url:'/common/upload',
filePath: url,
}).then((res)=>{
this.videoUrl = res.fileName
})
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise1(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise1(url) {
upload({
url: '/common/upload',
filePath: url,
}).then((res) => {
this.videoUrl = res.fileName
})
},
//
async getnewsadd(){
this.newsContent = await this.$refs.RboyEditor.editor_getcontents()
if(this.newsTitle==''||this.newsCover==''||this.newsContent==''){
uni.showToast({
title:'必填项不能有空!',
icon:'none'
})
return
}
let data={
newsTitle:this.newsTitle,
newsCover:this.newsCover,
},
//
async getnewsadd() {
this.newsContent = await this.$refs.RboyEditor.editor_getcontents()
if (this.newsTitle == '' || this.newsCover == '' || this.newsContent == '') {
uni.showToast({
title: '必填项不能有空!',
icon: 'none'
})
return
}
let data = {
newsTitle: this.newsTitle,
newsCover: this.newsCover,
newsContent: this.newsContent,
videoUrl: this.videoUrl,
category: this.value,
type: this.type,
ifShow: this.ifShow
}
let res = await request({
url: '/appInspection/news/add',
method: 'post',
data: data
})
if (res.code == 200) {
uni.showToast({
title: '发布成功,三秒后返回'
})
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 3000);
}
},
newsContent:this.newsContent,
videoUrl:this.videoUrl,
category:this.value,
type:this.type,
}
let res = await request({
url: '/appInspection/news/add',
method: 'post',
data:data
})
if(res.code == 200){
uni.showToast({
title:'发布成功,三秒后返回'
})
setTimeout(() => {
uni.navigateBack({
delta: 1
});
}, 3000);
}
},
getback() {
uni.navigateBack({
delta: 1,
})
},
getzhi(index) {
this.carzhi = index
},
getzhi2(index, value) {
this.value = value
this.maneizhi = index
},
getback(){
uni.navigateBack({
delta:1,
})
},
getzhi(index){
this.carzhi = index
},
getzhi2(index,value){
this.value =value
this.maneizhi = index
},
}
}
}
}
</script>
<style scoped lang="scss">
.content{
width: 100%;
height: calc(100vh);
background-color: #F6F6F6;
box-sizing: border-box;
// padding-top: 45px;
}
.content {
width: 100%;
height: calc(100vh);
background-color: #F6F6F6;
box-sizing: border-box;
// padding-top: 45px;
}
.dil{
box-sizing: border-box;
background-color: #F6F6F6;
padding: 0px 12px;
.dil {
box-sizing: border-box;
background-color: #F6F6F6;
padding: 0px 12px;
}
.top-icon{
margin-bottom: 45px;
}
.c-top{
width: 100%;
box-sizing: border-box;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
background-color: white;
padding-top: 40px;
}
.c-title{
font-size: 18px;
font-weight: bold
}
.top{
box-sizing: border-box;
padding: 0px 15px;
width: 100%;
background-color: white;
}
.top-box{
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 20px 0px;
}
.tb-left{
height: 100%;
width: 80%;
display: flex;
align-items: center;
}
.uicon{
width: 18px;
height: 18px;
border-radius: 4px;
color: white;
background: orangered;
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
font-weight: bold;
margin-right: 6px;
}
.tb-right{
width: 20px;
height: 26px;
image{
width: 100%;
height: 100%;
}
}
.text1{
font-size: 16px;
font-weight: bold;
color: #363636;
}
.hong1{
margin-top: 5px;
font-size: 12px;
font-weight: 400;
color: #FF5453;
}
.hong2{
margin-top: 5px;
font-size: 12px;
font-weight: 400;
}
}
.tinput{
width: 100%;
display: flex;
background: white;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 16px;
margin-top: 14px;
margin-bottom: 14px;
}
.xinput{
width: 100%;
background: white;
box-sizing: border-box;
padding: 16px;
margin-top: 14px;
}
.you{
text-align: right;
}
.xz{
margin-top: 10px;
display: flex;
align-items: center;
}
.kuang{
width: 80px;
height: 23px;
background: #ECECEC;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
color: #666666;
font-size: 14px;
margin-right: 15px;
}
.xlan{
background: #CDE7FF !important;
color: #1D62FF !important;
border: 1px solid #2A96FE;
}
.anniu{
width: 100%;
background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%);
border-radius: 50px ;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
color: #542F0E;
margin-top: 20px;
color: white;
}
.top-icon {
margin-bottom: 45px;
}
.c-top {
width: 100%;
box-sizing: border-box;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
background-color: white;
padding-top: 40px;
}
.c-title {
font-size: 18px;
font-weight: bold
}
.top {
box-sizing: border-box;
padding: 0px 15px;
width: 100%;
background-color: white;
}
.top-box {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 20px 0px;
}
.tb-left {
height: 100%;
width: 80%;
display: flex;
align-items: center;
}
.uicon {
width: 18px;
height: 18px;
border-radius: 4px;
color: white;
background: orangered;
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
font-weight: bold;
margin-right: 6px;
}
.tb-right {
width: 20px;
height: 26px;
image {
width: 100%;
height: 100%;
}
}
.text1 {
font-size: 16px;
font-weight: bold;
color: #363636;
}
.hong1 {
margin-top: 5px;
font-size: 12px;
font-weight: 400;
color: #FF5453;
}
.hong2 {
margin-top: 5px;
font-size: 12px;
font-weight: 400;
}
.tinput {
width: 100%;
display: flex;
background: white;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 16px;
margin-top: 14px;
margin-bottom: 14px;
}
.xinput {
width: 100%;
background: white;
box-sizing: border-box;
padding: 16px;
margin-top: 14px;
}
.you {
text-align: right;
}
.xz {
margin-top: 10px;
display: flex;
align-items: center;
}
.kuang {
width: 80px;
height: 23px;
background: #ECECEC;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
color: #666666;
font-size: 14px;
margin-right: 15px;
}
.xlan {
background: #CDE7FF !important;
color: #1D62FF !important;
border: 1px solid #2A96FE;
}
.anniu {
width: 100%;
background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%);
border-radius: 50px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
color: #542F0E;
margin-top: 20px;
color: white;
}
</style>

View File

@ -10,9 +10,8 @@
<!-- html -->
<view class="c-content" v-if="flag">
<view class="cont-gongs">{{ obj.publishUnit }}</view>
<u-parse :content="obj.newsContent" :tagStyle="style"></u-parse>
<view class="videobox" v-if="videoList != null ">
<view class="videobox" v-if="videoList != null && videoList !== ''">
<video :src="baseUrl+ videoList" controls></video>
</view>
<view class="cont-time">{{ getDate(createTime) || new Date() }}</view>

View File

@ -27,7 +27,7 @@
<view v-if="tapindex === 0">
<view class="c-b-top">
<view class="t-left">
<image :src="baseImageUrl+item.newsCover" mode="aspectFill"></image>
<image :src="baseImageUrl+getUrl(item.newsCover)" mode="aspectFill"></image>
</view>
<view class="t-right">
<view class="t-tilte">{{ item.newsTitle }}</view>
@ -59,7 +59,7 @@
</view>
</view>
<view class="circle-notification" v-if="ifSend">
<view class="circle-notification" v-if="ifSend" @click="toAdd">
+
</view>
@ -154,6 +154,21 @@ export default {
tabBar,
},
methods: {
getUrl(value){
if (!value){
return ""
}
if (value[0] === '/'){
return value
}else {
return "/" + value
}
},
toAdd(){
uni.navigateTo({
url: '/pages/authority/newadd?type=' + null
})
},
getIfSend() {
request({
url: '/system/inspectionNews/ifSend',
@ -231,7 +246,6 @@ export default {
}
let total = res.total
this.totalPages = Math.ceil(total / this.pageSize);
},