Commit 8e62fd6d authored by clone's avatar clone

合并test

parent 7e7e4166
<?php
use app\api_broker\extend\Basic;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/24
* Time : 14:24
* Intro:
*/
class FollowUp extends Basic{
public function __construct($request = null)
{
parent::__construct($request);
}
/**
* 报备
*/
public function report(){
$params = $this->params;
$params = array(
"user_id" => 1,
"shop_ids"=> "1,2,3",
""
);
$this->response("200","request success",[]);
}
}
\ No newline at end of file
<?php
namespace app\api_broker\controller;
class Index
{
public function index()
{
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
}
}
<?php
namespace app\api_broker\extend;
/**
* Created by PhpStorm.
* User: zw
* Date: 2018/1/24
* Time: 9:35
* 基类
*/
use app\model\Users;
use think\Controller;
use think\Request;
use think\Response;
use Qiniu;
class Basic extends Controller
{
/**
* 访问请求对象
* @var Request
*/
public $request;
public $params;
protected $authToken;
/**
* @var int userId
*/
protected $userId;
protected $userNick;
protected $phone;
protected $timeStamp_;
protected $filterVerify = array(
);
/**
* 基础接口SDK
* @param Request|null $request
*/
public function __construct(Request $request = null)
{
// CORS 跨域 Options 检测响应
$this->corsOptionsHandler();
// 输入对象
$this->request = is_null($request) ? Request::instance() : $request;
if (strtoupper($this->request->method()) === "GET") {
$this->params = $this->request->param();
} elseif (strtoupper($this->request->method()) === "POST") {
$this->params = $this->request->param() != null ? $this->request->param() : null;
}
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
}
/**
* token 验证
*/
public function tokenVerify()
{
if (!isset($this->params['AuthToken'])) {
echo json_encode(array( "code" => "300", "msg" => "AuthToken不能为空!", "data" => [], "type" => "json" ));
exit;
}
$this->verifyUserInfo();
$this->verifyTime();
}
public function verifyTime()
{
//authToken有效期为30天
if ((time() - $this->timeStamp_) > 2592000) {
echo json_encode(array( "code" => "300", "msg" => "AuthToken失效,请重新登录!", "data" => [], "type" => "json" ));
exit;
}
}
public function verifyUserInfo()
{
$userModel = new Users();
$userArr = $userModel->selectUser($this->userId);
if (count($userArr) > 0 && ($userArr["id"] != $this->userId || $userArr["user_phone"] != $this->phone)) {
echo json_encode(array( "code" => "300", "msg" => "用户验证失败,重新登录!", "data" => [], "type" => "json" ));
exit;
}
return true;
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $code 业务状态码
* @param mixed $data 要返回的数据
* @param string $type 返回类型 JSON XML
* @return Response
*/
public function response($code = 'SUCCESS', $msg, $data = [], $type = 'json')
{
$result = [ 'code' => $code, 'msg' => $msg, 'data' => $data, 'type' => strtolower($type) ];
return Response::create($result, $type);
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id 父ID Key
* @param string $pid ID Key
* @param string $son 定义子数据Key
* @return array
*/
public static function arr2tree($list, $id = 'id', $pid = 'pid', $son = 'sub')
{
list($tree, $map) = [ [], [] ];
foreach ($list as $item) {
$map[$item[$id]] = $item;
}
foreach ($list as $item) {
if (isset($item[$pid]) && isset($map[$item[$pid]])) {
$map[$item[$pid]][$son][] = &$map[$item[$id]];
} else {
$tree[] = &$map[$item[$id]];
}
}
unset($map);
return $tree;
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id ID Key
* @param string $pid 父ID Key
* @param string $path
* @param string $ppath
* @return array
*/
public static function arr2table(array $list, $id = 'id', $pid = 'pid', $path = 'path', $ppath = '')
{
$tree = [];
foreach (self::arr2tree($list, $id, $pid) as $attr) {
$attr[$path] = "{$ppath}-{$attr[$id]}";
$attr['sub'] = isset($attr['sub']) ? $attr['sub'] : [];
$attr['spl'] = str_repeat("&nbsp;&nbsp;&nbsp;├&nbsp;&nbsp;", substr_count($ppath, '-'));
$sub = $attr['sub'];
unset($attr['sub']);
$tree[] = $attr;
if (!empty($sub)) {
$tree = array_merge($tree, (array)self::arr2table($sub, $id, $pid, $path, $attr[$path]));
}
}
return $tree;
}
/**
* 获取数据树子ID
* @param array $list 数据列表
* @param int $id 起始ID
* @param string $key 子Key
* @param string $pkey 父Key
* @return array
*/
public static function getArrSubIds($list, $id = 0, $key = 'id', $pkey = 'pid')
{
$ids = [ intval($id) ];
foreach ($list as $vo) {
if (intval($vo[$pkey]) > 0 && intval($vo[$pkey]) === intval($id)) {
$ids = array_merge($ids, self::getArrSubIds($list, intval($vo[$key]), $key, $pkey));
}
}
return $ids;
}
/**
* Cors Options 授权处理
*/
public static function corsOptionsHandler()
{
if (request()->isOptions()) {
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers:Accept,Referer,Host,Keep-Alive,User-Agent,X-Requested-With,Cache-Control,Content-Type,Cookie,token');
header('Access-Control-Allow-Credentials:true');
header('Access-Control-Allow-Methods:GET,POST,OPTIONS');
header('Access-Control-Max-Age:1728000');
header('Content-Type:text/plain charset=UTF-8');
header('Content-Length: 0', true);
header('status: 204');
header('HTTP/1.0 204 No Content');
exit;
}
}
/**
* Cors Request Header信息
* @return array
*/
public static function corsRequestHander()
{
return [
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Credentials' => true,
'Access-Control-Allow-Methods' => 'GET,POST,OPTIONS',
'Access-Defined-X-Support' => 'service@cuci.cc',
'Access-Defined-X-Servers' => 'Guangzhou Cuci Technology Co. Ltd',
];
}
}
<?php
/**
* Created by PhpStorm.
* User: hujun
* Date: 2018/1/16
* Time: 13:51
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AuthGroup;
use app\model\AuthRule;
use think\Db;
class Auth extends Basic
{
protected $authGroupModel;
protected $authRuleModel;
function _initialize()
{
}
/**
* 权限列表页
*
* @return type
*/
public function index(){
return view('index');
}
/**
* 权限分配
*
* @param type $group_id
*/
public function access($group_id = 0) {
return view('access');
}
/**
* 用户组授权用户列表
*
* @param type $group_id
*/
public function accessUser($group_id = 0) {
return view('accessUser');
}
public function getAuth() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$auth_group = New AuthGroup();
$where = 'status <> 0';
$data['list'] = $auth_group->getList($pageNo, $pageSize, '','*', $where);
$data['total'] = $auth_group->getTotal($where);
return $this->response(200, '', $data);
}
/**
* 角色编辑
*/
public function roleEdit() {
//$this->assign('type','1');
// return $this->display();
return view('role_edit');
}
/**
* 验证数据
* @param string $validate 验证器名或者验证规则数组
* @param array $data [description]
* @return [type] [description]
*/
protected function validateData($data,$validate)
{
if (!$validate || empty($data)) return false;
$result = $this->validate($data,$validate);
if(true !== $result){
// 验证失败 输出错误信息
return $result;
}
return 1;
}
//添加角色
public function addAuth($group_id=0){
$data['status'] = 200;
$data['msg'] = '';
$title = $group_id ? '编辑':'新增';
$table= New AuthGroup();
$info= $table->find();
if (empty($group_id)) {
$data = input('post.');
$err=$this->validateData($data,
[
['title','require|chsAlpha','用户组名称不能为空|用户组名称只能是汉字和字母'],
['description','chsAlphaNum','描述只能是汉字字母数字']
]
);
if($err!=1){
return $this->response(100, $err);
}
$id = isset($data['id']) && $data['id']>0 ? $data['id']:false;
if ($table->editData($data,$id)) {
return $this->response(200, '成功');
} else {
return $this->response(101, '失败');
}
} else {
return $this->response(200, $title, $info);
}
}
public function test(){
// $this->authRuleModel = new AuthRule();
// dump($this->authRuleModel);die;
// $list= $this->authRuleModel->find();
// return $this->response(200, '', $list);
}
/**
* 权限分配
* @param integer $group_id 组ID
* @return [type] [description]
* @date 2018-01-22
* @author zfc
*/
public function accessLook($group_id=0){
$table= New AuthGroup();
$table2= New AuthRule();
$data['title']='权限分配';
// echo $group_id;
// exit;
if (IS_POST && $group_id=0) {
//添加or修改
$data['id'] = $group_id;
$menu_auth = input('post.menu_auth/a','');//获取所有授权菜单id
$data['rules'] = implode(',',$menu_auth);//拼接
$id = isset($data['id']) && $data['id']>0 ? $data['id']:false;
//开发过程中先关闭这个限制
//if($group_id==1){
//$this->error('不能修改超级管理员'.$title);
// }else{
if ( $table->editData($data,$id)) {
cache('admin_sidebar_menus_'.$this->currentUser['uid'],null);
return $this->response(200, '成功');
}else{
return $this->response(100, '失败');
}
//}
} else{
//查看
$role_auth_rule = $table->where(['id'=>intval($group_id)])->value('rules');
$data['menu_auth_rules']=explode(',',$role_auth_rule);//获取指定获取到的权限
}
$menu = $table2->where(['pid'=>0,'status'=>1])->order('sort asc')->select();
foreach($menu as $k=>$v){
$menu[$k]['_child']=$table2->where(['pid'=>$v['id']])->order('sort asc')->select();
}
$data['all_auth_rules']=$menu;//所以规则
return $this->response(200,'可以查看',$data);
}
/**
* 设置角色的状态
*/
public function setStatus($model ='auth_rule',$script = false){
$ids = input('request.ids/a');
if ($model =='AuthGroup') {
if (is_array($ids)) {
if(in_array(1, $ids)) {
$this->error('超级管理员不允许操作');
}
} else{
if($ids === 1) {
$this->error('超级管理员不允许操作');
}
}
} else{
//cache('admin_sidebar_menus_'.$this->currentUser['uid'],null);//清空后台菜单缓存
}
parent::setStatus($model);
}
//权限列表
public function authList(){
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 20 : $params['pageSize'];
$table= new authRule;
//条件
$field='a.id,a.name,a.title,a.depend_flag,a.type,a.pid,a.icon,a.sort,a.is_menu,a.status,b.name as name2';
$where='a.status=1';
$order='a.pid asc,a.sort asc';
$join=[['auth_rule b', ' a.pid=b.id','left']];
$list=$table->authList($pageNo, $pageSize,$order,$field,$join, $where);
// prt($list);//转化arr
//prt(collection($list)->toArray());//转化arr
return $this->response(200,'成功',$list);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hujun
* Date: 2018/1/17
* Time: 13:26
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\GBusinessDistrict;
use app\model\Regions;
class BusinessDistrict extends Basic
{
public function index() {
return view('business_district/index');
}
public function edit() {
if ($this->request->isPost()) {
$result['code'] = 200;
$result['msg'] = '';
$params = $this->request->param();
$business = new GBusinessDistrict();
if ($params['type'] == NULL) {
$data['province'] = $params['province'];
$data['city'] = $params['city'];
$data['disc'] = $params['disc'];
$data['province_code'] = $params['province_code'];
$data['city_code'] = $params['city_code'];
$data['disc_code'] = $params['disc_code'];
$data['name'] = $params['business'];
$data['create_time'] = date('Y-m-d H:i:s');
} else {
$data['status'] = $params['type'];
}
if ($params['id']) {
$num = $business->save($data, ['id' => $params['id']]);
} else {
$business->save($data);
$num = $business->id;
}
if ($num) {
$result['code'] = 200;
$result['msg'] = '添加成功';
} else {
$result['code'] = 101;
$result['msg'] = '添加失败';
}
return $this->response( $result['code'], $result['msg'], $result['data']);
} elseif ($this->request->param('id')) {
$business = new GBusinessDistrict();
$result['data'] = $business->get($this->request->param('id'));
return $this->response( 200, '', $result['data']);
} else{
return view('business_district/edit');
}
}
/**
* 删除商圈
*
* @return \think\Response
*/
public function del() {
$result['code'] = 200;
$result['msg'] = '';
$id = $this->request->param('id');
$business = new GBusinessDistrict();
$num = $business->save(['is_del' => 1],['id'=>$id]);
if ($num != 1) {
$result['code'] = 101;
}
return $this->response( $result['code'], '');
}
/**
* 获取商圈列表
*
* @return mixed
*/
public function getBusiness() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$auth_group = New GBusinessDistrict();
$where = 'is_del = 0';
if ($params['name'] != NULL) {
$where .= ' and name like "'.$params['name'].'%"';
}
$fields = 'id,name,province,city,disc,status,create_time';
$data['list'] = $auth_group->getList($pageNo, $pageSize, 'id desc',$fields, $where);
$data['total'] = $auth_group->getTotal($where);
return $this->response(200, '', $data);
}
/**
* 获取省市区数据
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function regions() {
$code = $this->request->get('code');
$parent_code = $this->request->get('parent_code');
$regions = new Regions();
if ($code) {
$where = 'code = '.$code;
} elseif ($parent_code) {
$where = 'parentCode = '.$parent_code;
} else {
$type = $this->request->get('type') ? $this->request->get('type') : 1;
$where = 'type = '.$type;
}
$fields = 'code,parentCode,name';
$data = $regions->field($fields)->where($where)->select();
return $this->response(200, '', $data);
}
}
\ No newline at end of file
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\HouseInfos;
/**
* Description of HouseInfo
*
* @author : fuju
* @date : 2018-1-15 11:09:56
* @internal : description
*/
class HouseInfo extends Basic{
protected $house_infos;
public function __construct() {
parent::__construct($request);
$this->house_infos = new HouseInfos();
}
public function index() {
return $this->house_infos->select();
}
}
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/17
* Time: 13:46
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\GHouses;
use app\model\GHousesExt;
use app\model\GHousesImgs;
use think\Request;
class Houses extends Basic
{
protected $house;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->house = new GHouses();
}
public function index() {
return view('houseList');
}
/**
* 新增和编辑商铺
*
* @return \think\response\View
* @throws \Exception
* @throws \think\exception\PDOException
*/
public function edit() {
$result['code'] = 200;
$result['msg'] = '';
$params = $this->request->param();
if ($this->request->isPost()) {
$date = date('Y-m-d H:i:s');
if ($params['id']) {
$params['update_time'] = $date;
}
$this->house->startTrans();
//新增或编辑
if ($params['id'] == '') {
$house_id = $this->house->allowField(true)->save($params);
} else {
$house_id = $this->house->allowField(true)->isUpdate(true)->save($params, ['id' => $params['id']]);
}
$params['house_id'] = $house_id;
$house_ext = new GHousesExt();
if ($params['start_business_date']) {
$params['start_business_date'] = date('Y-m-d H:i:s' , strtotime($params['start_business_date']));
}
//新增或编辑根据id
if ($params['id'] == '') {
$house_ext->allowField(true)->save($params);
} else {
$house_ext_data = $house_ext->field('id')->where('house_id',$params['id'])->find();
$house_ext->allowField(true)->isUpdate(true)->save($params, ['id' => $house_ext_data['id']]);
}
/***保存图片 hujun 2018.1.19 start***/
$house_img = new GHousesImgs();
if ($params['id'] == '') {
$house_img->add($params, $house_id);
} else {
$house_img->edit($params, $house_id);
}
/***保存图片 hujun 2018.1.19 end***/
if ($house_id) {
$this->house->commit();
$return = $this->response($result['code'], $result['msg']);
} else {
$this->house->rollback();
$return = $this->response(101, $result['msg']);
}
} elseif ($params['id']){
//获取商铺详情
$house = new GHouses();
$result['data'] = $house->getHouseById($params['id']);
$return = $this->response($result['code'], $result['msg'], $result['data']);
} else {
//商铺添加页面
$return = view('edit');
}
return $return;
}
/**
* 楼盘列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseList() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$fields = '';
/*精选商铺--0是1否*/
if ($params['is_carefully_chosen'] != NULL) {
$where['is_carefully_chosen'] = $params['is_carefully_chosen'];
}
/*0是1否显示在c端用户*/
if ($params['is_show'] != NULL) {
$where['is_show'] = $params['is_show'];
}
/*商铺类型(0商场,1街铺)*/
if ($params['shop_type'] != NULL) {
$where['shop_type'] = $params['shop_type'];
}
/*所在城市*/
if ($params['city'] != NULL) {
$where['city'] = $params['city'];
}
/*所在区*/
if ($params['disc'] != NULL) {
$where['disc'] = $params['disc'];
}
/*状态 0待审批 1上架 2下架 3回收*/
if ($params['status'] != NULL) {
$where['status'] = $params['status'];
}
/*价格 -1表示营业额扣点 存分*/
if ($params['rent_price'] != NULL) {
switch ($params['rent_price']) {
case 1:
$where['rent_price'] = ['>',10000];break;
case 2:
$where['rent_price'] = ['between','10000,30000'];break;
default :
$where['rent_price'] = ['>', '30000'];
}
}
/*对内楼盘名*/
if ($params['internal_title'] != NULL) {
$where['internal_title'] = ['LIKE', $params['internal_title'].'%'];
}
/*是否独家0否1是*/
if ($params['is_exclusive_type'] != NULL) {
$where['is_exclusive_type'] = ['LIKE', $params['is_exclusive_type'].'%'];
}
/*开始时间*/
if ($params['start_date'] != NULL) {
$where['create_time'] = ['> time', $params['start_date']. ' 00:00:00'];
}
/*结束时间*/
if ($params['end_date'] != NULL) {
$where['create_time'] = ['< time',$params['end_date']. ' 23:59:59'];
}
/*开始结束时间*/
if ($params['start_date'] != NULL && $params['end_date'] != NULL) {
$where['create_time'] = ['between time',[$params['start_date'].' 00:00:00'],$params['end_date']. ' 23:59:59'];
}
/*根据库存判断是否已租*/
if ($params['leased'] != NULL) {
if ($params['leased'] == 0) {
$where['residue_num'] = 0;
} else {
$where['residue_num'] = ['<>',0];
}
}
/*业态*/
if ($params['industry_type'] != NULL) {
$where['industry_type'] = ['LIKE',$params['industry_type'].'%'];
}
//案场权限人搜索
if (empty($params['dish'])) {
/*楼盘编号*/
if ($params['id'] != NULL) {
$where['id'] = $params['id'];
}
$where['status'] = ['<>',2];
$data['data']['list'] = $this->house->getHouseList($pageNo, $pageSize, 'id DESC', $fields, $where);
$data['data']['total'] = $this->house->getTotal($where);
} else {
//盘方人搜索
/*楼盘编号*/
if ($params['id'] != NULL) {
$where['a.id'] = $params['id'];
}
$where['a.status'] = ['<>',2];
$where['c.name'] = ['LIKE',$params['dish'].'%'];
$where['b.type'] = ['=',1];
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where);
$data['data']['total'] = $this->house->getHouseListDishTotal($where);
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 伪删除商铺
*
* @return \think\Response
*/
public function del() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
if ($params['id']) {
$this->house->isUpdate(true)->save(['status'=>3],['id'=>$params['id']]);
$data['msg'] = 'successfully deleted';
} else {
$data['status'] = 101;
$data['msg'] = 'id is null';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
}
\ No newline at end of file
This diff is collapsed.
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="business_district" /><!--关联js文件-->
<div id="page-content-wrapper">
<div class="container">
<div class="col-lg-10 col-lg-offset-0">
<div class="builder-tabs builder-form-tabs">
<ul class="nav nav-tabs">
<li class=""><a href="/admin.php/index/roleedit/1.html">角色信息</a></li>
<li class="active"><a href="/admin.php/index/access/1.html">权限分配</a></li>
<li class=""><a href="/admin.php/index/accessUser/1.html">成员授权</a></li>
</ul>
<div class="form-group"></div>
</div>
<div class="builder formbuilder-box panel-body bg-color-fff">
<div class="row">
<div class="col-md-7 col-md-offset-1">
<div id="tab2" class="tab-pane">
<form action="" method="post" class="form-builder form-horizontal responsive">
<div class="form-group">
<div class="auth" id="access_box">
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 tc">
<div class="col-md-3"><button class="btn btn-block btn-primary submit ajax-post" type="submit" target-form="form-builder">确认</button></div> &nbsp;
<div class="col-md-3"><button class="btn bg-aqua btn-block return" onclick="javascript:history.back(-1);return false;"><i class="fa fa-mail-reply"></i> 返回</button></div>
</div>
</div>
</form>
</div>
</div>
</div><!--row-->
</div>
</div>
</div>
</div>
\ No newline at end of file
{layout name="global/frame_tpl" /}
<div id="page-content-wrapper">
<div class="container">
<div class="col-lg-10 col-lg-offset-0">
<div class="builder-tabs builder-form-tabs">
<ul class="nav nav-tabs">
<li class=""><a href="/admin.php/index/roleedit/1.html">角色信息</a></li>
<li class=""><a href="/admin.php/index/access/1.html">权限分配</a></li>
<li class="active"><a href="/admin.php/index/accessUser/1.html">成员授权</a></li>
</ul>
<div class="form-group"></div>
</div>
<div class="builder formbuilder-box panel-body bg-color-fff">
<div class="row">
<div class="builder-table">
<!-- 数据列表 -->
<div class="col-sm-12">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th class="">UID</th>
<th class="">昵称</th>
<th class="">最后登录时间</th>
<th class="">最后登录IP</th>
<th class="">状态</th>
<th class="">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>1 </td>
<td>创始人</td>
<td><span>2018-01-16 16:49</span></td>
<td><span>127.0.0.1</span></td>
<td>正常</td>
<td><a href="/admin.php/admin/auth/removefromgroup/uid/1/group_id/1.html" class="ajax-get">解除授权</a>
</td>
</tr>
<tr>
<td>2 </td>
<td>心灵旅行</td>
<td><span>2016-09-18 22:18</span></td>
<td><span>1928388295</span></td>
<td>正常</td>
<td><a href="/admin.php/admin/auth/removefromgroup/uid/2/group_id/1.html" class="ajax-get">解除授权</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="main-title">
<div class="page_nav col-md-8">
</div>
<div id="add-to-group" class="tools col-md-4">
<form class="add-user" action="/admin.php/admin/auth/addtogroup.html" method="post" enctype="application/x-www-form-urlencoded">
<div class="form-group">
<div class="col-md-10">
<input class="form-control" type="text" name="uid" placeholder="请输入uid,多个用英文逗号分隔">
</div>
<input type="hidden" name="group_id" value="1">
<button type="submit" class="btn btn-info btn-raised btn-sm ajax-post col-md-2" target-form="add-user">新 增</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{layout name="global/frame_tpl" /}
<h4>权限管理</h4>
<a href="/index/roleedit">添加角色</a>
<input type="hidden" class="page-load" id="auth" />
<div id="page-content-wrapper">
<div class="container">
<div class="col-lg-10 col-lg-offset-0">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th class="text-center">ID</th>
<th class="text-center">角色名</th>
<th class="text-center">描述</th>
<th class="text-center">状态</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="auth_list">
</tbody>
</table>
</div>
<!-- /#page-content-wrapper -->
<div class="text-right pageinfo" id="pagediv">
</div>
</div>
</div>
\ No newline at end of file
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="role_edit"/>
<div id="page-content-wrapper">
<div class="container">
<div class="col-lg-10 col-lg-offset-0">
<div class="builder-tabs builder-form-tabs">
<ul class="nav nav-tabs">
<li class="active"><a href="/admin.php/index/roleedit/1.html">角色信息</a></li>
<li class=""><a href="/admin.php/index/access/1.html">权限分配</a></li>
<li class=""><a href="/admin.php/index/accessUser/1.html">成员授权</a></li>
</ul>
<div class="form-group"></div>
</div>
<div class="builder formbuilder-box panel-body bg-color-fff">
<div class="row">
<div class="col-md-7">
<form action="/index/addAUth" method="post" class="form-builder form-horizontal">
<fieldset>
<!-- <input type="hidden" name="id" value="3">-->
<div class="form-group">
<label for="title" class="col-md-2 control-label">名称:</label>
<div class="col-md-10">
<input type="text" class="form-control" name="title" placeholder="创建的角色名称" value="普通用户">
<span class="material-input"></span>
</div>
</div>
<div class="form-group item_description">
<label for="description" class="col-md-2 control-label">描述:</label>
<div class="col-md-10">
<textarea name="description" class="form-control" length="120" rows="5">这是普通用户的权限</textarea>
<span class="material-input"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-12 col-md-offset-2">
<div class="col-md-3"><button class="btn btn-block btn-primary submit ajax-post" type="submit" target-form="form-builder">确定</button></div>
<div class="col-md-3"><button class="btn btn-block btn-default return" onclick="javascript:history.back(-1);return false;">返回</button></div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="business_district" />
<!--导航star-->
<!-- Sidebar -->
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-0">
<div class="panel panel-default">
<div class="panel-heading breadcrumb">
<li><a href="#">商铺管理</a></li>
<li class="active">添加商圈</li>
<div class="pull-right">
<ul class="bread_btn">
<li>
<a href="#modal_business" data-toggle="modal" class="btn btn-default" id="modal_add"><i class="icon-plus"></i>
添加商圈</a>
</li>
</ul>
</div>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<td colspan="8">
<form action="" method="get" id="form_search">
<input class="form-control btn2" data-rule-phoneus="false" data-rule-required="false" id="name" name="name" placeholder="商圈名" type="text" value="">
<span class="btn btn-default btn3" id="search">搜索</span>
<span class="btn btn-default btn3" id="reset">重置</span>
</form>
</td>
</tr>
<tr>
<th class="text-center">编号</th>
<th class="text-center">商圈名</th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center"></th>
<th class="text-center">状态</th>
<th class="text-center">创建时间</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody id="business_list" class="text-center">
</tbody>
</table>
</div>
<!-- /#page-content-wrapper -->
<div class="text-right" id="pagediv">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /#wrapper -->
<!-- /#新增用户模态框 -->
<div class="modal fade" id="modal_business" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title" id="title">
添加商圈
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" action="/index/editBusinessDistrict" method="POST" id="add_business_form">
<div class="form-group">
<label for="province" class="col-md-3 control-label">省:</label>
<div class="col-md-7">
<select name="province" id="province" class="form-control btn6">
<option>请选择</option>
</select>
<span class="use-span text-danger">(必填)</span>
</div>
</div>
<div class="form-group">
<label for="city" class="col-md-3 control-label">市:</label>
<div class="col-md-7">
<select name="city" id="city" class="form-control btn6">
<option>请选择</option>
</select>
<span class="use-span text-danger">(必填)</span>
</div>
</div>
<div class="form-group">
<label for="disc" class="col-md-3 control-label">区:</label>
<div class="col-md-7">
<select name="disc" id="disc" class="form-control btn6">
<option>请选择</option>
</select>
<span class="use-span text-danger">(必填)</span>
</div>
</div>
<div class="form-group">
<label for="business" class="col-md-3 control-label">商圈:</label>
<div class="col-md-7">
<input type="text" id="business" name="business" class="form-control btn6">
<span class="use-span text-danger">(必填)</span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">关闭
</button>
<button type="button" class="btn btn-primary" id="add_business">
提交
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
<!-- /#wrapper -->
<!-- /#删除模态框 -->
<div class="modal fade" id="modal-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
&times;
</button>
<h4 class="modal-title">
删除
</h4>
</div>
<div class="modal-body">
<div class="modal-body" id="del_msg">
确认删除吗?
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" id="confirm_delete">
删除
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/20
* Time: 17:52
*/
namespace app\model;
class AAgents extends BaseModel
{
}
\ No newline at end of file
<?php
// 权限模型
namespace app\model;
class AuthGroup extends BaseModel
{
const TYPE_ADMIN = 1; // 管理员用户组类型标识
const MEMBER = 'agents';
const AUTH_GROUP_ACCESS = 'auth_group_access'; // 关系表表名
const AUTH_GROUP = 'auth_group'; // 用户组表名
const AUTH_EXTEND_CATEGORY_TYPE = 1; // 分类权限标识
const AUTH_EXTEND_MODEL_TYPE = 2; //分类权限标识
protected $insert =['status'=>1];
/**
* 返回用户组列表
* 默认返回正常状态的管理员用户组列表
* @param array $where 查询条件,供where()方法使用
*
*/
public function getGroups($where=array()){
$map = array('status'=>1);
$map = array_merge($map,$where);
return $this->where($map)->select();
}
/**
* 把用户添加到用户组,支持批量添加用户到用户组
*
* 示例: 把uid=1的用户添加到group_id为1,2的组 `AuthGroupModel->addToGroup(1,'1,2');`
*/
public function addToGroup($uid, $gid){
$uid = is_array($uid)? implode(',',$uid) : trim($uid,',');
$gid = is_array($gid)? $gid:explode( ',',trim($gid,',') );
$Access = model(self::AUTH_GROUP_ACCESS);
$del = true;
if( isset($_REQUEST['batch']) ){
//为单个用户批量添加用户组时,先删除旧数据
$del = $Access->where(['uid'=>['in',$uid]])->delete();
}
$uid_arr = explode(',',$uid);
$uid_arr = array_diff($uid_arr,get_administrators());
$add = [];
if( $del!==false ){
foreach ($uid_arr as $u){
foreach ($gid as $g){
if( is_numeric($u) && is_numeric($g) ){
//防止重复添加
if (!$Access->where(['group_id'=>$g,'uid'=>$u])->count()) {
$add[] = ['group_id'=>$g,'uid'=>$u];
}
}
}
}
if (!empty($add) && is_array($add)) {
$Access->saveAll($add);
} else{
$this->error = "添加失败,可能有重复添加操作";
return false;
}
}
if ($Access->getError()) {
if( count($uid_arr)==1 && count($gid)==1 ){
//单个添加时定制错误提示
$this->error = "不能重复添加";
}
return false;
}
return true;
}
/**
* 返回用户所属用户组信息
* @param int $uid 用户id
* @return array 用户所属的用户组 array(
* array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
* ...)
*/
static public function getUserGroup($uid){
static $groups = array();
if (isset($groups[$uid]))
return $groups[$uid];
$prefix = config('database.prefix');
$user_groups = model()
->field('uid,group_id,title,description,rules')
->table($prefix.self::AUTH_GROUP_ACCESS.' a')
->join ($prefix.self::AUTH_GROUP." g on a.group_id=g.id")
->where("a.uid='$uid' and g.status='1'")
->select();
$groups[$uid]=$user_groups?$user_groups:array();
return $groups[$uid];
}
/**
* 将用户从用户组中移除
* @param int|string|array $gid 用户组id
* @param int|string|array $cid 分类id
*/
public function removeFromGroup($uid,$gid){
$del_result = model(self::AUTH_GROUP_ACCESS)->where( array( 'uid'=>$uid,'group_id'=>$gid) )->delete();
if ($del_result) {
$user_auth_role = db('users')->where(array('uid'=>$uid))->value('auth_groups');
if ($user_auth_role) {
$user_auth_role=array_merge(array_diff(explode(',', $user_auth_role), array($gid)));
model('user')->where(array('uid'=>$uid))->setField('auth_groups',$user_auth_role);//同时将用户角色关联删除
}
}
return $del_result;
}
/**
* 获取某个用户组的用户列表
*
* @param int $group_id 用户组id
*/
static public function userInGroup($group_id){
$prefix = config('database.prefix');
$l_table = $prefix.self::MEMBER;
$r_table = $prefix.self::AUTH_GROUP_ACCESS;
$list = model() ->field('m.uid,u.username,m.last_login_time,m.last_login_ip,m.status')
->table($l_table.' m')
->join($r_table.' a ON m.uid=a.uid')
->where(array('a.group_id'=>$group_id))
->select();
return $list;
}
/**
* 检查id是否全部存在
* @param array|string $gid 用户组id列表
*/
public function checkId($modelname,$mid,$msg = '以下id不存在:'){
if(is_array($mid)){
$count = count($mid);
$ids = implode(',',$mid);
}else{
$mid = explode(',',$mid);
$count = count($mid);
$ids = $mid;
}
$s = model($modelname)->where(array('id'=>array('in',$ids)))->column('id');
if(count($s)===$count){
return true;
}else{
$diff = implode(',',array_diff($mid,$s));
$this->error = $msg.$diff;
return false;
}
}
/**
* 检查用户组是否全部存在
* @param array|string $gid 用户组id列表
*/
public function checkGroupId($gid){
return $this->checkId('AuthGroup',$gid, '以下用户组id不存在:');
}
/**
* 返回角色分组
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @return type
*/
public function getList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
}
<?php
// 权限模型
namespace app\admin\model;
class AuthGroupAccess extends Base
{
// 设置完整的数据表(包含前缀)
// protected $table = 'think_access';
// 设置数据表(不含前缀)
// protected $name = 'auth_rule';
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
/**
* 用户组信息
* @param integer $uid [description]
* @return [type] [description]
*/
public function userGroupInfo($uid = 0)
{
if (!$uid) return false;
$result = $this->alias('a')->join('__AUTH_GROUP__ b','a.group_id = b.id')->where(['a.uid'=>$uid,'a.status'=>1])->field('a.group_id,b.title')->select();
if ($result) {
foreach ($result as $key => $row) {
$return[$row['group_id']] = $row['title'];
}
return $return;
}
return false;
}
/**
* 获取组对应的用户Uids
* @param string $group_id [description]
* @return [type] [description]
* @date 2017-10-17
* @author 心云间、凝听 <981248356@qq.com>
*/
public static function groupUserUids($group_id)
{
return $return = self::where('group_id',$group_id)->column('uid');
}
}
\ No newline at end of file
<?php
//权限规则模型
namespace app\model;
use think\Model;
class AuthRule extends Model
{
// 设置完整的数据表(包含前缀)
// protected $table = 'think_access';
// 设置数据表(不含前缀)
// protected $name = 'auth_rule';
// 设置birthday为时间戳类型(整型)
// protected $type = [
// 'birthday' => 'timestamp',
// ];
// 定义时间戳字段名
protected $createTime = '';
//protected $updateTime = '';
/**
*返回功能权限列表
*
*
*/
public function authList($p = 1, $pageSize = 20, $order_ = '', $field = '',$join='', $where = ''){
$data = $this->field($field)
->alias('a')
->join($join)
->where($where)
->order($order_)
->limit($pageSize)
->page($p)
->select();
return $data;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/17
* Time: 15:44
*/
namespace app\model;
use think\Model;
class BaseModel extends Model
{
/**
* 记录总数
*
* @param $params
* @return int|string
*/
public function getTotal($params)
{
return $this->where($params)->count();
}
/**
* 新增或编辑数据
* @param array/object $data 来源数据
* @param boolean $kv 主键值
* @param string $key 主键名
* @return [type] 执行结果
*/
public function editData($data,$kv=false,$key='id',$confirm=false)
{
$this->allowField(true);
if ($confirm) {//是否验证
$this->validate($confirm);
}
if($kv){//编辑
$res=$this->save($data,[$key=>$kv]);
}else{
$res=$this->data($data)->save();
}
return $res;
}
/**
* 列表
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @return type
*/
public function getList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Model;
class GBusinessDistrict extends BaseModel
{
protected $table = 'g_business_district';
}
<?php
namespace app\model;
use think\Db;
class GHouses extends BaseModel
{
protected $table = 'g_houses';
/**
* 通过id获取商铺详情
*
* @param $id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseById($id) {
$fields = 'a.*,b.fee_rule,internal_item_advantage,external_item_advantage,tiny_brochure_url,auditorium,traffic,
enter_num,do_business_date,start_business_date,singn_rule,landlord_phone';
$select_data = $this->alias('a')->field($fields)
->join('g_houses_ext b','a.id = b.house_id', 'left')
->where('a.id',$id)
->find();
$data = $select_data->getData();
$img = new GHousesImgs();
$img_data = $img->field('id,img_type,img_name')
->where('img_status = 0 AND house_id = '.$id)
->select();
foreach ($img_data as $k=>$v) {
switch ($v->img_type) {
case 1 :
$data['cover'] = $v;break;
case 2 :
$data['slide_show'][$k] = $v;break;
default :
$data['plan'][$k] = $v;
}
}
return $data;
}
/**
* 楼盘列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
$data = $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
$house_id = array();
foreach ($data as $k => $v) {
$house_id[$k] = $v['id'];
}
$result = array();
if (empty($house_id)) {
$result = $data;
} else {
/*案场权限人和盘方*/
$house_agents = Db::table('g_houses_to_agents')->alias('a')
->field('a.houses_id,b.id,b.name,b.phone,a.type')
->join('a_agents b', 'a.agents_id=b.id','left')
->where('a.houses_id','IN', implode(',',$house_id))
->select();
foreach ($data as $k=>$v) {
$result[$k] = $v->toArray();
foreach ($house_agents as $k2 => $v2) {
if ($v->id == $v2['houses_id']) {
if ($v2['type'] == 0) {
$result[$k]['agents_name'][$k2]['id'] = $v2['id'];
$result[$k]['agents_name'][$k2]['name'] = $v2['name'];
$result[$k]['agents_name'][$k2]['phone'] = $v2['phone'];
}
if ($v2['type'] == 1) {
$result[$k]['dish_name'][$k2]['id'] = $v2['id'];
$result[$k]['dish_name'][$k2]['name'] = $v2['name'];
$result[$k]['dish_name'][$k2]['phone'] = $v2['phone'];
}
}
}
}
}
return $result;
}
/**
* 查询属于盘方的商铺列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return array|false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
$data = $this->field($field)->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id','left')
->join('a_agents c','b.agents_id=c.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
$house_id = array();
foreach ($data as $k => $v) {
$house_id[$k] = $v['id'];
}
$result = array();
if (empty($house_id)) {
$result = $data;
} else {
/*案场权限人和盘方*/
$house_agents = Db::table('g_houses_to_agents')->alias('a')
->field('a.houses_id,b.id,b.name,b.phone,a.type')
->join('a_agents b', 'a.agents_id=b.id','left')
->where('a.houses_id','IN', implode(',',$house_id))
->select();
foreach ($data as $k=>$v) {
$result[$k] = $v->toArray();
foreach ($house_agents as $k2 => $v2) {
if ($v->id == $v2['houses_id']) {
if ($v2['type'] == 0) {
$result[$k]['agents_name'][$k2]['id'] = $v2['id'];
$result[$k]['agents_name'][$k2]['name'] = $v2['name'];
$result[$k]['agents_name'][$k2]['phone'] = $v2['phone'];
}
if ($v2['type'] == 1) {
$result[$k]['dish_name'][$k2]['id'] = $v2['id'];
$result[$k]['dish_name'][$k2]['name'] = $v2['name'];
$result[$k]['dish_name'][$k2]['phone'] = $v2['phone'];
}
}
}
}
}
return $result;
}
/**
* 查询属于盘方的商铺列表总记录数
*
* @param string $params
* @return int|string
*/
public function getHouseListDishTotal($params = '') {
$data = $this->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id','left')
->join('a_agents c','b.agents_id=c.id','left')
->where($params)
->count();
return $data;
}
}
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/18
* Time: 17:39
*/
namespace app\model;
class GHousesExt extends BaseModel
{
protected $table = 'g_houses_ext';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/19
* Time: 11:33
*/
namespace app\model;
class GHousesImgs extends BaseModel
{
protected $table = 'g_houses_imgs';
/**
* 商铺图片添加
*
* @param $params
* @param $house_id
* @return array|false
* @throws \Exception
*/
public function add($params, $house_id)
{
$date = date('Y-m-d H:i:s');
$params['create_time'] = $date;
$params['update_time'] = $date;
$count = 0;
$insert_img = array();
//1列表页封面图
if ($params['cover']) {
$insert_img['0']['house_id'] = $house_id;
$insert_img['0']['img_type'] = 1;
$insert_img['0']['img_name'] = $params['cover'];
$insert_img['0']['create_time'] = $params['create_time'];
$insert_img['0']['update_time'] = $params['update_time'];
$count = count($insert_img) + 1;
}
//2详情页轮播图
if ($params['slide_show']) {
foreach ($params['slide_show'] as $k => $v) {
$k += $count;
$insert_img[$k]['house_id'] = $params['house_id'];
$insert_img[$k]['img_type'] = 2;
$insert_img[$k]['img_name'] = $v;
$insert_img[$k]['create_time'] = $params['create_time'];
$insert_img[$k]['update_time'] = $params['update_time'];
}
if (count($insert_img) > 0) {
$count = count($insert_img) + 1;
}
}
//3楼层平面图
if ($params['plan']) {
foreach ($params['plan'] as $kk => $vv) {
$kk += $count;
$insert_img[$kk]['house_id'] = $params['house_id'];
$insert_img[$kk]['img_type'] = 3;
$insert_img[$kk]['img_name'] = $vv;
$insert_img[$kk]['create_time'] = $params['create_time'];
$insert_img[$kk]['update_time'] = $params['update_time'];
}
}
return $this->saveAll($insert_img);
}
/**
* 商铺图片编辑
*
* @param $params
* @param $house_id
* @return array|false
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function edit($params, $house_id) {
//编辑图片
$house_img_data = $this->field('id,img_name,img_type')
->where('img_status <> 1 AND house_id = ' . $house_id)->select();
$key = 0;
$house_img_edit = array();
$slide_show = $params['slide_show'];
$plan = $params['plan'];
foreach ($house_img_data as $k => $v) {
//1列表页封面图
if ($v->img_type == 1) {
if ($params['cover'] != $v->img_name) {
/*伪删除之前的图片*/
$house_img_edit[$key]['id'] = $v->id;
$house_img_edit[$key]['img_status'] = 1;
$key++;
} else {
/*提交图片相同清除提交的图片*/
$params['cover'] = 0;
}
}
//2详情页轮播图
if ($v->img_type == 2) {
if ($slide_show != '') {
foreach ($slide_show as $kk => $vv) {
if (in_array($v->img_name,$slide_show)) {
$img_key = array_search($v->img_name,$params['slide_show']);//根据值查找对应的key
unset($params['slide_show'][$img_key]);
} else {
$house_img_edit[$key]['id'] = $v->id;
$house_img_edit[$key]['img_status'] = 1;
$key++;
}
}
} else {
//伪删除全部的轮播图
$house_img_edit[$key]['id'] = $v->id;
$house_img_edit[$key]['img_status'] = 1;
$key++;
}
}
//3楼层平面图
if ($v->img_type == 3) {
if ($plan != '') {
foreach ($plan as $kk => $vv) {
if (in_array($v->img_name,$plan)) {
$img_key = array_search($v->img_name,$params['plan']); //根据值查找对应的key
unset($params['plan'][$img_key]);
} else {
$house_img_edit[$key]['id'] = $v->id;
$house_img_edit[$key]['img_status'] = 1;
$key++;
}
}
} else {
//伪删除全部的轮播图
$house_img_edit[$key]['id'] = $v->id;
$house_img_edit[$key]['img_status'] = 1;
$key++;
}
}
}
$this->add($params, $house_id);
return $this->saveAll($house_img_edit);
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Model;
class GHousesToAgents extends BaseModel
{
protected $table = 'g_houses_to_agents';
protected $date = '';
public function __construct()
{
$this->date = date('Y-m-d H:i:s');
}
/**
* @param $data
* @param $houses_id
* @param $type 案场权限人:0,盘方:1,独家:2
* @return array|false|int
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addAgents($data, $houses_id, $type){
$agent_arr = array();
$data = array_unique($data);
foreach ($data as $k=>$v) {
$arr = explode('-',$v);
if (count($arr) == 3) {
$check = $this->where([
'houses_id' => $houses_id,
'agents_id' => $arr['0'],
'is_del' => 0 ,
'type' => $type
])->find();
if ($check) {
continue;
}
$agent_arr[$k]['agents_id'] = $arr['0'];
$agent_arr[$k]['houses_id'] = $houses_id;
$agent_arr[$k]['type'] = $type;
$agent_arr[$k]['create_time'] = $this->date;
$agent_arr[$k]['update_time'] = $this->date;
}
}
$res = $this->saveAll($agent_arr);
return $res;
}
/**
* 解除经纪人和楼盘关系
*
* @param $id
* @return bool|false|int
*/
public function del($id) {
if ($id) {
$res = $this->save(['is_del' => 1],['id'=>$id]);
} else {
$res = false;
}
return $res;
}
public function getAgentsHousesList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->alias('a')
->join('a_agents b', 'a.agents_id = b.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
}
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/24
* Time : 14:13
* Intro:
*/
// [ 应用入口文件 ]
// 定义应用目录
define('APP_PATH', __DIR__ . '/../application/');
// 加载框架引导文件
require __DIR__ . '/../thinkphp/start.php';
// 读取自动生成定义文件
$build = include './../build.php';
// 运行自动生成
\think\Build::run($build);
\ No newline at end of file
define (['doT', 'text!temp/auth_template_tpl.html', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
auth = {
pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/
init: function () {
//初始化dot
$ ("body").append (template);
auth.getList ();
auth.event ();
},
event: function () {
},
getList: function (pageNo) {
auth.pageNo = pageNo;
var params = {};
params.pageNo = auth.pageNo;
params.pageSize = auth.pageSize;
$.ajax ({
url: '/index/getAuth.html',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
var temp = document.getElementById ('auth_list_tpl').innerHTML;
var doTtmpl = doT.template (temp);
$ ("#auth_list").html (doTtmpl (data.data.list));
/*分页代码*/
$ ("#pagediv").pagination ({
length: data.data.total,
current: pageNo,
every: auth.pageSize,
onClick: function (el) {
auth.getList (el.num.current);
}
});
}
});
}
};
return auth;
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/**
* Created by 刘丹 on 2017/12/11.
*/
define (['doT', 'text!temp/house_template_tpl.html', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
business = {
pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/
id : '',
valueCurrent:'',
ajaxObj:'',
stopstatus:true,
ldHtml: $('.phone_list'),
boxphoto:'',
init: function () {
//初始化dot
$ ("body").append (template);
business.getList ();
business.event ();
business.resetLoad();
business.loadMain();
},
event: function () {
$("#search").click(function () {
business.getList(1);
});
$("#reset").click(function () {
document.getElementById("form_search").reset();
});
$("#modal_add").click(function () {
$("#title").html('新增商圈');
business.getRegionsProvince(310000, 310100, 310101); //默认上海,上海,黄浦
});
$("#province").change(function () {
business.getRegionsCity();
});
$("#city").change(function () {
business.getRegionsDisc();
});
$ (document).delegate (".del_modal", "click", function () {
business.id = $ (this).attr ("data-id");
});
$ (document).delegate ("#confirm_delete", "click", function () {
business.delBusiness();
});
$ (document).delegate (".jia", "click", function () {//加号
business.jiabox();
});
$ (document).delegate (".addphone", "click", function () {//加号
business.addphone(this);
});
$(document).on('input','.phone_jia,.phone_add', function(e) {//搜索手机号码
e.preventDefault();
e.stopPropagation();
var _this = $(this);
_this.next().css("display","block");
valueCurrent = _this.val();
if(valueCurrent != ''){
business.resetLoad(1);
business.loadMain(valueCurrent,_this.next());
}else{
business.ldHtml.html('');
return false;
}
});
$ (document).delegate (".is_show", "click", function () {
if (!confirm('是否继续?')) {
return ;
}
business.id = $ (this).attr ("data-id");
var params ={};
params.id = $ (this).attr ("data-id");
var str = $.trim($(this).html());
if (str === "推荐至首页") {
params.type = 1;
$(this).html('已推荐');
} else {
params.type = 0;
$(this).html('推荐至首页');
}
});
},
resetLoad:function (){//手机号
if(business.ajaxObj){
business.ajaxObj.abort();
}
business.ldHtml.html('');
business.stopstatus = true;
},
loadMain:function(phone, obj) {//手机号
business.ajaxObj=$.ajax({
type: "GET",
url: '/index/getBroker_new' ,
data: {
'phone': phone
},
timeout: 10000,
dataType: "json",
beforeSend: function() {
},
success: function(data) {
if(data.code === 200){
var _html = '';
$.each(data.data, function(i,data) {
_html += '<li class="addphone"><span class="id">'+data['id']+'-</span><span class="phone_name">'+data['name']+'</span><span class="phone_span">-</span><span class="phone-phone">'+data['phone']+'</span> </li>';
});
obj.html(_html);
}
},
error: function() {
},
complete: function(xhr, textStatus) {
if(textStatus === "timeout") {
//处理超时的逻辑
alert("请求超时");
}
}
});
},
addphone:function (obj){
var phone_name=$(obj).find(".phone_name").html();
console.log(phone_name);
var phone_phone=$(obj).find(".phone-phone").html();
var phone_span=$(obj).find(".phone_span").html();
var id= $(obj).find(".id").html();
$(obj).parent().prev().val(id+phone_name+phone_span+phone_phone);
$(obj).parent().hide();
business.ldHtml.html('');
return false;
},
jiabox:function () {
business.boxphoto = '<input name="phone[]" placeholder="请输入" type="tel" style="margin-left: 10px;float: left" class="phone_add">' +
'<ul class="phone_list1"></ul>'+
'<img src="/resource/image/qdao-sha.png" class="jian">';
$(".jian_class").append(business.boxphoto);//写入
business.jianbox();
},
// jiabox_data:function (id,name,phone) {
// business.boxphoto = '<input name="phone[]" placeholder="请输入" value='+name+'-'+phone+' type="tel" style="margin-left: 10px;float: left" class="phone_add">' +
// '<ul class="phone_list1"></ul>'+
// '<img src="/resource/image/qdao-sha.png" class="jian" onclick="jianbox()"><input type="hidden" value="'+id+'">';
// $(".jian_class").append(business.boxphoto);//写入
// business.jianbox();
//},
jianbox: function () {
$(".jian").click(function () {
$(this).prev().prev().remove();
$(this).prev().remove();
$(this).remove();
});
},
getList: function (pageNo) {
business.pageNo = pageNo;
var params = {};
params.pageNo = business.pageNo;
params.pageSize = business.pageSize;
params.is_carefully_chosen = $('#is_carefully_chosen option:selected') .val();//首页显示
params.is_show = $('#is_show option:selected') .val();//c端显示
params.shop_type = $('#shop_type option:selected') .val();//商铺类型
params.leased = $('#leased option:selected') .val();//商铺状态
params.rent_price = $('#rent_price option:selected') .val();//月租金
params.is_exclusive_type = $('#is_exclusive_type option:selected') .val();//是否独家
params.internal_title = $('#internal_title') .val();//商铺名称
params.industry_type = $('#industry_type') .val();//业态
params.dish = $('#dish') .val();//盘方
params.id = $('#id') .val();//店铺编号
params.start_date = $('#start_date') .val();//时间1
params.end_date = $('#end_date') .val();//时间2
$.ajax ({
url: '/index/getHouseList.html',//获取列表
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
var temp = document.getElementById ('house_list_tpl').innerHTML;
var doTtmpl = doT.template (temp);
$ ("#business_list").html (doTtmpl (data.data.list));
/*分页代码*/
$ ("#pagediv").pagination ({
length: data.data.total,
current: pageNo,
every: business.pageSize,
onClick: function (el) {
business.getList (el.num.current);
}
});
}
});
},
delBusiness : function () {
$.ajax({
url : '/index/houseDel',
type : 'POST',
async: true,
data: {"id":business.id},
dataType: 'json',
success : function (data) {
if (data.code == 200) {
business.getList(1);
$("#modal-delete").modal ('hide');
} else {
$("#del_msg").html('<span style="color: red">删除失败!</span>');
}
}
});
}
};
return business;
});
\ No newline at end of file
/* auth 2018/01/23 by dafei
*/
define (['doT', 'text!temp/user_template_tpl.html', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
var Role = {
init: function () {
//初始化dot
$ ("body").append (template);
Role.getList ();
Role.event ();
},
event: function () {
$("#sss").click(function(){
});
},
getList: function(){
//ajax
$("input[name = title]").val("1111");
}
}
return Role;
});
<script id="auth_list_tpl" type="text/template">
[% if(it) { %]
[% for(var item in it){ %]
<tr class="text-center">
<td>[%= it[item]['id'] %]</td>
<td>[%= it[item]['title'] %]</td>
<td>
[% if(it[item]['description']) { %]
[%= it[item]['description'] %]
[% } %]
</td>
<td>[%= it[item]["status"] %]</td>
<td>
<a title="编辑" class="btn btn-success btn-xs" href="/admin.php/index/roleedit?id=[%= it[item]['id']%].html" style="margin-right:6px;">编辑</a>
<a title="权限分配" class="btn btn-info btn-xs" href="/admin.php/index/access?id=[%= it[item]['id']%].html" style="margin-right:6px;">权限分配</a>
<a title="成员授权" class="btn btn-primary btn-xs" href="/admin.php/index/accessUser?id=[%= it[item]['id']%].html" style="margin-right:6px;">成员授权</a>
</td>
</tr>
[% } %]
[% }else{ %]
<tr>
<td colspan="8" style="text-align:center;"> 暂无数据</td>
</tr>
[% } %]
</script>
\ No newline at end of file
<script id="business_list_tpl" type="text/template">
[% if(it) { %]
[% for(var item in it){ %]
<tr class="text-center">
<td>[%= it[item]['id'] %]</td>
<td>[%= it[item]['name'] %]</td>
<td>[%= it[item]['province'] %]</td>
<td>[%= it[item]['city'] %]</td>
<td>[%= it[item]['disc'] %]</td>
<td>
[% if(it[item]["status"] == 0) { %]
不显示
[% }else{ %]
显示
[% } %]
</td>
<td>[%= it[item]['create_time']%]</td>
<td>
<a title="编辑" class="btn btn-success btn-xs edit_modal" href="#modal_business" data-toggle="modal" class="btn btn-default" data-id="[%= it[item]['id']%]" style="margin-right:6px;">编辑</a>
<a title="权限分配" class="btn btn-info btn-xs is_show" href="#modal-do" data-id="[%= it[item]['id']%]" style="margin-right:6px;">
[% if(it[item]["status"] == 0) { %]
不显示
[% }else{ %]
显示
[% } %]
</a>
<a title="成员授权" class="btn btn-danger btn-xs del_modal" href="#modal-delete" data-toggle="modal" class="btn btn-default" data-id='[%= it[item]["id"] %]' style="margin-right:6px;">删除</a>
</td>
</tr>
[% } %]
[% }else{ %]
<tr>
<td colspan="8" style="text-align:center;"> 暂无数据</td>
</tr>
[% } %]
</script>
\ No newline at end of file
<script id="house_list_tpl" type="text/template">
[% if(it) { %]
[% for(var item in it){ %]
<tr class="text-center">
<td>[%= it[item]['id'] %]</td>
<td>
[% if(it[item]["shop_type"] == 0) { %]
商场
[% }else{ %]
街铺
[% } %]
</td>
<td>[%= it[item]['internal_title'] %]</td>
<td>
[% if(it[item]["rent_price"] == 0) { %]
30000以上
[% }else if(it[item]["rent_price"] == 1) { %]
10000-30000
[% }else{ %]
10000以下
[% } %]
</td>
<td>
[% if(it[item]["is_show"] == 0) { %]
[% }else{ %]
[% } %]
</td>
<td>[%= it[item]['create_time'] %]</td>
<td>
[% if(it[item]["leased"] == 0) { %]
已租
[% }else{ %]
待租
[% } %]
</td>
<td>
[%= it[item]['dish_name'] %]
<a data-toggle="modal" data-id="77" href="#modal-watch" class="btn1 btn-danger add_applies">修改</a>
</td>
<td>
<a class="btn1 btn-success " href="/admin.php/index/houseEdit?id=[%= it[item]['id']%].html" data-toggle="modal" data-id="77" >编辑</a>
<a class="btn1 btn-success is_show" href="#modal-process" data-toggle="modal" data-id="77" >推荐至首页</a>
<a class="btn1 btn-success" data-target="#modal-anch" data-toggle="modal" data-id='[%= it[item]["id"] %]'>设置案场权限人</a>
<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" >是否独家</a>
<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" >操作记录</a>
<a data-toggle="modal" data-id='[%= it[item]["id"] %]' href="#modal-delete" class="btn1 btn-danger add_applies del_modal">删除</a>
</td>
</tr>
[% } %]
[% }else{ %]
<tr>
<td colspan="8" style="text-align:center;"> 暂无数据</td>
</tr>
[% } %]
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment