开发环境
编程语言:PHP
数据库 :Mysql
系统架构:B/S
前端技术:Vue
运行工具:PHPStudy
支持定做:java/php/python/android/小程序vue/爬虫/c#/asp.net
系统截图
核心代码
<?php
session_start();
class CaipinxinxiController 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','addtime'
,'caipinbianhao'
,'caipinmingcheng'
,'caipinfenlei'
,'tupian'
,'caipinjiage'
,'caipinshuliang'
,'caipinjieshao'
,'discussnum'
,'storeupnum'
];
/**
* 分页,列表
* 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'=>401,'msg'=>"你还没有登录。"]));
$userid = $tokens['id'];
$where = " where 1 ";//查询条件
$orwhere = '';
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
foreach ($_REQUEST as $k => $val){
if(in_array($k, $this->columData)){
if ($val != ''){
$where.= " and ".$k." like '".$val."'";
}
}
}
$sql = "select * from `caipinxinxi` ".$where;
$count = table_sql($sql);
if ($count->num_rows < 1){
$numberCount = 0;
}else{
$numberCount = $count->num_rows;
}
$page_count = ceil($numberCount/$limt);//页数
$startCount = ($page-1)*$limt;
$where .= empty($orwhere) ? '' : "and (".$orwhere.")";
$lists = "select * from `caipinxinxi` ".$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(){
$sql = "select * from `caipinxinxi`";
$result = table_sql($sql);
$arrayData = array();
if ($result->num_rows > 0) {
while ($datas = $result->fetch_assoc()){
array_push($arrayData,$datas);
}
}
exit(json_encode([
'code'=>0,
'data' =>$arrayData
]));
}
/**
* 分页,列表list
* get
*/
public function list(){
$page = isset($_REQUEST['page'])?$_REQUEST['page']:"1";
$limt = isset($_REQUEST['limit'])?$_REQUEST['limit']:"10";
$sort = isset($_REQUEST['sort'])?$_REQUEST['sort']:"id";
$order = isset($_REQUEST['order'])?$_REQUEST['order']:"asc";
$refid = isset($_REQUEST['refid']) ? $_REQUEST['refid'] : "0";
$where = " where 1 ";//查询条件
if(isset($_REQUEST['goodid'])) {
$where .= " and goodid = ".$_REQUEST['goodid']." ";
}