问答系统页面优化

This commit is contained in:
devil_gong 2019-03-11 10:58:09 +08:00
parent c1fcc7bf7b
commit b51785b0ad
8 changed files with 85 additions and 23 deletions

View File

@ -79,9 +79,11 @@
<tr> <tr>
<th>姓名</th> <th>姓名</th>
<th>电话</th> <th>电话</th>
<th>内容</th> <th>标题</th>
<th class="am-hide-sm-only">内容</th>
<th class="am-hide-sm-only">回复</th> <th class="am-hide-sm-only">回复</th>
<th class="am-hide-sm-only">是否显示</th> <th class="am-hide-sm-only">是否显示</th>
<th class="am-hide-sm-only">回复时间</th>
<th class="am-hide-sm-only">时间</th> <th class="am-hide-sm-only">时间</th>
</tr> </tr>
</thead> </thead>
@ -91,7 +93,8 @@
<tr> <tr>
<td>{{$v.name}}</td> <td>{{$v.name}}</td>
<td>{{$v.tel}}</td> <td>{{$v.tel}}</td>
<td class="reply-content">{{$v.content}}</td> <td>{{$v.title}}</td>
<td class="am-hide-sm-only reply-content">{{$v.content}}</td>
<td class="am-hide-sm-only reply-content"> <td class="am-hide-sm-only reply-content">
{{if $v['is_reply'] eq 1}} {{if $v['is_reply'] eq 1}}
{{$v.reply}} {{$v.reply}}
@ -100,6 +103,7 @@
{{/if}} {{/if}}
</td> </td>
<td class="am-hide-sm-only">{{$v.is_show_text}}</td> <td class="am-hide-sm-only">{{$v.is_show_text}}</td>
<td class="am-hide-sm-only">{{$v.reply_time}}</td>
<td class="am-hide-sm-only">{{$v.add_time}}</td> <td class="am-hide-sm-only">{{$v.add_time}}</td>
</tr> </tr>
{{/foreach}} {{/foreach}}

View File

@ -338,7 +338,7 @@ class Service
} }
// 字段 // 字段
$field = empty($params['field']) ? 'id,name,content,reply,is_reply,add_time' : $params['field']; $field = empty($params['field']) ? 'id,name,title,content,reply,is_reply,reply_time,add_time' : $params['field'];
// 获取列表 // 获取列表
$data_params = array( $data_params = array(
@ -373,7 +373,7 @@ class Service
]; ];
// 字段 // 字段
$field = 'content,reply,is_reply,add_time'; $field = 'title,content,reply,is_reply,reply_time,add_time';
// 获取列表 // 获取列表
$data_params = array( $data_params = array(

View File

@ -15,20 +15,24 @@
<!-- content start --> <!-- content start -->
<div class="am-g am-container plugins-answers plugins-answers-detail"> <div class="am-g am-container plugins-answers plugins-answers-detail">
<!-- 幻灯片 --> <!-- 幻灯片 -->
<div class="am-u-md-8 answers-slider"> <div class="am-u-md-8">
{{if isset($plugins_answers_detail['code']) and $plugins_answers_detail['code'] eq 0}} {{if isset($plugins_answers_detail['code']) and $plugins_answers_detail['code'] eq 0}}
{{if !empty($plugins_answers_detail['data']['content'])}} {{if !empty($plugins_answers_detail['data']['content'])}}
{{if !empty($plugins_answers_detail['data']['title'])}}
<h2>{{$plugins_answers_detail.data.title}}</h2>
{{/if}}
<div class="base-content"> <div class="base-content">
<p>{{$plugins_answers_detail.data.content}}</p> <p>{{$plugins_answers_detail.data.content}}</p>
<p class="base-date gray-text">{{$plugins_answers_detail.data.add_time_date}}</p> <p class="base-date gray-text">{{$plugins_answers_detail.data.add_time_date}}</p>
</div> </div>
<div class="am-panel base {{if isset($plugins_answers_detail['data']['is_reply']) and $plugins_answers_detail['data']['is_reply'] eq 1}} am-panel-success{{else /}} am-panel-default{{/if}}"> <div class="am-panel base {{if isset($plugins_answers_detail['data']['is_reply']) and $plugins_answers_detail['data']['is_reply'] eq 1}} am-panel-success{{else /}} am-panel-warning{{/if}}">
<div class="am-panel-bd"> <div class="am-panel-bd">
{{if isset($plugins_answers_detail['data']['is_reply']) and $plugins_answers_detail['data']['is_reply'] eq 1}} {{if isset($plugins_answers_detail['data']['is_reply']) and $plugins_answers_detail['data']['is_reply'] eq 1}}
<span class="am-badge am-radius am-badge-success">已回答</span> <span class="am-badge am-radius am-badge-success">管理员已回答</span>
{{$plugins_answers_detail.data.reply}} <p class="reply-content">{{$plugins_answers_detail.data.reply}}</p>
<p class="base-date gray-text">{{$plugins_answers_detail.data.reply_time_date}}</p>
{{else /}} {{else /}}
<span class="am-badge am-radius">待回答</span> <span class="am-badge am-radius">管理员待回复</span>
{{/if}} {{/if}}
</div> </div>
</div> </div>
@ -64,7 +68,13 @@
<ul class="am-list"> <ul class="am-list">
{{foreach $plugins_answers_rc_list as $answers}} {{foreach $plugins_answers_rc_list as $answers}}
<li class="am-g am-list-item-dated"> <li class="am-g am-list-item-dated">
<a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd ">{{$answers.content}}</a> <a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd">
{{if empty($answers['title'])}}
{{$answers.content}}
{{else /}}
{{$answers.title}}
{{/if}}
</a>
<span class="am-list-date">{{$answers.add_time_date}}</span> <span class="am-list-date">{{$answers.add_time_date}}</span>
</li> </li>
{{/foreach}} {{/foreach}}

View File

@ -61,7 +61,13 @@
<ul class="am-list"> <ul class="am-list">
{{foreach $plugins_answers_rc_list as $answers}} {{foreach $plugins_answers_rc_list as $answers}}
<li class="am-g am-list-item-dated"> <li class="am-g am-list-item-dated">
<a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd ">{{$answers.content}}</a> <a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd">
{{if empty($answers['title'])}}
{{$answers.content}}
{{else /}}
{{$answers.title}}
{{/if}}
</a>
<span class="am-list-date">{{$answers.add_time_date}}</span> <span class="am-list-date">{{$answers.add_time_date}}</span>
</li> </li>
{{/foreach}} {{/foreach}}
@ -98,7 +104,13 @@
<ul class="am-list"> <ul class="am-list">
{{foreach $plugins_answers_middle_answer_list as $answers}} {{foreach $plugins_answers_middle_answer_list as $answers}}
<li class="am-g am-list-item-dated"> <li class="am-g am-list-item-dated">
<a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd ">{{$answers.content}}</a> <a href="{{:PluginsHomeUrl('answers', 'index', 'detail', ['id'=>$answers['id']])}}" target="_blank" class="am-list-item-hd">
{{if empty($answers['title'])}}
{{$answers.content}}
{{else /}}
{{$answers.title}}
{{/if}}
</a>
<span class="am-list-date">{{$answers.add_time_date}}</span> <span class="am-list-date">{{$answers.add_time_date}}</span>
</li> </li>
{{/foreach}} {{/foreach}}

View File

@ -8,15 +8,19 @@
<form class="am-form form-validation-plugins-answer-ask view-save" action="{{:PluginsHomeUrl('answers', 'index', 'answer')}}" method="POST" request-type="ajax-reload"> <form class="am-form form-validation-plugins-answer-ask view-save" action="{{:PluginsHomeUrl('answers', 'index', 'answer')}}" method="POST" request-type="ajax-reload">
<div class="am-form-group"> <div class="am-form-group">
<label>姓名<span class="am-form-group-label-tips">选填</span></label> <label>姓名<span class="am-form-group-label-tips">选填</span></label>
<input type="text" name="name" placeholder="姓名" data-validation-message="请填写姓名" class="am-radius" /> <input type="text" name="name" placeholder="姓名" maxlength="30" data-validation-message="联系人最多30个字符" class="am-radius" />
</div> </div>
<div class="am-form-group"> <div class="am-form-group">
<label>电话<span class="am-form-group-label-tips">选填</span></label> <label>电话<span class="am-form-group-label-tips">选填</span></label>
<input type="text" name="tel" placeholder="电话" data-validation-message="请填写电话" class="am-radius" /> <input type="text" name="tel" placeholder="电话" data-validation-message="请填写电话" class="am-radius" />
</div> </div>
<div class="am-form-group">
<label>标题<span class="am-form-group-label-tips">必填</span></label>
<input type="text" name="title" placeholder="标题" maxlength="60" data-validation-message="标题最多60个字符" class="am-radius" required />
</div>
<div class="am-form-group"> <div class="am-form-group">
<label>内容<span class="am-form-group-label-tips">必填</span></label> <label>内容<span class="am-form-group-label-tips">必填</span></label>
<textarea class="am-radius am-validate" name="content" rows="5" minlength="5" maxlength="300" placeholder="内容至少5个字" data-validation-message="内容格式 5~300 个字符之间" required></textarea> <textarea class="am-radius am-validate" name="content" rows="5" minlength="5" maxlength="230" placeholder="内容至少5个字" data-validation-message="内容格式 5~230 个字符之间" required></textarea>
</div> </div>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">提交</button> <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">提交</button>

View File

@ -160,7 +160,7 @@
</legend> </legend>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<label>姓名</label> <label>姓名</label>
<input type="text" name="name" placeholder="姓名" data-validation-message="请填写姓名" class="am-radius" required /> <input type="text" name="name" placeholder="姓名" maxlength="30" data-validation-message="联系人最多30个字符" class="am-radius" required />
</div> </div>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<label>电话</label> <label>电话</label>
@ -168,7 +168,7 @@
</div> </div>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<label>内容</label> <label>内容</label>
<textarea class="am-radius am-validate" name="content" rows="3" minlength="5" maxlength="300" placeholder="内容至少5个字" data-validation-message="内容格式 5~300 个字符之间" required></textarea> <textarea class="am-radius am-validate" name="content" rows="3" minlength="5" maxlength="230" placeholder="内容格式 5~230 个字符之间" data-validation-message="内容格式 5~300 个字符之间" required></textarea>
</div> </div>
<div class="am-form-group am-form-group-refreshing"> <div class="am-form-group am-form-group-refreshing">
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">提交</button> <button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">提交</button>

View File

@ -77,12 +77,20 @@ class AnswerService
$v['is_show_text'] = $common_is_show_list[$v['is_show']]['name']; $v['is_show_text'] = $common_is_show_list[$v['is_show']]['name'];
} }
// 回复时间
if(isset($v['reply_time']))
{
$reply_time = $v['reply_time'];
$v['reply_time'] = empty($reply_time) ? '' : date('Y-m-d H:i:s', $reply_time);
$v['reply_time_date'] = empty($reply_time) ? '' : date('Y-m-d', $reply_time);
}
// 创建时间 // 创建时间
if(isset($v['add_time'])) if(isset($v['add_time']))
{ {
$add_time = $v['add_time']; $add_time = $v['add_time'];
$v['add_time'] = date('Y-m-d H:i:s', $add_time); $v['add_time'] = empty($add_time) ? '' : date('Y-m-d H:i:s', $add_time);
$v['add_time_date'] = date('Y-m-d', $add_time); $v['add_time_date'] = empty($add_time) ? '' : date('Y-m-d', $add_time);
} }
// 更新时间 // 更新时间
@ -167,15 +175,24 @@ class AnswerService
// 参数校验 // 参数校验
$p = [ $p = [
[ [
'checked_type' => 'isset', 'checked_type' => 'length',
'key_name' => 'name', 'key_name' => 'name',
'error_msg' => '联系人有误', 'checked_data' => '30',
'is_checked' => 1,
'error_msg' => '联系人最多30个字符',
], ],
[ [
'checked_type' => 'isset', 'checked_type' => 'isset',
'key_name' => 'tel', 'key_name' => 'tel',
'error_msg' => '联系电话有误', 'error_msg' => '联系电话有误',
], ],
[
'checked_type' => 'length',
'key_name' => 'title',
'checked_data' => '60',
'is_checked' => 1,
'error_msg' => '标题最多60个字符',
],
[ [
'checked_type' => 'empty', 'checked_type' => 'empty',
'key_name' => 'content', 'key_name' => 'content',
@ -193,6 +210,7 @@ class AnswerService
'user_id' => isset($params['user']['id']) ? intval($params['user']['id']) : 0, 'user_id' => isset($params['user']['id']) ? intval($params['user']['id']) : 0,
'name' => isset($params['name']) ? $params['name'] : '', 'name' => isset($params['name']) ? $params['name'] : '',
'tel' => isset($params['tel']) ? $params['tel'] : '', 'tel' => isset($params['tel']) ? $params['tel'] : '',
'title' => isset($params['title']) ? $params['title'] : '',
'content' => $params['content'], 'content' => $params['content'],
'add_time' => time(), 'add_time' => time(),
]; ];
@ -317,6 +335,7 @@ class AnswerService
$data = [ $data = [
'reply' => $params['reply'], 'reply' => $params['reply'],
'is_reply' => 1, 'is_reply' => 1,
'reply_time' => time(),
'upd_time' => time() 'upd_time' => time()
]; ];
if(Db::name('Answer')->where($where)->update($data)) if(Db::name('Answer')->where($where)->update($data))

View File

@ -113,3 +113,16 @@
box-shadow: none; box-shadow: none;
-webkit-box-shadow: none; -webkit-box-shadow: none;
} }
.plugins-answers-detail .am-panel-warning {
background: #fff7ef;
}
.plugins-answers-detail .am-panel-success {
background: #f2fff1;
}
.plugins-answers-detail h2 {
margin-bottom: 5px;
font-weight: 500;
}
.plugins-answers-detail .base .reply-content {
margin-top: 5px;
}