diff --git a/app/admin/controller/Sign.php b/app/admin/controller/Sign.php index 116b35a..a338532 100644 --- a/app/admin/controller/Sign.php +++ b/app/admin/controller/Sign.php @@ -9,7 +9,7 @@ use app\common\model\UserSignrule; class Sign extends BaseController { - + //添加签到积分规则 public function add() { $data = Request::only(['days','score']); @@ -28,6 +28,40 @@ class Sign extends BaseController return json($res); } + //删除签到积分规则 + public function delete($id) + { + if(Request::isAjax()){ + $user =UserSignrule::find($id); + $result = $user->delete(); + + if($result){ + return json(['code'=>0,'msg'=>'删除成功']); + }else{ + return json(['code'=>-1,'msg'=>'删除失败']); + } + } + } + + //编辑签到积分规则 + public function signEdit() + { + if(Request::isAjax()){ + $data = Request::param(); + $result = UserSignrule::update($data); + if($result){ + $res = ['code'=>0,'msg'=>'编辑成功']; + }else{ + $res = ['code'=>-1,'msg'=>'编辑失败']; + } + return json($res); + } + $sign = Db::name('user_signrule')->find(input('id')); + View::assign('sign',$sign); + return View::fetch('set/system/signedit'); + } + + //显示签到积分规则 public function signRule() { $keys = UserSignrule::select(); diff --git a/app/admin/controller/Vip.php b/app/admin/controller/Vip.php index 2ac9924..7d0d6fd 100644 --- a/app/admin/controller/Vip.php +++ b/app/admin/controller/Vip.php @@ -9,7 +9,7 @@ use app\common\model\UserViprule; class Vip extends BaseController { - + //添加VIP积分规则 public function add() { $data = Request::only(['score','vip']); @@ -27,6 +27,41 @@ class Vip extends BaseController return json($res); } + //删除VIP积分规则 + public function delete($id) + { + if(Request::isAjax()){ + $user =UserViprule::find($id); + $result = $user->delete(); + + if($result){ + return json(['code'=>0,'msg'=>'删除成功']); + }else{ + return json(['code'=>-1,'msg'=>'删除失败']); + } + } + } + + //编辑VIP积分规则 + public function vipEdit($id) + { + if(Request::isAjax()){ + $data = Request::param(); + $result = UserViprule::update($data); + if($result){ + $res = ['code'=>0,'msg'=>'编辑成功']; + }else{ + $res = ['code'=>-1,'msg'=>'编辑失败']; + } + return json($res); + } + $vip = Db::name('user_viprule')->find($id); + $level = UserViprule::column('vip'); + View::assign(['vip'=>$vip,'level'=>$level]); + return View::fetch('set/system/vipedit'); + } + + //显示VIP规则 public function vipRule() { $keys = UserViprule::select(); @@ -35,7 +70,7 @@ class Vip extends BaseController if($count){ $res = ['code'=>0,'msg'=>'','count'=>$count]; foreach($keys as $k=>$v){ - $res['data'][] = ['id'=>$v['id'],'score'=>$v['score'],'vip'=>$v['vip'],'ctime'=>$v['create_time']]; + $res['data'][] = ['id'=>$v['id'],'score'=>$v['score'],'nick'=>$v['nick'],'vip'=>$v['vip'],'ctime'=>$v['create_time']]; } } else { $res = ['code'=>-1,'msg'=>'还没有任何vip等级设置!']; diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php index 69d12d1..a695a54 100644 --- a/app/common/controller/BaseController.php +++ b/app/common/controller/BaseController.php @@ -237,7 +237,7 @@ abstract class BaseController protected function showUser() { //1.查询用户 - $user = Db::name('user')->field('id,name,nickname,user_img,sex,auth,city,email,sign,point,create_time')->where('id',Session::get('user_id'))->cache(600)->find(); + $user = Db::name('user')->field('id,name,nickname,user_img,sex,auth,city,email,sign,point,vip,create_time')->where('id',Session::get('user_id'))->cache(600)->find(); //2.将User变量赋给模板 公共模板nav.html View::assign('user',$user); } diff --git a/app/common/model/UserViprule.php b/app/common/model/UserViprule.php index 57a4fef..fbd6956 100644 --- a/app/common/model/UserViprule.php +++ b/app/common/model/UserViprule.php @@ -21,4 +21,11 @@ class UserViprule extends Model return $this->belongsTo('User','user_id','id'); } + //获取等级名 + public function getVipAttr($value) + { + $vip = [0=>'普通',1=>'VIP1',2=>'VIP2',3=>'VIP3',4=>'VIP4',5=>'VIP5']; + return $vip[$value]; + } + } \ No newline at end of file diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 74562f2..9d719a1 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -45,7 +45,7 @@ class Article extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->where(['status'=>1,'jie'=>1])->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15); break; @@ -56,7 +56,7 @@ class Article extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->where('status',1)->where($where)->where('is_hot',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15); break; @@ -67,7 +67,7 @@ class Article extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->where('status',1)->where($where)->where('is_top',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15); break; @@ -78,7 +78,7 @@ class Article extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15); @@ -110,7 +110,7 @@ class Article extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->find($id); Cache::set('article_'.$id,$article,3600); diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 0a4f82e..338b42c 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -11,7 +11,6 @@ use app\common\model\User; use app\common\model\Cate; use app\common\model\Comment; - class Index extends BaseController { public function index() @@ -32,7 +31,7 @@ class Index extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->order('create_time','desc')->limit(5)->select(); Cache::set('arttop',$artTop,60); @@ -46,7 +45,7 @@ class Index extends BaseController $query->where('delete_time',0)->field('id,catename'); }, 'user' => function($query){ - $query->field('id,name,nickname,user_img,area_id'); + $query->field('id,name,nickname,user_img,area_id,vip'); } ])->withCount(['comments'])->where(['status'=>1,'delete_time'=>0])->order('create_time','desc')->limit(20)->select(); Cache::set('artlist',$artList,60); diff --git a/app/index/controller/Sign.php b/app/index/controller/Sign.php index 6155dc4..f2e637f 100644 --- a/app/index/controller/Sign.php +++ b/app/index/controller/Sign.php @@ -8,6 +8,7 @@ use think\facade\Db; use think\facade\View; use think\Collection; use think\Response; +use taoler\com\Level; class Sign extends BaseController { @@ -56,14 +57,13 @@ class Sign extends BaseController return json(['code'=>-1,'msg'=>'你今天已签过到!']); } else { $data = $this->getInsertData($uid); - + $days = $data['days']; // 无今天数据 - $data['uid'] = $uid; $data['stime'] = time(); $id = Db::name('user_sign')->insertGetId($data); - + if ($id) { //$will_getscore //$score = $this->getTodayScores($days); @@ -86,7 +86,9 @@ class Sign extends BaseController $point = $user['point']+$score; $user->save(['point' => $point]); //point_note($score, $uid, $id); - + + //到达积分值升级Vip等级 + $viplv = Level::writeLv($uid); } return json(['code'=>200,'score'=>$score,'days'=>$days,'msg'=>$msg]); } else { diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql index 29c9869..4354bac 100644 --- a/app/install/data/taoler.sql +++ b/app/install/data/taoler.sql @@ -19,15 +19,15 @@ CREATE TABLE `tao_admin` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '软删除', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; INSERT INTO `tao_admin` VALUES ('1', 'admin', '管理员', '95d6f8d0d0c3b45e5dbe4057da1b149e', 'taoler@qq.com', '13812345678', '1', '1', '1', '2019.1.1 新年发布新版本!', '127.0.0.1', '1578986287', '1579053025', '1578986600', '0'); -INSERT INTO `tao_admin` VALUES ('2', 'test', '', '3dbfa76bd34a2a0274f5d52f5529ccb3', 'tao@qq.com', '13567891236', '0', '0', '2', '', '127.0.0.1', '1578643147', '1555892325', '1576554415', '0'); +INSERT INTO `tao_admin` VALUES ('2', 'test', '', '3dbfa76bd34a2a0274f5d52f5529ccb3', 'test@qq.com', '13567891236', '0', '0', '2', '', '127.0.0.1', '1578643147', '1555892325', '1576554415', '0'); DROP TABLE IF EXISTS `tao_article`; CREATE TABLE `tao_article` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '文章ID', + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', `title` varchar(50) NOT NULL COMMENT '标题', `content` text NOT NULL COMMENT '内容', `status` enum('0','1') NOT NULL DEFAULT '1' COMMENT '状态1显示0隐藏', @@ -38,15 +38,19 @@ CREATE TABLE `tao_article` ( `is_reply` enum('1','0') NOT NULL DEFAULT '1' COMMENT '0禁评1可评', `pv` int(11) NOT NULL DEFAULT '0' COMMENT '浏览量', `jie` enum('1','0') NOT NULL DEFAULT '0' COMMENT '0未结1已结', - `upzip` varchar(70) DEFAULT NULL, - `tags` varchar(255) DEFAULT NULL, + `upzip` varchar(70) DEFAULT NULL COMMENT '文章附件', + `tags` varchar(255) DEFAULT NULL COMMENT 'tag', + `read_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '阅读权限0开放1回复可读2密码可读3私密', + `art_pass` varchar(6) DEFAULT NULL COMMENT '文章加密密码', + `title_color` varchar(10) DEFAULT NULL COMMENT '标题颜色', + `title_font` varchar(20) DEFAULT NULL COMMENT '标题字形', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=32 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -INSERT INTO `tao_article` VALUES ('1', 'Fly Template 社区模版', '[quote]\r\n 你们认为layui官方Fly Template 社区模版怎么样?\r\n[/quote]\r\n你喜欢吗?\r\n很多人都说比较喜欢,我个人认为不错的,这个板子非常喜欢,我看到有一些人做了开发,可惜的是都没有很好的维护,有的漏洞比较多,不完善,很美好的一个板子,但没有长久 的更新,非常的可惜。\r\n如果用别人的不好用,那我就做一个出来吧。喜欢的人多关注,适当时候放出来大家一起用。\r\n关于详情页的内容解析\r\n该模板自带一个特定语法的编辑器,当你把内容存储到数据库后,在页面读取后浏览,会发现诸如“表情、代码、图片”等无法解析,这是因为需要对该内容进行一次转义,通常来说这是在服务端完成的,但鉴于简单化,你还可以直接在前端去解析,在模板的detail.html中,我们已经把相关的代码写好了,你只需打开注释即可(在代码的最下面)。当然,如果觉得编辑器无法满足你的需求,你也可以把该编辑器换成别的HTML编辑器或MarkDown编辑器。', '1', '1', '1', '0', '0', '1', '155', '0', null, null, '1546698225', '1577772362', '0'); +INSERT INTO `tao_article` VALUES ('1', 'Fly Template 社区模版', '[quote]\r\n 你们认为layui官方Fly Template 社区模版怎么样?\r\n[/quote]\r\n你喜欢吗?\r\n很多人都说比较喜欢,我个人认为不错的,这个板子非常喜欢,我看到有一些人做了开发,可惜的是都没有很好的维护,有的漏洞比较多,不完善,很美好的一个板子,但没有长久 的更新,非常的可惜。\r\n如果用别人的不好用,那我就做一个出来吧。喜欢的人多关注,适当时候放出来大家一起用。\r\n关于详情页的内容解析\r\n该模板自带一个特定语法的编辑器,当你把内容存储到数据库后,在页面读取后浏览,会发现诸如“表情、代码、图片”等无法解析,这是因为需要对该内容进行一次转义,通常来说这是在服务端完成的,但鉴于简单化,你还可以直接在前端去解析,在模板的detail.html中,我们已经把相关的代码写好了,你只需打开注释即可(在代码的最下面)。当然,如果觉得编辑器无法满足你的需求,你也可以把该编辑器换成别的HTML编辑器或MarkDown编辑器。', '1', '1', '1', '0', '0', '1', '12', '0', null, null, '0', null, null, null, '1546698225', '1577772362', '0'); DROP TABLE IF EXISTS `tao_auth_group`; CREATE TABLE `tao_auth_group` ( @@ -60,7 +64,7 @@ CREATE TABLE `tao_auth_group` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; INSERT INTO `tao_auth_group` VALUES ('1', '超级管理员', '5,15,21,22,62,63,23,17,27,28,64,16,24,26,25,4,20,32,33,34,14,29,30,31,1,65,6,35,36,37,38,7,39,40,41,42,8,43,44,45,66,9,47,48,49,50,46,67,2,10,51,11,18,52,54,55,19,56,57,58,59,60,53,3,12,13', '管理所有的管理员', '所有权限', '1', '0', '1578984825', '0'); INSERT INTO `tao_auth_group` VALUES ('2', '管理员', '5,15,21,22,62,63,23,17,27,28,64,16,24,26,25,1,65,6,35,36,37,38,67,3,12,13', '所有列表的管理', '普通管理员', '1', '0', '1578984832', '0'); @@ -101,11 +105,12 @@ CREATE TABLE `tao_auth_rule` ( `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=MyISAM AUTO_INCREMENT=68 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=77 DEFAULT CHARSET=utf8; INSERT INTO `tao_auth_rule` VALUES ('1', 'admin', '管理', '1', '1', '0', '0', 'layui-icon-user', '1', '3', '', '0', '0', '0'); INSERT INTO `tao_auth_rule` VALUES ('2', 'set', '设置', '1', '1', '0', '0', 'layui-icon-set', '1', '4', '', '0', '0', '0'); INSERT INTO `tao_auth_rule` VALUES ('3', 'administrator', '账户', '1', '1', '0', '0', 'layui-icon-username', '1', '5', '', '0', '1578980034', '0'); +INSERT INTO `tao_auth_rule` VALUES ('4', 'app', '应用', '1', '1', '0', '0', 'layui-icon-app', '1', '2', '', '0', '0', '0'); INSERT INTO `tao_auth_rule` VALUES ('5', 'article', '内容', '1', '1', '0', '0', 'layui-icon-read', '1', '0', '', '0', '1578902321', '0'); INSERT INTO `tao_auth_rule` VALUES ('6', 'admin/User/list', '用户管理', '1', '1', '1', '1', '', '1', '1', '', '0', '1578901015', '0'); INSERT INTO `tao_auth_rule` VALUES ('7', 'admin/Admin/index', '管理员', '1', '1', '1', '1', '', '1', '6', '', '0', '1578901133', '0'); @@ -159,7 +164,16 @@ INSERT INTO `tao_auth_rule` VALUES ('63', 'admin/Forum/hot', '加精帖子', '1' INSERT INTO `tao_auth_rule` VALUES ('64', 'admin/Froum/recheck', '审核评论', '1', '1', '5', '1', '', '0', '10', '', '0', '0', '0'); INSERT INTO `tao_auth_rule` VALUES ('65', 'admin/User/uploadImg', '上传用户头像', '1', '1', '1', '1', '', '0', '0', '', '0', '1578981624', '0'); INSERT INTO `tao_auth_rule` VALUES ('66', 'admin/AuthGroup/check', '审核角色', '1', '1', '1', '1', '', '0', '15', '', '0', '0', '0'); -INSERT INTO `tao_auth_rule` VALUES ('67', 'admin/User/auth', '设置超级用户', '1', '1', '1', '1', '', '0', '22', '', '1578984801', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('67', 'admin/Sign/signRule', '签到规则', '1', '1', '2', '1', '', '0', '15', '', '1585547595', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('68', 'admin/Sign/add', '添加签到', '1', '1', '2', '1', '', '0', '16', '', '1585547705', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('69', 'admin/Sign/signEdit', '编辑签到', '1', '1', '2', '1', '', '0', '17', '', '1585547774', '1585548298', '0'); +INSERT INTO `tao_auth_rule` VALUES ('70', 'admin/Sign/delete', '删除签到', '1', '1', '2', '1', '', '0', '18', '', '1585547817', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('71', 'admin/Vip/vipRule', '用户等级', '1', '1', '2', '1', '', '0', '19', '', '1585547921', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('72', 'admin/Vip/add', '添加vip等级', '1', '1', '2', '1', '', '0', '20', '', '1585547981', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('73', 'admin/Vip/vipEdit', '编辑vip等级', '1', '1', '1', '1', '', '0', '21', '', '1585548029', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('74', 'admin/Vip/delete', '删除vip等级', '1', '1', '2', '1', '', '0', '22', '', '1585548077', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('75', 'admin/Set/email', '邮箱设置', '1', '1', '2', '1', '', '0', '23', '', '1585548143', '0', '0'); +INSERT INTO `tao_auth_rule` VALUES ('76', 'admin/User/auth', '设置超级用户', '1', '1', '1', '1', '', '0', '22', '', '1578984801', '0', '0'); DROP TABLE IF EXISTS `tao_cate`; CREATE TABLE `tao_cate` ( @@ -175,7 +189,7 @@ CREATE TABLE `tao_cate` ( `updata_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; INSERT INTO `tao_cate` VALUES ('1', '提问', 'ask', '1', '1', '0', 'TaoLer社区提问专栏1', '0', '0', '0', '0'); INSERT INTO `tao_cate` VALUES ('2', '分享', 'share', '2', '1', '0', '', '0', '0', '0', '0'); @@ -190,7 +204,7 @@ CREATE TABLE `tao_collection` ( `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=149 DEFAULT CHARSET=utf8 COMMENT='文章收藏表'; +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='文章收藏表'; DROP TABLE IF EXISTS `tao_comment`; @@ -206,7 +220,7 @@ CREATE TABLE `tao_comment` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=79 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; INSERT INTO `tao_comment` VALUES ('1', 'https://www.aieok.com', '1', '1', '0', '0', '1', '1555127897', '1578977505', '1578977505'); @@ -229,14 +243,14 @@ DROP TABLE IF EXISTS `tao_message`; CREATE TABLE `tao_message` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '消息ID', `title` varchar(255) NOT NULL COMMENT '消息标题', - `content` tinytext NOT NULL COMMENT '消息内容', + `content` tinytext COMMENT '消息内容', `user_id` int(11) NOT NULL COMMENT '发送人ID', `link` varchar(255) NOT NULL COMMENT '链接', `create_time` int(11) NOT NULL COMMENT '创建时间', `update_time` int(11) NOT NULL COMMENT '更新时间', `delete_time` int(11) NOT NULL COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `tao_message_to`; CREATE TABLE `tao_message_to` ( @@ -249,7 +263,7 @@ CREATE TABLE `tao_message_to` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; DROP TABLE IF EXISTS `tao_slider`; @@ -267,7 +281,7 @@ CREATE TABLE `tao_slider` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; INSERT INTO `tao_slider` VALUES ('1', 'CODING', '1', '/storage/slider/F1.jpg', '#', '', '1574870400', '1575043200', '1', '0', '0', '0'); INSERT INTO `tao_slider` VALUES ('3', '通用右栏底部广告', '2', '/storage/slider/20200101/851c0b88a72590293bcb45454bdce056.jpg', 'http://www.aieok.com', '', '1571155200', '1609344000', '1', '0', '0', '0'); @@ -330,7 +344,7 @@ CREATE TABLE `tao_user` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=41 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; INSERT INTO `tao_user` VALUES ('1', 'admin', '95d6f8d0d0c3b45e5dbe4057da1b149e', '2147483647', 'admin@qq.com', '管理员', '北京市', '1', '这是我的第一个TP5系统,2019北京。OK! OK!ok@', 0x2F73746F726167652F686561645F7069632F32303139313231372F39343036636334623866336538323731613238616339646239353339333766352E6A7067, '1', '14', '1', '1', '0', '127.0.0.1', '0', '0', '0', '0', '1579053025', '1578469091', '0'); @@ -362,7 +376,7 @@ CREATE TABLE `tao_user_sign` ( `stime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签到的时间', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 COMMENT='用户签到表'; +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户签到表'; DROP TABLE IF EXISTS `tao_user_signrule`; @@ -374,7 +388,7 @@ CREATE TABLE `tao_user_signrule` ( `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '升级时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='用户签到积分规则'; +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户签到积分规则'; INSERT INTO `tao_user_signrule` VALUES ('1', '1', '2', '0', '0', '0'); INSERT INTO `tao_user_signrule` VALUES ('2', '3', '3', '0', '0', '0'); @@ -385,11 +399,18 @@ CREATE TABLE `tao_user_viprule` ( `id` int(2) NOT NULL AUTO_INCREMENT COMMENT '用户等级ID', `score` varchar(255) NOT NULL DEFAULT '0' COMMENT '积分区间', `vip` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'vip等级', + `nick` varchar(20) DEFAULT NULL COMMENT '认证昵称', + `rules` varchar(255) DEFAULT NULL COMMENT '权限', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '升级时间', `delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +INSERT INTO `tao_user_viprule` VALUES ('1', '0-99', '0', '游民', '', '1585476523', '1585544577', '0'); +INSERT INTO `tao_user_viprule` VALUES ('2', '100-299', '1', '富农', '', '1585476551', '1585546376', '0'); +INSERT INTO `tao_user_viprule` VALUES ('3', '300-500', '2', '地主', '', '1585545450', '1585546241', '0'); +INSERT INTO `tao_user_viprule` VALUES ('4', '501-699', '3', '土豪', '', '1585545542', '1585569657', '0'); DROP TABLE IF EXISTS `tao_user_zan`; CREATE TABLE `tao_user_zan` ( @@ -398,5 +419,5 @@ CREATE TABLE `tao_user_zan` ( `user_id` int(11) NOT NULL COMMENT '用户id', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '点赞时间', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; diff --git a/extend/taoler/com/Level.php b/extend/taoler/com/Level.php new file mode 100644 index 0000000..3893285 --- /dev/null +++ b/extend/taoler/com/Level.php @@ -0,0 +1,41 @@ +point; + $userLv = $user->vip; + + $vipLv = self::getLevel($score); + if($vipLv>$userLv){ + $result = User::update(['id'=>$uid,'vip'=>$vipLv]); + if($result){ + return true; + }else{ + return false; + } + } + } + + //根据积分获取用户vip等级 + public static function getLevel($point) + { + $vip = Db::name('user_viprule')->select(); + foreach($vip as $k => $v){ + $score = explode('-',$v['score']); + if($score[0] <= $point && $point <= $score[1]){ + return $v['vip']; + } + } + } + +} \ No newline at end of file diff --git a/public/static/admin/modules/webset.js b/public/static/admin/modules/webset.js new file mode 100644 index 0000000..ba1d4d3 --- /dev/null +++ b/public/static/admin/modules/webset.js @@ -0,0 +1,230 @@ +//网站后台综合设置 + +layui.define(['table', 'form'], function(exports){ + var $ = layui.$ + ,table = layui.table + ,form = layui.form; + + //签到规则 + table.render({ + elem: '#sign-rule', + url: '/admin/Sign/signRule', + limit: 5, + cols:[[ + {type: 'numbers', fixed: 'left'}, + {field: 'days',title: '天数'}, + {field: 'score',title: '积分'}, + {field: 'ctime',title: '时间'}, + {title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#sign-rule-button'} + + ]] + }); + + //监听工具条 + table.on('tool(sign-rule)', function(obj){ + var data = obj.data; + if(obj.event === 'del'){ + layer.prompt({ + formType: 1 + ,title: '敏感操作,请验证口令' + }, function(value, index){ + layer.close(index); + + layer.confirm('真的删除行么', function(index){ + //obj.del(); + $.ajax({ + type:'post', + url:"/admin/Sign/delete", + data:{id:data.id}, + dataType:'json', + success:function(data){ + if(data.code == 0){ + layer.msg(data.msg,{ + icon:6, + time:2000 + }); + } else { + layer.open({ + title:'删除失败', + content:data.msg, + icon:5, + adim:6 + }) + } + } + }); + table.reload('sign-rule'); + layer.close(index); + }); + }); + } else if(obj.event === 'edit'){ + var tr = $(obj.tr); + + layer.open({ + type: 2 + ,title: '编辑签到' + ,content: '/admin/Sign/signEdit?id='+ data.id + ,maxmin: true + ,area: ['350px', '300px'] + ,btn: ['确定', '取消'] + ,yes: function(index, layero){ + + var iframeWindow = window['layui-layer-iframe'+ index] + ,submitID = 'LAY-user-sign-submit' + ,submit = layero.find('iframe').contents().find('#'+ submitID); + + //监听提交 + iframeWindow.layui.form.on('submit('+ submitID +')', function(data){ + var field = data.field; //获取提交的字段 + + //提交 Ajax 成功后,静态更新表格中的数据 + $.ajax({ + type:"post", + url:"/admin/Sign/signEdit", + data:field, + daType:"json", + success:function (res){ + if (res.code == 0) { + layer.msg(res.msg,{ + icon:6, + time:2000 + }); + } else { + layer.open({ + tiele:'修改失败', + content:res.msg, + icon:5, + anim:6 + }); + } + } + }); + + table.reload('sign-rule'); //数据刷新 + layer.close(index); //关闭弹层 + }); + + submit.trigger('click'); + } + ,success: function(layero, index){ + + } + }); + } + }); + + + //Vip规则 + table.render({ + elem: '#vip-rule', + url: '/admin/Vip/vipRule', + limit: 5, + cols:[[ + {type: 'numbers', fixed: 'left'}, + {field: 'vip',title: '等级'}, + {field: 'score',title: '积分'}, + {field: 'nick',title: '认证'}, + {field: 'rules',title: '权限'}, + {field: 'ctime',title: '时间'}, + {title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#vip-rule-button'} + + ]] + }); + + //监听工具条 + table.on('tool(vip-rule)', function(obj){ + var data = obj.data; + if(obj.event === 'del'){ + layer.prompt({ + formType: 1 + ,title: '敏感操作,请验证口令' + }, function(value, index){ + layer.close(index); + + layer.confirm('真的删除行么', function(index){ + //obj.del(); + $.ajax({ + type:'post', + url:"/admin/Vip/delete", + data:{id:data.id}, + dataType:'json', + success:function(data){ + if(data.code == 0){ + layer.msg(data.msg,{ + icon:6, + time:2000 + }); + } else { + layer.open({ + title:'删除失败', + content:data.msg, + icon:5, + adim:6 + }) + } + } + }); + table.reload('vip-rule'); //数据刷新 + layer.close(index); + }); + }); + } else if(obj.event === 'edit'){ + var tr = $(obj.tr); + + layer.open({ + type: 2 + ,title: '编辑VIP' + ,content: '/admin/Vip/vipEdit?id='+ data.id + ,maxmin: true + ,area: ['400px', '370px'] + ,btn: ['确定', '取消'] + ,yes: function(index, layero){ + + var iframeWindow = window['layui-layer-iframe'+ index] + ,submitID = 'LAY-user-vip-submit' + ,submit = layero.find('iframe').contents().find('#'+ submitID); + + //监听提交 + iframeWindow.layui.form.on('submit('+ submitID +')', function(data){ + var field = data.field; //获取提交的字段 + + //提交 Ajax 成功后,静态更新表格中的数据 + $.ajax({ + type:"post", + url:"/admin/Vip/vipEdit", + data:field, + daType:"json", + success:function (res){ + if (res.code == 0) { + layer.msg(res.msg,{ + icon:6, + time:2000 + }); + } else { + layer.open({ + tiele:'修改失败', + content:res.msg, + icon:5, + anim:6 + }); + } + } + }); + + table.reload('vip-rule'); //数据刷新 + layer.close(index); //关闭弹层 + }); + + submit.trigger('click'); + } + ,success: function(layero, index){ + + } + }); + } + }); + + + + exports('webset', {}) +}); \ No newline at end of file diff --git a/view/admin/.gitignore b/view/admin/.gitignore index 1f7e4bf..79e6287 100644 --- a/view/admin/.gitignore +++ b/view/admin/.gitignore @@ -1,2 +1,3 @@ /keyauth +/time_line /version \ No newline at end of file diff --git a/view/admin/public/side_menu.html b/view/admin/public/side_menu.html index d2fe0a5..1f87468 100644 --- a/view/admin/public/side_menu.html +++ b/view/admin/public/side_menu.html @@ -13,7 +13,7 @@
- 控制台 + 控制台
diff --git a/view/admin/set/system/server.html b/view/admin/set/system/server.html index adf9f5c..a580d4a 100644 --- a/view/admin/set/system/server.html +++ b/view/admin/set/system/server.html @@ -9,11 +9,11 @@
@@ -115,7 +115,7 @@
- +
@@ -140,7 +140,6 @@
- {/block} {block name="js"} @@ -149,7 +148,7 @@ base: '/static/admin/' //静态资源所在路径 }).extend({ index: 'lib/index' //主入口模块 - }).use(['index', 'set','table','form'], function(){ + }).use(['index', 'set', 'webset', 'table', 'form'], function(){ var $ = layui.$ ,admin = layui.admin ,element = layui.element @@ -207,12 +206,11 @@ daType:"json", success:function (data){ if (data.code == 0) { - console.log(data); layer.msg(data.msg,{ icon:6, time:2000 }, function(){ - location.reload(); + table.reload('sign-rule'); //数据刷新 }); } else { layer.open({ @@ -227,7 +225,6 @@ return false; }); - //添加VIP规则 form.on('submit(vip-rule-submit)',function(data){ var field = data.field; @@ -238,12 +235,11 @@ daType:"json", success:function (data){ if (data.code == 0) { - console.log(data); layer.msg(data.msg,{ icon:6, time:2000 }, function(){ - location.reload(); + table.reload('vip-rule'); //数据刷新 }); } else { layer.open({ @@ -258,36 +254,6 @@ return false; }); - //签到规则 - table.render({ - elem: '#sign-rule', - url: '/admin/Sign/signRule', - limit: 5, - cols:[[ - {type: 'numbers', fixed: 'left'}, - {field: 'days',title: '天数'}, - {field: 'score',title: '积分',minWidth:100}, - {field: 'ctime',title: '时间',minWidth:100}, - {title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#sign-rule-button'} - - ]] - }); - //Vip规则 - table.render({ - elem: '#vip-rule', - url: '/admin/Vip/vipRule', - limit: 5, - cols:[[ - {type: 'numbers', fixed: 'left'}, - {field: 'score',title: '积分'}, - {field: 'vip',title: '等级',minWidth:100}, - {field: 'ctime',title: '时间',minWidth:100}, - {title: '操作', width: 150, align:'center', fixed: 'right', toolbar: '#vip-rule-button'} - - ]] - }); - - }); {/block} diff --git a/view/admin/set/system/signedit.html b/view/admin/set/system/signedit.html new file mode 100644 index 0000000..db3d3b1 --- /dev/null +++ b/view/admin/set/system/signedit.html @@ -0,0 +1,38 @@ +{extend name="public/base" /} + +{block name="body"} + +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +{/block} +{block name="js"} + +{/block} \ No newline at end of file diff --git a/view/admin/set/system/vipedit.html b/view/admin/set/system/vipedit.html new file mode 100644 index 0000000..1c68013 --- /dev/null +++ b/view/admin/set/system/vipedit.html @@ -0,0 +1,54 @@ +{extend name="public/base" /} + +{block name="body"} + +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +{/block} +{block name="js"} + +{/block} \ No newline at end of file diff --git a/view/index/article/cate.html b/view/index/article/cate.html index 580dff2..cba51e8 100644 --- a/view/index/article/cate.html +++ b/view/index/article/cate.html @@ -27,8 +27,10 @@ {$art.user.nickname ?: $art.user.name} + {if($art.user.vip > 0)} + VIP{$art.user.vip} + {/if} {$art.create_time|date='Y-m-d'} diff --git a/view/index/article/detail.html b/view/index/article/detail.html index 2ceafc0..e551c89 100644 --- a/view/index/article/detail.html +++ b/view/index/article/detail.html @@ -56,7 +56,9 @@ {:getAsing($article.user.area_id) ?: '无'} {$article.user.nickname ?: $article.user.name} - + {if($article.user.vip > 0)} + VIP{$article.user.vip} + {/if} {$article.create_time|date='Y-m-d H:d'}
diff --git a/view/index/index/index.html b/view/index/index/index.html index 5cc66a7..bb01588 100644 --- a/view/index/index/index.html +++ b/view/index/index/index.html @@ -45,7 +45,9 @@ {:getAsing($top.user.area_id) ?: '无'} {$top.user.nickname ?: $top.user.name} - + {if($top.user.vip > 0)} + VIP{$top.user.vip} + {/if} {$top.create_time|date='Y-m-d'} @@ -82,8 +84,10 @@ {$art.user.nickname ?: $art.user.name} + {if($art.user.vip > 0)} + VIP{$art.user.vip} + {/if} {$art.create_time|date='Y-m-d'} @@ -117,7 +121,7 @@
程序下载
-
应用说明
+
应用说明
申请Key
@@ -126,7 +130,7 @@
Git 仓库
-
模板
+
版本更新日志
关于积分
diff --git a/view/index/public/header.html b/view/index/public/header.html index aedea51..c6540a8 100644 --- a/view/index/public/header.html +++ b/view/index/public/header.html @@ -26,7 +26,7 @@ {:session('user_name')} - VIP3 + VIP{$user.vip} diff --git a/view/index/user/index.html b/view/index/user/index.html index 11b6b68..8e261ac 100644 --- a/view/index/user/index.html +++ b/view/index/user/index.html @@ -25,7 +25,7 @@
我的会员信息
-

您的财富经验值:{$user.point} 金币

您当前为:非 VIP

+

您的财富经验值:{$user.point} 金币

您当前为:VIP{$user.vip}

快捷方式