| | |
| | | var id = $("#id").val(); |
| | | const App = { |
| | | mixins: [sharedMixin],/////共用的方法///// |
| | | data() { |
| | | return { |
| | | blog_id: id, |
| | | addBlogForm: { |
| | | title: '', |
| | | en_title: '', |
| | |
| | | mounted() { |
| | | }, |
| | | created() { |
| | | window.setHtmlValue = this.setHtmlValue; |
| | | window.getHtmlValue = this.getHtmlValue; |
| | | if (this.blog_id > 0) { |
| | | this.getBlogInfo(); |
| | | } |
| | | }, |
| | | methods: { |
| | | /////获取富文本内容///// |
| | | setHtmlValue(value, type = 1) { |
| | | getHtmlValue(value, type = 1) { |
| | | if (type == 1) { |
| | | this.addBlogForm.content = value; |
| | | } else { |
| | |
| | | } |
| | | }, |
| | | |
| | | /////上传图片成功后///// |
| | | handleCoverImgSuccess(response, uploadFile) { |
| | | if (response.code != 200) { |
| | | this.$message({ |
| | |
| | | return false; |
| | | } |
| | | this.addBlogForm.cover_img = response.data.url; |
| | | // console.log(response,uploadFile); |
| | | // this.addBlogForm.cover_img = arguments[0].url; |
| | | }, |
| | | |
| | | handleRemove(){}, |
| | | |
| | | /////上传图片之前///// |
| | | beforeCoverImgUpload(rawFile) { |
| | | // console.log(rawFile); |
| | | if (rawFile.type !== 'image/jpeg') { |
| | |
| | | } |
| | | return true; |
| | | }, |
| | | |
| | | /////获取博客信息///// |
| | | getBlogInfo() { |
| | | let that = this; |
| | | let url = "/admin/blog/get_blog_info.html"; |
| | | postRequest(url, { id: that.blog_id }).then(res => { |
| | | if (res.data.code == 200) { |
| | | that.addBlogForm = res.data.data; |
| | | setTimeout(function () { |
| | | window.setHtmlValue(res.data.data.content, 1); |
| | | window.setHtmlValue(res.data.data.en_content, 2); |
| | | }) |
| | | } else { |
| | | that.$message({ |
| | | message: res.data.message, |
| | | type: 'error', |
| | | duration: 1500, |
| | | center: true |
| | | }); |
| | | } |
| | | }) |
| | | }, |
| | | /////保存///// |
| | | onSubmit() { |
| | | var that = this; |