From 3a4912083c38e1b64b9c5a5aa88ee1d219287dd5 Mon Sep 17 00:00:00 2001
From: HFO4 <912394456@qq.com>
Date: Thu, 14 Mar 2019 10:00:53 +0800
Subject: [PATCH] Feat: User profile
---
application/index/controller/Profile.php | 61 ++--
application/index/view/home/home.html | 7 +-
application/index/view/member/setting.html | 4 +-
.../index/view/member/setting_old.html | 265 ------------------
application/index/view/profile/profile.html | 192 ++++++-------
5 files changed, 128 insertions(+), 401 deletions(-)
delete mode 100644 application/index/view/member/setting_old.html
diff --git a/application/index/controller/Profile.php b/application/index/controller/Profile.php
index 458d78df..ff9a77c3 100644
--- a/application/index/controller/Profile.php
+++ b/application/index/controller/Profile.php
@@ -14,47 +14,46 @@ class Profile extends Controller{
public $siteOptions;
public function _initialize(){
- $this->siteOptions = Option::getValues(["basic"]);
}
- public function index(){
- $this->visitorObj = new User(cookie('user_id'),cookie('login_key'));
- $userId = (string)input("param.uid");
+ public function getList(){
+ $userId = (string)input("post.uid");
$userData = Db::name("users")->where("id",$userId)->find();
+ $page = (int)input("post.page");
if (empty($userId) || empty($userData) || $userData["profile"] == 0){
- $this->error('用户主页不存或者用户关闭了个人主页',404,$this->siteOptions);
- }
- $groupData = Db::name("groups")->where("id",$userData["user_group"])->find();
- $shareCount = Db::name('shares')
- ->where('owner',$userId)
- ->where('type',"public")
- ->count();
- $regDays = (int)((time()-strtotime($userData["user_date"]))/86400);
- switch (input("get.type")) {
+ $this->error('用户主页不存或者用户关闭了个人主页',404,$this->siteOptions);
+ }
+ switch (input("post.type")) {
case 'all':
$list = Db::name('shares')
->where('owner',$userId)
->where('type',"public")
->order('share_time DESC')
- ->paginate(10);
+ ->page($page.',10')
+ ->select();
break;
case 'hot':
$num = Option::getValue("hot_share_num");
$list = Db::name('shares')
->where('owner',$userId)
->where('type',"public")
- ->paginate($num);
+ ->order('download_num DESC')
+ ->limit($num)
+ ->select();
break;
default:
$list = Db::name('shares')
->where('owner',$userId)
->where('type',"public")
->order('share_time DESC')
- ->paginate(10);
+ ->page($page.',10')
+ ->select();
break;
}
- $listData = $list->all();
+ $listData = $list;
foreach ($listData as $key => $value) {
+ unset($listData[$key]["share_pwd"]);
+ unset($listData[$key]["source_name"]);
if($value["source_type"]=="file"){
$listData[$key]["fileData"] = Db::name('files')->where('id',$value["source_name"])->find()["orign_name"];
@@ -63,14 +62,34 @@ class Profile extends Controller{
$listData[$key]["fileData"] = end($pathDir);
}
}
+
+ return json($listData);
+
+
+ }
+
+ public function index(){
+ $this->visitorObj = new User(cookie('user_id'),cookie('login_key'));
+ $this->siteOptions = Option::getValues(["basic"],$this->visitorObj->userSQLData);
+ $userId = (string)input("param.uid");
+ $userData = Db::name("users")->where("id",$userId)->find();
+ if (empty($userId) || empty($userData) || $userData["profile"] == 0){
+ $this->error('用户主页不存或者用户关闭了个人主页',404,$this->siteOptions);
+ }
+ $groupData = Db::name("groups")->where("id",$userData["user_group"])->find();
+ $shareCount = Db::name('shares')
+ ->where('owner',$userId)
+ ->where('type',"public")
+ ->count();
+ $regDays = (int)((time()-strtotime($userData["user_date"]))/86400);
+
return view("profile",[
"options" => $this->siteOptions,
'loginStatus' => $this->visitorObj->loginStatus,
- 'userInfo' => $userData,
- 'userData' => $this->visitorObj->userSQLData,
+ 'targetUserInfo' => $userData,
+ 'userSQL' => $this->visitorObj->userSQLData,
+ 'userInfo' => $this->visitorObj->getInfo(),
'groupData' => $groupData,
- 'list' => $listData,
- 'listOrigin' => $list,
'type' => input("get.type"),
'shareCount' => $shareCount,
'regDays' => $regDays,
diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html
index 97cb3d47..1572af84 100644
--- a/application/index/view/home/home.html
+++ b/application/index/view/home/home.html
@@ -83,10 +83,11 @@
-
-
-
+
+
+
+