新增设备管理部分代码
This commit is contained in:
parent
db421ccee5
commit
77e42aa6ea
|
|
@ -8,12 +8,14 @@ use think\Cache;
|
|||
class Savemsg extends Base{
|
||||
|
||||
|
||||
// 设备名称列表
|
||||
protected $name_list = [
|
||||
[
|
||||
'name'=>'c03',
|
||||
],
|
||||
|
||||
['name'=>'PC-C02Pro']
|
||||
// [
|
||||
// 'name'=>'PC-C02Pro',
|
||||
// ],
|
||||
];
|
||||
// 默认选中的设备名称下标
|
||||
protected $name_default = 0;
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
|
|
@ -31,7 +33,7 @@ class Savemsg extends Base{
|
|||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent["line"] = $e->getLine(); =
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
|
|
@ -45,7 +47,7 @@ class Savemsg extends Base{
|
|||
|
||||
}
|
||||
|
||||
public function save_device_msg($data = ['mac'=>'564654564654654','device_name'=>'bl_5520','batch_code'=>'bc250826']){
|
||||
public function save_device_msg($data = ['mac'=>'564654564654654','device_name'=>'bl_5520','batch_code'=>'bc250826','token'=>'as56d4a56s1d5as4d6']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
|
|
@ -60,6 +62,9 @@ class Savemsg extends Base{
|
|||
if(!array_key_exists('batch_code', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['mac'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
|
|
@ -69,6 +74,9 @@ class Savemsg extends Base{
|
|||
if(!$this->verify_data_is_ok($data['batch_code'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$result = $this->save_device_msg_action($data);
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -90,27 +98,67 @@ class Savemsg extends Base{
|
|||
|
||||
}
|
||||
|
||||
// 历史箱号数据
|
||||
public function device_batch_list(){
|
||||
// try {
|
||||
|
||||
$result = $this->device_batch_list_action();
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input()) > 0){
|
||||
$data = input();
|
||||
}
|
||||
if(!array_key_exists('token', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['token'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$result = $this->device_batch_list_action($data);
|
||||
return $result;
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// // dump($data);
|
||||
// // die;
|
||||
// $this->record_api_log([], $logContent, null);
|
||||
// return $this->msg(99999);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log([], $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 详细批次数据
|
||||
public function device_content_msg($data = ['batch_code'=>'tcxbc250904']){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('batch_code', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
if(!$this->verify_data_is_ok($data['batch_code'],'str')){
|
||||
return $this->msg(10005);
|
||||
}
|
||||
$result = $this->device_content_msg_action($data);
|
||||
return $this->msg($result);
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "函数名: " . __FUNCTION__ . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log([], $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -131,37 +179,79 @@ class Savemsg extends Base{
|
|||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function save_device_msg_action($data){
|
||||
// 验证mac地址是否存在且不为空
|
||||
if (!isset($data['mac']) || empty(trim($data['mac']))) {
|
||||
return $this->msg(10002, 'MAC地址不能为空');
|
||||
}
|
||||
$device_enter = Db::connect('device_enter_db');
|
||||
|
||||
$mac_code = $device_enter->table('device_C02pro')->where(['device_mac'=>$data['mac']])->count();
|
||||
if($mac_code > 0){
|
||||
return $this->msg(10002,'该MAC地址已录入');
|
||||
}
|
||||
$result = $device_enter->table('device_C02pro')->insert([
|
||||
// $mac_code = $device_enter->table('device_C03')->where(['device_mac'=>$data['mac']])->find();
|
||||
// if($mac_code){
|
||||
// return $this->msg(10002,'该MAC地址已录入,批次号:'.$mac_code['batch_code']);
|
||||
// }
|
||||
$result = $device_enter->table('device_C03')->insert([
|
||||
'device_mac'=>$data['mac'],
|
||||
'device_name'=>$data['device_name'],
|
||||
'batch_code'=>$data['batch_code'],
|
||||
'token'=>$data['token'],
|
||||
'create_time'=>date('Y-m-d H:i:s'),
|
||||
]);
|
||||
if($result){
|
||||
return $this->msg([]);
|
||||
$all_data = $this->device_content_msg_action($data);
|
||||
return $this->msg($all_data);
|
||||
}else{
|
||||
return $this->msg(10002);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function device_batch_list_action(){
|
||||
public function device_batch_list_action($data){
|
||||
$device_enter = Db::connect('device_enter_db');
|
||||
$result = $device_enter->query("
|
||||
SELECT device_name, batch_code, COUNT(*) as num
|
||||
FROM device_C02pro
|
||||
FROM device_C03
|
||||
WHERE token = '".$data['token']."'
|
||||
GROUP BY batch_code,device_name
|
||||
ORDER BY MAX(id) desc
|
||||
");
|
||||
return $this->msg($result);
|
||||
}
|
||||
|
||||
public function device_content_msg_action($data){
|
||||
|
||||
$device_enter = Db::connect('device_enter_db');
|
||||
$result = $device_enter->query("
|
||||
SELECT device_mac
|
||||
FROM device_C03
|
||||
WHERE batch_code = '".$data['batch_code']."'
|
||||
order by id desc
|
||||
");
|
||||
$return_result = [
|
||||
'list'=>[],
|
||||
'num'=>0,
|
||||
];
|
||||
for ($i=0; $i < count($result); $i++) {
|
||||
array_push($return_result['list'],$result[$i]['device_mac']);
|
||||
$return_result['num'] = $return_result['num']+1;
|
||||
}
|
||||
return $return_result;
|
||||
}
|
||||
|
||||
|
||||
################################################################测试################################################################
|
||||
################################################################测试################################################################
|
||||
################################################################测试################################################################
|
||||
|
||||
public function ceshi(){
|
||||
// $device_enter = Db::connect('device_enter_db');
|
||||
// $mac_code = $device_enter->table('device_C03')->select();
|
||||
// $data = [];
|
||||
// foreach ($mac_code as $key => $value) {
|
||||
// $data[] = $value['device_mac'];
|
||||
// }
|
||||
// dump($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace app\DeviceEnter\controller;
|
||||
|
||||
|
||||
use think\Db;
|
||||
|
||||
|
||||
class Wechat extends Base{
|
||||
// 品川科技蓝牙工具的小程序信息
|
||||
private $app_id = 'wx02bd10b0ee5c329f'; // 微信小程序的AppID
|
||||
private $app_secret = 'c36a7398acc405d6e18d5dae903bc289'; // 微信小程序的AppSecret
|
||||
|
||||
|
||||
public function login(){
|
||||
try {
|
||||
// 你的业务逻辑
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
if(!array_key_exists('code', $data)){
|
||||
// return $this->msg(10001,'');
|
||||
return $this->msg(10001,'code is miss');
|
||||
}
|
||||
// 校验参数
|
||||
if (empty($data['code'])) {
|
||||
return $this->msg(10001,'code is miss.');
|
||||
}
|
||||
|
||||
$code = $data['code'];
|
||||
$config = [
|
||||
'app_id' => $this->app_id,
|
||||
'app_secret' => $this->app_secret,
|
||||
];
|
||||
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$config['app_id']}&secret={$config['app_secret']}&js_code={$code}&grant_type=authorization_code";
|
||||
|
||||
$result = file_get_contents($url);
|
||||
$data = json_decode($result, true);
|
||||
if (isset($data['errcode'])) {
|
||||
// return json(['code' => 500, 'msg' => '获取openid失败:'.$data['errmsg']]);
|
||||
return $this->msg(10002,'获取openid失败:'.$data['errmsg']);
|
||||
}
|
||||
|
||||
|
||||
$device_enter = Db::connect('device_enter_db');
|
||||
|
||||
$user_find = $device_enter->table('device_user')->where(['openid'=>$data['openid']])->find();
|
||||
if($user_find){
|
||||
return $this->msg(['token' => $user_find['token']]);
|
||||
}else{
|
||||
$token = md5($data['openid']);
|
||||
$user_result = $device_enter->table('device_user')
|
||||
->insert([
|
||||
'openid'=>$data['openid'],
|
||||
'token'=>$token,
|
||||
'create_time'=>date('Y-m-d H:i:s')
|
||||
]);
|
||||
if($user_result){
|
||||
return $this->msg(['token' => $token]);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "方法: " . __METHOD__ . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return $this->msg(99999);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
namespace app\DeviceEnter\controller\admin;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Base extends Controller{
|
||||
|
||||
protected $token_time = 30;//30天的秒数
|
||||
protected $file_size = 5*1024*1024;
|
||||
protected $return_data_all = [
|
||||
'10001'=>'关键参数缺失',
|
||||
'10002'=>'操作失败',
|
||||
'10003'=>'信息核实错误',
|
||||
'10004'=>'未找到有效数据',
|
||||
'10005'=>'参数格式错误',
|
||||
'10006'=>'参数不能为空',
|
||||
'10007'=>'参数错误',
|
||||
'10008'=>'',
|
||||
'10009'=>'',
|
||||
'10010'=>'自定义信息',
|
||||
'20001'=>'登录失效',
|
||||
'99999'=>'网络异常,请稍后重试',
|
||||
];
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
################################################################接口################################################################
|
||||
// 接口记录
|
||||
public function record_api_log($params, $error = null, $response = null){
|
||||
// dump($params);
|
||||
// dump($error);
|
||||
// die;
|
||||
$logContent = "接口请求参数:" . json_encode($params, JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
||||
if ($error) {
|
||||
$logContent .= "错误信息:" . $error['all_content'] . PHP_EOL;
|
||||
if(!cache($error['flie']."_".$error['line'])){
|
||||
cache($error['flie']."_".$error['line'],"API错误",3600);
|
||||
$this->send_email_api_error(["tsf3920322@126.com"],['title'=>'接口报错','from_user_name'=>'设备录入','content'=>$logContent]);
|
||||
}
|
||||
}
|
||||
if ($response) {
|
||||
$logContent .= "返回信息:" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
||||
}
|
||||
// 使用ThinkPHP的日志记录方法
|
||||
Log::record($logContent, 'api_log');
|
||||
}
|
||||
|
||||
/* 接口说明(发邮件)
|
||||
* $address(收件人的邮箱地址) 数组 格式: ['460834639@qq.com','460834639@qq.com'.......]
|
||||
* $content(邮件的主题数据信息) 数组 格式:['title'=>'123','from_user_name'=>'123','content'=>'123']
|
||||
* $annex(附件路径信息) 字符串
|
||||
*/
|
||||
public function send_email_api_error($address,$content,$annex=''){
|
||||
// $ad = '460834639@qq.com';
|
||||
$ad1 = '295155911@qq.com';
|
||||
$mail = new PHPMailer(); //实例化
|
||||
$mail->IsSMTP(); // 启用SMTP
|
||||
$mail->Host = "smtp.126.com"; //SMTP服务器 163邮箱例子
|
||||
$mail->Port = 465; //邮件发送端口
|
||||
$mail->SMTPAuth = true; //启用SMTP认证
|
||||
$mail->SMTPSecure = 'ssl';
|
||||
$mail->CharSet = "UTF-8"; //字符集
|
||||
$mail->Encoding = "base64"; //编码方式
|
||||
$mail->Username = "tsf3920322@126.com"; //你的邮箱
|
||||
$mail->Password = "HLWXNRPUCTHJFIIX"; //你的密码(邮箱后台的授权密码)
|
||||
$mail->From = "tsf3920322@126.com"; //发件人地址(也就是你的邮箱)
|
||||
|
||||
// $mail->Subject = "微盟测试邮件"; //邮件标题
|
||||
$mail->Subject = $content['title']; //邮件标题
|
||||
|
||||
// $mail->FromName = "微盟体测中心"; //发件人姓名
|
||||
$mail->FromName = $content['from_user_name']; //发件人姓名
|
||||
|
||||
|
||||
for ($i=0; $i < count($address); $i++) {
|
||||
$mail->AddAddress($address[$i], ""); //添加收件人(地址,昵称)
|
||||
}
|
||||
|
||||
if($annex != ''){
|
||||
// $url = ROOT_PATH. 'public' . DS . 'tsf' . DS .'demoooo.jpg';
|
||||
$mail->AddAttachment($annex,''); // 添加附件,并指定名称
|
||||
}
|
||||
|
||||
$mail->IsHTML(true); //支持html格式内容
|
||||
|
||||
$neirong = $content['content'];
|
||||
|
||||
$mail->Body = $neirong; //邮件主体内容
|
||||
//发送
|
||||
if (!$mail->Send()) {
|
||||
|
||||
return ['code' => 10003,'msg'=>$mail->ErrorInfo];
|
||||
// return $mail->ErrorInfo;
|
||||
} else {
|
||||
return ['code' => 0];
|
||||
// return 'success';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 验证
|
||||
public function verify_data_is_ok($data = 2,$type){
|
||||
if($type == 'str'){
|
||||
if (is_string($data)) {
|
||||
return true;
|
||||
} else {
|
||||
$this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为字符串',[]]);
|
||||
return false;
|
||||
}
|
||||
}else if($type == 'num'){
|
||||
if (is_numeric($data)) {
|
||||
return true;
|
||||
} else {
|
||||
$this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为数字',[]]);
|
||||
return false;
|
||||
}
|
||||
}else if($type == 'intnum'){
|
||||
$pattern = '/^\d+$/';
|
||||
// dump($data);
|
||||
if (preg_match($pattern, $data)) {
|
||||
return true; // 匹配成功,返回 true
|
||||
} else {
|
||||
$this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为整数数字',[]]);
|
||||
return false; // 匹配失败,返回 false
|
||||
}
|
||||
}else if($type == 'datetime'){
|
||||
$formats = ['Y-m-d','Y-m-d H:i:s'];
|
||||
foreach ($formats as $format) {
|
||||
$dateTime = \DateTime::createFromFormat($format, $data);
|
||||
// 检查时间字符串是否成功解析,并且解析后的日期时间与原始字符串表示的时间一致
|
||||
if ($dateTime && $dateTime->format($format) === $data) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// 如果所有格式都解析失败,则返回 false
|
||||
$this->record_api_log($data, null, ['code'=>10005,'msg'=>'校验参数不为日期格式',[]]);
|
||||
return false;
|
||||
}else if($type == 'other'){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function msg($data,$str='',$result = []){
|
||||
if(is_array($data)){
|
||||
if($str != ''){
|
||||
return json(['code'=>0,'msg'=>$str,'data'=>$data]);
|
||||
}else{
|
||||
return json(['code'=>0,'msg'=>'操作成功','data'=>$data]);
|
||||
}
|
||||
}else{
|
||||
if($str != ''){
|
||||
return json(['code'=>$data,'msg'=>$str,'data'=>$result]);
|
||||
}
|
||||
return json(['code'=>$data,'msg'=>$this->return_data_all[$data],'data'=>$result]);
|
||||
}
|
||||
}
|
||||
|
||||
public function generateRandomString($length = 10) {
|
||||
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
public function ceshi(){
|
||||
echo 'hello';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace app\DeviceEnter\controller\admin;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Device extends Base{
|
||||
|
||||
protected $page_num = 10;
|
||||
protected $file_max = 1024*1024*5;//xxxMB
|
||||
public function index($page = 1){
|
||||
$data = input();
|
||||
$pd = true;
|
||||
$parameter = [];
|
||||
// $parameter['is_del'] = 0;
|
||||
if(array_key_exists('tt', $data)){
|
||||
$page = $data['page_num'];
|
||||
unset($data['page_num']);
|
||||
unset($data['tt']);
|
||||
$pd = false;
|
||||
// if($data['status_num'] === "0" || $data['status_num'] === "1"){
|
||||
// $parameter['is_del'] = $data['status_num'];
|
||||
// }
|
||||
|
||||
// if($data['tel']){
|
||||
// $parameter['tel'] = $data['tel'];
|
||||
// }
|
||||
// if($data['email']){
|
||||
// $parameter['email'] = $data['email'];
|
||||
// }
|
||||
// if($data['s_time']){
|
||||
// $parameter['create_time'] = ['>=',$data['s_time']];
|
||||
// }
|
||||
// if($data['e_time']){
|
||||
// $parameter['create_time'] = ['<=',$data['e_time']];
|
||||
// }
|
||||
}
|
||||
$device = Db::connect('device_enter_db');
|
||||
$num = $device->table('device_batch')->where($parameter)->count();
|
||||
$result = $device->table('device_batch')->where($parameter)->order('is_activate,id desc')->page($page,$this->page_num)->select();
|
||||
if(!$pd){
|
||||
$result['num'] = $num;
|
||||
$result['data'] = $result;
|
||||
return $this->msg(0,'success',$result);
|
||||
}
|
||||
$this->assign([
|
||||
'result' => $result,
|
||||
'num' => $num,
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function device_list($page = 1){
|
||||
$data = input();
|
||||
$pd = true;
|
||||
$parameter = [];
|
||||
$parameter['batch_code'] = $data['id'];
|
||||
if(array_key_exists('tt', $data)){
|
||||
$page = $data['page_num'];
|
||||
unset($data['page_num']);
|
||||
unset($data['tt']);
|
||||
$pd = false;
|
||||
}
|
||||
$device = Db::connect('device_enter_db');
|
||||
$num = $device->table('device_C03')->where($parameter)->count();
|
||||
$result = $device->table('device_C03')->where($parameter)->order('is_activate,id desc')->page($page,$this->page_num)->select();
|
||||
if(!$pd){
|
||||
$result['num'] = $num;
|
||||
$result['data'] = $result;
|
||||
$result['id'] = $parameter['batch_code'];
|
||||
return $this->msg(0,'success',$result);
|
||||
}
|
||||
$this->assign([
|
||||
'result' => $result,
|
||||
'num' => $num,
|
||||
'id' => $parameter['batch_code'],
|
||||
]);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function device_all(){
|
||||
$data = input();
|
||||
$device = Db::connect('device_enter_db');
|
||||
$device->startTrans();
|
||||
try{
|
||||
$device->table('device_batch')->where(['id'=>$data['id']])->update(['is_activate'=>$data['state']]);
|
||||
|
||||
$device->table('device_C03')->where(['batch_code'=>$data['id']])->update(['is_activate'=>$data['state']]);
|
||||
// 提交事务
|
||||
$device->commit();
|
||||
return $this->msg([]);
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
$device->rollback();
|
||||
return $this->msg(10002,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace app\DeviceEnter\controller\admin;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Index extends Base{
|
||||
|
||||
public function index(){
|
||||
// $this->assign('domain',$a);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function welcome(){
|
||||
// $this->assign('domain',$a);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace app\DeviceEnter\controller\admin;
|
||||
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use think\Cache;
|
||||
use think\Log;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Login extends Base{
|
||||
|
||||
protected $token_time = 30;//30天的秒数
|
||||
protected $file_size = 5*1024*1024;
|
||||
|
||||
|
||||
public function login(){
|
||||
// dump(md5('DeviceEnter0932'));
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
// 检测登录信息是否超时
|
||||
public function login_action(){
|
||||
$data = input();
|
||||
// 验证数据项是否完整
|
||||
if(!array_key_exists('username', $data) || !array_key_exists('password', $data)){
|
||||
return $this->msg(10001);
|
||||
}
|
||||
$data['password_md5'] = md5($data['password']);
|
||||
$device = Db::connect('device_enter_db');
|
||||
$account = $device->ttable('admin_account')->where(['user_name'=>$data['username'],'pass_word'=>$data['password_md5']])->find();
|
||||
if($account>0){
|
||||
return $this->msg([]);
|
||||
}else{
|
||||
return $this->msg(10003);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="x-admin-sm">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>设备管理_add</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
|
||||
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<form class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label for="L_email" class="layui-form-label">
|
||||
<span class="x-red">*</span>封面</label>
|
||||
</label>
|
||||
<div class="layui-input-inline">
|
||||
<!-- <input type="text" id="L_email" name="email" required="" lay-verify="email" autocomplete="off" class="layui-input"> -->
|
||||
<input type="file" id="upload_file_app" lay-verify="upload_file_app" name="file_data">
|
||||
</div>
|
||||
<!-- <div class="layui-form-mid layui-word-aux">
|
||||
<span class="x-red">*</span>将会成为您唯一的登入名
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="device_name" class="layui-form-label">
|
||||
<span class="x-red">*</span>设备名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="device_name" name="device_name" required="" lay-verify="device_name" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="device_model" class="layui-form-label">
|
||||
<span class="x-red">*</span>设备型号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="device_model" name="device_model" required="" lay-verify="device_model" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="bluetooth_type" class="layui-form-label">
|
||||
<span class="x-red">*</span>蓝牙类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="bluetooth_type" name="bluetooth_type" required="" lay-verify="bluetooth_type" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="page_measure" class="layui-form-label">
|
||||
<span class="x-red"></span>测量页路径</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="page_measure" name="page_measure" required="" lay-verify="page_measure" autocomplete="off" class="layui-input"></div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="content" class="layui-form-label">
|
||||
<span class="x-red"></span>描述</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="content" name="content" required="" lay-verify="content" autocomplete="off" class="layui-input"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="L_repass" class="layui-form-label"></label>
|
||||
<!-- <div class="layui-btn" id="add" lay-filter="add" lay-submit="">增加</div>
|
||||
<input value="登录" lay-submit lay-filter="add" type="submit" class="layui-btn"> -->
|
||||
<button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var file_name_all = ''
|
||||
var file_name = ''
|
||||
var file_extension = ''
|
||||
var pd = true
|
||||
|
||||
$('#upload_file_app').on('change', function() {
|
||||
// 获取被选择的文件
|
||||
var fileInput = $(this)[0];
|
||||
var file = fileInput.files[0];
|
||||
|
||||
// 检查是否有文件被选择
|
||||
if (file) {
|
||||
// 获取文件的名称
|
||||
file_name_all = file.name;
|
||||
// 使用lastIndexOf和substring来获取文件名(不包括后缀)
|
||||
var lastIndex = file_name_all.lastIndexOf('.');
|
||||
file_name = lastIndex !== -1 ? file_name_all.substring(0, lastIndex) : file_name_all;
|
||||
// 获取文件后缀
|
||||
file_extension = lastIndex !== -1 ? file_name_all.substring(lastIndex + 1) : '';
|
||||
$('#file_name').val(file_name)
|
||||
console.log(file_name)
|
||||
console.log(file_extension)
|
||||
// formdata.append('apk',$('#upload_file_app')[0].files[0])
|
||||
}
|
||||
});
|
||||
|
||||
function add_data(){
|
||||
if(pd === false){
|
||||
return
|
||||
}
|
||||
var formdata = new FormData();
|
||||
formdata.append('upload_file_app',$('#upload_file_app')[0].files[0])
|
||||
formdata.append('device_name',$('#device_name').val())
|
||||
formdata.append('device_model',$('#device_model').val())
|
||||
formdata.append('bluetooth_type',$('#bluetooth_type').val())
|
||||
formdata.append('page_measure',$('#page_measure').val())
|
||||
formdata.append('content',$('#content').val())
|
||||
formdata.append('file_extension',file_extension)
|
||||
|
||||
load()
|
||||
pd = false
|
||||
console.log('进来了')
|
||||
$.ajax({
|
||||
url:"/device/device_add_action", //请求的url地址
|
||||
contentType:false,
|
||||
processData:false,
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:formdata, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
pd = true
|
||||
if(req.code == 0){
|
||||
layer.alert("增加成功", {icon: 6},function() {
|
||||
//关闭当前frame
|
||||
xadmin.close();
|
||||
// 可以对父窗口进行刷新
|
||||
xadmin.father_reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert("增加失败"+req.msg, {icon: 6},function() {
|
||||
//关闭当前frame
|
||||
xadmin.close();
|
||||
// 可以对父窗口进行刷新
|
||||
xadmin.father_reload();
|
||||
});
|
||||
}
|
||||
//请求成功时处理
|
||||
|
||||
console.log(req)
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
pd = true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
layui.use(['form', 'layer','jquery'],function() {
|
||||
$ = layui.jquery;
|
||||
var form = layui.form,
|
||||
layer = layui.layer;
|
||||
|
||||
//自定义验证规则
|
||||
form.verify({
|
||||
|
||||
upload_file_app: function(value) {
|
||||
if (value == '') {
|
||||
return '请先选择文件';
|
||||
}
|
||||
},
|
||||
device_name: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写设备名称';
|
||||
}
|
||||
},
|
||||
// version_num: [/[\d.]{0,9}$/, '版本号必须以大写V开头最多10个字符(由数字跟英文"."组成)'],
|
||||
device_model: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写设备类型';
|
||||
}
|
||||
},
|
||||
bluetooth_type: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写蓝牙类型';
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(add)',function(data) {
|
||||
//发异步,把数据提交给php
|
||||
add_data()
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//加载提示开启
|
||||
function load() {
|
||||
var index = layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
}
|
||||
// 关闭加载提示
|
||||
function c_load() {
|
||||
layer.close(layer.index)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// });
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="x-admin-sm">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>设备管理_edit</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script type="text/javascript" src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
|
||||
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row">
|
||||
<form class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label for="L_email" class="layui-form-label">
|
||||
<span class="x-red">*</span>封面</label>
|
||||
</label>
|
||||
<div class="layui-input-inline">
|
||||
<!-- <input type="text" id="L_email" name="email" required="" lay-verify="email" autocomplete="off" class="layui-input"> -->
|
||||
<input type="file" id="upload_file_app" lay-verify="upload_file_app" name="file_data">
|
||||
</div>
|
||||
<!-- <div class="layui-form-mid layui-word-aux">
|
||||
<span class="x-red">*</span>将会成为您唯一的登入名
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="device_name" class="layui-form-label">
|
||||
<span class="x-red">*</span>设备名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="device_name" name="device_name" required="" lay-verify="device_name" autocomplete="off" class="layui-input" value="{$result.name}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="device_model" class="layui-form-label">
|
||||
<span class="x-red">*</span>设备型号</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="device_model" name="device_model" required="" lay-verify="device_model" autocomplete="off" class="layui-input" value="{$result.device_model}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="bluetooth_type" class="layui-form-label">
|
||||
<span class="x-red">*</span>蓝牙类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="bluetooth_type" name="bluetooth_type" required="" lay-verify="bluetooth_type" autocomplete="off" class="layui-input" value="{$result.bluetooth_type}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="page_measure" class="layui-form-label">
|
||||
<span class="x-red"></span>测量页路径</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="page_measure" name="page_measure" required="" lay-verify="page_measure" autocomplete="off" class="layui-input" value="{$result.page_measure}">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="content" class="layui-form-label">
|
||||
<span class="x-red"></span>描述</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="content" name="content" required="" lay-verify="content" autocomplete="off" class="layui-input" value="{$result.content}"></div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="L_repass" class="layui-form-label"></label>
|
||||
<!-- <div class="layui-btn" id="add" lay-filter="add" lay-submit="">增加</div>
|
||||
<input value="登录" lay-submit lay-filter="add" type="submit" class="layui-btn"> -->
|
||||
<button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-fluid">
|
||||
<div id="official_1" class="layui-row">
|
||||
<div style="margin-left: 8%;margin-top: 5%;font-size: 25px;">请先下载模板文件,信息填写完成并上传该文件后点击生成</div>
|
||||
<img style="width: 90%;margin-left: 3%;"src="/uploads/code_demo.png?v=1.0" alt="">
|
||||
<div class="layui-form-item" style="width: 30%;margin-left: 33%;margin-top: 5%;">
|
||||
<span>步骤1:</span><a href="/uploads/code_demo.xlsx" class="layui-btn" lay-filter="add">下载模板文件</a>
|
||||
</div>
|
||||
<div class="layui-form-item" style="width: 50%;margin-left: 33%;margin-top: 5%;">
|
||||
<span>步骤2:</span><input type="file" id="data_excel" name="data_excel">
|
||||
</div>
|
||||
<div class="layui-form-item" style="width: 30%;margin-left: 33%;margin-top: 5%;">
|
||||
<span>步骤3:</span><button class="layui-btn" lay-filter="add" lay-submit="" onclick="add_data()">生成</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var id = "{$result.id}"
|
||||
var file_name_all = ''
|
||||
var file_name = ''
|
||||
var file_extension = ''
|
||||
var pd = true
|
||||
|
||||
$('#upload_file_app').on('change', function() {
|
||||
// 获取被选择的文件
|
||||
var fileInput = $(this)[0];
|
||||
var file = fileInput.files[0];
|
||||
|
||||
// 检查是否有文件被选择
|
||||
if (file) {
|
||||
// 获取文件的名称
|
||||
file_name_all = file.name;
|
||||
// 使用lastIndexOf和substring来获取文件名(不包括后缀)
|
||||
var lastIndex = file_name_all.lastIndexOf('.');
|
||||
file_name = lastIndex !== -1 ? file_name_all.substring(0, lastIndex) : file_name_all;
|
||||
// 获取文件后缀
|
||||
file_extension = lastIndex !== -1 ? file_name_all.substring(lastIndex + 1) : '';
|
||||
$('#file_name').val(file_name)
|
||||
// console.log($('#upload_file_app')[0].files[0])
|
||||
// formdata.append('apk',$('#upload_file_app')[0].files[0])
|
||||
}
|
||||
});
|
||||
|
||||
function edit_data(){
|
||||
if(pd === false){
|
||||
return
|
||||
}
|
||||
var formdata = new FormData();
|
||||
formdata.append('upload_file_app',$('#upload_file_app')[0].files[0])
|
||||
formdata.append('device_name',$('#device_name').val())
|
||||
formdata.append('device_model',$('#device_model').val())
|
||||
formdata.append('bluetooth_type',$('#bluetooth_type').val())
|
||||
formdata.append('page_measure',$('#page_measure').val())
|
||||
formdata.append('content',$('#content').val())
|
||||
formdata.append('file_extension',file_extension)
|
||||
formdata.append('id',id)
|
||||
load()
|
||||
pd = false
|
||||
console.log('进来了')
|
||||
$.ajax({
|
||||
url:"/device/device_edit_action", //请求的url地址
|
||||
contentType:false,
|
||||
processData:false,
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:formdata, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
pd = true
|
||||
if(req.code == 0){
|
||||
layer.alert("修改成功", {icon: 6},function() {
|
||||
//关闭当前frame
|
||||
xadmin.close();
|
||||
// 可以对父窗口进行刷新
|
||||
xadmin.father_reload();
|
||||
});
|
||||
}else{
|
||||
layer.alert("修改失败"+req.msg, {icon: 6},function() {
|
||||
//关闭当前frame
|
||||
xadmin.close();
|
||||
// 可以对父窗口进行刷新
|
||||
xadmin.father_reload();
|
||||
});
|
||||
}
|
||||
//请求成功时处理
|
||||
|
||||
console.log(req)
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
pd = true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
layui.use(['form', 'layer','jquery'],function() {
|
||||
$ = layui.jquery;
|
||||
var form = layui.form,
|
||||
layer = layui.layer;
|
||||
|
||||
//自定义验证规则
|
||||
form.verify({
|
||||
|
||||
// upload_file_app: function(value) {
|
||||
// if (value == '') {
|
||||
// return '请先选择文件';
|
||||
// }
|
||||
// },
|
||||
device_name: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写设备名称';
|
||||
}
|
||||
},
|
||||
// version_num: [/[\d.]{0,9}$/, '版本号必须以大写V开头最多10个字符(由数字跟英文"."组成)'],
|
||||
device_model: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写设备类型';
|
||||
}
|
||||
},
|
||||
bluetooth_type: function(value) {
|
||||
if (value == '') {
|
||||
return '必须填写蓝牙类型';
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(add)',function(data) {
|
||||
//发异步,把数据提交给php
|
||||
edit_data()
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//加载提示开启
|
||||
function load() {
|
||||
var index = layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
}
|
||||
// 关闭加载提示
|
||||
function c_load() {
|
||||
layer.close(layer.index)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// });
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="x-admin-sm">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>所有设备管理</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<style>
|
||||
/* th{
|
||||
min-width:30px;
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
<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-body ">
|
||||
<form class="layui-form layui-col-space5">
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="s_time">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="e_time">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input type="text" name="username" placeholder="请输入用户手机" autocomplete="off" class="layui-input" id="tel">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input type="text" name="username" placeholder="请输入用户邮箱" autocomplete="off" class="layui-input" id="email">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-show-xs-block">
|
||||
<select name="contrller" id="status_num">
|
||||
<option value="">状态</option>
|
||||
<option value="0">启用</option>
|
||||
<option value="1">停用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<div class="layui-btn" lay-submit="" lay-filter="sreach" onclick="find('y')"><i class="layui-icon"></i></div>
|
||||
</div>
|
||||
</form>
|
||||
</div> -->
|
||||
<div class="layui-card-header">
|
||||
<button class="layui-btn" onclick="activateAll(1)">全部激活</button>
|
||||
<button class="layui-btn layui-btn-danger" onclick="activateAll(0)">全部停用</button>
|
||||
<!-- <button class="layui-btn" onclick="xadmin.open('添加用户','/appversion/app_add','100%','100%')"><i class="layui-icon"></i>添加</button> -->
|
||||
<!-- <button class="layui-btn" onclick="xadmin.open('添加版本','/device/device_add','50%','70%')"><i class="layui-icon"></i>添加</button> -->
|
||||
</div>
|
||||
<div class="layui-card-body layui-table-body layui-table-main">
|
||||
<table class="layui-table layui-form">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
|
||||
<th>设备码</th>
|
||||
<th>创建时间</th>
|
||||
<th>是否激活</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id='content'>
|
||||
|
||||
{volist name="result" id="vo"}
|
||||
<tr>
|
||||
<td>{$vo.id}</td>
|
||||
|
||||
<td>{$vo.device_mac}</td>
|
||||
<td>{$vo.create_time}</td>
|
||||
{if condition="$vo.is_activate == 1"}
|
||||
<td style="color:green;font-weight: bold;">已激活</td>
|
||||
<!-- <span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span> -->
|
||||
{else /}
|
||||
<td style="color:red;font-weight: bold;">未激活</td>
|
||||
<!-- <span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span> -->
|
||||
{/if}
|
||||
<td>
|
||||
<button>站位</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="layui-card-body ">
|
||||
<div id="page" style="text-align: center;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
var form
|
||||
layui.use(['laydate','form'], function(){
|
||||
var laydate = layui.laydate;
|
||||
form = layui.form;
|
||||
|
||||
|
||||
//执行一个laydate实例
|
||||
laydate.render({
|
||||
elem: '#s_time' //指定元素
|
||||
});
|
||||
|
||||
//执行一个laydate实例
|
||||
laydate.render({
|
||||
elem: '#e_time' //指定元素
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
var page_num;
|
||||
var batch_id = "{$id}";
|
||||
var laypage;
|
||||
var all_page = "{$num}";
|
||||
layui.use('laypage', function () {
|
||||
laypage = layui.laypage;
|
||||
|
||||
//执行一个laypage实例
|
||||
laypage.render({
|
||||
elem: 'page',
|
||||
count: all_page, //数据总数,从服务端得到
|
||||
limit: 10,
|
||||
groups:10,
|
||||
jump: function (obj, first) {
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
page_num = obj.curr;
|
||||
find("n")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*用户-停用*/
|
||||
function app_stop(obj,id){
|
||||
|
||||
// return
|
||||
var title = '',is_del,num
|
||||
if($(obj).attr('title')=='启用'){
|
||||
title = '停用'
|
||||
is_del = 1
|
||||
num = 5
|
||||
}else{
|
||||
title = '启用'
|
||||
is_del = 0
|
||||
num = 6
|
||||
}
|
||||
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
|
||||
layer.confirm('确认要'+ title +'吗?',function(index){
|
||||
load()
|
||||
$.ajax({
|
||||
url:"/device/device_del", //请求的url地址
|
||||
dataType:"json", //返回格式为json
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:{"id":id,'is_del':is_del}, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
//请求成功时处理
|
||||
if(req['code'] == 0){
|
||||
//发异步把用户状态进行更改
|
||||
$(obj).attr('title',title)
|
||||
if(is_del == 1){
|
||||
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
|
||||
}else{
|
||||
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
|
||||
}
|
||||
layer.msg('已'+ title,{icon: num});
|
||||
}else{
|
||||
layer.msg('操作失败!',{icon: 5});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
function activateAll (argument) {
|
||||
layer.confirm('确认要激活吗?',function(index){
|
||||
//捉到所有被选中的,发异步进行删除
|
||||
$.ajax({
|
||||
url:"/de/admin/device/device_all", //请求的url地址
|
||||
dataType:"json", //返回格式为json
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:{"id":batch_id,'state':argument}, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
//请求成功时处理
|
||||
if(req['code'] == 0){
|
||||
//发异步把用户状态进行更改
|
||||
// layer.msg('停用成功', {icon: 1});
|
||||
layer.msg('操作成功', {
|
||||
icon: 1,
|
||||
time: 1000, // 提示显示1秒
|
||||
end: function(){ // 提示结束后执行
|
||||
window.location.reload(); // 刷新页面
|
||||
}
|
||||
});
|
||||
// $(".layui-form-checked").not('.header').parents('tr').find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
|
||||
}else{
|
||||
layer.msg('操作失败!',{icon: 2});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
}});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function find(pd) {
|
||||
if(!page_num || pd == 'y'){
|
||||
page_num = 1;
|
||||
}
|
||||
|
||||
page({
|
||||
"status_num":$('#status_num').val(),
|
||||
"tel":$('#tel').val(),
|
||||
"email":$('#email').val(),
|
||||
"s_time":$('#s_time').val(),
|
||||
"e_time":$('#e_time').val(),
|
||||
"page_num":page_num,
|
||||
"tt":1},pd);
|
||||
}
|
||||
function page(data,pd) {
|
||||
console.log(data)
|
||||
load()
|
||||
$.ajax({
|
||||
url: "member_list", //请求的url地址s
|
||||
dataType: "json", //返回格式为json
|
||||
async: true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data: data, //参数值
|
||||
type: "POST", //请求方式
|
||||
success: function (req) {
|
||||
console.log(req)
|
||||
c_load();
|
||||
if (req['code'] == 0) {
|
||||
|
||||
var str,str_s,str_c,str_all="";
|
||||
|
||||
for (let i = 0; i < req['data']['data'].length; i++) {
|
||||
if(req['data']['data'][i]['is_del'] == 1){
|
||||
str = '<span onclick="member_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
|
||||
}else{
|
||||
str = '<span onclick="member_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
|
||||
}
|
||||
str_c = "<tr>"+
|
||||
'<td><input type="checkbox" name="id" value="'+req['data']['data'][i]['id']+'" lay-skin="primary"></td>'+
|
||||
'<td>'+req['data']['data'][i]['id']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['token']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['tel']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['email']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
|
||||
'<td class="td-status">'+
|
||||
str+
|
||||
'</td>'
|
||||
'</tr>'
|
||||
str_all = str_all+str_c;
|
||||
}
|
||||
$('#content').html(str_all);
|
||||
|
||||
form.render();
|
||||
if(pd == 'y'){
|
||||
$("#page").html("")
|
||||
laypage.render({
|
||||
elem: 'page',
|
||||
count: req['data']['num'], //数据总数,从服务端得到
|
||||
limit: 10,
|
||||
groups:10,
|
||||
jump: function (obj, first) {
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
page_num = obj.curr;
|
||||
// page({"page":page_num,"tt":1});
|
||||
find("n")
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
layer.msg(req['msg'])
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
//请求出错处理
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//加载提示开启
|
||||
function load() {
|
||||
var index = layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
}
|
||||
// 关闭加载提示
|
||||
function c_load() {
|
||||
layer.close(layer.index)
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,357 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="x-admin-sm">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>所有设备管理</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<style>
|
||||
/* th{
|
||||
min-width:30px;
|
||||
} */
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="x-nav">
|
||||
<span class="layui-breadcrumb">
|
||||
<a href="">首页</a>
|
||||
<a href="">演示</a>
|
||||
<a>
|
||||
<cite>导航元素</cite></a>
|
||||
</span>
|
||||
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
|
||||
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
|
||||
</div>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<!-- <div class="layui-card-body ">
|
||||
<form class="layui-form layui-col-space5">
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="s_time">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="e_time">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input type="text" name="username" placeholder="请输入用户手机" autocomplete="off" class="layui-input" id="tel">
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<input type="text" name="username" placeholder="请输入用户邮箱" autocomplete="off" class="layui-input" id="email">
|
||||
</div>
|
||||
<div class="layui-input-inline layui-show-xs-block">
|
||||
<select name="contrller" id="status_num">
|
||||
<option value="">状态</option>
|
||||
<option value="0">启用</option>
|
||||
<option value="1">停用</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-show-xs-block">
|
||||
<div class="layui-btn" lay-submit="" lay-filter="sreach" onclick="find('y')"><i class="layui-icon"></i></div>
|
||||
</div>
|
||||
</form>
|
||||
</div> -->
|
||||
<div class="layui-card-header">
|
||||
<!-- <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量停用</button> -->
|
||||
<!-- <button class="layui-btn" onclick="xadmin.open('添加用户','/appversion/app_add','100%','100%')"><i class="layui-icon"></i>添加</button> -->
|
||||
<!-- <button class="layui-btn" onclick="xadmin.open('添加版本','/device/device_add','50%','70%')"><i class="layui-icon"></i>添加</button> -->
|
||||
</div>
|
||||
<div class="layui-card-body layui-table-body layui-table-main">
|
||||
<table class="layui-table layui-form">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>设备型号</th>
|
||||
<th>批次编号</th>
|
||||
<th>创建时间</th>
|
||||
<th>创建人</th>
|
||||
<th>是否激活</th>
|
||||
<th>操作</th></tr>
|
||||
</thead>
|
||||
<tbody id='content'>
|
||||
|
||||
{volist name="result" id="vo"}
|
||||
<tr>
|
||||
<td>{$vo.id}</td>
|
||||
<td>{$vo.name}</td>
|
||||
<td>{$vo.batch_code}</td>
|
||||
<td>{$vo.create_time}</td>
|
||||
<td>{$vo.token}</td>
|
||||
{if condition="$vo.is_activate == 1"}
|
||||
<td style="color:green;font-weight: bold;">已激活</td>
|
||||
<!-- <span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span> -->
|
||||
{else /}
|
||||
<td style="color:red;font-weight: bold;">未激活</td>
|
||||
<!-- <span onclick="app_stop(this,'{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span> -->
|
||||
{/if}
|
||||
<td>
|
||||
<button class="layui-btn" onclick="xadmin.open('查看设备码','/de/admin/device/device_list?id={$vo.id}','100%','100%')">查看设备码</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="layui-card-body ">
|
||||
<div id="page" style="text-align: center;">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="layui-card-body ">
|
||||
<div class="page">
|
||||
<div>
|
||||
<a class="prev" href=""><<</a>
|
||||
<a class="num" href="">1</a>
|
||||
<span class="current">2</span>
|
||||
<a class="num" href="">3</a>
|
||||
<a class="num" href="">489</a>
|
||||
<a class="next" href="">>></a>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
var form
|
||||
layui.use(['laydate','form'], function(){
|
||||
var laydate = layui.laydate;
|
||||
form = layui.form;
|
||||
|
||||
|
||||
// 监听全选
|
||||
form.on('checkbox(checkall)', function(data){
|
||||
|
||||
if(data.elem.checked){
|
||||
$('tbody input').prop('checked',true);
|
||||
}else{
|
||||
$('tbody input').prop('checked',false);
|
||||
}
|
||||
form.render('checkbox');
|
||||
});
|
||||
|
||||
//执行一个laydate实例
|
||||
laydate.render({
|
||||
elem: '#s_time' //指定元素
|
||||
});
|
||||
|
||||
//执行一个laydate实例
|
||||
laydate.render({
|
||||
elem: '#e_time' //指定元素
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
var page_num;
|
||||
var laypage;
|
||||
var all_page = "{$num}";
|
||||
layui.use('laypage', function () {
|
||||
laypage = layui.laypage;
|
||||
|
||||
//执行一个laypage实例
|
||||
laypage.render({
|
||||
elem: 'page',
|
||||
count: all_page, //数据总数,从服务端得到
|
||||
limit: 10,
|
||||
groups:10,
|
||||
jump: function (obj, first) {
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
page_num = obj.curr;
|
||||
find("n")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*用户-停用*/
|
||||
function app_stop(obj,id){
|
||||
|
||||
// return
|
||||
var title = '',is_del,num
|
||||
if($(obj).attr('title')=='启用'){
|
||||
title = '停用'
|
||||
is_del = 1
|
||||
num = 5
|
||||
}else{
|
||||
title = '启用'
|
||||
is_del = 0
|
||||
num = 6
|
||||
}
|
||||
// console.log('点击时'+$(obj).attr('title')+'====='+id+'===传到后台是否删除:'+is_del)
|
||||
layer.confirm('确认要'+ title +'吗?',function(index){
|
||||
load()
|
||||
$.ajax({
|
||||
url:"/device/device_del", //请求的url地址
|
||||
dataType:"json", //返回格式为json
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:{"id":id,'is_del':is_del}, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
//请求成功时处理
|
||||
if(req['code'] == 0){
|
||||
//发异步把用户状态进行更改
|
||||
$(obj).attr('title',title)
|
||||
if(is_del == 1){
|
||||
$(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已'+ title);
|
||||
}else{
|
||||
$(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已'+ title);
|
||||
}
|
||||
layer.msg('已'+ title,{icon: num});
|
||||
}else{
|
||||
layer.msg('操作失败!',{icon: 5});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
function delAll (argument) {
|
||||
// layer.msg('停用成功', {icon: 2});
|
||||
// return
|
||||
var ids = [];
|
||||
// 获取选中的id
|
||||
$('tbody input').each(function(index, el) {
|
||||
if($(this).prop('checked')){
|
||||
ids.push($(this).val())
|
||||
}
|
||||
});
|
||||
if(ids.length <= 0){
|
||||
return
|
||||
}
|
||||
console.log(ids);
|
||||
layer.confirm('确认要停用吗?ID为:'+ids.toString(),function(index){
|
||||
//捉到所有被选中的,发异步进行删除
|
||||
$.ajax({
|
||||
url:"/device/device_del", //请求的url地址
|
||||
dataType:"json", //返回格式为json
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:{"id":ids,'is_del':1}, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
c_load()
|
||||
//请求成功时处理
|
||||
if(req['code'] == 0){
|
||||
//发异步把用户状态进行更改
|
||||
layer.msg('停用成功', {icon: 1});
|
||||
$(".layui-form-checked").not('.header').parents('tr').find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
|
||||
}else{
|
||||
layer.msg('操作失败!',{icon: 2});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
}});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function find(pd) {
|
||||
if(!page_num || pd == 'y'){
|
||||
page_num = 1;
|
||||
}
|
||||
|
||||
page({
|
||||
"status_num":$('#status_num').val(),
|
||||
"tel":$('#tel').val(),
|
||||
"email":$('#email').val(),
|
||||
"s_time":$('#s_time').val(),
|
||||
"e_time":$('#e_time').val(),
|
||||
"page_num":page_num,
|
||||
"tt":1},pd);
|
||||
}
|
||||
function page(data,pd) {
|
||||
console.log(data)
|
||||
load()
|
||||
$.ajax({
|
||||
url: "member_list", //请求的url地址s
|
||||
dataType: "json", //返回格式为json
|
||||
async: true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data: data, //参数值
|
||||
type: "POST", //请求方式
|
||||
success: function (req) {
|
||||
console.log(req)
|
||||
c_load();
|
||||
if (req['code'] == 0) {
|
||||
|
||||
var str,str_s,str_c,str_all="";
|
||||
|
||||
for (let i = 0; i < req['data']['data'].length; i++) {
|
||||
if(req['data']['data'][i]['is_del'] == 1){
|
||||
str = '<span onclick="member_stop(this,\''+req['data']['data'][i]['id']+'\')" class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled" title="停用">已停用</span>'
|
||||
}else{
|
||||
str = '<span onclick="member_stop(this,\''+ req['data']['data'][i]['id'] +'\')" class="layui-btn layui-btn-normal layui-btn-mini" title="启用">已启用</span>'
|
||||
}
|
||||
str_c = "<tr>"+
|
||||
'<td><input type="checkbox" name="id" value="'+req['data']['data'][i]['id']+'" lay-skin="primary"></td>'+
|
||||
'<td>'+req['data']['data'][i]['id']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['token']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['tel']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['email']+'</td>'+
|
||||
'<td>'+req['data']['data'][i]['create_time']+'</td>'+
|
||||
'<td class="td-status">'+
|
||||
str+
|
||||
'</td>'
|
||||
'</tr>'
|
||||
str_all = str_all+str_c;
|
||||
}
|
||||
$('#content').html(str_all);
|
||||
|
||||
form.render();
|
||||
if(pd == 'y'){
|
||||
$("#page").html("")
|
||||
laypage.render({
|
||||
elem: 'page',
|
||||
count: req['data']['num'], //数据总数,从服务端得到
|
||||
limit: 10,
|
||||
groups:10,
|
||||
jump: function (obj, first) {
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
page_num = obj.curr;
|
||||
// page({"page":page_num,"tt":1});
|
||||
find("n")
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} else {
|
||||
layer.msg(req['msg'])
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
//请求出错处理
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//加载提示开启
|
||||
function load() {
|
||||
var index = layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
}
|
||||
// 关闭加载提示
|
||||
function c_load() {
|
||||
layer.close(layer.index)
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
<!doctype html>
|
||||
<html class="x-admin-sm">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>后台登录-X-admin2.2</title>
|
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<!-- <link rel="stylesheet" href="./css/theme5.css"> -->
|
||||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<script>
|
||||
// 是否开启刷新记忆tab功能
|
||||
// var is_remember = false;
|
||||
</script>
|
||||
</head>
|
||||
<body class="index">
|
||||
<!-- 顶部开始 -->
|
||||
<div class="container">
|
||||
<div class="logo">
|
||||
<a href="./index.html">X-admin v2.2</a></div>
|
||||
<div class="left_open">
|
||||
<a><i title="展开左侧栏" class="iconfont"></i></a>
|
||||
</div>
|
||||
|
||||
<ul class="layui-nav right" lay-filter="">
|
||||
<li class="layui-nav-item">
|
||||
<a href="javascript:;">admin</a>
|
||||
<dl class="layui-nav-child">
|
||||
<!-- 二级菜单 -->
|
||||
<dd>
|
||||
<a onclick="xadmin.open('切换帐号','http://www.baidu.com')">切换帐号</a></dd>
|
||||
<dd>
|
||||
<a href="./login.html">退出</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 顶部结束 -->
|
||||
<!-- 中部开始 -->
|
||||
<!-- 左侧菜单开始 -->
|
||||
<div class="left-nav">
|
||||
<div id="side-nav">
|
||||
<ul id="nav">
|
||||
<li>
|
||||
<a href="javascript:;">
|
||||
<i class="iconfont left-nav-li" lay-tips="设备管理"></i>
|
||||
<cite>设备管理</cite>
|
||||
<i class="iconfont nav_right"></i></a>
|
||||
<ul class="sub-menu">
|
||||
<li>
|
||||
<a onclick="xadmin.add_tab('设备批次','/de/admin/device/index')">
|
||||
<i class="iconfont"></i>
|
||||
<cite>设备批次</cite></a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="x-slide_left"></div> -->
|
||||
<!-- 左侧菜单结束 -->
|
||||
<!-- 右侧主体开始 -->
|
||||
<div class="page-content">
|
||||
<div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="home">
|
||||
<i class="layui-icon"></i>我的桌面</li></ul>
|
||||
<div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
|
||||
<dl>
|
||||
<dd data-type="this">关闭当前</dd>
|
||||
<dd data-type="other">关闭其它</dd>
|
||||
<dd data-type="all">关闭全部</dd></dl>
|
||||
</div>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<iframe src='/admin/welcome' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab_show"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-content-bg"></div>
|
||||
<style id="theme_style"></style>
|
||||
<!-- 右侧主体结束 -->
|
||||
<!-- 中部结束 -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="x-admin-sm">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>欢迎页面-X-admin2.2</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="/x_admin/js/xadmin.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid">
|
||||
<div class="layui-row layui-col-space15">
|
||||
|
||||
<div class="layui-col-sm12 layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">最新一周新增用户</div>
|
||||
<div class="layui-card-body" style="min-height: 280px;">
|
||||
<div id="main1" class="layui-col-sm12" style="height: 300px;"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-sm12 layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">最新一周PV/UV量</div>
|
||||
<div class="layui-card-body" style="min-height: 280px;">
|
||||
<div id="main2" class="layui-col-sm12" style="height: 300px;"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-sm12 layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">用户来源</div>
|
||||
<div class="layui-card-body" style="min-height: 280px;">
|
||||
<div id="main3" class="layui-col-sm12" style="height: 300px;"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-sm12 layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">硬盘使用量</div>
|
||||
<div class="layui-card-body" style="min-height: 280px;">
|
||||
<div id="main4" class="layui-col-sm12" style="height: 300px;"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('main1'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
grid: {
|
||||
top: '5%',
|
||||
right: '1%',
|
||||
left: '1%',
|
||||
bottom: '10%',
|
||||
containLabel: true
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['周一','周二','周三','周四','周五','周六','周日']
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [{
|
||||
name:'用户量',
|
||||
data: [820, 932, 901, 934, 1290, 1330, 1320],
|
||||
type: 'line',
|
||||
smooth: true
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('main2'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
tooltip : {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
label: {
|
||||
backgroundColor: '#6a7985'
|
||||
}
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
top: '5%',
|
||||
right: '2%',
|
||||
left: '1%',
|
||||
bottom: '10%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis : [
|
||||
{
|
||||
type : 'category',
|
||||
boundaryGap : false,
|
||||
data : ['周一','周二','周三','周四','周五','周六','周日']
|
||||
}
|
||||
],
|
||||
yAxis : [
|
||||
{
|
||||
type : 'value'
|
||||
}
|
||||
],
|
||||
series : [
|
||||
{
|
||||
name:'PV',
|
||||
type:'line',
|
||||
areaStyle: {normal: {}},
|
||||
data:[120, 132, 101, 134, 90, 230, 210],
|
||||
smooth: true
|
||||
},
|
||||
{
|
||||
name:'UV',
|
||||
type:'line',
|
||||
areaStyle: {normal: {}},
|
||||
data:[45, 182, 191, 234, 290, 330, 310],
|
||||
smooth: true,
|
||||
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('main3'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
tooltip : {
|
||||
trigger: 'item',
|
||||
formatter: "{a} <br/>{b} : {c} ({d}%)"
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: ['直接访问','邮件营销','联盟广告','视频广告','搜索引擎']
|
||||
},
|
||||
series : [
|
||||
{
|
||||
name: '访问来源',
|
||||
type: 'pie',
|
||||
radius : '55%',
|
||||
center: ['50%', '60%'],
|
||||
data:[
|
||||
{value:335, name:'直接访问'},
|
||||
{value:310, name:'邮件营销'},
|
||||
{value:234, name:'联盟广告'},
|
||||
{value:135, name:'视频广告'},
|
||||
{value:1548, name:'搜索引擎'}
|
||||
],
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = echarts.init(document.getElementById('main4'));
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
tooltip : {
|
||||
formatter: "{a} <br/>{b} : {c}%"
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '硬盘使用量',
|
||||
type: 'gauge',
|
||||
detail: {formatter:'{value}%'},
|
||||
data: [{value: 88, name: '已使用'}]
|
||||
}
|
||||
]
|
||||
};
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<!doctype html>
|
||||
<html class="x-admin-sm">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>后台登录-X-admin2.2</title>
|
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
|
||||
<meta http-equiv="Cache-Control" content="no-siteapp" />
|
||||
<link rel="stylesheet" href="/x_admin/css/font.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/login.css">
|
||||
<link rel="stylesheet" href="/x_admin/css/xadmin.css">
|
||||
<script type="text/javascript" src="/x_admin/js/jq.js"></script>
|
||||
<script src="/x_admin/lib/layui/layui.js" charset="utf-8"></script>
|
||||
|
||||
</head>
|
||||
<body class="login-bg">
|
||||
|
||||
<div class="login layui-anim layui-anim-up">
|
||||
<div class="message">设备录入管理后台</div>
|
||||
<div id="darkbannerwrap"></div>
|
||||
<form method="post" class="layui-form" >
|
||||
<input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input" >
|
||||
<hr class="hr15">
|
||||
<input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
|
||||
<hr class="hr15">
|
||||
<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
|
||||
<hr class="hr20" >
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
var pd = true
|
||||
layui.use('form', function(){
|
||||
var form = layui.form;
|
||||
// layer.msg('玩命卖萌中', function(){
|
||||
// //关闭后的操作
|
||||
// });
|
||||
//监听提交
|
||||
form.on('submit(login)', function(data){
|
||||
if(pd){
|
||||
pd = false
|
||||
console.log('进来了')
|
||||
$.ajax({
|
||||
url:"/de/admin/login_a", //请求的url地址
|
||||
dataType:"json", //返回格式为json
|
||||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||
data:{"username":data.field.username,"password":data.field.password}, //参数值
|
||||
type:"POST", //请求方式
|
||||
success:function(req){
|
||||
//请求成功时处理
|
||||
|
||||
if(req.code == 0){
|
||||
layer.msg('登录成功,准备跳转',function(){
|
||||
location.href='/de/admin/index'
|
||||
},500);
|
||||
}else{
|
||||
layer.msg('登录失败',function(){
|
||||
pd = true
|
||||
});
|
||||
}
|
||||
},
|
||||
error:function(){
|
||||
//请求出错处理
|
||||
pd = true
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
})
|
||||
</script>
|
||||
<!-- 底部结束 -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -424,7 +424,7 @@ class Cookbook extends Base{
|
|||
}
|
||||
}
|
||||
// 获取所有食材列表
|
||||
public function get_food_list($data=['food_level2_id'=>'2','search_data'=>'','page'=>1]){
|
||||
public function get_food_list($data=['food_level2_id'=>'6','search_data'=>'','page'=>1]){
|
||||
// 尝试捕获异常
|
||||
try {
|
||||
if(count(input('post.')) > 0){
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Countfood extends Base{
|
|||
'followlist'=>'app_user_follow_list',//关注列表
|
||||
'collect_list'=>'app_user_collect_list',//收藏列表
|
||||
'foodlist3'=>'app_z_national_standard_food_type_3',//食材列表3
|
||||
'foodlist4'=>'app_z_national_standard_food_type_4',//食材列表3
|
||||
'eat_log'=>'app_user_kcal_log',//食材列表3
|
||||
'user'=>'app_user_data',//banner
|
||||
];
|
||||
|
|
@ -74,9 +75,9 @@ class Countfood extends Base{
|
|||
}
|
||||
}
|
||||
// 获取记食器板块内容
|
||||
public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'time'=>'2025-08-25']){
|
||||
public function get_countfoot_content($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'time'=>'2025-09-17']){
|
||||
// 尝试捕获异常
|
||||
try {
|
||||
// try {
|
||||
if(count(input('post.')) > 0){
|
||||
$data = input('post.');
|
||||
}
|
||||
|
|
@ -101,20 +102,20 @@ class Countfood extends Base{
|
|||
|
||||
$return_data = $this->get_countfoot_content_action($data);
|
||||
return $return_data;
|
||||
} catch (\Exception $e) {
|
||||
// 捕获异常
|
||||
$logContent["flie"] = $e->getFile();
|
||||
$logContent["line"] = $e->getLine();
|
||||
$logContent['all_content'] = "异常信息:\n";
|
||||
$logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
$logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
$logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
$logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
$logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// 记录日志
|
||||
$this->record_api_log($data, $logContent, null);
|
||||
return json(['status' => 'error', 'message' => '系统错误']);
|
||||
}
|
||||
// } catch (\Exception $e) {
|
||||
// // 捕获异常
|
||||
// $logContent["flie"] = $e->getFile();
|
||||
// $logContent["line"] = $e->getLine();
|
||||
// $logContent['all_content'] = "异常信息:\n";
|
||||
// $logContent['all_content'] .= "消息: " . $e->getMessage() . "\n";
|
||||
// $logContent['all_content'] .= "代码: " . $e->getCode() . "\n";
|
||||
// $logContent['all_content'] .= "文件: " . $e->getFile() . "\n";
|
||||
// $logContent['all_content'] .= "行号: " . $e->getLine() . "\n";
|
||||
// $logContent['all_content'] .= "跟踪信息:\n" . $e->getTraceAsString() . "\n";
|
||||
// // 记录日志
|
||||
// $this->record_api_log($data, $logContent, null);
|
||||
// return json(['status' => 'error', 'message' => '系统错误']);
|
||||
// }
|
||||
}
|
||||
// 获取记食器记录
|
||||
public function get_log_list($data=['token'=>'caadd1be045a65f30b92aa805f1de54a','aud_id'=>1,'s_time'=>'2025-03-15','e_time'=>'2025-03-16']){
|
||||
|
|
@ -418,10 +419,13 @@ class Countfood extends Base{
|
|||
->alias('a')
|
||||
->join('app_z_national_standard_food_type_3 b','a.food_id = b.id','LEFT')
|
||||
->where("a.is_del = 0 AND a.aud_id = " . $data['aud_id'] . " AND CAST(a.create_time AS DATE) = CAST('" . $data['time'] . "' AS DATE)")
|
||||
->field('a.meals_type,a.food_name,a.weight,a.kcal_val,a.carbohydrate_val,a.protein_val,a.fat_val,a.id,\'https://tc.pcxbc.com\' + b.pic_url as pic_url')
|
||||
->field('a.meals_type,a.food_name,a.weight,a.kcal_val,a.carbohydrate_val,a.protein_val,a.fat_val,a.id,\'https://tc.pcxbc.com\' + b.pic_url as pic_url,a.food_id')
|
||||
->select();
|
||||
// dump($food_content);
|
||||
// die;
|
||||
|
||||
if(count($food_content) > 0){
|
||||
$food_content = $this->calculate_nutrients($food_content);
|
||||
}
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$return_data = [
|
||||
'suggestion'=>[
|
||||
|
|
@ -493,7 +497,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else if($value['meals_type'] == '午餐'){
|
||||
$return_data['list'][1]['val'] = bcadd($return_data['list'][1]['val'],$value['kcal_val'],2);
|
||||
|
|
@ -502,7 +509,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else if($value['meals_type'] == '晚餐'){
|
||||
$return_data['list'][2]['val'] = bcadd($return_data['list'][2]['val'],$value['kcal_val'],2);
|
||||
|
|
@ -511,7 +521,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else if($value['meals_type'] == '早加餐'){
|
||||
$return_data['list'][3]['val'] = bcadd($return_data['list'][3]['val'],$value['kcal_val'],2);
|
||||
|
|
@ -520,7 +533,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else if($value['meals_type'] == '午加餐'){
|
||||
$return_data['list'][4]['val'] = bcadd($return_data['list'][4]['val'],$value['kcal_val'],2);
|
||||
|
|
@ -529,7 +545,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else if($value['meals_type'] == '晚加餐'){
|
||||
$return_data['list'][5]['val'] = bcadd($return_data['list'][5]['val'],$value['kcal_val'],2);
|
||||
|
|
@ -538,7 +557,10 @@ class Countfood extends Base{
|
|||
'weight'=>$value['weight'].'克',
|
||||
'id'=>$value['id'],
|
||||
'pic_url'=>$value['pic_url'],
|
||||
'val'=>$value['kcal_val'].'kcal'
|
||||
// 'val'=>$value['kcal_val'].'kcal',
|
||||
'val'=>$value['kcal_val'],
|
||||
'nutrients_four' => $value['nutrients_four'],
|
||||
'nutrients_list' => $value['nutrients_list']
|
||||
]);
|
||||
}else{
|
||||
|
||||
|
|
@ -552,6 +574,7 @@ class Countfood extends Base{
|
|||
}
|
||||
$return_data['list'] = array_values($return_data['list']);
|
||||
$return_data['remaining_kcal'] = bcsub($return_data['suggestion']['kcal'],$return_data['today_intake']['kcal'],2)>=0?bcsub($return_data['suggestion']['kcal'],$return_data['today_intake']['kcal'],2):0;
|
||||
|
||||
return $this->msg($return_data);
|
||||
|
||||
}
|
||||
|
|
@ -850,6 +873,110 @@ class Countfood extends Base{
|
|||
'e_time' => $endTime->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
// 计算营养物质
|
||||
public function calculate_nutrients($data){
|
||||
// dump($data);
|
||||
$food_id_arr = [];
|
||||
for ($i=0; $i < count($data); $i++) {
|
||||
$food_id_arr[] = $data[$i]['food_id'];
|
||||
}
|
||||
|
||||
$cfc = Db::connect('cfc_db');
|
||||
$nutrients_list = $cfc->table($this->kitchenscale_db_msg['foodlist4'])
|
||||
->where("father_id in ('".implode("','",$food_id_arr)."')")
|
||||
// ->field()
|
||||
->select();
|
||||
|
||||
$nutrients_arr = ['VitaminA','VitaminB1','VitaminB2','VitaminB6','VitaminB12','VitaminD','VitaminK','Niacin','VitaminC','VitaminE','FolicAcid','Biotin','PantothenicAcid','TotalCholine','Ca','Phosphorus','Kalium','Mg','Na','Fe','Zn','Se','Cu','Mn','Iodine'];
|
||||
// dump($nutrients_list);
|
||||
// 加 bcadd(,,20)
|
||||
// 减 bcsub(,,20)
|
||||
// 乘 bcmul(,,20)
|
||||
// 除 bcdiv(,,20)
|
||||
for ($i=0; $i < count($data); $i++) {
|
||||
$data[$i]['nutrients_four'][] = [
|
||||
'name' => '卡路里',
|
||||
'unit' => 'kcal',
|
||||
'color' => '',
|
||||
'value' => $data[$i]['kcal_val'],
|
||||
'proportion' => 0,
|
||||
];
|
||||
$data[$i]['nutrients_four'][] = [
|
||||
'name' => '蛋白质',
|
||||
'unit' => 'g',
|
||||
'color' => '#5180D8',
|
||||
'value' => $data[$i]['protein_val'],
|
||||
'proportion' => bcmul(bcdiv($data[$i]['protein_val'],bcadd($data[$i]['protein_val'],bcadd($data[$i]['fat_val'],$data[$i]['carbohydrate_val'],20),20),2),100,0),
|
||||
];
|
||||
$data[$i]['nutrients_four'][] = [
|
||||
'name' => '脂肪',
|
||||
'unit' => 'g',
|
||||
'color' => '#ED7886',
|
||||
'value' => $data[$i]['fat_val'],
|
||||
'proportion' => bcmul(bcdiv($data[$i]['fat_val'],bcadd($data[$i]['protein_val'],bcadd($data[$i]['fat_val'],$data[$i]['carbohydrate_val'],20),20),2),100,0),
|
||||
];
|
||||
$data[$i]['nutrients_four'][] = [
|
||||
'name' => '碳水化合物',
|
||||
'unit' => 'g',
|
||||
'color' => '#FFB169',
|
||||
'value' => $data[$i]['carbohydrate_val'],
|
||||
'proportion' => bcmul(bcdiv($data[$i]['carbohydrate_val'],bcadd($data[$i]['protein_val'],bcadd($data[$i]['fat_val'],$data[$i]['carbohydrate_val'],20),20),2),100,0),
|
||||
];
|
||||
$data[$i]['nutrients_list'][] = [
|
||||
'name' => 'Calorie',
|
||||
'name_ch' => '卡路里',
|
||||
'unit' => 'kcal',
|
||||
'value' => $data[$i]['kcal_val'],
|
||||
'type' => 1,
|
||||
'type_name' => '能量及宏量营养素',
|
||||
'color' => '#C4FFE0',
|
||||
];
|
||||
$data[$i]['nutrients_list'][] = [
|
||||
'name' => 'Protein',
|
||||
'name_ch' => '蛋白质',
|
||||
'unit' => 'g',
|
||||
'value' => $data[$i]['protein_val'],
|
||||
'type' => 1,
|
||||
'type_name' => '能量及宏量营养素',
|
||||
'color' => '#C4FFE0',
|
||||
];
|
||||
$data[$i]['nutrients_list'][] = [
|
||||
'name' => 'Fat',
|
||||
'name_ch' => '脂肪',
|
||||
'unit' => 'g',
|
||||
'value' => $data[$i]['fat_val'],
|
||||
'type' => 1,
|
||||
'type_name' => '能量及宏量营养素',
|
||||
'color' => '#C4FFE0',
|
||||
];
|
||||
$data[$i]['nutrients_list'][] = [
|
||||
'name' => 'Carbohydrate',
|
||||
'name_ch' => '碳水化合物',
|
||||
'unit' => 'g',
|
||||
'value' => $data[$i]['carbohydrate_val'],
|
||||
'type' => 1,
|
||||
'type_name' => '能量及宏量营养素',
|
||||
'color' => '#C4FFE0',
|
||||
];
|
||||
foreach ($nutrients_list as $key => $value) {
|
||||
if($value['father_id'] == $data[$i]['food_id']){
|
||||
if(in_array($value['name'],$nutrients_arr)){
|
||||
$data[$i]['nutrients_list'][] = [
|
||||
'name' => $value['name'],
|
||||
'name_ch' => $value['name_ch'],
|
||||
'unit' => $value['unit'],
|
||||
'value' => bcmul($value['value'],bcdiv($data[$i]['weight'],100,20),2),
|
||||
'type' => $value['type'],
|
||||
'type_name' => $value['type'] == 1?'能量及宏量营养素':($value['type'] == 2?'维生素':($value['type'] == 3?'矿物质':'')),
|
||||
'color' => $value['type'] == 1?'#C4FFE0':($value['type'] == 2?'#FFEFB7':($value['type'] == 3?'#7DA8E0':'')),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -359,6 +359,8 @@ class Savemsg extends Base{
|
|||
######################################################测试#########################################################
|
||||
|
||||
public function ceshiyong(){
|
||||
$data = input('post.');
|
||||
dump($data);
|
||||
// // 添加测试一维码数据
|
||||
// $data = [];
|
||||
// for ($i = 0; $i < 500; $i++) {
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ class Msginformation extends Base{
|
|||
'notice'=>[],
|
||||
'banner'=>[]
|
||||
];
|
||||
// return $this->msg($return_data);
|
||||
return $this->msg($return_data);
|
||||
// 所有可用记录.
|
||||
$all_data = Db::table($this->msginformation_use_db_name['3'])->where("is_del = 0 AND scene_data IN (1,2,3)")->order('sort_num')->select();
|
||||
// 用户阅读记录
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class Qrcode extends Base{
|
|||
$pathinfo_video = pathinfo($name_video);
|
||||
$extension_video = strtolower($pathinfo_video['extension']); // 转换为小写以进行不区分大小写的比较
|
||||
$new_filename_video = 'pic_'.time().$this->generateRandomString(). '.' . $extension_video;
|
||||
$info_video = $video->validate(['size'=>90*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
|
||||
$info_video = $video->validate(['size'=>1024*1024*1024,'ext'=>'mp4,avi,mkv,wmv'])->move(ROOT_PATH . 'public' . DS . 'teaching_video',$new_filename_video);
|
||||
if(!$info_video){
|
||||
// 上传失败获取错误信息
|
||||
unlink(ROOT_PATH . 'public' . DS . 'teaching_video' . DS . $new_filename_pic);
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@
|
|||
|
||||
<div><span>设备图片:</span><button onclick="change_action_pic()">选择图片</button><span style="font-size: 12px;color: red;">请不要上传超过10M的图片</span></div></br>
|
||||
<div><span>图片预览:</span><img id="show_pic" src="" alt=""></div></br>
|
||||
<div><span>设备视频:</span><button onclick="change_action_video()">选择视频</button><span style="font-size: 12px;color: red;">请不要上传超过90M的视频,大于90M的视频概率会导致提交失败</span></div></br>
|
||||
<div><span>设备视频:</span><button onclick="change_action_video()">选择视频</button><span style="font-size: 12px;color: red;">请不要上传超过1G的视频,大于1G的视频概率会导致提交失败</span></div></br>
|
||||
<div><span>视频名称:</span><span id="show_video"></span></div></br>
|
||||
<div>
|
||||
<span>设备分类:</span>
|
||||
|
|
|
|||
|
|
@ -626,11 +626,30 @@ Route::any('/z/print_combined_code', 'app/ZengJieCode/admin.printaction/print_co
|
|||
################################################################下面是设备入库录入################################################################
|
||||
################################################################################################################################################
|
||||
// 默认配置
|
||||
Route::any('/de/login', 'app/DeviceEnter/Wechat/login');
|
||||
// 默认配置
|
||||
Route::any('/de/config_msg', 'app/DeviceEnter/savemsg/config_msg');
|
||||
// 存入设备信息
|
||||
Route::any('/de/save_device_msg', 'app/DeviceEnter/savemsg/save_device_msg');
|
||||
// 获取设备批次列表
|
||||
Route::any('/de/device_batch_list', 'app/DeviceEnter/savemsg/device_batch_list');
|
||||
// 详细批次数据
|
||||
Route::any('/de/device_content_msg', 'app/DeviceEnter/savemsg/device_content_msg');
|
||||
// 详细批次数据
|
||||
Route::any('/de/ceshi', 'app/DeviceEnter/savemsg/ceshi');
|
||||
################################################################管理后台
|
||||
// 登录页
|
||||
Route::any('/de/admin/login', 'app/DeviceEnter/admin.login/login');
|
||||
Route::any('/de/admin/login_a', 'app/DeviceEnter/admin.login/login_action');
|
||||
|
||||
// 首页
|
||||
Route::any('/de/admin/index', 'app/DeviceEnter/admin.index/index');
|
||||
Route::any('/de/admin/welcome', 'app/DeviceEnter/admin.index/welcome');
|
||||
|
||||
// 设备管理
|
||||
Route::any('/de/admin/device/index', 'app/DeviceEnter/admin.device/index');
|
||||
Route::any('/de/admin/device/device_list', 'app/DeviceEnter/admin.device/device_list');
|
||||
Route::any('/de/admin/device/device_all', 'app/DeviceEnter/admin.device/device_all');
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,37 @@ class Testuse extends Controller{
|
|||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$type_arr = [
|
||||
'Calorie' => 1,
|
||||
'Protein' => 1,
|
||||
'Fat' => 1,
|
||||
'Carbohydrate' => 1,
|
||||
'VitaminA' => 2,
|
||||
'VitaminB1' => 2,
|
||||
'VitaminB2' => 2,
|
||||
'VitaminB6' => 2,
|
||||
'VitaminB12' => 2,
|
||||
'VitaminD' => 2,
|
||||
'VitaminK' => 2,
|
||||
'Niacin' => 2,
|
||||
'VitaminC' => 2,
|
||||
'VitaminE' => 2,
|
||||
'FolicAcid' => 2,
|
||||
'Biotin' => 2,
|
||||
'PantothenicAcid' => 2,
|
||||
'TotalCholine' => 2,
|
||||
'Ca' => 3,
|
||||
'Phosphorus' => 3,
|
||||
'Kalium' => 3,
|
||||
'Mg' => 3,
|
||||
'Na' => 3,
|
||||
'Fe' => 3,
|
||||
'Zn' => 3,
|
||||
'Se' => 3,
|
||||
'Cu' => 3,
|
||||
'Mn' => 3,
|
||||
'Iodine' => 3,
|
||||
];
|
||||
foreach ($data as $key => $value) {
|
||||
$temporary_arr2 = [];
|
||||
foreach ($temporary_arr_title as $k => $v) {
|
||||
|
|
@ -121,10 +151,12 @@ class Testuse extends Controller{
|
|||
$temporary_arr2['name_ch'] = $temporary_arr2['desc'];
|
||||
unset($temporary_arr2['desc']);
|
||||
unset($temporary_arr2['description']);
|
||||
|
||||
$temporary_arr2['type'] = $type_arr[$temporary_arr2['name']];
|
||||
array_push($temporary_arr,$temporary_arr2);
|
||||
}
|
||||
// dump($type_arr);
|
||||
// dump($temporary_arr);
|
||||
// die;
|
||||
$cfc = Db::connect('cfc_db');
|
||||
// 获取账号下信息以及用户信息
|
||||
$user_data = $cfc->table('app_z_national_standard_food_type_4')->insertAll($temporary_arr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue