mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-11 03:46:47 +08:00
提问题
This commit is contained in:
@@ -9,18 +9,25 @@
|
|||||||
<!-- <view class="bar-center">提问题</view> -->
|
<!-- <view class="bar-center">提问题</view> -->
|
||||||
<view @click="goSubmit()" class="bar-go">提交</view>
|
<view @click="goSubmit()" class="bar-go">提交</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="content">
|
<view class="content" >
|
||||||
<view class="big-box-content">
|
<view class="big-box-content">
|
||||||
<view class="row row-lin">
|
<view class="row row-lin">
|
||||||
<u--input placeholder="请输入标题" placeholder-style="font-size:36upx;color:#c1c1c1;font-weight: normal;" maxlength="30" class="row-input" border="surround" v-model="qa.title" @change="change"></u--input>
|
<u--input placeholder="请输入标题" placeholder-style="font-size:36upx;color:#c1c1c1;font-weight: normal;" maxlength="30" class="row-input" border="surround" v-model="qa.title" @change="change"></u--input>
|
||||||
</view>
|
</view>
|
||||||
<view class="row ">
|
<view class="row" style="min-height: 300upx !important;">
|
||||||
<u--textarea class="row-input row-text" placeholder-style="font-size:42upx;color:#c1c1c1;font-weight: normal;" :height="300" count maxlength="500" v-model="qa.content" placeholder="请输入正文"></u--textarea>
|
<!-- <u--textarea class="row-input row-text" placeholder-style="font-size:42upx;color:#c1c1c1;font-weight: normal;" :height="300" count maxlength="500" v-model="qa.content" placeholder="请输入正文"></u--textarea> -->
|
||||||
|
<editor id="editor" class="editor-content" placeholder="请输入正文"
|
||||||
|
:show-img-size="true"
|
||||||
|
:show-img-toolbar="true"
|
||||||
|
:show-img-resize="true"
|
||||||
|
@statuschange="onStatusChange"
|
||||||
|
@ready="onEditorReady">
|
||||||
|
</editor>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="row">
|
<view v-if="qaimage" class="row">
|
||||||
<u-upload uploadIcon="plus" :fileList="fileList" multiple @afterRead="afterRead" @delete="deletePic" name="coverImg" :maxCount="1">
|
<u-upload uploadIcon="plus" :fileList="fileList" multiple @afterRead="afterRead" @delete="deletePic" name="coverImg" :maxCount="1">
|
||||||
</u-upload>
|
</u-upload>
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -65,6 +72,9 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
qaimage:false,
|
||||||
|
editorCtx: '',
|
||||||
|
formats: {},
|
||||||
fileUrl:this.$config.fileUrl,
|
fileUrl:this.$config.fileUrl,
|
||||||
qa:{
|
qa:{
|
||||||
id:'',
|
id:'',
|
||||||
@@ -76,28 +86,91 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
insertLabel(){
|
||||||
|
let $this=this;
|
||||||
|
this.editorCtx.getContents({
|
||||||
|
success(data) {
|
||||||
|
// 获取编辑器中的文本
|
||||||
|
let _html = data.html;
|
||||||
|
// 去掉文本中默认的标签
|
||||||
|
_html = _html.replace('<p><br></p>','');
|
||||||
|
// 接去掉文本中最后面的</p>标签
|
||||||
|
_html = _html.substring(0,_html.length-4);
|
||||||
|
// 重新拼接文本,并在末尾添加</p>标签
|
||||||
|
let html = `${_html}<span style="color: #3a8afb;"> #标签名#</span><i style="font-style: normal;"> </i></p>`;
|
||||||
|
// 给富文本设置内容
|
||||||
|
$this.editorCtx.setContents({html});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
insertDate() {
|
||||||
|
const date = new Date()
|
||||||
|
const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
|
||||||
|
this.editorCtx.insertText({
|
||||||
|
text: formatDate
|
||||||
|
})
|
||||||
|
},
|
||||||
|
insertImage() {
|
||||||
|
this.qaimage = true
|
||||||
|
},
|
||||||
|
//初始化富文本编辑器
|
||||||
|
onEditorReady() {
|
||||||
|
let $this=this;
|
||||||
|
/** #ifdef APP-PLUS || H5 ||MP-WEIXIN */
|
||||||
|
uni.createSelectorQuery().select('#editor').context((res) => {
|
||||||
|
//将内容写入编辑器
|
||||||
|
$this.editorCtx = res.context;
|
||||||
|
}).exec();
|
||||||
|
/** #endif */
|
||||||
|
},
|
||||||
|
onStatusChange(e){
|
||||||
|
const myFormats = e.detail;
|
||||||
|
this.formats = myFormats;
|
||||||
|
},
|
||||||
|
undo(){
|
||||||
|
this.editorCtx.undo()
|
||||||
|
},
|
||||||
|
redo(){
|
||||||
|
this.editorCtx.redo()
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
this.editorCtx.clear({
|
||||||
|
success: function(res) {
|
||||||
|
console.log("clear success")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
toBack(){
|
toBack(){
|
||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
},
|
},
|
||||||
goSubmit() {
|
goSubmit() {
|
||||||
|
let $this=this;
|
||||||
let images=[];
|
let images=[];
|
||||||
this.fileList.forEach(file=>{
|
this.fileList.forEach(file=>{
|
||||||
images.push(file.path);
|
images.push(file.path);
|
||||||
})
|
})
|
||||||
this.qa.images=images.join();
|
$this.qa.images=images.join();
|
||||||
uni.showLoading({title:'提交中...'})
|
uni.showLoading({title:'提交中...'})
|
||||||
apiQa.save(this.qa).then(rs=>{
|
this.editorCtx.getContents({
|
||||||
if(rs.status==200){
|
success(res){
|
||||||
this.$refs.messager.show({message:'提交成功',type:'success'});
|
$this.qa.content=res.html;
|
||||||
uni.redirectTo({
|
apiQa.save($this.qa).then((rs)=>{
|
||||||
url:'/pages/resource/qaDetail?id='+rs.result.id
|
setTimeout(function(){uni.hideLoading()},1000);
|
||||||
|
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);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}else{
|
|
||||||
this.$refs.messager.show({message:rs.message,type:'error'});
|
|
||||||
setTimeout(function(){uni.hideLoading()},1000);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
change(e) {
|
change(e) {
|
||||||
//console.log('change', e);
|
//console.log('change', e);
|
||||||
@@ -140,6 +213,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
::v-deep .content{
|
||||||
|
height: 750upx !important;
|
||||||
|
}
|
||||||
.editor-btn{
|
.editor-btn{
|
||||||
padding: 0upx 12upx;
|
padding: 0upx 12upx;
|
||||||
color: #656565;
|
color: #656565;
|
||||||
@@ -213,8 +289,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
margin: 18rpx;
|
margin: 18rpx;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
// position: relative;
|
|
||||||
|
|
||||||
.bar-cancel{
|
.bar-cancel{
|
||||||
font-size: 32upx;
|
font-size: 32upx;
|
||||||
color: #7F7F7F;
|
color: #7F7F7F;
|
||||||
@@ -227,8 +301,6 @@
|
|||||||
color: #0D0D0D;
|
color: #0D0D0D;
|
||||||
}
|
}
|
||||||
.bar-go{
|
.bar-go{
|
||||||
// position: absolute;
|
|
||||||
// right: 18rpx;
|
|
||||||
color: #588AFC;
|
color: #588AFC;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
font-family: Source Han Sans CN;
|
font-family: Source Han Sans CN;
|
||||||
|
|||||||
Reference in New Issue
Block a user