mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 12:23:06 +08:00
Merge branch 'koogua/v1.4.5' into demo
This commit is contained in:
commit
b1584c2bb4
@ -64,11 +64,16 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="answer-anchor"></div>
|
||||
{% if question.me.answered == 0 and question.published == 2 %}
|
||||
{% if question.me.allow_answer == 1 %}
|
||||
<div class="answer-wrap wrap">
|
||||
<button class="layui-btn layui-btn-fluid btn-answer" data-url="{{ answer_add_url }}">回答问题</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if question.closed == 1 %}
|
||||
<div class="answer-wrap wrap">
|
||||
<button class="layui-btn layui-btn-fluid layui-btn-disabled">问题已关闭</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if answer_id > 0 %}
|
||||
<div class="answer-wrap wrap">
|
||||
<div id="answer-info" data-url="{{ answer_url }}"></div>
|
||||
|
@ -95,18 +95,19 @@ class QuestionInfo extends LogicService
|
||||
protected function handleMeInfo(QuestionModel $question, UserModel $user)
|
||||
{
|
||||
$me = [
|
||||
'allow_answer' => 0,
|
||||
'liked' => 0,
|
||||
'favorited' => 0,
|
||||
'answered' => 0,
|
||||
'owned' => 0,
|
||||
];
|
||||
|
||||
$isOwner = $user->id == $question->owner_id;
|
||||
$approved = $question->published == QuestionModel::PUBLISH_APPROVED;
|
||||
$closed = $question->closed == 1;
|
||||
$solved = $question->solved == 1;
|
||||
|
||||
if ($question->published == QuestionModel::PUBLISH_APPROVED) {
|
||||
if ($user->id == $question->owner_id) {
|
||||
$me['owned'] = 1;
|
||||
} else {
|
||||
$me['owned'] = $isOwner ? 1 : 0;
|
||||
}
|
||||
|
||||
if ($user->id > 0) {
|
||||
@ -134,6 +135,12 @@ class QuestionInfo extends LogicService
|
||||
if ($userAnswers->count() > 0) {
|
||||
$me['answered'] = 1;
|
||||
}
|
||||
|
||||
$answered = $me['answered'] == 1;
|
||||
|
||||
if ($approved && !$closed && !$solved && !$answered) {
|
||||
$me['allow_answer'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $me;
|
||||
|
Loading…
x
Reference in New Issue
Block a user