Commit 5dabf285 by yanju

Merge branch 'master' of coding.yundingshuyuan.com:pigbigbig/beyond-clouds-front

parents 3872a944 0ba564f5
...@@ -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:{
......
<template> <template>
<div> <div>
<div class="select-container" v-if="selectType === '1'" style="height: 100px;"> <div class="select-container" v-if="selectType === '1'" style="min-height: 100px;width: 354px;">
<div class="select-container__input-box"> <div class="select-container__input-box">
<div> <div>
<!--@focus="handleShow"--> <!--@focus="handleShow"-->
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
@blur="isShow=false" @blur="isShow=false"
@keyup.enter="handleSearch" @keyup.enter="handleSearch"
v-model="value.tag" v-model="value.tag"
ref="tag"
> >
<span>{{list.length ? list.length : 0}}</span>
<transition name="fade"> <transition name="fade">
<div class="label-list__wrap" v-if="isShow || isShow2" @mouseleave="isShow2=false"> <div class="label-list__wrap" v-if="isShow || isShow2" @mouseleave="isShow2=false">
<div class="label-list"> <div class="label-list">
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
></label-wrap> ></label-wrap>
</div> </div>
</div> </div>
<div class="select-container" v-if="selectType === '2'" style="width: 196px"> <div class="select-container" v-if="selectType === '2'" style="width: 196px" @mouseleave="isShow=false">
<div class="input-box" @click="handleShow"> <div class="input-box" @click="handleShow">
<input type="text" v-model="value.tag" disabled="true" :placeholder="placeholder"> <input type="text" v-model="value.tag" :placeholder="placeholder" ref="select">
<div class="icon-box"> <div class="icon-box">
<yun-icon name="down_arrow" size="10px" color="#999"></yun-icon> <yun-icon name="down_arrow" size="10px" color="#999"></yun-icon>
</div> </div>
...@@ -82,7 +82,6 @@ export default { ...@@ -82,7 +82,6 @@ export default {
tag: 'web' tag: 'web'
}], }],
searchList: [], searchList: [],
arr: [],
result: [], result: [],
value: { value: {
tagId: '', tagId: '',
...@@ -124,6 +123,7 @@ export default { ...@@ -124,6 +123,7 @@ export default {
// 删除选中的标签 // 删除选中的标签
handleDelete(index){ handleDelete(index){
this.result.splice(index, 1); this.result.splice(index, 1);
this.$emit('handleTag', this.result);
}, },
// 回车后,进行搜索 // 回车后,进行搜索
async handleSearch(){ async handleSearch(){
...@@ -154,9 +154,9 @@ export default { ...@@ -154,9 +154,9 @@ export default {
}, },
// 点击 标签 自动选择 // 点击 标签 自动选择
handleTags(){ handleTags(){
this.arr.push(this.value); this.result.push(this.value);
let map = new Map(); let map = new Map();
for (let item of this.arr) { for (let item of this.result) {
console.log(item); console.log(item);
if (!map.has(item.tag)) { if (!map.has(item.tag)) {
map.set(item.tag, item) map.set(item.tag, item)
...@@ -182,8 +182,13 @@ export default { ...@@ -182,8 +182,13 @@ export default {
tagName: value, tagName: value,
tagType: 0 tagType: 0
}).then(res => { }).then(res => {
console.log(res);
if (res.code === 0) { if (res.code === 0) {
let obj = {
tagId: res.data.tagId,
tag: res.data.tagName
};
this.result.push(obj);
this.$popupbox.close();
this.$message({ this.$message({
type: 'success', type: 'success',
message: '标签创建成功' message: '标签创建成功'
...@@ -221,13 +226,6 @@ export default { ...@@ -221,13 +226,6 @@ export default {
background-color: #F4F8FA; background-color: #F4F8FA;
@include border-radius(4*$length); @include border-radius(4*$length);
} }
> span {
position: absolute;
right: 16*$length;
top: 14*$length;
@extend %cursorPointer;
@include fontStyle(14,19,500,#666,left);
}
.label-list{ .label-list{
position: absolute; position: absolute;
top:56*$length; top:56*$length;
......
...@@ -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,//评论权限
allowForward: this.allowForward,//转载权限
blogAbstract: this.blogAbstract,//摘要
content: this.content,//内容
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,//评论权限 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,//文章类型 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