+
{{ item.create_time|time_ago }}
{{ item.view_count }} 浏览
{{ item.like_count }} 点赞
diff --git a/app/Http/Home/Views/user/questions.volt b/app/Http/Home/Views/user/questions.volt
new file mode 100644
index 00000000..b83eb067
--- /dev/null
+++ b/app/Http/Home/Views/user/questions.volt
@@ -0,0 +1,26 @@
+{% if pager.total_pages > 0 %}
+
+
+ {% for item in pager.items %}
+ {% set question_url = url({'for':'home.question.show','id':item.id}) %}
+
+
+
+
+
{{ substr(item.summary,0,80) }}
+
+ {{ item.create_time|time_ago }}
+ {{ item.view_count }} 浏览
+ {{ item.like_count }} 点赞
+ {{ item.answer_count }} 回答
+
+
+
+
+ {% endfor %}
+
+
+ {{ partial('partials/pager_ajax') }}
+{% endif %}
\ No newline at end of file
diff --git a/app/Http/Home/Views/user/show.volt b/app/Http/Home/Views/user/show.volt
index 82a50354..f43de825 100644
--- a/app/Http/Home/Views/user/show.volt
+++ b/app/Http/Home/Views/user/show.volt
@@ -43,11 +43,15 @@
{% set show_tab_courses = user.course_count > 0 %}
{% set show_tab_articles = user.article_count > 0 %}
+ {% set show_tab_questions = user.question_count > 0 %}
+ {% set show_tab_answers = user.answer_count > 0 %}
{% set show_tab_friends = user.friend_count > 0 %}
{% set show_tab_groups = user.group_count > 0 %}
{% set courses_url = url({'for':'home.user.courses','id':user.id}) %}
{% set articles_url = url({'for':'home.user.articles','id':user.id}) %}
+ {% set questions_url = url({'for':'home.user.questions','id':user.id}) %}
+ {% set answers_url = url({'for':'home.user.answers','id':user.id}) %}
{% set friends_url = url({'for':'home.user.friends','id':user.id}) %}
{% set groups_url = url({'for':'home.user.groups','id':user.id}) %}
@@ -58,6 +62,12 @@
{% if show_tab_articles %}
文章
{% endif %}
+ {% if show_tab_questions %}
+
提问
+ {% endif %}
+ {% if show_tab_answers %}
+
回答
+ {% endif %}
{% if show_tab_friends %}
好友
{% endif %}
@@ -70,6 +80,12 @@
{% if show_tab_articles %}
{% endif %}
+ {% if show_tab_questions %}
+
+ {% endif %}
+ {% if show_tab_answers %}
+
+ {% endif %}
{% if show_tab_friends %}
{% endif %}
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php
index 3da14655..b0c2f504 100644
--- a/app/Library/AppInfo.php
+++ b/app/Library/AppInfo.php
@@ -11,7 +11,7 @@ class AppInfo
protected $link = 'https://koogua.com';
- protected $version = '1.3.5';
+ protected $version = '1.3.6';
public function __get($name)
{
diff --git a/app/Library/Helper.php b/app/Library/Helper.php
index 79eabbdd..7bb4534a 100644
--- a/app/Library/Helper.php
+++ b/app/Library/Helper.php
@@ -449,6 +449,8 @@ function kg_parse_summary($content, $length = 100)
$content = strip_tags($content);
+ $content = trim($content);
+
return kg_substr($content, 0, $length);
}
diff --git a/app/Models/Answer.php b/app/Models/Answer.php
index e2fa9a30..40dab0cc 100644
--- a/app/Models/Answer.php
+++ b/app/Models/Answer.php
@@ -153,27 +153,11 @@ class Answer extends Model
public function beforeCreate()
{
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
-
- if (empty($this->summary)) {
- $this->summary = kg_parse_summary($this->content);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
{
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
-
- if (empty($this->summary)) {
- $this->summary = kg_parse_summary($this->content);
- }
-
$this->update_time = time();
}
diff --git a/app/Models/Article.php b/app/Models/Article.php
index 644696cf..5a69307e 100644
--- a/app/Models/Article.php
+++ b/app/Models/Article.php
@@ -225,14 +225,6 @@ class Article extends Model
public function beforeCreate()
{
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
-
- if (is_array($this->tags) || is_object($this->tags)) {
- $this->tags = kg_json_encode($this->tags);
- }
-
$this->create_time = time();
}
@@ -246,19 +238,14 @@ class Article extends Model
$sync->addItem($this->id);
}
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
+ $this->update_time = time();
+ }
- if (empty($this->summary)) {
- $this->summary = kg_parse_summary($this->content);
- }
-
- if (is_array($this->tags) || is_array($this->tags)) {
+ public function beforeSave()
+ {
+ if (is_array($this->tags) || is_object($this->tags)) {
$this->tags = kg_json_encode($this->tags);
}
-
- $this->update_time = time();
}
public function afterCreate()
diff --git a/app/Models/Course.php b/app/Models/Course.php
index 8db6710a..1d9927a8 100644
--- a/app/Models/Course.php
+++ b/app/Models/Course.php
@@ -313,12 +313,6 @@ class Course extends Model
$this->attrs = kg_json_encode($this->attrs);
}
- if (empty($this->cover)) {
- $this->cover = kg_default_course_cover_path();
- } elseif (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
$this->create_time = time();
}
@@ -332,22 +326,10 @@ class Course extends Model
$sync->addItem($this->id);
}
- if (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
- if (empty($this->summary)) {
- $this->summary = kg_parse_summary($this->details);
- }
-
if (is_array($this->attrs) || is_object($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}
- if (empty($this->origin_price)) {
- $this->origin_price = 1.5 * $this->market_price;
- }
-
if ($this->deleted == 1) {
$this->published = 0;
}
@@ -355,6 +337,23 @@ class Course extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ if (empty($this->cover)) {
+ $this->cover = kg_default_course_cover_path();
+ } elseif (Text::startsWith($this->cover, 'http')) {
+ $this->cover = self::getCoverPath($this->cover);
+ }
+
+ if (empty($this->summary)) {
+ $this->summary = kg_parse_summary($this->details);
+ }
+
+ if (empty($this->origin_price)) {
+ $this->origin_price = 1.5 * $this->market_price;
+ }
+ }
+
public function afterCreate()
{
$cache = new MaxCourseIdCache();
diff --git a/app/Models/FlashSale.php b/app/Models/FlashSale.php
index 81c6ab62..6009d062 100644
--- a/app/Models/FlashSale.php
+++ b/app/Models/FlashSale.php
@@ -125,18 +125,19 @@ class FlashSale extends Model
public function beforeCreate()
{
- if (is_array($this->item_info) || is_object($this->item_info)) {
- $this->item_info = kg_json_encode($this->item_info);
- }
-
- if (is_array($this->schedules) || is_object($this->schedules)) {
- $this->schedules = kg_json_encode($this->schedules);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ if ($this->deleted == 1) {
+ $this->published = 0;
+ }
+
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->item_info) || is_object($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
@@ -145,12 +146,6 @@ class FlashSale extends Model
if (is_array($this->schedules) || is_object($this->schedules)) {
$this->schedules = kg_json_encode($this->schedules);
}
-
- if ($this->deleted == 1) {
- $this->published = 0;
- }
-
- $this->update_time = time();
}
public function afterCreate()
diff --git a/app/Models/ImGroup.php b/app/Models/ImGroup.php
index 677c0308..0ba90945 100644
--- a/app/Models/ImGroup.php
+++ b/app/Models/ImGroup.php
@@ -127,12 +127,6 @@ class ImGroup extends Model
public function beforeCreate()
{
- if (empty($this->avatar)) {
- $this->avatar = kg_default_group_avatar_path();
- } elseif (Text::startsWith($this->avatar, 'http')) {
- $this->avatar = self::getAvatarPath($this->avatar);
- }
-
$this->create_time = time();
}
@@ -143,10 +137,6 @@ class ImGroup extends Model
$sync->addItem($this->id);
}
- if (Text::startsWith($this->avatar, 'http')) {
- $this->avatar = self::getAvatarPath($this->avatar);
- }
-
if ($this->deleted == 1) {
$this->published = 0;
}
@@ -154,6 +144,15 @@ class ImGroup extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ if (empty($this->avatar)) {
+ $this->avatar = kg_default_group_avatar_path();
+ } elseif (Text::startsWith($this->avatar, 'http')) {
+ $this->avatar = self::getAvatarPath($this->avatar);
+ }
+ }
+
public function afterCreate()
{
$cache = new MaxImGroupIdCache();
diff --git a/app/Models/ImNotice.php b/app/Models/ImNotice.php
index 31b29225..6b26a4cb 100644
--- a/app/Models/ImNotice.php
+++ b/app/Models/ImNotice.php
@@ -85,20 +85,19 @@ class ImNotice extends Model
public function beforeCreate()
{
- if (is_array($this->item_info)) {
- $this->item_info = kg_json_encode($this->item_info);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/ImUser.php b/app/Models/ImUser.php
index 52b5e951..4725f21e 100644
--- a/app/Models/ImUser.php
+++ b/app/Models/ImUser.php
@@ -112,22 +112,21 @@ class ImUser extends Model
public function beforeCreate()
{
- if (empty($this->avatar)) {
- $this->avatar = kg_default_user_avatar_path();
- } elseif (Text::startsWith($this->avatar, 'http')) {
- $this->avatar = self::getAvatarPath($this->avatar);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
{
- if (Text::startsWith($this->avatar, 'http')) {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
+ {
+ if (empty($this->avatar)) {
+ $this->avatar = kg_default_user_avatar_path();
+ } elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/Notification.php b/app/Models/Notification.php
index b7cfab4e..defa7c44 100644
--- a/app/Models/Notification.php
+++ b/app/Models/Notification.php
@@ -180,20 +180,19 @@ class Notification extends Model
public function beforeCreate()
{
- if (is_array($this->event_info) || is_object($this->event_info)) {
- $this->event_info = kg_json_encode($this->event_info);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->event_info) || is_object($this->event_info)) {
$this->event_info = kg_json_encode($this->event_info);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/Order.php b/app/Models/Order.php
index 5e6ab4f5..7574d40a 100644
--- a/app/Models/Order.php
+++ b/app/Models/Order.php
@@ -170,18 +170,15 @@ class Order extends Model
{
$this->sn = date('YmdHis') . rand(1000, 9999);
- if (is_array($this->item_info) || is_object($this->item_info)) {
- $this->item_info = kg_json_encode($this->item_info);
- }
-
- if (is_array($this->promotion_info) || is_object($this->promotion_info)) {
- $this->promotion_info = kg_json_encode($this->promotion_info);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->item_info) || is_object($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
@@ -190,8 +187,6 @@ class Order extends Model
if (is_array($this->promotion_info) || is_object($this->promotion_info)) {
$this->promotion_info = kg_json_encode($this->promotion_info);
}
-
- $this->update_time = time();
}
public function afterSave()
diff --git a/app/Models/Package.php b/app/Models/Package.php
index b9e27eb5..07c46194 100644
--- a/app/Models/Package.php
+++ b/app/Models/Package.php
@@ -105,21 +105,11 @@ class Package extends Model
public function beforeCreate()
{
- if (empty($this->cover)) {
- $this->cover = kg_default_package_cover_path();
- } elseif (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
{
- if (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
if ($this->deleted == 1) {
$this->published = 0;
}
@@ -127,6 +117,15 @@ class Package extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ if (empty($this->cover)) {
+ $this->cover = kg_default_package_cover_path();
+ } elseif (Text::startsWith($this->cover, 'http')) {
+ $this->cover = self::getCoverPath($this->cover);
+ }
+ }
+
public function afterCreate()
{
$cache = new MaxPackageIdCache();
diff --git a/app/Models/PointGift.php b/app/Models/PointGift.php
index 63c1de87..2b567ab4 100644
--- a/app/Models/PointGift.php
+++ b/app/Models/PointGift.php
@@ -166,21 +166,11 @@ class PointGift extends Model
$this->attrs = kg_json_encode($this->attrs);
}
- if (empty($this->cover)) {
- $this->cover = kg_default_gift_cover_path();
- } elseif (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
{
- if (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
if (is_array($this->attrs) || is_object($this->attrs)) {
$this->attrs = kg_json_encode($this->attrs);
}
@@ -192,6 +182,15 @@ class PointGift extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ if (empty($this->cover)) {
+ $this->cover = kg_default_gift_cover_path();
+ } elseif (Text::startsWith($this->cover, 'http')) {
+ $this->cover = self::getCoverPath($this->cover);
+ }
+ }
+
public function afterCreate()
{
$cache = new MaxPointGiftIdCache();
diff --git a/app/Models/PointHistory.php b/app/Models/PointHistory.php
index e2688a1b..6aa8de9d 100644
--- a/app/Models/PointHistory.php
+++ b/app/Models/PointHistory.php
@@ -95,20 +95,19 @@ class PointHistory extends Model
public function beforeCreate()
{
- if (is_array($this->event_info) || is_object($this->event_info)) {
- $this->event_info = kg_json_encode($this->event_info);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->event_info) || is_object($this->event_info)) {
$this->event_info = kg_json_encode($this->event_info);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/Question.php b/app/Models/Question.php
index 0b9b2564..ca731b15 100644
--- a/app/Models/Question.php
+++ b/app/Models/Question.php
@@ -239,14 +239,6 @@ class Question extends Model
public function beforeCreate()
{
- if (is_array($this->tags) || is_object($this->tags)) {
- $this->tags = kg_json_encode($this->tags);
- }
-
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
-
$this->create_time = time();
}
@@ -260,19 +252,14 @@ class Question extends Model
$sync->addItem($this->id);
}
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
+ {
if (is_array($this->tags) || is_object($this->tags)) {
$this->tags = kg_json_encode($this->tags);
}
-
- if (empty($this->cover)) {
- $this->cover = kg_parse_first_content_image($this->content);
- }
-
- if (empty($this->summary)) {
- $this->summary = kg_parse_summary($this->content);
- }
-
- $this->update_time = time();
}
public function afterCreate()
diff --git a/app/Models/Review.php b/app/Models/Review.php
index 83589aad..c2610eaa 100644
--- a/app/Models/Review.php
+++ b/app/Models/Review.php
@@ -152,15 +152,11 @@ class Review extends Model
public function beforeCreate()
{
- $this->rating = $this->getAvgRating();
-
$this->create_time = time();
}
public function beforeUpdate()
{
- $this->rating = $this->getAvgRating();
-
if ($this->deleted == 1) {
$this->published = 0;
}
@@ -168,6 +164,11 @@ class Review extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ $this->rating = $this->getAvgRating();
+ }
+
protected function getAvgRating()
{
$sumRating = $this->rating1 + $this->rating2 + $this->rating3;
diff --git a/app/Models/Role.php b/app/Models/Role.php
index faf819fc..2478f9e1 100644
--- a/app/Models/Role.php
+++ b/app/Models/Role.php
@@ -103,20 +103,19 @@ class Role extends Model
public function beforeCreate()
{
- if (is_array($this->routes) || is_object($this->routes)) {
- $this->routes = kg_json_encode($this->routes);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->routes) || is_object($this->routes)) {
$this->routes = kg_json_encode($this->routes);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/Slide.php b/app/Models/Slide.php
index cbe149bf..1fc5c03a 100644
--- a/app/Models/Slide.php
+++ b/app/Models/Slide.php
@@ -124,6 +124,20 @@ class Slide extends Model
}
public function beforeCreate()
+ {
+ $this->create_time = time();
+ }
+
+ public function beforeUpdate()
+ {
+ if ($this->deleted == 1) {
+ $this->published = 0;
+ }
+
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (empty($this->cover)) {
$this->cover = kg_default_slide_cover_path();
@@ -134,25 +148,6 @@ class Slide extends Model
if (is_array($this->target_attrs) || is_object($this->target_attrs)) {
$this->target_attrs = kg_json_encode($this->target_attrs);
}
-
- $this->create_time = time();
- }
-
- public function beforeUpdate()
- {
- if (Text::startsWith($this->cover, 'http')) {
- $this->cover = self::getCoverPath($this->cover);
- }
-
- if (is_array($this->target_attrs) || is_object($this->target_attrs)) {
- $this->target_attrs = kg_json_encode($this->target_attrs);
- }
-
- if ($this->deleted == 1) {
- $this->published = 0;
- }
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index eca6f7ab..4d6a957f 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -98,21 +98,11 @@ class Tag extends Model
public function beforeCreate()
{
- if (empty($this->icon)) {
- $this->icon = kg_default_icon_path();
- } elseif (Text::startsWith($this->icon, 'http')) {
- $this->icon = self::getIconPath($this->icon);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
{
- if (Text::startsWith($this->icon, 'http')) {
- $this->icon = self::getIconPath($this->icon);
- }
-
if ($this->deleted == 1) {
$this->published = 0;
}
@@ -120,6 +110,15 @@ class Tag extends Model
$this->update_time = time();
}
+ public function beforeSave()
+ {
+ if (empty($this->icon)) {
+ $this->icon = kg_default_icon_path();
+ } elseif (Text::startsWith($this->icon, 'http')) {
+ $this->icon = self::getIconPath($this->icon);
+ }
+ }
+
public function afterCreate()
{
$cache = new MaxTagIdCache();
diff --git a/app/Models/Task.php b/app/Models/Task.php
index 8ac27e11..5c2278ce 100644
--- a/app/Models/Task.php
+++ b/app/Models/Task.php
@@ -126,20 +126,19 @@ class Task extends Model
public function beforeCreate()
{
- if (is_array($this->item_info) || is_object($this->item_info)) {
- $this->item_info = kg_json_encode($this->item_info);
- }
-
$this->create_time = time();
}
public function beforeUpdate()
+ {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
{
if (is_array($this->item_info) || is_object($this->item_info)) {
$this->item_info = kg_json_encode($this->item_info);
}
-
- $this->update_time = time();
}
public function afterFetch()
diff --git a/app/Models/User.php b/app/Models/User.php
index d07fab74..891284e4 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -199,12 +199,6 @@ class User extends Model
public function beforeCreate()
{
- if (empty($this->avatar)) {
- $this->avatar = kg_default_user_avatar_path();
- } elseif (Text::startsWith($this->avatar, 'http')) {
- $this->avatar = self::getAvatarPath($this->avatar);
- }
-
$this->create_time = time();
}
@@ -215,11 +209,16 @@ class User extends Model
$sync->addItem($this->id);
}
- if (Text::startsWith($this->avatar, 'http')) {
+ $this->update_time = time();
+ }
+
+ public function beforeSave()
+ {
+ if (empty($this->avatar)) {
+ $this->avatar = kg_default_user_avatar_path();
+ } elseif (Text::startsWith($this->avatar, 'http')) {
$this->avatar = self::getAvatarPath($this->avatar);
}
-
- $this->update_time = time();
}
public function afterCreate()
diff --git a/app/Repos/User.php b/app/Repos/User.php
index c6b19ea9..4692118e 100644
--- a/app/Repos/User.php
+++ b/app/Repos/User.php
@@ -5,8 +5,6 @@ namespace App\Repos;
use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
use App\Models\Answer as AnswerModel;
use App\Models\Article as ArticleModel;
-use App\Models\ArticleFavorite as ArticleFavoriteModel;
-use App\Models\CourseFavorite as CourseFavoriteModel;
use App\Models\CourseUser as CourseUserModel;
use App\Models\ImUser as ImUserModel;
use App\Models\Notification as NotificationModel;
@@ -199,22 +197,6 @@ class User extends Repository
]);
}
- public function countCourseFavorites($userId)
- {
- return (int)CourseFavoriteModel::count([
- 'conditions' => 'user_id = :user_id: AND deleted = 0',
- 'bind' => ['user_id' => $userId],
- ]);
- }
-
- public function countArticleFavorites($userId)
- {
- return (int)ArticleFavoriteModel::count([
- 'conditions' => 'user_id = :user_id: AND deleted = 0',
- 'bind' => ['user_id' => $userId],
- ]);
- }
-
public function countUnreadNotifications($userId)
{
return (int)NotificationModel::count([
diff --git a/app/Services/Logic/Answer/AnswerCreate.php b/app/Services/Logic/Answer/AnswerCreate.php
index 5b1871b8..990c4110 100644
--- a/app/Services/Logic/Answer/AnswerCreate.php
+++ b/app/Services/Logic/Answer/AnswerCreate.php
@@ -22,6 +22,7 @@ class AnswerCreate extends LogicService
use ClientTrait;
use QuestionTrait;
use AnswerTrait;
+ use AnswerDataTrait;
public function handle()
{
@@ -41,15 +42,15 @@ class AnswerCreate extends LogicService
$answer = new AnswerModel();
- $answer->published = $this->getPublishStatus($user);
- $answer->content = $validator->checkContent($post['content']);
- $answer->client_type = $this->getClientType();
- $answer->client_ip = $this->getClientIp();
- $answer->question_id = $question->id;
- $answer->owner_id = $user->id;
+ $data = $this->handlePostData($post);
- $answer->create();
+ $data['published'] = $this->getPublishStatus($user);
+ $data['question_id'] = $question->id;
+ $data['owner_id'] = $user->id;
+ $answer->create($data);
+
+ $this->saveDynamicAttrs($answer);
$this->incrUserDailyAnswerCount($user);
$this->recountQuestionAnswers($question);
$this->recountUserAnswers($user);
diff --git a/app/Services/Logic/Answer/AnswerDataTrait.php b/app/Services/Logic/Answer/AnswerDataTrait.php
new file mode 100644
index 00000000..2bb8b0ad
--- /dev/null
+++ b/app/Services/Logic/Answer/AnswerDataTrait.php
@@ -0,0 +1,37 @@
+getClientType();
+ $data['client_ip'] = $this->getClientIp();
+
+ $validator = new AnswerValidator();
+
+ $data['content'] = $validator->checkContent($post['content']);
+
+ return $data;
+ }
+
+ protected function saveDynamicAttrs(AnswerModel $answer)
+ {
+ $answer->cover = kg_parse_first_content_image($answer->content);
+
+ $answer->summary = kg_parse_summary($answer->content);
+
+ $answer->update();
+ }
+
+}
diff --git a/app/Services/Logic/Answer/AnswerInfo.php b/app/Services/Logic/Answer/AnswerInfo.php
index a49a7267..70f74c19 100644
--- a/app/Services/Logic/Answer/AnswerInfo.php
+++ b/app/Services/Logic/Answer/AnswerInfo.php
@@ -75,8 +75,16 @@ class AnswerInfo extends LogicService
{
$me = [
'liked' => 0,
+ 'owned' => 0,
];
+ $isOwner = $user->id == $answer->owner_id;
+ $approved = $answer->published = AnswerModel::PUBLISH_APPROVED;
+
+ if ($isOwner || $approved) {
+ $me['owned'] = 1;
+ }
+
if ($user->id > 0) {
$likeRepo = new AnswerLikeRepo();
diff --git a/app/Services/Logic/Answer/AnswerList.php b/app/Services/Logic/Answer/AnswerList.php
new file mode 100644
index 00000000..832132f5
--- /dev/null
+++ b/app/Services/Logic/Answer/AnswerList.php
@@ -0,0 +1,72 @@
+getParams();
+
+ $params['deleted'] = 0;
+
+ $sort = $pagerQuery->getSort();
+ $page = $pagerQuery->getPage();
+ $limit = $pagerQuery->getLimit();
+
+ $answerRepo = new AnswerRepo();
+
+ $pager = $answerRepo->paginate($params, $sort, $page, $limit);
+
+ return $this->handleAnswers($pager);
+ }
+
+ public function handleAnswers($pager)
+ {
+ if ($pager->total_items == 0) {
+ return $pager;
+ }
+
+ $builder = new AnswerListBuilder();
+
+ $answers = $pager->items->toArray();
+
+ $questions = $builder->getQuestions($answers);
+
+ $users = $builder->getUsers($answers);
+
+ $items = [];
+
+ foreach ($answers as $answer) {
+
+ $question = $questions[$answer['question_id']] ?? new \stdClass();
+ $owner = $users[$answer['owner_id']] ?? new \stdClass();
+
+ $items[] = [
+ 'id' => $answer['id'],
+ 'summary' => $answer['summary'],
+ 'published' => $answer['published'],
+ 'accepted' => $answer['accepted'],
+ 'comment_count' => $answer['comment_count'],
+ 'like_count' => $answer['like_count'],
+ 'create_time' => $answer['create_time'],
+ 'update_time' => $answer['update_time'],
+ 'question' => $question,
+ 'owner' => $owner,
+ ];
+ }
+
+ $pager->items = $items;
+
+ return $pager;
+ }
+
+}
diff --git a/app/Services/Logic/Answer/AnswerUpdate.php b/app/Services/Logic/Answer/AnswerUpdate.php
index 3cfc159d..3506e15b 100644
--- a/app/Services/Logic/Answer/AnswerUpdate.php
+++ b/app/Services/Logic/Answer/AnswerUpdate.php
@@ -14,6 +14,7 @@ class AnswerUpdate extends LogicService
use ClientTrait;
use QuestionTrait;
use AnswerTrait;
+ use AnswerDataTrait;
public function handle($id)
{
@@ -29,11 +30,11 @@ class AnswerUpdate extends LogicService
$validator->checkIfAllowEdit($answer);
- $answer->content = $validator->checkContent($post['content']);
- $answer->client_type = $this->getClientType();
- $answer->client_ip = $this->getClientIp();
+ $data = $this->handlePostData($post);
- $answer->update();
+ $answer->update($data);
+
+ $this->saveDynamicAttrs($answer);
$this->eventsManager->fire('Answer:afterUpdate', $this, $answer);
diff --git a/app/Services/Logic/Article/ArticleCreate.php b/app/Services/Logic/Article/ArticleCreate.php
index 5ab11e4c..39a026ce 100644
--- a/app/Services/Logic/Article/ArticleCreate.php
+++ b/app/Services/Logic/Article/ArticleCreate.php
@@ -29,7 +29,6 @@ class ArticleCreate extends LogicService
$data = $this->handlePostData($post);
$data['published'] = $this->getPublishStatus($user);
-
$data['owner_id'] = $user->id;
$article->create($data);
@@ -38,6 +37,7 @@ class ArticleCreate extends LogicService
$this->saveTags($article, $post['xm_tag_ids']);
}
+ $this->saveDynamicAttrs($article);
$this->incrUserDailyArticleCount($user);
$this->recountUserArticles($user);
diff --git a/app/Services/Logic/Article/ArticleDataTrait.php b/app/Services/Logic/Article/ArticleDataTrait.php
index 8dc2bfba..0c005068 100644
--- a/app/Services/Logic/Article/ArticleDataTrait.php
+++ b/app/Services/Logic/Article/ArticleDataTrait.php
@@ -19,6 +19,9 @@ trait ArticleDataTrait
{
$data = [];
+ $data['client_type'] = $this->getClientType();
+ $data['client_ip'] = $this->getClientIp();
+
$validator = new ArticleValidator();
$data['title'] = $validator->checkTitle($post['title']);
@@ -48,6 +51,20 @@ trait ArticleDataTrait
return $data;
}
+ protected function saveDynamicAttrs(ArticleModel $article)
+ {
+ $article->cover = kg_parse_first_content_image($article->content);
+
+ $article->summary = kg_parse_summary($article->content);
+
+ $article->update();
+
+ /**
+ * 重新执行afterFetch
+ */
+ $article->afterFetch();
+ }
+
protected function saveTags(ArticleModel $article, $tagIds)
{
$originTagIds = [];
diff --git a/app/Services/Logic/Article/ArticleList.php b/app/Services/Logic/Article/ArticleList.php
index ae58b3ea..684f455a 100644
--- a/app/Services/Logic/Article/ArticleList.php
+++ b/app/Services/Logic/Article/ArticleList.php
@@ -8,7 +8,6 @@ use App\Models\Article as ArticleModel;
use App\Repos\Article as ArticleRepo;
use App\Services\Logic\Service as LogicService;
use App\Validators\ArticleQuery as ArticleQueryValidator;
-use Phalcon\Text;
class ArticleList extends LogicService
{
@@ -52,18 +51,8 @@ class ArticleList extends LogicService
$items = [];
- $baseUrl = kg_cos_url();
-
foreach ($articles as $article) {
- if (!empty($article['cover']) && !Text::startsWith($article['cover'], 'http')) {
- $article['cover'] = $baseUrl . $article['cover'];
- }
-
- if (empty($article['summary'])) {
- $article['summary'] = kg_parse_summary($article['content']);
- }
-
$article['tags'] = json_decode($article['tags'], true);
$category = $categories[$article['category_id']] ?? new \stdClass();
diff --git a/app/Services/Logic/Article/ArticleUpdate.php b/app/Services/Logic/Article/ArticleUpdate.php
index 9046a313..79b41cf1 100644
--- a/app/Services/Logic/Article/ArticleUpdate.php
+++ b/app/Services/Logic/Article/ArticleUpdate.php
@@ -44,6 +44,8 @@ class ArticleUpdate extends LogicService
$this->saveTags($article, $post['xm_tag_ids']);
}
+ $this->saveDynamicAttrs($article);
+
$this->eventsManager->fire('Article:afterUpdate', $this, $article);
return $article;
diff --git a/app/Services/Logic/Article/XmTagList.php b/app/Services/Logic/Article/XmTagList.php
new file mode 100644
index 00000000..450a8123
--- /dev/null
+++ b/app/Services/Logic/Article/XmTagList.php
@@ -0,0 +1,50 @@
+findAll(['published' => 1]);
+
+ if ($allTags->count() == 0) return [];
+
+ $articleTagIds = [];
+
+ if ($id > 0) {
+ $article = $this->findArticle($id);
+ if (!empty($article->tags)) {
+ $articleTagIds = kg_array_column($article->tags, 'id');
+ }
+ }
+
+ $list = [];
+
+ foreach ($allTags as $tag) {
+ $selected = in_array($tag->id, $articleTagIds);
+ $list[] = [
+ 'name' => $tag->name,
+ 'value' => $tag->id,
+ 'selected' => $selected,
+ ];
+ }
+
+ return $list;
+ }
+
+ protected function findArticle($id)
+ {
+ $articleRepo = new ArticleRepo();
+
+ return $articleRepo->findById($id);
+ }
+
+}
diff --git a/app/Services/Logic/Comment/CommentReply.php b/app/Services/Logic/Comment/CommentReply.php
index 33b7bb45..500ca074 100644
--- a/app/Services/Logic/Comment/CommentReply.php
+++ b/app/Services/Logic/Comment/CommentReply.php
@@ -40,7 +40,7 @@ class CommentReply extends LogicService
'owner_id' => $user->id,
];
- $item = $validator->checkItem($comment->item_type, $comment->item_id);
+ $item = $validator->checkItem($comment->item_id, $comment->item_type);
/**
* 子评论中回复用户
diff --git a/app/Services/Logic/Page/PageInfo.php b/app/Services/Logic/Page/PageInfo.php
index 50e0c6a6..7431d923 100644
--- a/app/Services/Logic/Page/PageInfo.php
+++ b/app/Services/Logic/Page/PageInfo.php
@@ -3,6 +3,7 @@
namespace App\Services\Logic\Page;
use App\Models\Page as PageModel;
+use App\Models\User as UserModel;
use App\Services\Logic\PageTrait;
use App\Services\Logic\Service as LogicService;
@@ -13,22 +14,38 @@ class PageInfo extends LogicService
public function handle($id)
{
+ $user = $this->getCurrentUser(true);
+
$page = $this->checkPage($id);
- return $this->handlePage($page);
+ return $this->handlePage($page, $user);
}
- protected function handlePage(PageModel $page)
+ protected function handlePage(PageModel $page, UserModel $user)
{
$page->content = kg_parse_markdown($page->content);
+ $me = $this->handleMeInfo($page, $user);
+
return [
'id' => $page->id,
'title' => $page->title,
'content' => $page->content,
'create_time' => $page->create_time,
'update_time' => $page->update_time,
+ 'me' => $me,
];
}
+ protected function handleMeInfo(PageModel $page, UserModel $user)
+ {
+ $me = ['owned' => 0];
+
+ if ($page->published == 1) {
+ $me['owned'] = 1;
+ }
+
+ return $me;
+ }
+
}
diff --git a/app/Services/Logic/Question/QuestionCreate.php b/app/Services/Logic/Question/QuestionCreate.php
index 54ce8c41..7e756eb5 100644
--- a/app/Services/Logic/Question/QuestionCreate.php
+++ b/app/Services/Logic/Question/QuestionCreate.php
@@ -28,7 +28,6 @@ class QuestionCreate extends LogicService
$data = $this->handlePostData($post);
$data['published'] = $this->getPublishStatus($user);
-
$data['owner_id'] = $user->id;
$question->create($data);
@@ -37,6 +36,7 @@ class QuestionCreate extends LogicService
$this->saveTags($question, $post['xm_tag_ids']);
}
+ $this->saveDynamicAttrs($question);
$this->incrUserDailyQuestionCount($user);
$this->recountUserQuestions($user);
diff --git a/app/Services/Logic/Question/QuestionDataTrait.php b/app/Services/Logic/Question/QuestionDataTrait.php
index b412332a..6a92b0c3 100644
--- a/app/Services/Logic/Question/QuestionDataTrait.php
+++ b/app/Services/Logic/Question/QuestionDataTrait.php
@@ -36,7 +36,21 @@ trait QuestionDataTrait
return $data;
}
-
+
+ protected function saveDynamicAttrs(QuestionModel $question)
+ {
+ $question->cover = kg_parse_first_content_image($question->content);
+
+ $question->summary = kg_parse_summary($question->content);
+
+ $question->update();
+
+ /**
+ * 重新执行afterFetch
+ */
+ $question->afterFetch();
+ }
+
protected function saveTags(QuestionModel $question, $tagIds)
{
$originTagIds = [];
diff --git a/app/Services/Logic/Question/QuestionList.php b/app/Services/Logic/Question/QuestionList.php
index cc90cc02..08c1c9f6 100644
--- a/app/Services/Logic/Question/QuestionList.php
+++ b/app/Services/Logic/Question/QuestionList.php
@@ -8,7 +8,6 @@ use App\Models\Question as QuestionModel;
use App\Repos\Question as QuestionRepo;
use App\Services\Logic\Service as LogicService;
use App\Validators\QuestionQuery as QuestionQueryValidator;
-use Phalcon\Text;
class QuestionList extends LogicService
{
@@ -49,21 +48,12 @@ class QuestionList extends LogicService
$items = [];
- $baseUrl = kg_cos_url();
-
foreach ($questions as $question) {
- if (!empty($question['cover']) && !Text::startsWith($question['cover'], 'http')) {
- $question['cover'] = $baseUrl . $question['cover'];
- }
-
- if (empty($question['summary'])) {
- $question['summary'] = kg_parse_summary($question['content'], 80);
- }
-
$question['tags'] = json_decode($question['tags'], true);
$owner = $users[$question['owner_id']] ?? new \stdClass();
+
$lastReplier = $users[$question['last_replier_id']] ?? new \stdClass();
$items[] = [
diff --git a/app/Services/Logic/Question/QuestionUpdate.php b/app/Services/Logic/Question/QuestionUpdate.php
index ed6979b5..4404ac21 100644
--- a/app/Services/Logic/Question/QuestionUpdate.php
+++ b/app/Services/Logic/Question/QuestionUpdate.php
@@ -50,6 +50,8 @@ class QuestionUpdate extends LogicService
$this->saveTags($question, $post['xm_tag_ids']);
}
+ $this->saveDynamicAttrs($question);
+
$this->eventsManager->fire('Question:afterUpdate', $this, $question);
return $question;
diff --git a/app/Services/Logic/Question/XmTagList.php b/app/Services/Logic/Question/XmTagList.php
new file mode 100644
index 00000000..65bbb41d
--- /dev/null
+++ b/app/Services/Logic/Question/XmTagList.php
@@ -0,0 +1,50 @@
+findAll(['published' => 1]);
+
+ if ($allTags->count() == 0) return [];
+
+ $questionTagIds = [];
+
+ if ($id > 0) {
+ $question = $this->findQuestion($id);
+ if (!empty($question->tags)) {
+ $questionTagIds = kg_array_column($question->tags, 'id');
+ }
+ }
+
+ $list = [];
+
+ foreach ($allTags as $tag) {
+ $selected = in_array($tag->id, $questionTagIds);
+ $list[] = [
+ 'name' => $tag->name,
+ 'value' => $tag->id,
+ 'selected' => $selected,
+ ];
+ }
+
+ return $list;
+ }
+
+ protected function findQuestion($id)
+ {
+ $questionRepo = new QuestionRepo();
+
+ return $questionRepo->findById($id);
+ }
+
+}
diff --git a/app/Services/Logic/User/AnswerList.php b/app/Services/Logic/User/AnswerList.php
new file mode 100644
index 00000000..109528a5
--- /dev/null
+++ b/app/Services/Logic/User/AnswerList.php
@@ -0,0 +1,47 @@
+checkUser($id);
+
+ $pagerQuery = new PagerQuery();
+
+ $params = $pagerQuery->getParams();
+
+ $params['owner_id'] = $user->id;
+ $params['published'] = AnswerModel::PUBLISH_APPROVED;
+ $params['deleted'] = 0;
+
+ $sort = $pagerQuery->getSort();
+ $page = $pagerQuery->getPage();
+ $limit = $pagerQuery->getLimit();
+
+ $answerRepo = new AnswerRepo();
+
+ $pager = $answerRepo->paginate($params, $sort, $page, $limit);
+
+ return $this->handleAnswers($pager);
+ }
+
+ protected function handleAnswers($pager)
+ {
+ $service = new AnswerListService();
+
+ return $service->handleAnswers($pager);
+ }
+
+}
diff --git a/app/Services/Logic/User/Console/AnswerList.php b/app/Services/Logic/User/Console/AnswerList.php
index b956f440..24792b9c 100644
--- a/app/Services/Logic/User/Console/AnswerList.php
+++ b/app/Services/Logic/User/Console/AnswerList.php
@@ -2,9 +2,9 @@
namespace App\Services\Logic\User\Console;
-use App\Builders\AnswerList as AnswerListBuilder;
use App\Library\Paginator\Query as PagerQuery;
use App\Repos\Answer as AnswerRepo;
+use App\Services\Logic\Answer\AnswerList as AnswerListService;
use App\Services\Logic\Service as LogicService;
class AnswerList extends LogicService
@@ -34,44 +34,9 @@ class AnswerList extends LogicService
protected function handleAnswers($pager)
{
- if ($pager->total_items == 0) {
- return $pager;
- }
+ $service = new AnswerListService();
- $builder = new AnswerListBuilder();
-
- $answers = $pager->items->toArray();
-
- $questions = $builder->getQuestions($answers);
-
- $users = $builder->getUsers($answers);
-
- $items = [];
-
- foreach ($answers as $answer) {
-
- $answer['summary'] = kg_parse_summary($answer['content'], 64);
-
- $question = $questions[$answer['question_id']] ?? new \stdClass();
- $owner = $users[$answer['owner_id']] ?? new \stdClass();
-
- $items[] = [
- 'id' => $answer['id'],
- 'summary' => $answer['summary'],
- 'published' => $answer['published'],
- 'accepted' => $answer['accepted'],
- 'comment_count' => $answer['comment_count'],
- 'like_count' => $answer['like_count'],
- 'create_time' => $answer['create_time'],
- 'update_time' => $answer['update_time'],
- 'question' => $question,
- 'owner' => $owner,
- ];
- }
-
- $pager->items = $items;
-
- return $pager;
+ return $service->handleAnswers($pager);
}
}
diff --git a/app/Services/Logic/User/QuestionList.php b/app/Services/Logic/User/QuestionList.php
new file mode 100644
index 00000000..932d16a6
--- /dev/null
+++ b/app/Services/Logic/User/QuestionList.php
@@ -0,0 +1,47 @@
+checkUser($id);
+
+ $pagerQuery = new PagerQuery();
+
+ $params = $pagerQuery->getParams();
+
+ $params['owner_id'] = $user->id;
+ $params['published'] = QuestionModel::PUBLISH_APPROVED;
+ $params['deleted'] = 0;
+
+ $sort = $pagerQuery->getSort();
+ $page = $pagerQuery->getPage();
+ $limit = $pagerQuery->getLimit();
+
+ $articleRepo = new QuestionRepo();
+
+ $pager = $articleRepo->paginate($params, $sort, $page, $limit);
+
+ return $this->handleQuestions($pager);
+ }
+
+ protected function handleQuestions($pager)
+ {
+ $service = new QuestionListService();
+
+ return $service->handleQuestions($pager);
+ }
+
+}
diff --git a/app/Services/Logic/User/UserInfo.php b/app/Services/Logic/User/UserInfo.php
index d6a6a36f..b5bb88fa 100644
--- a/app/Services/Logic/User/UserInfo.php
+++ b/app/Services/Logic/User/UserInfo.php
@@ -37,6 +37,8 @@ class UserInfo extends LogicService
'locked' => $user->locked,
'course_count' => $user->course_count,
'article_count' => $user->article_count,
+ 'question_count' => $user->question_count,
+ 'answer_count' => $user->answer_count,
'friend_count' => $imUser->friend_count,
'group_count' => $imUser->group_count,
'active_time' => $user->active_time,
diff --git a/app/Services/Search/ArticleDocument.php b/app/Services/Search/ArticleDocument.php
index 2ac3c4a2..9d2610c3 100644
--- a/app/Services/Search/ArticleDocument.php
+++ b/app/Services/Search/ArticleDocument.php
@@ -35,10 +35,6 @@ class ArticleDocument extends Component
*/
public function formatDocument(ArticleModel $article)
{
- if (empty($article->summary)) {
- $article->summary = kg_parse_summary($article->content);
- }
-
if (is_array($article->tags) || is_object($article->tags)) {
$article->tags = kg_json_encode($article->tags);
}
diff --git a/app/Services/Search/CourseDocument.php b/app/Services/Search/CourseDocument.php
index 6e8853b9..1a59650e 100644
--- a/app/Services/Search/CourseDocument.php
+++ b/app/Services/Search/CourseDocument.php
@@ -61,10 +61,6 @@ class CourseDocument extends Component
$course->cover = CourseModel::getCoverPath($course->cover);
- if (empty($course->summary)) {
- $course->summary = kg_parse_summary($course->details);
- }
-
return [
'id' => $course->id,
'title' => $course->title,
diff --git a/app/Services/Search/QuestionDocument.php b/app/Services/Search/QuestionDocument.php
index 64b8de41..e056766e 100644
--- a/app/Services/Search/QuestionDocument.php
+++ b/app/Services/Search/QuestionDocument.php
@@ -36,10 +36,6 @@ class QuestionDocument extends Component
*/
public function formatDocument(QuestionModel $question)
{
- if (empty($question->summary)) {
- $question->summary = kg_parse_summary($question->content);
- }
-
if (is_array($question->tags) || is_object($question->tags)) {
$question->tags = kg_json_encode($question->tags);
}
diff --git a/public/static/admin/img/default/article_cover.png b/public/static/admin/img/default/article_cover.png
deleted file mode 100644
index 45118a54..00000000
Binary files a/public/static/admin/img/default/article_cover.png and /dev/null differ
diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css
index 7fe806dc..76bc1534 100644
--- a/public/static/home/css/common.css
+++ b/public/static/home/css/common.css
@@ -265,6 +265,8 @@
.page-info {
min-height: 500px;
+ padding-top: 30px;
+ padding-bottom: 30px;
}
.help-list li {
@@ -1763,6 +1765,20 @@
padding: 10px 8px;
}
+.user-tab .article-card {
+ height: 110px;
+ overflow: hidden;
+}
+
+.user-tab .article-card .title {
+ border-bottom: 1px solid #f2f2f2;
+ padding-bottom: 10px;
+}
+
+.user-tab .article-card .summary {
+ max-height: 3em;
+}
+
.user-card {
float: left;
width: 100%;
diff --git a/public/static/home/js/chapter.live.player.js b/public/static/home/js/chapter.live.player.js
index bcebb321..84bafdfc 100644
--- a/public/static/home/js/chapter.live.player.js
+++ b/public/static/home/js/chapter.live.player.js
@@ -14,12 +14,11 @@ layui.use(['jquery', 'helper'], function () {
var options = {
live: true,
autoplay: true,
- h5_flv: true,
width: 760,
height: 428,
};
- var formats = ['rtmp', 'flv', 'm3u8'];
+ var formats = ['m3u8'];
var rates = ['od', 'hd', 'sd'];
$.each(formats, function (i, format) {
diff --git a/public/static/home/js/user.console.account.js b/public/static/home/js/user.console.account.js
deleted file mode 100644
index f26f703c..00000000
--- a/public/static/home/js/user.console.account.js
+++ /dev/null
@@ -1,45 +0,0 @@
-layui.use(['jquery', 'layer'], function () {
-
- var $ = layui.jquery;
- var layer = layui.layer;
-
- $('.btn-edit-pwd').on('click', function () {
- var url = $(this).data('url');
- layer.open({
- type: 2,
- title: '修改密码',
- content: [url, 'no'],
- area: ['640px', '320px'],
- cancel: function () {
- window.location.reload();
- }
- });
- });
-
- $('.btn-edit-phone').on('click', function () {
- var url = $(this).data('url');
- layer.open({
- type: 2,
- title: '修改手机',
- content: [url, 'no'],
- area: ['640px', '420px'],
- cancel: function () {
- window.location.reload();
- }
- });
- });
-
- $('.btn-edit-email').on('click', function () {
- var url = $(this).data('url');
- layer.open({
- type: 2,
- title: '修改邮箱',
- content: [url, 'no'],
- area: ['640px', '420px'],
- cancel: function () {
- window.location.reload();
- }
- });
- });
-
-});
\ No newline at end of file
diff --git a/public/static/home/js/user.console.js b/public/static/home/js/user.console.js
index d30afa58..41ceb461 100644
--- a/public/static/home/js/user.console.js
+++ b/public/static/home/js/user.console.js
@@ -1,8 +1,7 @@
-layui.use(['jquery', 'layer', 'helper'], function () {
+layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery;
var layer = layui.layer;
- var helper = layui.helper;
/**
* 查看咨询
@@ -124,14 +123,4 @@ layui.use(['jquery', 'layer', 'helper'], function () {
});
});
- if ($('#tab-courses').length > 0) {
- var $tabCourses = $('#tab-courses');
- helper.ajaxLoadHtml($tabCourses.data('url'), $tabCourses.attr('id'));
- }
-
- if ($('#tab-users').length > 0) {
- var $tabUsers = $('#tab-users');
- helper.ajaxLoadHtml($tabUsers.data('url'), $tabUsers.attr('id'));
- }
-
});
\ No newline at end of file
diff --git a/public/static/home/js/user.show.js b/public/static/home/js/user.show.js
index b5f070a6..7571113b 100644
--- a/public/static/home/js/user.show.js
+++ b/public/static/home/js/user.show.js
@@ -13,6 +13,16 @@ layui.use(['jquery', 'helper'], function () {
helper.ajaxLoadHtml($tabArticles.data('url'), $tabArticles.attr('id'));
}
+ if ($('#tab-questions').length > 0) {
+ var $tabQuestions = $('#tab-questions');
+ helper.ajaxLoadHtml($tabQuestions.data('url'), $tabQuestions.attr('id'));
+ }
+
+ if ($('#tab-answers').length > 0) {
+ var $tabAnswers = $('#tab-answers');
+ helper.ajaxLoadHtml($tabAnswers.data('url'), $tabAnswers.attr('id'));
+ }
+
if ($('#tab-friends').length > 0) {
var $tabFriends = $('#tab-friends');
helper.ajaxLoadHtml($tabFriends.data('url'), $tabFriends.attr('id'));