From ef636bc2d178da92b9ebe45b2bd4a47aaec7e923 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 14 Mar 2019 11:29:09 +0800 Subject: [PATCH] Feat: My share --- application/index/controller/Share.php | 41 +++-- application/index/model/ShareHandler.php | 6 +- application/index/view/home/home.html | 7 +- application/index/view/share/share_home.html | 157 ++++++++---------- .../index/view/share/share_homr_old.html | 98 +++++++++++ .../index/view/share/share_lock_old.html | 53 ------ 6 files changed, 199 insertions(+), 163 deletions(-) create mode 100644 application/index/view/share/share_homr_old.html delete mode 100644 application/index/view/share/share_lock_old.html diff --git a/application/index/controller/Share.php b/application/index/controller/Share.php index f35f5534..71fc98c4 100644 --- a/application/index/controller/Share.php +++ b/application/index/controller/Share.php @@ -222,36 +222,39 @@ class Share extends Controller{ $shareId = input('post.id'); $shareObj = new ShareHandler($shareId,false); if(!$shareObj->querryStatus){ - return array( + return json(array( "error" => 1, "msg" => "分享不存在" - ); + )); } - return $shareObj->deleteShare($this->userObj->uid); + return json($shareObj->deleteShare($this->userObj->uid)); } public function ChangePromission(){ $shareId = input('post.id'); $shareObj = new ShareHandler($shareId,false); if(!$shareObj->querryStatus){ - return array( + return json(array( "error" => 1, "msg" => "分享不存在" - ); + )); } - return $shareObj->changePromission($this->userObj->uid); + return json($shareObj->changePromission($this->userObj->uid)); } - public function My(){ + public function ListMyShare(){ if(!$this->userObj->loginStatus){ $this->redirect(url('/Login','','')); exit(); } - $userInfo = $this->userObj->getInfo(); - $groupData = $this->userObj->getGroupData(); - $list = Db::name('shares')->where('owner',$this->userObj->uid)->order('share_time DESC')->paginate(30); - $listData = $list->all(); + $list = Db::name('shares') + ->where('owner',$this->userObj->uid) + ->order('share_time DESC') + ->page(input("post.page").",18") + ->select(); + $listData = $list; foreach ($listData as $key => $value) { + unset($listData[$key]["source_name"]); if($value["source_type"]=="file"){ $listData[$key]["fileData"] = Db::name('files')->where('id',$value["source_name"])->find()["orign_name"]; @@ -259,12 +262,20 @@ class Share extends Controller{ $listData[$key]["fileData"] = $value["source_name"]; } } + return json($listData); + } + + public function My(){ + if(!$this->userObj->loginStatus){ + $this->redirect(url('/Login','','')); + exit(); + } + $userInfo = $this->userObj->getInfo(); + $groupData = $this->userObj->getGroupData(); return view('share_home', [ - 'options' => Option::getValues(['basic','share']), - 'userInfo' => $userInfo, + 'options' => Option::getValues(['basic','share'],$this->userObj->userSQLData), + 'userData' => $userInfo, 'groupData' => $groupData, - 'list' => $listData, - 'listOrigin' => $list ]); } diff --git a/application/index/model/ShareHandler.php b/application/index/model/ShareHandler.php index 5e4823dc..9278fa7e 100644 --- a/application/index/model/ShareHandler.php +++ b/application/index/model/ShareHandler.php @@ -57,13 +57,15 @@ class ShareHandler extends Model{ "msg" => "无权操作" ); } + $newPwd = self::getRandomKey(6); Db::name('shares')->where('share_key',$this->shareData["share_key"])->update([ 'type' => $this->shareData["type"] == "public"?"private":"public", - 'share_pwd' => self::getRandomKey(6) + 'share_pwd' => $newPwd ]); return array( "error" =>0, - "msg" => "更改成功" + "msg" => "更改成功", + "newPwd" => $newPwd, ); } diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html index 1572af84..8209f248 100644 --- a/application/index/view/home/home.html +++ b/application/index/view/home/home.html @@ -84,10 +84,11 @@ - - - + + + + \ No newline at end of file diff --git a/application/index/view/share/share_home.html b/application/index/view/share/share_home.html index 2af2eb1f..97bcc70b 100644 --- a/application/index/view/share/share_home.html +++ b/application/index/view/share/share_home.html @@ -1,98 +1,75 @@ -{extend name="header_home" /} -{block name="title"}我的分享- {$options.siteName}{/block} -{block name="content"} - - - + + + + + + + + + + + 我的分享- {$options.siteName} + + - - - -
- {include file="navbar_home" /} + +
+ - - + + + + + + - -{$options.js_code} - -{/block} \ No newline at end of file + \ No newline at end of file diff --git a/application/index/view/share/share_homr_old.html b/application/index/view/share/share_homr_old.html new file mode 100644 index 00000000..2af2eb1f --- /dev/null +++ b/application/index/view/share/share_homr_old.html @@ -0,0 +1,98 @@ +{extend name="header_home" /} +{block name="title"}我的分享- {$options.siteName}{/block} +{block name="content"} + + + + + + + +
+ {include file="navbar_home" /} + + +