mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-06 17:36:45 +08:00
255 lines
5.6 KiB
Vue
255 lines
5.6 KiB
Vue
<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()">取消</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:36upx;color:#c1c1c1;font-weight: normal;" 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:#c1c1c1;font-weight: normal;" :height="300" count maxlength="500" v-model="qa.content" placeholder="请输入正文"></u--textarea>
|
|
</view>
|
|
<!-- <view class="row">
|
|
<u-upload uploadIcon="plus" :fileList="fileList" multiple @afterRead="afterRead" @delete="deletePic" name="coverImg" :maxCount="1">
|
|
</u-upload>
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view>
|
|
<view style="display: flex;justify-content:space-around;">
|
|
|
|
<view class="Articleicon">
|
|
<text class="editor-btn" @tap="insertImage()">
|
|
<image src="../../static/images/article/image.png" mode=""></image>
|
|
</text>
|
|
</view>
|
|
|
|
<view class="Articleicon">
|
|
<text class="editor-btn" @tap="undo()">
|
|
<image src="../../static/images/icon/artleft.png" mode=""></image>
|
|
</text>
|
|
</view>
|
|
<view class="Articleicon">
|
|
<text class="editor-btn" @tap="redo()">
|
|
<image src="../../static/images/icon/artright.png" mode=""></image>
|
|
</text>
|
|
</view>
|
|
<view class="Articleicon">
|
|
<text class="editor-btn" @tap="clear()">
|
|
<image src="../../static/images/icon/del.png" mode=""></image>
|
|
</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- <view style="margin-top: 20px;">
|
|
<view>
|
|
<u-button type="primary" text="提交问题"></u-button>
|
|
</view>
|
|
</view> -->
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import apiQa from '@/api/modules/qa.js'
|
|
import uploadUtil from '@/utils/upload.js'
|
|
export default {
|
|
data() {
|
|
return {
|
|
fileUrl:this.$config.fileUrl,
|
|
qa:{
|
|
id:'',
|
|
title:'',
|
|
content:'',
|
|
images:''
|
|
},
|
|
fileList: [],
|
|
}
|
|
},
|
|
methods: {
|
|
toBack(){
|
|
uni.navigateBack();
|
|
},
|
|
goSubmit() {
|
|
|
|
let images=[];
|
|
this.fileList.forEach(file=>{
|
|
images.push(file.path);
|
|
})
|
|
this.qa.images=images.join();
|
|
uni.showLoading({title:'提交中...'})
|
|
apiQa.save(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);
|
|
}
|
|
})
|
|
},
|
|
change(e) {
|
|
//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'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.editor-btn{
|
|
padding: 0upx 12upx;
|
|
color: #656565;
|
|
border-radius: 6upx;
|
|
image{
|
|
width: 35upx;
|
|
height: 35upx;
|
|
}
|
|
}
|
|
.Articleicon{
|
|
height: 120upx;
|
|
line-height: 120upx;
|
|
background-color: #fff;
|
|
}
|
|
.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: #588AFC;
|
|
font-size: 30rpx;
|
|
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>
|