From ab361640346ea5e6c96d1ec5aeab276aa30ebf83 Mon Sep 17 00:00:00 2001
From: toogee <changlin_zhao@qq.com>
Date: Sun, 29 Mar 2020 19:57:18 +0800
Subject: [PATCH] sign scroe vip

---
 app/admin/controller/Set.php      |  16 +-
 app/admin/controller/Sign.php     |  47 +++++
 app/admin/controller/Vip.php      |  46 +++++
 app/api/controller/Message.php    |   2 +-
 app/common/model/UserSignrule.php |  24 +++
 app/common/model/UserViprule.php  |  24 +++
 app/index/controller/Article.php  |   3 +-
 app/index/controller/Message.php  |   4 +-
 app/index/controller/Sign.php     |   5 +-
 app/index/controller/User.php     |   2 +-
 app/install/data/taoler.sql       |  23 ++-
 extend/taoler/com/Message.php     |  37 ++++
 public/static/res/mods/user.js    |   2 +-
 view/admin/set/system/email.html  |  66 -------
 view/admin/set/system/server.html | 293 ++++++++++++++++++++++++++++++
 view/index/login/login.html       |   2 +-
 view/index/user/message.html      |  41 +----
 17 files changed, 518 insertions(+), 119 deletions(-)
 create mode 100644 app/admin/controller/Sign.php
 create mode 100644 app/admin/controller/Vip.php
 create mode 100644 app/common/model/UserSignrule.php
 create mode 100644 app/common/model/UserViprule.php
 create mode 100644 extend/taoler/com/Message.php
 delete mode 100644 view/admin/set/system/email.html
 create mode 100644 view/admin/set/system/server.html

diff --git a/app/admin/controller/Set.php b/app/admin/controller/Set.php
index 38d3653..37c736b 100644
--- a/app/admin/controller/Set.php
+++ b/app/admin/controller/Set.php
@@ -42,21 +42,23 @@ class Set extends AdminController
         View::assign(['sysInfo'=>$sysInfo,'syscy'=>$syscy]);
 		return View::fetch('set/system/website');
     }
+	
+	//综合设置
+	public function server()
+	{
+		 return $this->email();
+	}
 
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
+    /**邮箱设置
+     * parem $id
      */
     public function email()
     {
-		//$mailserver = Db::name('mail_server')->find(1);
 		$mailserver = MailServer::find(1);
         //邮箱配置
 		if(Request::isAjax()){
 			$data = Request::param();
 			$res = $mailserver->save($data);
-			//dump($data);
 			if($res){
 				return json(['code'=>0,'msg'=>'更新成功']);
 			} else {
@@ -65,7 +67,7 @@ class Set extends AdminController
 		}
 		
 		View::assign('mailserver',$mailserver);
-		return View::fetch('set/system/email');
+		return View::fetch('set/system/server');
     }
 
     /**
diff --git a/app/admin/controller/Sign.php b/app/admin/controller/Sign.php
new file mode 100644
index 0000000..116b35a
--- /dev/null
+++ b/app/admin/controller/Sign.php
@@ -0,0 +1,47 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\controller\BaseController;
+use think\facade\View;
+use think\facade\Request;
+use think\facade\Db;
+use app\common\model\UserSignrule;
+
+class Sign extends BaseController
+{
+
+	public function add()
+	{
+		$data = Request::only(['days','score']);
+		$day = UserSignrule::where('days',$data['days'])->find();
+		//$day = Db::name('user_signrule')->where('days',$data['days'])->find();
+		if($day){
+			$res = ['code'=>-1,'msg'=>'不能重复设置'];
+		} else {
+			$result = UserSignrule::create($data);
+			if($result){
+				$res = ['code'=>0,'msg'=>'设置积分成功'];
+			} else {
+				$res = ['code'=>-1,'msg'=>'保存失败'];
+			}
+		}
+		return json($res);
+	}
+	
+	public function signRule()
+	{
+		$keys = UserSignrule::select();
+		$count = $keys->count();
+		$res = [];
+		if($count){
+			$res = ['code'=>0,'msg'=>'','count'=>$count];
+			foreach($keys as $k=>$v){
+				$res['data'][] = ['id'=>$v['id'],'days'=>$v['days'],'score'=>$v['score'],'ctime'=>$v['create_time']];
+			}  
+		} else {
+				$res = ['code'=>-1,'msg'=>'还没有任何积分设置!'];
+			}
+		return json($res);	
+	}
+
+}
\ No newline at end of file
diff --git a/app/admin/controller/Vip.php b/app/admin/controller/Vip.php
new file mode 100644
index 0000000..2ac9924
--- /dev/null
+++ b/app/admin/controller/Vip.php
@@ -0,0 +1,46 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\controller\BaseController;
+use think\facade\View;
+use think\facade\Request;
+use think\facade\Db;
+use app\common\model\UserViprule;
+
+class Vip extends BaseController
+{
+
+	public function add()
+	{
+		$data = Request::only(['score','vip']);
+		$vip = UserViprule::where('vip',$data['vip'])->find();
+		if($vip){
+			$res = ['code'=>-1,'msg'=>'vip等级不能重复设置'];
+		} else {
+			$result = UserViprule::create($data);
+			if($result){
+				$res = ['code'=>0,'msg'=>'设置vip等级成功'];
+			} else {
+				$res = ['code'=>-1,'msg'=>'vip保存失败'];
+			}
+		}
+		return json($res);
+	}
+	
+	public function vipRule()
+	{
+		$keys = UserViprule::select();
+		$count = $keys->count();
+		$res = [];
+		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']];
+			}  
+		} else {
+				$res = ['code'=>-1,'msg'=>'还没有任何vip等级设置!'];
+			}
+		return json($res);	
+	}
+
+}
\ No newline at end of file
diff --git a/app/api/controller/Message.php b/app/api/controller/Message.php
index 08e39ac..9d1462d 100644
--- a/app/api/controller/Message.php
+++ b/app/api/controller/Message.php
@@ -28,7 +28,7 @@ class Message
 		->alias('t')
 		->join('message m','t.message_id = m.id' )
 		->join('user u','t.send_id = u.id')
-		->field('t.id as id,name,title,link,receve_id,t.create_time as create_time')
+		->field('t.id as id,name,title,link,receve_id,t.create_time as create_time,is_read')
 		->where('t.receve_id',$uid)
 		->where('t.delete_time',0)
 		->select();
diff --git a/app/common/model/UserSignrule.php b/app/common/model/UserSignrule.php
new file mode 100644
index 0000000..497ac26
--- /dev/null
+++ b/app/common/model/UserSignrule.php
@@ -0,0 +1,24 @@
+<?php
+namespace app\common\model;
+
+use think\Model;
+use think\model\concern\SoftDelete;
+
+class UserSignrule extends Model
+{
+	protected $autoWriteTimestamp = true; //开启自动时间戳
+    protected $createTime = 'create_time';
+    
+	
+	//软删除
+	use SoftDelete;
+	protected $deleteTime = 'delete_time';
+	protected $defaultSoftDelete = 0;
+	
+	public function user()
+	{
+		//评论关联用户
+		return $this->belongsTo('User','user_id','id');
+	}
+	
+}
\ No newline at end of file
diff --git a/app/common/model/UserViprule.php b/app/common/model/UserViprule.php
new file mode 100644
index 0000000..57a4fef
--- /dev/null
+++ b/app/common/model/UserViprule.php
@@ -0,0 +1,24 @@
+<?php
+namespace app\common\model;
+
+use think\Model;
+use think\model\concern\SoftDelete;
+
+class UserViprule extends Model
+{
+	protected $autoWriteTimestamp = true; //开启自动时间戳
+    protected $createTime = 'create_time';
+    
+	
+	//软删除
+	use SoftDelete;
+	protected $deleteTime = 'delete_time';
+	protected $defaultSoftDelete = 0;
+	
+	public function user()
+	{
+		//评论关联用户
+		return $this->belongsTo('User','user_id','id');
+	}
+	
+}
\ No newline at end of file
diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php
index 9a66140..74562f2 100644
--- a/app/index/controller/Article.php
+++ b/app/index/controller/Article.php
@@ -11,10 +11,9 @@ use app\common\model\User;
 use app\common\model\Comment;
 use app\common\model\Collection;
 use app\common\model\Article as ArticleModel;
-use app\facade\Message;
 use think\exception\ValidateException;
 use think\facade\Config;
-
+use taoler\com\Message;
 
 class Article extends BaseController
 {
diff --git a/app/index/controller/Message.php b/app/index/controller/Message.php
index ff82fed..fadf935 100644
--- a/app/index/controller/Message.php
+++ b/app/index/controller/Message.php
@@ -5,7 +5,7 @@ use app\common\controller\BaseController;
 use think\facade\Session;
 use think\facade\Request;
 use think\facade\Db;
-use app\facade\Message as MessageApi;
+use taoler\com\Message as MessageApi;
 
 class Message extends BaseController
 {
@@ -33,7 +33,7 @@ class Message extends BaseController
 		if($count){
 			$res = ['status'=>0,'msg'=>'','count'=>$count];
 			foreach ($msg as $k => $v){
-			$data = ['id'=>$v['id'],'name'=>$v['name'],'content'=>$v['title'],'time'=>date("Y-m-d H:i",$v['create_time']),'link'=>$v['link']];
+			$data = ['id'=>$v['id'],'name'=>$v['name'],'content'=>$v['title'],'time'=>date("Y-m-d H:i",$v['create_time']),'link'=>$v['link'],'read'=>$v['is_read'] ? '已读':'未读'];
 			$res['rows'][] = $data;
 			}
 		} else {
diff --git a/app/index/controller/Sign.php b/app/index/controller/Sign.php
index 496b14a..6155dc4 100644
--- a/app/index/controller/Sign.php
+++ b/app/index/controller/Sign.php
@@ -45,14 +45,15 @@ class Sign extends BaseController
     public function sign()
     {
         if (!Session::has('user_id') || !Session::has('user_name')) {
-            return json(array('code' => 0, 'msg' => '亲,登陆后才能签到哦','url' => 'index/login/index'));
+            return json(array('code' => 0, 'msg' => '亲,登陆后才能签到哦','url' => url('Login/index')));
         } else {
             $uid = session('user_id');
 			$todayData = $this->todayData()->getData();    
 			//var_dump($todayData);
 
             if ($todayData['is_sign'] == 1) { //数组中是返回的是一个对象,不能直接用[]来显示,正确的输出方法是:$pic[0]->title问题解决!
-                exit('{"code":-1,"msg":"你今天已经签过到了"}');
+                //exit('{"code":-1,"msg":"你今天已经签过到了"}');
+				return json(['code'=>-1,'msg'=>'你今天已签过到!']);
             } else {
                 $data = $this->getInsertData($uid);
 
diff --git a/app/index/controller/User.php b/app/index/controller/User.php
index 311b591..3525a69 100644
--- a/app/index/controller/User.php
+++ b/app/index/controller/User.php
@@ -13,7 +13,7 @@ use app\common\model\Article;
 use app\common\model\Collection;
 use app\common\model\User as userModel;
 use think\facade\Config;
-use app\facade\Message;
+use taoler\com\Message;
 
 class User extends BaseController
 {	
diff --git a/app/install/data/taoler.sql b/app/install/data/taoler.sql
index 0c292ff..29c9869 100644
--- a/app/install/data/taoler.sql
+++ b/app/install/data/taoler.sql
@@ -112,7 +112,7 @@ INSERT INTO `tao_auth_rule` VALUES ('7', 'admin/Admin/index', '管理员', '1',
 INSERT INTO `tao_auth_rule` VALUES ('8', 'admin/AuthGroup/list', '角色管理', '1', '1', '1', '1', '', '1', '11', '', '0', '1578901282', '0');
 INSERT INTO `tao_auth_rule` VALUES ('9', 'admin/AuthRule/index', '权限管理', '1', '1', '1', '1', '', '1', '16', '', '0', '1578981541', '0');
 INSERT INTO `tao_auth_rule` VALUES ('10', 'admin/set/website', '网站设置', '1', '1', '2', '1', '', '1', '1', '', '0', '0', '0');
-INSERT INTO `tao_auth_rule` VALUES ('11', 'admin/set/email', '邮件服务', '1', '1', '2', '1', '', '1', '3', '', '0', '0', '0');
+INSERT INTO `tao_auth_rule` VALUES ('11', 'admin/set/server', '综合服务', '1', '1', '2', '1', '', '1', '3', '', '0', '0', '0');
 INSERT INTO `tao_auth_rule` VALUES ('12', 'admin/Admin/info', '基本资料', '1', '1', '3', '1', '', '1', '50', '', '0', '1578980034', '0');
 INSERT INTO `tao_auth_rule` VALUES ('13', 'admin/Admin/repass', '修改密码', '1', '1', '3', '1', '', '1', '51', '', '0', '1578980034', '0');
 INSERT INTO `tao_auth_rule` VALUES ('15', 'admin/Forum/list', '帖子管理', '1', '1', '5', '1', '', '1', '1', '', '0', '1578902605', '0');
@@ -370,13 +370,26 @@ CREATE TABLE `tao_user_signrule` (
   `id` int(2) unsigned NOT NULL AUTO_INCREMENT,
   `days` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '连续天数',
   `score` int(3) unsigned NOT NULL DEFAULT '0' 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=13 DEFAULT CHARSET=utf8 COMMENT='用户签到积分规则';
+) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT='用户签到积分规则';
 
-INSERT INTO `tao_user_signrule` VALUES ('1', '1', '2');
-INSERT INTO `tao_user_signrule` VALUES ('2', '3', '3');
-INSERT INTO `tao_user_signrule` VALUES ('3', '5', '5');
+INSERT INTO `tao_user_signrule` VALUES ('1', '1', '2', '0', '0', '0');
+INSERT INTO `tao_user_signrule` VALUES ('2', '3', '3', '0', '0', '0');
+INSERT INTO `tao_user_signrule` VALUES ('3', '5', '5', '0', '0', '0');
 
+DROP TABLE IF EXISTS `tao_user_viprule`;
+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等级',
+  `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;
 
 DROP TABLE IF EXISTS `tao_user_zan`;
 CREATE TABLE `tao_user_zan` (
diff --git a/extend/taoler/com/Message.php b/extend/taoler/com/Message.php
new file mode 100644
index 0000000..54d1b6d
--- /dev/null
+++ b/extend/taoler/com/Message.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace taoler\com;
+
+use think\facade\Db;
+use app\common\model\Message as MessageModel;
+use app\common\model\MessageTo;
+
+class Message
+{	
+	//send msg
+	public static function sendMsg($sendId,$receveId,$data)
+	{
+		$msg = MessageModel::create($data);
+		$msgId = $msg->id;
+		$result = MessageTo::create(['send_id'=>$sendId,'receve_id'=>$receveId,'message_id'=>$msgId]);
+		if($result){
+			return true;
+		}
+    }
+	
+	//receve msg
+	public static function receveMsg($uid)
+	{
+		 $msg = Db::name('message_to')
+		->alias('t')
+		->join('message m','t.message_id = m.id' )
+		->join('user u','t.send_id = u.id')
+		->field('t.id as id,name,title,link,receve_id,t.create_time as create_time,is_read')
+		->where('t.receve_id',$uid)
+		->where(['t.delete_time'=>0])
+		->order(['t.create_time'=>'desc'])
+		->select();
+		return $msg;
+    }
+
+}
\ No newline at end of file
diff --git a/public/static/res/mods/user.js b/public/static/res/mods/user.js
index e6a2776..b63abfe 100644
--- a/public/static/res/mods/user.js
+++ b/public/static/res/mods/user.js
@@ -308,7 +308,7 @@ layui.define(['laypage', 'fly', 'element', 'flow'], function(exports){
       <ul class="mine-msg">\
       {{# for(var i = 0; i < len; i++){ }}\
         <li data-id="{{d.rows[i].id}}">\
-          <blockquote class="layui-elem-quote"><a href="/index/jump?name={{ d.rows[i].name}}" target="_blank"><cite>{{ d.rows[i].name}}</cite></a>回答了您的求解<a target="_blank" name="title" id-data="{{ d.rows[i].id}}" href="{{ d.rows[i].link}}"><cite>{{ d.rows[i].content}}</cite></a></blockquote>\
+          <blockquote class="layui-elem-quote"><a href="/index/jump?name={{ d.rows[i].name}}" target="_blank"><cite>{{ d.rows[i].name}}</cite></a>回答了您的帖子<a target="_blank" class="art-title" id-data="{{ d.rows[i].id}}" href="{{ d.rows[i].link}}"><cite>{{ d.rows[i].content}}</cite></a> <span class="float:right">{{ d.rows[i].read}}</span></blockquote>\
           <p><span>{{d.rows[i].time}}</span><a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger fly-delete">删除</a></p>\
         </li>\
       {{# } }}\
diff --git a/view/admin/set/system/email.html b/view/admin/set/system/email.html
deleted file mode 100644
index 4caa547..0000000
--- a/view/admin/set/system/email.html
+++ /dev/null
@@ -1,66 +0,0 @@
-{extend name="public/base" /}
-
-{block name="body"}
-  <div class="layui-fluid">
-    <div class="layui-row layui-col-space15">
-      <div class="layui-col-md12">
-        <div class="layui-card">
-          <div class="layui-card-header">邮件服务</div>
-          <div class="layui-card-body">
-            
-            <div class="layui-form" wid100 lay-filter="">
-              <div class="layui-form-item">
-                <label class="layui-form-label">SMTP服务器</label>
-                <div class="layui-input-inline">
-                  <input type="text" name="host" value="{$mailserver.host}" class="layui-input">
-                </div>
-                <div class="layui-form-mid layui-word-aux">如:smtp.163.com</div>
-              </div>
-              <div class="layui-form-item">
-                <label class="layui-form-label">SMTP端口号</label>
-                <div class="layui-input-inline" style="width: 80px;">
-                  <input type="text" name="port" lay-verify="number" value="{$mailserver.port}" class="layui-input">
-                </div>
-                <div class="layui-form-mid layui-word-aux">一般为 25 或 465</div>
-              </div>
-              <div class="layui-form-item">
-                <label class="layui-form-label">发件人邮箱</label>
-                <div class="layui-input-inline">
-                  <input type="text" name="mail" value="{$mailserver.mail}" lay-verify="email" autocomplete="off" class="layui-input">
-                </div>
-              </div>
-              <div class="layui-form-item">
-                <label class="layui-form-label">发件人昵称</label>
-                <div class="layui-input-inline">
-                  <input type="text" name="nickname" value="{$mailserver.nickname}" autocomplete="off" class="layui-input">
-                </div>
-              </div>
-              <div class="layui-form-item">
-                <label class="layui-form-label">邮箱登入密码</label>
-                <div class="layui-input-inline">
-                  <input type="password" name="password" value="{$mailserver.password}" autocomplete="off" class="layui-input">
-                </div>
-              </div>
-              <div class="layui-form-item">
-                <div class="layui-input-block">
-                  <button class="layui-btn" lay-submit lay-filter="set_system_email">确认保存</button>
-                </div>
-              </div>
-            </div>
-            
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-  
-{/block}
-{block name="js"}
-  <script>
-  layui.config({
-    base: '/static/admin/' //静态资源所在路径
-  }).extend({
-    index: 'lib/index' //主入口模块
-  }).use(['index', 'set']);
-  </script>
-{/block}
\ No newline at end of file
diff --git a/view/admin/set/system/server.html b/view/admin/set/system/server.html
new file mode 100644
index 0000000..adf9f5c
--- /dev/null
+++ b/view/admin/set/system/server.html
@@ -0,0 +1,293 @@
+{extend name="public/base" /}
+
+{block name="body"}
+  <div class="layui-fluid" id="component-tabs">
+    <div class="layui-row">
+      <div class="layui-col-md12">
+        <div class="layui-card">
+          <!--div class="layui-card-header">简洁风格</div-->
+          <div class="layui-card-body">
+            <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
+              <ul class="layui-tab-title">
+                <li class="layui-this">邮件设置</li>
+                <li>积分设置</li>
+                <li>用户等级</li>
+                <li>商品管理</li>
+                <li>订单管理</li>
+              </ul>
+              <div class="layui-tab-content">
+                <div class="layui-tab-item layui-show">
+					<div class="layui-form" wid100 lay-filter="">
+					  <div class="layui-form-item">
+						<label class="layui-form-label">SMTP服务器</label>
+						<div class="layui-input-inline">
+						  <input type="text" name="host" value="{$mailserver.host}" class="layui-input">
+						</div>
+						<div class="layui-form-mid layui-word-aux">如:smtp.163.com</div>
+					  </div>
+					  <div class="layui-form-item">
+						<label class="layui-form-label">SMTP端口号</label>
+						<div class="layui-input-inline" style="width: 80px;">
+						  <input type="text" name="port" lay-verify="number" value="{$mailserver.port}" class="layui-input">
+						</div>
+						<div class="layui-form-mid layui-word-aux">一般为 25 或 465</div>
+					  </div>
+					  <div class="layui-form-item">
+						<label class="layui-form-label">发件人邮箱</label>
+						<div class="layui-input-inline">
+						  <input type="text" name="mail" value="{$mailserver.mail}" lay-verify="email" autocomplete="off" class="layui-input">
+						</div>
+					  </div>
+					  <div class="layui-form-item">
+						<label class="layui-form-label">发件人昵称</label>
+						<div class="layui-input-inline">
+						  <input type="text" name="nickname" value="{$mailserver.nickname}" autocomplete="off" class="layui-input">
+						</div>
+					  </div>
+					  <div class="layui-form-item">
+						<label class="layui-form-label">邮箱登入密码</label>
+						<div class="layui-input-inline">
+						  <input type="password" name="password" value="{$mailserver.password}" autocomplete="off" class="layui-input">
+						</div>
+					  </div>
+					  <div class="layui-form-item">
+						<div class="layui-input-block">
+						  <button class="layui-btn" lay-submit lay-filter="set_system_email">确认保存</button>
+						</div>
+					  </div>
+					</div>
+                </div>
+                <div class="layui-tab-item">
+					<div class="layui-tab-content" style="padding: 20px 0;">
+						<div class="layui-form layui-card-header layuiadmin-card-header-auto">
+
+							<div class="layui-form-item">
+								<div class="layui-inline">
+								  <label class="layui-form-label">连续签到</label>
+									<div class="layui-input-inline" style="width: 90px;">
+										<select name="days">
+										  <option value="1">1天</option>
+										  <option value="2">2天</option>
+										  <option value="3">3天</option>
+										  <option value="5">5天</option>
+										  <option value="7">7天</option>
+										  <option value="10">10天</option>
+										  <option value="20">20天</option>
+										  <option value="100">100天</option>
+										  <option value="365">365天</option>
+										</select>
+									</div>
+									<div class="layui-input-inline">
+										<input type="tel" name="score" lay-verify="required" placeholder="获得积分" autocomplete="off" class="layui-input">
+									</div>
+									<div class="layui-input-inline">
+									<input type="submit" class="layui-btn" lay-submit lay-filter="sign-rule-submit" id="sign-rule-submit" value="立即提交">
+									</div>
+								</div>	
+							</div>
+							<div class="layui-form-item">
+							 <table id="sign-rule" lay-filter="sign-rule"></table>
+							 <script type="text/html" id="sign-rule-button">
+							 <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+							 <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+							 </script>
+							</div>	
+						</div>	 
+					</div>
+					
+				</div>
+                <div class="layui-tab-item">
+					<div class="layui-tab-content" style="padding: 20px 0;">
+						<div class="layui-form layui-card-header layuiadmin-card-header-auto">
+
+							<div class="layui-form-item">
+								<div class="layui-inline">
+								  <label class="layui-form-label">用户积分</label>
+									<div class="layui-input-inline" style="width: 120px;">
+										<select name="vip">
+										  <option value="0">普通</option>
+										  <option value="1">VIP1</option>
+										  <option value="2">VIP2</option>
+										  <option value="3">VIP3</option>
+										  <option value="4">VIP4</option>
+										  <option value="5">VIP5</option>
+										  
+										</select>
+									</div>
+									<div class="layui-input-inline">
+										<input type="tel" name="score" lay-verify="required" placeholder="积分区间" autocomplete="off" class="layui-input">
+									</div>
+									<div class="layui-input-inline">
+									<input type="submit" class="layui-btn" lay-submit lay-filter="vip-rule-submit" id="vip-rule-submit" value="立即提交">
+									</div>
+								</div>	
+							</div>
+							<div class="layui-form-item">
+							 <table id="vip-rule" lay-filter="vip-rule"></table>
+							 <script type="text/html" id="vip-rule-button">
+							 <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
+							 <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
+							 </script>
+							</div>	
+						</div>	 
+					</div>
+				</div>
+                <div class="layui-tab-item">内容4</div>
+                <div class="layui-tab-item">内容5</div>
+              </div>
+            </div>
+          </div>
+        </div>
+     </div>
+  </div>
+
+  
+{/block}
+{block name="js"} 
+  <script>
+  layui.config({
+    base: '/static/admin/' //静态资源所在路径
+  }).extend({
+    index: 'lib/index' //主入口模块
+  }).use(['index', 'set','table','form'], function(){
+    var $ = layui.$
+    ,admin = layui.admin
+    ,element = layui.element
+	,table = layui.table
+	,form = layui.form
+    ,router = layui.router();
+
+    element.render();
+    
+    element.on('tab(component-tabs-brief)', function(obj){
+      layer.msg(obj.index + ':' + this.innerHTML);
+    });
+    
+    /* 触发事件 */
+    var active = {
+      tabAdd: function(){
+        /* 新增一个Tab项 */
+        element.tabAdd('demo', {
+          title: '新选项'+ (Math.random()*1000|0) /* 用于演示 */
+          ,content: '内容'+ (Math.random()*1000|0)
+          ,id: new Date().getTime() /* 实际使用一般是规定好的id,这里以时间戳模拟下 */
+        })
+      }
+      ,tabDelete: function(othis){
+        /* 删除指定Tab项 */
+        element.tabDelete('demo', '22');
+        othis.addClass('layui-btn-disabled');
+      }
+      ,tabChange: function(){
+        /* 切换到指定Tab项 */
+        element.tabChange('demo', '33');
+      }
+    };
+    
+    $('#component-tabs .site-demo-active').on('click', function(){
+      var othis = $(this), type = othis.data('type');
+      active[type] ? active[type].call(this, othis) : '';
+    });
+    
+    /* Hash地址的定位 */
+    var layid = router.hash.replace(/^#layid=/, '');
+    layid && element.tabChange('component-tabs-hash', layid);
+    
+    element.on('tab(component-tabs-hash)', function(elem){
+      location.hash = '/'+ layui.router().path.join('/') + '#layid=' + $(this).attr('lay-id');
+    });
+	
+	//添加签到规则
+	form.on('submit(sign-rule-submit)',function(data){
+			var field = data.field;
+				$.ajax({
+					type:"post",
+					url:"{:url('admin/Sign/add')}",
+					data:field,
+					daType:"json",
+					success:function (data){
+							if (data.code == 0) {
+							console.log(data);
+								layer.msg(data.msg,{
+									icon:6,
+									time:2000
+								}, function(){
+								location.reload();
+								});
+							} else {
+								layer.open({
+									tiele:'添加失败',
+									content:data.msg,
+									icon:5,
+									anim:6
+								});
+							}
+						}
+				});
+			return false;
+		});
+	
+	
+	//添加VIP规则
+	form.on('submit(vip-rule-submit)',function(data){
+			var field = data.field;
+				$.ajax({
+					type:"post",
+					url:"{:url('admin/Vip/add')}",
+					data:field,
+					daType:"json",
+					success:function (data){
+							if (data.code == 0) {
+							console.log(data);
+								layer.msg(data.msg,{
+									icon:6,
+									time:2000
+								}, function(){
+								location.reload();
+								});
+							} else {
+								layer.open({
+									tiele:'添加失败',
+									content:data.msg,
+									icon:5,
+									anim: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'}
+				
+			]]
+		});
+	
+	
+  });
+  </script>
+{/block}
diff --git a/view/index/login/login.html b/view/index/login/login.html
index 244a929..5bf4635 100644
--- a/view/index/login/login.html
+++ b/view/index/login/login.html
@@ -93,7 +93,7 @@ $(function() {
     layui.cache.page = 'user';
     layui.cache.user = {
         username: '{$user.name??'游客'}'
-        ,uid: {$user.id ? 168*$user.id : -1}
+        ,uid: {$user.id ? $user.id : -1}
         ,avatar: '{if condition="$user['user_img'] neq ''"}{$user['user_img']}{else /}/static/res/images/avatar/00.jpg{/if}'
         ,experience: 83
         ,sex: '{if condition="$user['sex'] eq 0"}男{else/}女{/if}'
diff --git a/view/index/user/message.html b/view/index/user/message.html
index 442005b..362a09f 100644
--- a/view/index/user/message.html
+++ b/view/index/user/message.html
@@ -3,26 +3,7 @@
 {block name="content"}
 	<div class="layui-tab layui-tab-brief" lay-filter="user" id="LAY_msg" style="margin-top: 15px;">
 	    <button class="layui-btn layui-btn-danger" id="LAY_delallmsg">清空全部消息</button>
-	    <div id="LAY_minemsg" style="margin-top: 10px;"></div>
-		<!--div  id="LAY_minemsg1" style="margin-top: 10px;">
-        <ul class="mine-msg">
-		{volist name="msg" id="vo"}
-		<li data-id="{$vo.id}">
-            <blockquote class="layui-elem-quote">
-              <a href="/index/jump?name={$vo.name}" target="_blank"><cite>{$vo.name}</cite></a>回答了您的求解<a target="_blank" name="title" id-data="{$vo.id}" href="{$vo.link}"><cite>{$vo.title}</cite></a>
-            </blockquote>
-            <p><span>{$vo.create_time|date='Y-m-d H:i'}</span><a href="javascript:;" class="layui-btn layui-btn-small layui-btn-danger fly-delete">删除</a></p>
-          </li>
-		{/volist}
-          <li data-id="123">
-            <blockquote class="layui-elem-quote">
-              系统消息:欢迎使用 layui
-            </blockquote>
-            <p><span>1小时前</span><a href="javascript:;" class="layui-btn layui-btn-small layui-btn-danger fly-delete">删除</a></p>
-          </li>
-        </ul>
-      </div-->
-		
+	    <div id="LAY_minemsg" style="margin-top: 10px;"></div>		
 	</div>
 {/block}
 {block name="script"}
@@ -42,23 +23,21 @@
         fly: 'index'
     }).use('fly');
 	//
-	$('a[name=title]').on('click','a', function(){
+	$('#LAY_minemsg').on('click','.art-title', function(){
 		var id = $(this).attr('id-data');
-		console.log('11111');
+		var othis = $(this);
+		console.log(othis);
 		$.ajax({
 				type:"post",
 				url:"{:url('message/read')}",
 				data:{"id":id},
 				daType:"json",
-				success:function (data){
-					if (data.status == 0) {
-						layer.msg(data.msg,{
-							icon:6,
-							time:2000
-						}, function(){
-							location.reload();
-						});
-					}
+				success:function (res){
+				if(res.status == 0){
+				location.reload();
+				//othis.append('<span class="float:right">已读</span>');
+				}
+				
 				}
 			 });
 	});