Browse Source

录方后台

pull/1/head
pengda 8 months ago
parent
commit
435c7d48c9
  1. 7
      config/define.php
  2. 27
      control/index.php
  3. 2
      model/mFormula.php
  4. 2
      model/mPage.php
  5. 11
      model/mUser.php
  6. 2
      view/templates/index/home.html
  7. 64
      view/templates/index/login.html

7
config/define.php

@ -51,10 +51,13 @@
//后台账号密码缓存 //后台账号密码缓存
define('_QR_ADMIN_USER_INFO', '_rq_admin_user_info'); define('_QR_ADMIN_USER_INFO', '_rq_admin_user_info');
define('_QR_ADMIN_LOGIN_USER_INFO', '_rq_admin_login_user_info');
define('ADMIN_PASSWORD_GET_EMAIL', '2115531468@qq.com'); define('ADMIN_PASSWORD_GET_EMAIL', '2115531468@qq.com');
$GLOBALS['admin_list'] = array(
'2115531468@qq.com',
// '1225425695@qq.com',
);
$GLOBALS['num_list'] = array( $GLOBALS['num_list'] = array(
'num' => array( 'num' => array(
'半'=>0.5, '半'=>0.5,

27
control/index.php

@ -10,8 +10,6 @@ include_once(SERVER_ROOT . "/model/mPage.php");
class index extends publicBase { class index extends publicBase {
private function _check_login() { private function _check_login() {
return array('uid' => $this->post('uid'));
$uid = $this->post('uid'); $uid = $this->post('uid');
$token = $this->post('token'); $token = $this->post('token');
if ($uid < 0 || !$token) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE)); if ($uid < 0 || !$token) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE));
@ -28,7 +26,6 @@ class index extends publicBase {
} }
public function login() { public function login() {
$name = trim($this->get('name')); $name = trim($this->get('name'));
$password = trim($this->get('password')); $password = trim($this->get('password'));
@ -44,29 +41,25 @@ class index extends publicBase {
} }
public function home() { public function home() {
$mformula = new mFormula(); if ($_COOKIE['uid'] !== 0 && empty($_COOKIE['token'])) header('Location: /index/login');
$robj = $mformula->initRedis();
$user_info = $robj->get(_QR_ADMIN_LOGIN_USER_INFO);
$user_info = json_decode($user_info, true);
if (empty($user_info)) header('Location: /index/login');
$this->view['uid'] = $user_info['uid']; $this->view['uid'] = $_COOKIE['uid'];
$this->view['token'] = $user_info['token']; $this->view['token'] = $_COOKIE['token'];
$is_all = $this->get('is_all') + 0; $is_all = $this->get('is_all') + 0;
$name = trim($this->get('name')); $name = trim($this->get('name'));
$condition = array(); $condition = array();
$url = "/index/home"; $url = "/index/home/is_all/{$is_all}";
if ($name) { if ($name) {
$condition['name'] = $name; $condition['name'] = $name;
$url .= "/name/{$name}"; $url .= "/name/{$name}";
} }
if (!$is_all) { if (!$is_all) {
$condition['uid'] = 0; $condition['uid'] = 0;
$url .= "/is_all/{$is_all}";
} }
$mformula = new mFormula();
$total = $mformula->getFormulaTotal($condition); $total = $mformula->getFormulaTotal($condition);
// 分页 // 分页
@ -89,14 +82,10 @@ class index extends publicBase {
} }
public function formula_add() { public function formula_add() {
$mformula = new mFormula(); if ($_COOKIE['uid'] !== 0 && empty($_COOKIE['token'])) header('Location: /index/login');
$robj = $mformula->initRedis();
$user_info = $robj->get(_QR_ADMIN_LOGIN_USER_INFO);
$user_info = json_decode($user_info, true);
if (empty($user_info)) header('Location: /index/login');
$this->view['uid'] = $user_info['uid']; $this->view['uid'] = $_COOKIE['uid'];
$this->view['token'] = $user_info['token']; $this->view['token'] = $_COOKIE['token'];
$id = $this->get('id'); $id = $this->get('id');
if ($id) { if ($id) {

2
model/mFormula.php

@ -55,8 +55,6 @@ class mFormula extends mBase {
$formula_arr = $this->getFormulaHerbData($formula_ids); $formula_arr = $this->getFormulaHerbData($formula_ids);
foreach ($data as &$da) { foreach ($data as &$da) {
//格式化日期
$da['create_time'] = date('Y-m-d', strtotime($da['create_time']));
if (isset($formula_arr[$da['id']])) $da['formula'] = $formula_arr[$da['id']]; if (isset($formula_arr[$da['id']])) $da['formula'] = $formula_arr[$da['id']];
//原方信息 //原方信息

2
model/mPage.php

@ -5,7 +5,7 @@ class Page extends publicBase {
public $totalnum; // 总记录数[必填],例:$page->setTotalnum(100); public $totalnum; // 总记录数[必填],例:$page->setTotalnum(100);
public $page; // 当前页码[必填] public $page; // 当前页码[必填]
public $url; // 分页URL[必填] public $url; // 分页URL[必填]
public $pagesize=100; // 每页记录数 public $pagesize=50; // 每页记录数
public $viewpagenum=7; // 每页看到的页码数 public $viewpagenum=7; // 每页看到的页码数
public $virtualpage='...'; // 省略或跨越页码 public $virtualpage='...'; // 省略或跨越页码

11
model/mUser.php

@ -30,7 +30,8 @@ class mUser extends mBase {
} }
//设置登录状态 //设置登录状态
$robj->setex(_QR_ADMIN_LOGIN_USER_INFO, 12 * 60 * 60, json_encode(array('uid' => 0, 'token' => $this->getToken(0)))); setcookie("uid", 0, time() + 7200, '/');
setcookie("token", $this->getToken(0), time() + 7200, '/');
return true; return true;
} }
@ -38,11 +39,15 @@ class mUser extends mBase {
$robj = $this->initRedis(); $robj = $this->initRedis();
$user_info = $robj->get(_QR_ADMIN_USER_INFO); $user_info = $robj->get(_QR_ADMIN_USER_INFO);
if (empty($user_info)) { if (empty($user_info)) {
$email = ADMIN_PASSWORD_GET_EMAIL; $email = $GLOBALS['admin_list'];
$pass = bin2hex(openssl_random_pseudo_bytes(8)); $pass = bin2hex(openssl_random_pseudo_bytes(8));
$robj->setex(_QR_ADMIN_USER_INFO, 12 * 60 * 60, json_encode(array('name' => 'admin', 'password' => $pass))); $robj->setex(_QR_ADMIN_USER_INFO, 12 * 60 * 60, json_encode(array('name' => 'admin', 'password' => $pass)));
$this->sendMail(array($email), '医案录入后台', '新密码是:' . $pass); $content = "后台地址:" . TCM_DOMAIN . "/index/login<br>";
$content .= "用户名:admin" . "<br>";
$content .= "密码:" . $pass;
$this->sendMail($email, '医案录入后台', $content);
return true; return true;
} }

2
view/templates/index/home.html

@ -14,7 +14,7 @@
<div id="page"> <div id="page">
<div class="container"> <div class="container">
<section id="main"> <section id="main" style="width: 100%;">
<div id="main-content"> <div id="main-content">
<div class="entry"> <div class="entry">
<div class="modal-body"> <div class="modal-body">

64
view/templates/index/login.html

@ -15,36 +15,33 @@
<div id="page"> <div id="page">
<div class="container"> <div class="container">
<section id="main"> <form id="prescription-form" onsubmit="submitForm(event)">
<form id="prescription-form" onsubmit="submitForm(event)"> <h1>登录</h1>
<input id="id" name="id" type="hidden" value="{$data.id}"> <input id="id" name="id" type="hidden" value="{$data.id}">
<div class="row">&nbsp;</div> <div class="row">&nbsp;</div>
<div class="row"> <div class="row">
<label for="name">用户名<font color='red'>*</font></label> <label for="name">用户名<font color='red'>*</font></label>
<input type="text" id="name" name="name" maxlength="" style="width:280px" value="{$data.name}"> <input type="text" id="name" name="name" maxlength="" style="width:280px" value="{$data.name}">
</div> </div>
<div class="row">&nbsp;</div> <div class="row">&nbsp;</div>
<div class="row"> <div class="row">
<label for="source">密码<font color='red'>*</font></label> <label for="password">密码<font color='red'>*</font></label>
<input type="text" id="password" name="password" maxlength="" style="width:280px" <input type="text" id="password" name="password" maxlength="" style="width:280px"
value="{$data.source}"> value="{$data.source}">
</div> </div>
<div class="row">&nbsp;</div> <div class="row">&nbsp;</div>
<div class="row" id="" style="position:relative;"> <div class="row">
<label>&nbsp;</label> <button class="button primary next submitlock" id="submitbtn" onclick="check_submit()"><span
class="tdesc_text" style="color:white;">提交</span></button>
<button class="button primary next submitlock" id="submitbtn" onclick="check_submit()"><span class="tdesc_text" style="color:white;">提交</span></button> </div>
</div>
</form>
</section><!--end of main section-->
</form>
</div><!--end of container--> </div><!--end of container-->
</div><!--end of #page--> </div><!--end of #page-->
@ -64,18 +61,21 @@
} }
</script> </script>
<style> <style>
#main { .container {
width: 600px; display: flex;
height: 300px; justify-content: center;
position: absolute; align-items: center;
top: 50%; height: 100vh;
left: 50%; text-align: center;
margin-left: -300px;
margin-top: -150px;
} }
#prescription-form { #prescription-form {
margin: 0 auto; padding: 50px;
border: 1px solid #ccc;
}
#prescription-form label {
text-align: center;
} }
</style> </style>
{/literal} {/literal}

Loading…
Cancel
Save