Commit 2e0a4d88 by yanju

Merge branch 'xue' into 'master'

Xue

See merge request pigbigbig/beyond-clouds-front!35
parents 7328e4d8 0fff5835
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
:canMove="option.canMove" :canMove="option.canMove"
:canMoveBox="option.canMoveBox" :canMoveBox="option.canMoveBox"
:original="option.original" :original="option.original"
:autoCrop="option.autoCrop" :autoCrop="autoCrop"
:fixed="option.fixed" :fixed="option.fixed"
:fixedNumber="[cropperW, cropperH]" :fixedNumber="[cropperW, cropperH]"
:centerBox="option.centerBox" :centerBox="option.centerBox"
...@@ -83,6 +83,10 @@ ...@@ -83,6 +83,10 @@
type:Number, type:Number,
default: 1, default: 1,
}, },
autoCrop:{
type:Boolean,
default:1,
},
addImg:Function addImg:Function
}, },
computed:{ computed:{
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<span>*</span> <span>*</span>
<select-card selectType="1" @handleTag="handleTagList"></select-card> <select-card selectType="1" @handleTag="handleTagList"></select-card>
</div> </div>
<select-card selectType="2" :class-list="classList" @handleClass="handleQuestionClass" placeholder="请选择问题分类"></select-card> <select-card selectType="2" :class-list="classList.title" @handleClass="handleQuestionClass" placeholder="请选择问题分类"></select-card>
</div> </div>
<div class="choose-container"> <div class="choose-container">
<div class="input-box__wrap"> <div class="input-box__wrap">
...@@ -103,17 +103,18 @@ ...@@ -103,17 +103,18 @@
</div> </div>
<div class="blog-release__footer"> <div class="blog-release__footer">
<p class="footer__left">上传封面 <p class="footer__left">上传封面
<img :src="imgSrc" alt=""> <img :src="this.userCover" alt="">
<input type="file" @change="changeToUploadCover(e)" placeholder="上传项目封面图" accept="image/png,image/gif,image/jpeg" > <input type="file" @change="(e)=>openCropper(e)" placeholder="上传项目封面图" accept="image/png,image/gif,image/jpeg" >
</p> </p>
<div class="footer__right"> <div class="footer__right">
<p>已自动存为草稿</p> <p>已自动存为草稿</p>
<button class="preview" @click="readScreen">预览</button> <button class="preview" @click="readScreen">预览</button>
<button class="submit" v-on:click="postBlog">提交</button> <button class="submit" v-on:click="dataPost">提交</button>
</div> </div>
</div> </div>
</div> </div>
</card-container> </card-container>
<yun-cropper :type="1" :autoCrop="false" :file="addFile" v-on:listenCropperPic="getCroppedPic"></yun-cropper>
</div> </div>
</div> </div>
</template> </template>
...@@ -170,13 +171,17 @@ ...@@ -170,13 +171,17 @@
way: '', way: '',
comment: '', comment: '',
reprint: '', reprint: '',
imgSrc: '',
lastSaveTime: new Date(), lastSaveTime: new Date(),
blogClass: '', blogClass: '',
addFile:{},
userCover:'',
cover:'',
originLink:'', originLink:'',
blogAbstract:'', //blogAbstract:'',
questionClass: '', questionClass: '',
classList: ['web', 'java', 'javascript'] img:"",
//classList: [{id:1,title:"web"}, {id:2,title:"java"},{id:3,title:"javascript"}]
classList:["web","java","javascript"]
} }
}, },
methods: { methods: {
...@@ -185,15 +190,15 @@ ...@@ -185,15 +190,15 @@
}, },
// 获得下拉框得内容 // 获得下拉框得内容
handleBlogClass(value) { handleBlogClass(value) {
this.blogClass = value; this.blogClass = value.tag;
if(value=="web"){ if(value.tag==="web"){
this.blogClass=1 this.blogClass=1;
}else if(value=="java"){ }else if(value.tag==="java"){
this.blogClass=2 this.blogClass=2
}else if(value=="javascript"){ }else if(value.tag==="javascript"){
this.blogClass=3 this.blogClass=3
} }
console.log(this.blogClass); console.log(this.blogClass)
}, },
handleQuestionClass(value) { handleQuestionClass(value) {
this.class = value; this.class = value;
...@@ -204,14 +209,63 @@ ...@@ -204,14 +209,63 @@
console.log(tagList); console.log(tagList);
}, },
postBlog(){
//this.handleTag(); openCropper(e){
this.$axios.$post(config.api.post.Blog.release,{ this.addFile = e.target.files[0];
},
getCroppedPic(pic){
if(pic){
this.userCover = pic;
console.log(this.cover)
//this.dataPostSaveUserInfo(1);
}
},
dataPost() {
this.cover = this.userCover;
if (this.originLink.slice(0, 12) === "https://www." || this.originLink.length === 0) {
if (this.originLink.length === 0) {
this.originLink = "null";
}
if (this.cover === '') {
this.dataPostSaveUserInfo(2)
} else {
this.dataPostSaveUserInfo(1)
}
} else {
this.$message({
message: "请输入开头为https://www.的有效网址",
type: 'warning'
})
}
},
dataPostSaveUserInfo(type){
let userInfo1 = {
allowComment: this.allowComment,//评论权限 allowComment: this.allowComment,//评论权限
allowForward: this.allowForward,//转载权限 allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract, blogAbstract: this.blogAbstract,//摘要
content: this.content, content: this.content,//内容
blogTitle: this.blogTitle, blogTitle: this.blogTitle,//标题
categoryId: this.blogClass,//文章类型
cover: this.cover,//封面图
originLink: this.originLink,
tagIds: [
"Java"//标签id
],
topicIds: [
"Java"//话题id
],
viewPrivileges: this.way //1公开,0私有
};
let userInfo2 = {
allowComment: this.allowComment,//评论权限
allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract,//摘要
content: this.content,//内容
blogTitle: this.blogTitle,//标题
categoryId: this.blogClass,//文章类型 categoryId: this.blogClass,//文章类型
cover: "string",//封面图 cover: "string",//封面图
originLink: this.originLink, originLink: this.originLink,
...@@ -222,23 +276,33 @@ ...@@ -222,23 +276,33 @@
"Java"//话题id "Java"//话题id
], ],
viewPrivileges: this.way //1公开,0私有 viewPrivileges: this.way //1公开,0私有
}).then((response)=>{ };
//处理response this.$axios.$post(config.api.post.Blog.release,type===1?userInfo1:userInfo2).then((response)=>{
if(response.code===0) { if(response.code===0){
let user = {userAvatar:this.userAvatar}
this.$store.commit('userProfile/setUser', user);
this.$message({ this.$message({
type: 'success', message:response.msg,
message: '提交成功!' type:'success'
}); })
}else{ }else{
this.$message({ this.$message({
message:"提交失败 "+response.data.errMsg, message:response.data.errMsg,
type:'error' type:'warning'
}) })
} }
}) })
}, },
imgAdd(pos, file) { imgAdd(pos, file) {
//添加图片,pos为位置 //添加图片,pos为位置
// 第一步.将图片上传到服务器. // 第一步.将图片上传到服务器.
...@@ -257,7 +321,8 @@ ...@@ -257,7 +321,8 @@
* 2. 通过$refs获取: html声明ref : `<mavon-editor ref=md ></mavon-editor>,`$vm`为 `this.$refs.md` * 2. 通过$refs获取: html声明ref : `<mavon-editor ref=md ></mavon-editor>,`$vm`为 `this.$refs.md`
* *
*/ */
$vm.$img2Url(pos, url); //$vm.$img2Url(pos, url);
console.log(url)
}) })
}, },
imgDel(pos, url) { //删除图片,并不是修改就会触发,仅支持工具栏操作 imgDel(pos, url) { //删除图片,并不是修改就会触发,仅支持工具栏操作
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment