112 行
4.7 KiB
PHP
可执行文件
112 行
4.7 KiB
PHP
可执行文件
<?php
|
|
|
|
namespace Retail\Controller;
|
|
|
|
use Think\Controller;
|
|
//[1.1.96]
|
|
class BasetwoController extends BaseController
|
|
{
|
|
Public function _initialize()
|
|
{
|
|
$this->loadBaseInfo();
|
|
$this->checkwebset();
|
|
$user = session('ls_userinfo');
|
|
|
|
if ($user['account_type'] == 1) {
|
|
//商户+门店
|
|
$from_class = M('retail_store')->where(array('merchantid' => $user['id'],'state' => 0))->field('id,storetag as name')->select();
|
|
array_unshift($from_class, array('id' => -1, 'name' => '商户'));
|
|
array_unshift($from_class, array('id' => 0, 'name' => '所有'));
|
|
//商户upload_image_class
|
|
$merchantClass = M('upload_image_class')->where(array('p_id' => 3))->select();
|
|
array_unshift($merchantClass, array('id' => 0, 'name' => '所有'));
|
|
//门店upload_image_class
|
|
$storeClass = M('upload_image_class')->where(array('p_id' => 4))->select();
|
|
array_unshift($storeClass, array('id' => 0, 'name' => '所有'));
|
|
$this->assign('from_class', json_encode($from_class));
|
|
$this->assign('merchantClass', json_encode($merchantClass));
|
|
$this->assign('storeClass', json_encode($storeClass));
|
|
}else{
|
|
//门店是否有查看商户图片权限
|
|
$auth = M('retail_store_jurisdiction')->where(array('storeid' => session('storeid')))->find();
|
|
$from_class = M('upload_image_class')->where(array('type' => 2, 'p_id' => 4))->select();
|
|
if($auth['merchant_img_use'] == 1){
|
|
array_unshift($from_class, array('id' => -1, 'name' => '商户图片', 'type' => 4, 'p_id' => 4));
|
|
}
|
|
array_unshift($from_class, array('id' => 0, 'name' => '所有', 'type' => 4, 'p_id' => 4));
|
|
$this->assign('from_class', json_encode($from_class));
|
|
$this->assign('merchantClass', json_encode(array()));
|
|
$this->assign('storeClass', json_encode(array()));
|
|
}
|
|
|
|
}
|
|
public function getGalleryImages()
|
|
{
|
|
$user = session('ls_userinfo');
|
|
if (!empty($user)) {
|
|
$page = I('post.page');
|
|
$limit = I('post.limit');
|
|
$selectTypeC = I('post.selectTypeC');
|
|
$selectTypeD = I('post.selectTypeD');
|
|
$key = I('post.key');if (!empty($key)) {
|
|
$where['name|original_name'] = array('like', '%' . $key . '%');
|
|
}
|
|
if ($user['account_type'] == 1){
|
|
if($selectTypeC == -1){
|
|
//商户
|
|
$where['merchant_id'] = $user['id'];
|
|
$where['user_type'] = 3;
|
|
if($selectTypeD != ''){
|
|
$where['from_type_id'] = $selectTypeD;
|
|
}
|
|
}elseif($selectTypeC == 0){
|
|
//所有
|
|
$where['merchant_id'] = $user['id'];
|
|
}else{
|
|
//门店
|
|
$where['store_id'] = $selectTypeC;
|
|
$where['user_type'] = 4;
|
|
if($selectTypeD != ''){
|
|
$where['from_type_id'] = $selectTypeD;
|
|
}
|
|
}
|
|
}else{
|
|
if($selectTypeC == -1){
|
|
//商户图片
|
|
$where['merchant_id'] = $user['merchantid'];
|
|
$where['user_type'] = 3;
|
|
}elseif($selectTypeC == 0){
|
|
//所有图片
|
|
$where['merchant_id'] = $user['merchantid'];
|
|
}else{
|
|
//门店图片
|
|
$where['store_id'] = session('storeid');
|
|
$where['from_type_id'] = $selectTypeC;
|
|
}
|
|
}
|
|
$images = D('ImageGallery')->getSelect($where, 'id,path,name,original_name,size', 'id desc', $page, $limit);
|
|
if($images){
|
|
foreach ($images as &$val) {
|
|
if ($val['add_time']) {
|
|
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
|
|
}
|
|
if ($val['size']) {
|
|
$val['size'] = getFileSize($val['size']);
|
|
}
|
|
$val['checked'] = false;
|
|
}
|
|
$res['list'] = $images;
|
|
$res['status'] = 1;
|
|
$res['msg'] = '获取成功';
|
|
}else{
|
|
$res['list'] = array();
|
|
$res['status'] = 1;
|
|
$res['msg'] = '暂无数据';
|
|
}
|
|
}else{
|
|
$res['status'] = 0;
|
|
$res['msg'] = '登录超时';
|
|
}
|
|
$this->ajaxReturn($res);
|
|
}
|
|
} |