Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix: 发布资讯接口地址变更
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jun 28, 2018
1 parent 730da50 commit 7e5ecb4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
22 changes: 22 additions & 0 deletions src/api/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ export function getMyNews({ type = 0, limit = 15, after = 0 }) {
});
}

/**
* 新增投稿
* @author mutoe <[email protected]>
* @export
* @param {Number} categoryId
* @param {Object} params
* @param {String} params.title 标题
* @param {String} params.content 内容
* @param {Number|Number[]} params.tags 标签id或其数组
* @param {String=} params.subject 概要
* @param {Number=} params.image 缩略图
* @param {String=} params.from 资讯来源
* @param {String=} params.author 作者
* @param {String=} params.text_content 纯文本
* @returns {Promise}
*/
export function postNews(categoryId, params) {
return api.post(`/news/categories/${categoryId}/currency-news`, params, {
validateStatus: s => s === 201
});
}

/**
* 搜索资讯
* @author jsonleex <[email protected]>
Expand Down
21 changes: 9 additions & 12 deletions src/page/post/PostNews.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,14 @@
<choose-cate />
</div>
</template>

<script>
import bus from "@/bus.js";
import { mapState } from "vuex";
import sendImage from "@/util/SendImage.js";
import chooseCate from "@/page/chooseCate.vue";
import sendImage from "@/util/SendImage.js";
import { postNews } from "@/api/news.js";
export default {
name: "post-news",
components: {
Expand Down Expand Up @@ -296,17 +299,10 @@ export default {
this.news.author && (param.author = this.news.author);
this.news.subject && (param.subject = this.news.subject);
// POST /news/categories/:category/news
this.$http
.post(`/news/categories/${this.category.id}/news`, param)
.then(({ data }) => {
this.$Message.success(data);
this.goBack();
})
.catch(err => {
console.log(err);
this.$Message.error("发生了一些错误");
});
postNews(this.category.id, param).then(({ data }) => {
this.$Message.success(data);
this.goBack();
});
},
handleOk() {
const { title, content } = this.news;
Expand Down Expand Up @@ -365,6 +361,7 @@ export default {
}
};
</script>

<style lang="less">
.p-post-news {
min-height: 100vh;
Expand Down

0 comments on commit 7e5ecb4

Please sign in to comment.