文件
mashangyoujiu/Application/SmallProgramApi/Controller/ResourceController.class.php

50 行
1.4 KiB
PHP
可执行文件

<?php
namespace SmallProgramApi\Controller;
use Think\Controller;
//[1.4.13]
class ResourceController extends BaseController
{
public function _initialize()
{
parent::_initialize();
if (empty(self::$store_id)) {
$result['status'] = 0;
$result['msg'] = '缺少门店ID';
$this->ajaxReturn($result);
}
}
public function getResourceList()
{
$map = [];
$keyword = I('post.keyword');
if (!empty($keyword)) {
$map['title|docuat'] = array('like', '%' . $keyword . '%');
}
$list = M("retail_resource")
->where($map)
->page($_POST['page'], $_POST['limit'])
->order('time desc')
->select();
$count = count(M("retail_news")->select());
foreach ($list as $k => &$val) {
$val['index'] = round(($_POST['page'] - 1) * $_POST['limit'] + $k + 1);
}
$res['code'] = 0;
$res['msg'] = '';
$res['data'] = $list;
$res['count'] = $count;
$this->ajaxReturn($res);
}
public function getResourceDetail()
{
$id = I('get.id');
$content = M('retail_resource')->where(array('id' => $id))->getField('content');
$content = htmlspecialchars_decode($content);
$this->assign('content', $content);
$this->display();
}
}