目录
一、项目技术介绍
软件开发环境及开发工具:
后台语言:PHP
安卓框架:Uniapp
JDK版本:JDK1.8
服务器:tomcat9.0
数据库:mysql 5.7
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
二、项目功能介绍
功能介绍:
本系统使用php、uni-app框架、MySQL数据库技术开发的四大名著儿童阅读app,系统分为前台和后台,用户和管理员两种用户角色,不同的用户角色有不同的功能模块,管理员可以根据系统给定的账号进行登录,登录后可以进入四大名著儿童阅读app,对后台所有模块进行管理。包括查看和修改自己的个人信息以及登录密码。该系统为每一个用户都分配了一个用户账号,用户通过账号的登录可以在系统中查看app内容及对个人信息进行修改等功能。
前台用户端:App的登录与注册,首页,图书信息,留言反馈,学习园地,个人中心等功能模块;
后台管理员端:管理员登录,首页,个人中心,用户管理,故事人物管理、图书信息管理,学习园地,系统管理等功能模块。
下面是系统运行起来后的一些截图:











三、相关代码
<?php
session_start();
class ConfigController extends CommonController {
public function __construct()
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header('Access-Control-Allow-Headers:Origin,Content-Type,Accept,token,X-Requested-With,device');
}
public $columData = [
'id','name','value'
];
/**
* 分页,列表
* get
*/
public function page(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$page = isset($_GET['page'])?$_GET['page']:"1";
$limt = isset($_GET['limit'])?$_GET['limit']:"10";
$sort = isset($_GET['sort'])?$_GET['sort']:"id";
$order = isset($_GET['order'])?$_GET['order']:"asc";
$where = "";//查询条件
$sql = "select * from `config`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 1;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*10;
$lists = "select * from `config` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 分页,列表list
* get
*/
public function lists(){
$page = isset($_GET['page'])?$_GET['page']:"1";
$limt = isset($_GET['limit'])?$_GET['limit']:"10";
$sort = isset($_GET['sort'])?$_GET['sort']:"id";
$order = isset($_GET['order'])?$_GET['order']:"asc";
$where = " where 1 ";//查询条件
$sql = "select * from `config`".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 1;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*10;
$lists = "select * from `config` ".$where." order by ".$sort." ".$order." limit ".$startCount.",".$limt;
$result = table_sql($lists);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' => [
"total" => $numberCount,
"pageSize" => $limt,
"totalPage" => $page_count,
"currPage" => $page,
"list" => $arrayData
]
]));
}
/**
* 新增数据接口
* post
*/
public function save(){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$keyArr = $valArr = array();
$tmpData = strval(file_get_contents("php://input"));//Content-Type: application/json 需要用到php://input 处理输入流
if (!empty($tmpData)&& isset($tmpData)){
$postData = json_decode($tmpData,true);
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if(!empty($value) || $value === 0) {
array_push($keyArr,"`".$key."`");
array_push($valArr,"'".$value."'");
}
}
}
}
$k = implode(',',$keyArr);
$v = implode(',',$valArr);
$sql = "INSERT INTO `config` (".$k.") VALUES (".$v.")";
$result = table_sql($sql);
if (!$result) exit(json_encode(['code'=>500,'msg'=>"新增失败"]));
exit(json_encode(['code'=>0]));
}
/**
* 更新接口
* post
*/
public function update(){
$tmpData = strval(file_get_contents("php://input"));
$postData = json_decode($tmpData,true);
$length = count($postData);
$v = array();
$i=0;
foreach ($postData as $key => $value){
if (in_array($key, $this->columData)){
if ($key == "id"){
$id = $value;
}
array_push($v,$key." = '".$value."'");
}
}
$value = implode(',',$v);
$sql = "UPDATE config SET ".$value." where id = ".$id;
$result = table_sql($sql);
if (!$result) echo json_encode(['code'=>500,'msg'=>"修改失败"]);
exit(json_encode(['code'=>0]));
}
/**
* 查询一条数据
* get
*/
public function info($id=false){
$token = $this->token();
$tokens = json_decode(base64_decode($token),true);
if (!isset($tokens['id']) || empty($tokens['id'])) exit(json_encode(['code'=>403,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$name = isset($_REQUEST['name'])? $_REQUEST['name']:"";
if (!empty($id)){
$where = "`id` = ".$id;
}else{
$where = "`name` = ".$name;
}
$sql = "select * from `config` where ".$where;
$result = table_sql($sql);
if (!$result) echo json_encode(['code'=>500,'msg'=>"查询数据发生错误。"]);
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
$lists = $row;
}
}
exit(json_encode([
'code'=>0,
'data'=> $lists
]));
}
}

1995

被折叠的 条评论
为什么被折叠?



