Files
2021-07-05 09:56:27 +08:00

81 lines
2.3 KiB
PHP
Executable File

<?php
defined('WXAPP_CONTENT') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2019/12/10
* Time: 11:32
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
class Cms extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = 'all';//登录白名单
$this->majia_white = array('get');//超级管理员披上马甲可操作权限
$this->load->model('app/appusual/app_cms_model', 'cms_model');
}
/**
* @return array
* @throws Exception
*/
protected function get()
{
$page = $this->input_param('page');
$size = $this->input_param('size');
$position = $this->input_param('position');
$type = $this->input_param('type');
!$page && $page = 1;
!$size && $size = 20;
$now = time();
$where = array(
'app_id' => $this->app_id,
'status' => self::STATUS_NOR,
);
if (is_numeric($position)) {
$where['position'] = $position;
} elseif ($position) {
$where["position in ({$position})"] = null;
}
if($type == 1){
$where['e_time <= '] = time();
} else {
$where['e_time >= '] = time();
}
$total = $this->cms_model->count($where);
$lists = array();
if ($total) {
$select = 'id, title, cover, url, position, content,e_time';
$rows = $this->cms_model->select($where, 'sort desc, id desc', $page, $size, $select);
foreach ($rows as $item) {
$value = array(
'id' => $item['id'],
'title' => $item['title'],
'img' => $item['cover'] ? build_qiniu_image_url($item['cover']) : '',
'url' => build_app_url($item['url']),
'content' => $item['content'],
'e_time' => date('Y-m-d H:i:s',$item['e_time']),
'status' => $item['e_time']<time() ? 0 : 1,
);
$lists[] = $value;
}
}
$data = array(
'list' => $lists,
'total' => $total
);
return $data;
}
}