我的问答编辑

This commit is contained in:
zhaofang
2022-11-17 15:09:59 +08:00
parent 69b4b90719
commit 8c55c2fde0
3 changed files with 258 additions and 4 deletions

250
pages/plus/editAnser.vue Normal file
View File

@@ -0,0 +1,250 @@
<template>
<!--添加文章-->
<view style="background-color: #fff;">
<u-toast ref="messager"></u-toast>
<!-- <page-title :showBack="true">编辑问题</page-title> -->
<view style="background-color: #fff;padding-top: 18rpx;">
<view class="bar-box">
<view class="bar-cancel" @click="toBack()"><u-icon style="color: #333333;font-weight: 600;" name="arrow-left"></u-icon></view>
<view class="bar-center">编辑回答</view>
<view @click="goSubmit()" class="bar-go">发布</view>
</view>
<view class="content">
<view class="big-box-content">
<view class="row row-lin">
<u--input placeholder="请输入标题" placeholder-style="font-size:42upx;color:#c1c1c1;display:inline-block;white-space: pre-wrap; word-wrap: break-word;height: auto;
" maxlength="30" class="row-input" border="surround" v-model="qa.title" @change="change"></u--input>
</view>
<view class="row ">
<u--textarea class="row-input row-text" placeholder-style="font-size:42upx;color:#666;font-weight: normal;" :height="300" count maxlength="140" v-model="inputValue" placeholder="请输入正文"></u--textarea>
</view>
<!-- <view class="row">
<u-upload uploadIcon="plus" :fileList="fileList" multiple @afterRead="afterRead" @delete="deletePic" name="coverImg" :maxCount="5">
</u-upload>
</view> -->
</view>
</view>
</view>
</view>
</template>
<script>
import apiQa from '@/api/modules/qa.js'
import uploadUtil from '@/utils/upload.js'
import { mapGetters } from 'vuex';
import apiStat from '@/api/phase2/stat.js'
export default {
data() {
return {
fileUrl:this.$config.fileUrl,
inputValue:'',
qa:{
id:'',
title:'',
answercontent:'',
},
fileList: [],
}
},
computed:{
...mapGetters(['userInfo']),
},
methods: {
toBack(){
uni.navigateBack();
},
goSubmit() {
let $this = this;
// let images=[];
// this.fileList.forEach(file=>{
// images.push(file.path);
// })
// this.qa.images=images.join();
// uni.showLoading({title:'提交中...'})
// apiQa.update(this.qa).then(rs=>{
// if(rs.status==200){
// this.$refs.messager.show({message:'提交成功',type:'success'});
// uni.redirectTo({
// url:'/pages/resource/qaDetail?id='+rs.result.id
// })
// }else{
// this.$refs.messager.show({message:rs.message,type:'error'});
// setTimeout(function(){uni.hideLoading()},1000);
// }
// })
let {answerid,content,sysCreateAid,favorites,praises,shares}=this.qa;
apiQa
.updateAnswer({id:answerid,sysCreateAid,content:$this.inputValue})
.then(res => {
if (res.status == 200) {
uni.showToast({
title:'修改成功'
})
// $this.$refs.articleToast.show({message:'修改成功',type:'success'});
// $this.closeInput();
// $this.findAnData(true);
uni.redirectTo({
url:'/pages/resource/qaDetail?id='+this.qa.qid
})
// this.toBack();
} else {
// $this.$refs.articleToast.show({message:'修改失败',type:'error'});
}
})
},
change(e) {
//没有任何处理打印console.log无意义
//console.log('change', e);
},
//删除图片
// deletePic(event) {
// this.fileList.splice(event.index, 1);
// },
//新增图片
// async afterRead(event) {
// //当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
// //console.log(event.file);
// let $this=this;
// event.file.forEach(img=>{
// uploadUtil.uploadFile(img.url).then(rs=>{
// //console.log(rs);
// let item={
// status: 'success',
// message: '已上传',
// path:rs.result.filePath,
// url:rs.result.httpPath
// }
// this.fileList.push(item)
// uni.hideLoading();
// });
// })
// },
reverse() {
uni.navigateBack({
url: '/pages/plus/index'
})
}
},
onLoad(option){
if(option.value){
this.qa=JSON.parse(option.value)
this.inputValue = this.qa.answercontent;
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .uni-textarea-textarea{
color: #666 !important;
}
::v-deep .uni-input-input{
font-size: 36upx !important;
font-weight: 500 !important;
color: #333333 !important;
}
.sub-box{
padding: 20rpx;
.sub-success{
.sub-title{
font-size: 40rpx;
font-weight: 500;
line-height: 45rpx;
margin-bottom: 10rpx;
padding: 20rpx;
}
.sub-text{
font-size: 30rpx;
line-height: 30rpx;
margin-bottom: 20rpx;
padding: 20rpx;
}
.sub-bar{
display: flex;
justify-content: space-between;
padding: 20rpx;
border-bottom: 2rpx solid #ccc;
.bar-time{
font-size: 26rpx;
color: #ccc;
}
}
.bar-reply{
text-align: center;
padding: 30rpx;
.field-icon{
display: block;
width: 40rpx;
margin: 0 auto;
}
}
.bar-cor{
height: 20rpx;
background-color: #ebebeb;
}
.bar-bon{
text-align: center;
min-height: 600rpx;
margin-top: 35rpx;
.bon-icon{
display: inline-block;
}
.bon-text{
display: inline-block;
margin-right: 10rpx;
}
}
}
}
.bar-box{
display: flex;
margin: 18rpx;
justify-content: space-between;
// position: relative;
.bar-cancel{
font-size: 32upx;
color: #7F7F7F;
font-family: Source Han Sans CN;
line-height: 36rpx;
}
.bar-center{
font-size: 36upx;
font-weight: 600;
color: #0D0D0D;
}
.bar-go{
// position: absolute;
// right: 18rpx;
color: #387DF7;
font-size: 32rpx;
font-family: Source Han Sans CN;
font-weight: bold;
line-height: 36rpx;
}
}
.row {
margin-bottom: 10rpx;
.row-input{
border: none;
}
}
.row-lin{
// border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
}
.btn {
padding: 0px;
}
</style>