This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,24 @@ export function getAnswer(answerId) { | |
return api.get(url, { validateStatus: s => s === 200 }); | ||
} | ||
|
||
/** | ||
* 添加回答 | ||
* @author mutoe <[email protected]> | ||
* @export | ||
* @param {number} questionId | ||
* @param {Object} data | ||
* @param {string} data.body | ||
* @param {string} [data.text_body] | ||
* @param {number} [data.anonymity] 1: 匿名 0: 不匿名 | ||
* @returns | ||
*/ | ||
export function postAnswer(questionId, data) { | ||
const url = `/questions/${questionId}/answers`; | ||
return api.post(url, data, { | ||
validateStatus: s => s === 201 | ||
}); | ||
} | ||
|
||
/** | ||
* 打赏回答 | ||
* @author mutoe <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as answerApi from "@/api/question/answer"; | ||
import Message from "@/plugins/message"; | ||
|
||
const actions = { | ||
async postAnswer(state, payload) { | ||
const { questionId, content } = payload; | ||
const { data } = await answerApi | ||
.postAnswer(questionId, { | ||
body: content, | ||
text_body: content | ||
}) | ||
.catch(({ response }) => { | ||
const { errors } = response.data; | ||
Message.error(errors); | ||
}); | ||
return data; | ||
} | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
actions | ||
}; |