Commit 04620bf2 authored by clone's avatar clone

Merge branch 'chat_0818' into test

# Conflicts: # application/model/Agents.php
parents e74505b7 8657770f
......@@ -93,14 +93,14 @@ class Shop extends Basic
//面积 room_area最小面积 room_area2最大面积 参考老版本
//面积 room_area最小面积 room_area2最大面积 参考老版本
if (isset($params['area_start']) && isset($params['area_end'])) {
$conditions['a.room_area'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
$conditions['a.room_area'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
//街铺只有一个room_area
if($params['shangpu_type'] == 0){
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'between', array( $params['area_start'], $params['area_end'] ) );
}
} else if (isset($params['area_start']) && !isset($params['area_end'])) { //100米以上不用传结束面积
$conditions['a.room_area'] = array( 'egt', $params['area_start'] );
if($params['shangpu_type'] == 0){
$conditions['a.room_area'] = array( 'egt', $params['area_start'] );
if ($params['shangpu_type'] == 0) {
$conditions['a.room_area2'] = array( 'egt', $params['area_start'] );
}
}
......@@ -178,7 +178,7 @@ class Shop extends Basic
$result["api_path"] = IMG_PATH;
$param["house_id"] = $params['id'];
//todo 这里的是否要更改成b端后台上传的类型
$param["imgtype"] = 2;
$param["imgtype"] = 2;
$result["images"] = $this->dbImg->getHouseImages($param, 15);
$param["imgtype"] = 4;//图片类型:1效果图,2实景图,3样板图,4户型图,5交通图
$result["plan_images"] = $this->dbImg->getHouseImages($param, 4);
......
<?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
//配置文件
return [
];
\ No newline at end of file
<?php
namespace app\chat\consts;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 13:27
* Intro:
*/
class ConfigConst
{
const CLIENT_ID = "YXA6hqlTwLr0EeeNFrlhHiI-Xg";
const CLIENT_SECRET = "YXA6BkraoPZqZYJoLce4sCyRebXMC48";
const API_PATH = "https://a1.easemob.com/";
const ORG_NAME = "1157170531115254";
const APP_NAME = "tonglianjituan";
}
\ No newline at end of file
<?php
namespace app\chat\consts;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 16:54
* Intro:
*/
class ErrorCodeConst
{
//聊天
const ERROR_CODE_PARAM_NOT_EXIST = 110001;
const ERROR_CODE_TARGET_TYPE_ERROR = 110002;
}
\ No newline at end of file
<?php
namespace app\chat\controller;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\consts\ErrorCodeConst;
use app\chat\extend\Basic;
use app\chat\service\ChatService;
use app\chat\utils\RPush;
use app\extra\RedisPackage;
use app\model\ChatMsg;
use app\model\GHousesExt;
use app\model\HouseImgs;
use app\model\HouseinfoExts;
use app\model\HouseInfos;
use think\Cache;
use Think\Log;
class AppChat extends Basic
{
/**
* @var RPush
*/
private $_push;//环信接口消息推送
/**
* @var ChatService
*/
private $_chat;
public function __construct($request = null)
{
parent::__construct($request);
$this->_push = new RPush();
$this->_chat = new ChatService();
}
public function index()
{
/*
log 常规日志,用于记录日志
error 错误,一般会导致程序的终止
notice 警告,程序可以运行但是还不够完美的错误
info 信息,程序输出信息
debug 调试,用于调试信息
sql SQL语句,用于SQL记录,只在数据库的调试模式开启时有效
*/
Cache::set('name', '121212');
echo Cache::get('name');
$redis = new RedisPackage();
$redis::set('test', 'hello redis');
echo $redis::get('test');
Log::record('日志', 'notice');
return null;
}
/**
* 验证用户角色,生成唯一id
*
* @return \think\Response
*/
public function userChat()
{
/* $params = array(
"user_id" => 10,
"mobile" => "15821506182",
"source" => 1 //1经纪人 2用户
);*/
$params = $this->params;
if (!isset($params['user_id']) || !isset($params['mobile']) || !isset($params['source'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
$user_id = $params['user_id'];
$mobile = $params['mobile'];
$source = $params['source'];
$only_arr = $this->_chat->register($user_id, $mobile, $source);
if ($only_arr["code"] == 200) {
return $this->response("200", "success", [ "only_id" => $only_arr["only_id"] ]);
} else {
return $this->response("101", $only_arr["msg"]);
}
}
/**
* 获取经纪人或用户的信息
* @return \think\Response
*/
public function getUserOrAgentInfo()
{
$params = $this->params;
if (!isset($params['only_id']) || !isset($params['source'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
"only_id" => "agent_9",
"source" => 2,// 1经纪人 or 2用户
);*/
$result = $this->_chat->getUserInfo($params['only_id'], $params["source"]);
if ($result) {
return $this->response("200", "request success", $result);
}
return $this->response("101", "request error ,not fund list", []);
}
/**
* 发送消息接口
* @return \think\Response
*/
public function pushMsg()
{
$params = $this->params;
if (!isset($params['target_type']) || !isset($params['target']) || !isset($params['type'])
|| !isset($params['msg_content']) || !isset($params['source']) || !isset($params['is_user']) || !isset($params['from'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
'user_name' => 'cesh',
'msg_content' => 'ceshi666',
'target_type' => 'users',
'source' => '1',
'from' => 'admin',
'type' => '1',
'is_user' => '0',
'target' => '18112347151',
);*/
$user_name = isset($params['user_name']) ? $params['user_name'] : $params['from'];//用户昵称
$target_type = $params['target_type']; // 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target = $params['target']; //接受人 if target_type 群 者表示群id
$source = $params['source']; //消息来源 1c端app 2b端app 3其他
$is_user = $params['is_user']; //发送人是否是会员 0是1经济人
$type = $params['type']; //消息类型 1文字 2图片 3楼盘
$msg_content = $params['msg_content'];
$from = $params['from']; //消息发送人
if ($target_type != "users" && $target_type != "chatgroups" && $target_type != "chatrooms") {
return $this->response(ErrorCodeConst::ERROR_CODE_TARGET_TYPE_ERROR, "错误的消息类型");
}
$result = $this->_chat->sendMsg($user_name,$target_type, $target, $source, $is_user, $type, $msg_content, $from, $this->accessToken);
if ($result) {
return $this->response("200", "", [ "msg" => "消息发送成功" ]);
} else {
return $this->response("101", "", [ "msg" => "消息内容错误" ]);
}
}
/**
* 查询历史和搜索历史
* @return \think\Response
*/
public function getChatHistory()
{
$params = $this->params;
if (!isset($params['target_type']) || !isset($params['from']) || !isset($params['target'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
}
/* $params = array(
'target_type' => 'users', // 消息类型 users 用户消息。chatgroups: 群消息,chatrooms: 聊天室消息
'from' => 'app_64', //发送人
'target' => '18112347151', //接受人
'page_no' => '1', //第几页
'page_size' => '15' //每页多少条
);*/
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "a.id,a.to_id,a.from_id,a.created_at,b.type,b.body";
$msgModel = new ChatMsg();
$history_result = $msgModel->getChatHistory($params, $field, $page_no, $page_size);
return $this->response("200", "request success", array_reverse($history_result));
}
/**
* 上传聊天图片
* @return \think\Response
*/
public function uploadImg()
{
$file = request()->file('image');
$data = [];
if ($file) {
$path = ROOT_PATH . 'public' . DS . 'static' . DS . 'chat_image';
$info = $file->validate([ 'size' => 512000, 'ext' => 'jpg,png' ])//限制500KB
->move($path);
if ($info) {
$img_path = $info->getSaveName(); //生成的图片路径
$static_path = $path . DS . $img_path; //生成图片的绝对路径
$image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图
$data = [ 'name' => $img_path ];
} else {
// 上传失败获取错误信息
return $this->response("101", $file->getError());
}
} else {
return $this->response("101", "没有该文件");
}
return $this->response("200", "request success", $data);
}
/**
* 聊天页面获取三个商铺信息
* @return \think\Response
*/
public function pushMsg_gethouseinfo()
{
$homeurl = IMG_PATH;
$params = $this->params;
/*$params['id']=4762;
$params['from']='b';*/
if (!isset($params['id']) || !isset($params['from'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$id = $params['id'];
$from = $params['from'];
//主表查询商铺详细信息
$HouseInfos = new HouseInfos();
$HouseInfosre = $HouseInfos->getHousepusmessage($id);
//dump($HouseInfosre);
if ($HouseInfosre) {
$data['title'] = $HouseInfosre[0]['title'];
if ($from == 'c') {
//副表查询c端显示名称
$HouseinfoExts = new HouseinfoExts();
$HouseinfoExtsInfosre = $HouseinfoExts->getHouse_ext($id);
//dump($HouseinfoExtsInfosre);
$data['title'] = $HouseinfoExtsInfosre[0]['foreign_name'] ? $HouseinfoExtsInfosre[0]['foreign_name'] : '未知商铺';
}
//dump($HouseInfosre[0]['room_area']);
//dump($HouseInfosre[0]['room_area2']);
$room_area = $HouseInfosre[0]['room_area'] ? $HouseInfosre[0]['room_area'] : '';
$room_area2 = $HouseInfosre[0]['room_area2'] ? '-' . $HouseInfosre[0]['room_area2'] : '';
$data['room_area_all'] = '暂无!';
if ($room_area || $room_area2) {
$data['room_area_all'] = $room_area . $room_area2 . 'm²';
}
$data['price'] = '暂无!';
if ($HouseInfosre[0]['rent_type']) {
//rent_type COMMENT '1.月租金 2.营业额扣点 3.每平方米租金',
$message[1] = '月租金:' . $HouseInfosre[0]['price'] . '元/月';
$message[2] = '营业额扣点:' . $HouseInfosre[0]['price'] . '%';
$message[3] = '每平方米租金:' . $HouseInfosre[0]['price'] . '元/天/㎡';
$data['price'] = $message[$HouseInfosre[0]['rent_type']];
}
//同联默认图片,如果用户没上传的话/img/houseinfobackgroundimg.png
$data['imagename'] = $homeurl . '/img/houseinfobackgroundimg_new.png';
$HouseImgs = new HouseImgs();
$HouseImgsre = $HouseImgs->getHouseImgs($id, 1);
//用户上传了就用上传的
if ($HouseImgsre) {
$data['imagename'] = $homeurl . '/small_' . $HouseImgsre[0]['imagename'];
}
// dump($HouseInfosre);
// dump($data);
// exit;
return $this->response("200", "success!", $data);
} else {
return $this->response("400", "暂无数据!");
}
}
}
<?php
namespace app\chat\controller;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/23
* Time : 13:47
* Intro:
*/
use app\chat\extend\Basic;
use app\chat\utils\UGroup;
use app\model\ChatGroup;
use app\model\ChatGroupMember;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use think\Db;
class Group extends Basic
{
public function createGroupByOnlyId()
{
//todo 组群创建 1.存表,2调用环信接口
$params = $this->params;
//exit;
/*$params['group_name']='雷神先锋';
$params['group_users']=["18112347151"];
$params['group_users_admin']="admin";*/
if (!isset($params['group_name']) || !isset($params['group_users']) || !isset($params['group_users_admin'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_name = $params['group_name'];
$group_users = $params['group_users'];
$group_users_admin = $params['group_users_admin'];
$UGroup= new UGroup();
$result = $UGroup->createGroup($group_name, $group_users, $group_users_admin,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result);
//判断环信群是否建立成功
if(isset($result['data']['groupid'])){
//群表记录数据
$user = new ChatGroup;
$user->group_name = $group_name;
$user->platform_group_id = $result['data']['groupid'];
$user->type = 0;
$user->is_close = 0;
$user->save();
//群id
$group_id = $user->id;
//var_dump($user->id);
//群成员表表记录数据
$group_users[]=$group_users_admin;
$msgModel = new ChatGroupMember();
foreach ($group_users as $k => $v) {
$msgModel->addChatMsgExt([
'unique_id' => $v,
'group_id' => $group_id,
"type" => ($v == $group_users_admin) ? 1 : 0 ,
"is_close" => 0]);
}
return $this->response("200", "request success", ['remote_groupid'=>$result['data']['groupid']]);
}else{
return $this->response("400", "建群失败", ['remote_groupid'=>'']);
}
}
public function updateGroup()
{
//todo 修改组群信息 1.群信息完善到后台表 无需调用环信接口
}
public function delGroup()
{
//todo 删除群组 1.改变我们group表的状态2.调用环信删群接口
//是否隐藏 0正常 1删除
$params = $this->params;
/*exit;
$params['group_id']='39285903392772';*/
if (!isset($params['group_id'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->deleteGroup($group_id,$this->accessToken);
$result=json_decode($result,true);
//判断环信群是否建立成功
if(isset($result['data']['success']) and $result['data']['success']){
//更新ChatGroup数据
$ChatGroup = new ChatGroup;
$ChatGroupre=$ChatGroup->save(['is_close' => 1],['platform_group_id' => $group_id]);
//更新ChatGroupMember表
$ChatGroup1 = ChatGroup::get(['platform_group_id' => $group_id]);
Db::table('chat_group_member')
->where('group_id',$ChatGroup1['id'])
->update(['is_close' => 1]);
return $this->response("200", "request success");
}else{
return $this->response("400", "删除群组失败", ['remote_groupid'=>'']);
}
}
/**
* 群组管理
*/
public function getGroupUser()
{
//todo 获取群组成员/管理员 我们的数据库获取
$params = $this->params;
// exit;
/*$params['group_id']='39285903392772';
$params['pagenum']=1;//页码,从1开始
$params['pagesize']=10;//每页显示数量,最大不超过1000*/
if (!isset($params['group_id']) and !isset($params['pagenum'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_id = $params['group_id'];
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = $params['pagesize'];
/* $UGroup = new UGroup();
$result = $UGroup->getGroupUser($group_id,$pagenum,$pagesize,$this->accessToken);
$result=json_decode($result,true);*/
$pre = ($pagenum-1)*$pagesize;
$GroupUser=Db::query("SELECT * FROM chat_group_member WHERE group_id=(SELECT id FROM chat_group WHERE platform_group_id={$group_id}) AND is_close=0 LIMIT {$pre},{$pagesize} ");
//var_dump($GroupUser) ;
$total=Db::query("SELECT count(*) as total FROM chat_group_member WHERE group_id=(SELECT id FROM chat_group WHERE platform_group_id={$group_id}) AND is_close=0");
//var_dump($total[0]['total']) ;
$total = $total[0]['total'];
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
//判断环信群是否建立成功
if($GroupUser){
return $this->response("200", "request success",['user_date'=>$GroupUser,'pagenum'=>$pagenum,'total'=>$total]);
}else{
return $this->response("400", "获取失败");
}
}
public function addGroupUserByIds()
{
//todo 添加群组成员 1.单个/多个到表中,2.调用环信接口更新进去
$params = $this->params;
//exit;
/*$params['group_users']=["18112347151"];
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_users'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_users = $params['group_users'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
foreach ($group_users as $k => $v) {
$result = $UGroup->addGroupUserByIds($group_id,$v,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$v} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$v,'group_id'=>$chat_group_group_id])
->update(['is_close' => 0]);
}else{
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->addChatMsgExt([
'unique_id' => $v,
'group_id' => $chat_group_group_id,
"type" => 0 ,
"is_close" => 0]);
}
}
}
return $this->response("200", "request success");
}
public function delGroupUserByIds()
{
//todo 移除群组成员 1.单个或多个跟新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_users']=["18112347151"];
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_users'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_users = $params['group_users'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
foreach ($group_users as $k => $v) {
$result = $UGroup->delGroupUserByIds($group_id,$v,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$v,'group_id'=>$chat_group_group_id])
->update(['is_close' => 1]);
}
}
return $this->response("200", "request success");
}
public function addGroupManage()
{
//todo 添加群组管理员 1.单个更新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_user']="18112347151";
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_user'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_user = $params['group_user'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->addGroupManage($group_id,$group_user,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']=='success'){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$group_user} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$group_user,'group_id'=>$chat_group_group_id])
->update(['type' => 1]);
}
return $this->response("200", "request success");
}else{
return $this->response("400", "添加失败!");
}
}
public function delGroupManage()
{
//todo 移除群组管理员 1.单个更新到库, 2.调用环信接口更新
$params = $this->params;
//exit;
/*$params['group_user']="18112347151";
$params['group_id']="39285903392772";*/
if (!isset($params['group_id']) and !isset($params['group_user'])) {
return $this->response("300", "参数不全", ['remote_groupid'=>'']);
}
$group_user = $params['group_user'];
$group_id = $params['group_id'];
$UGroup = new UGroup();
$result = $UGroup->delGroupManage($group_id,$group_user,$this->accessToken);
$result=json_decode($result,true);
//var_dump($result) ;
if(isset($result['data']['result']) and $result['data']['result']=='success'){
$Dbreturn=Db::query("SELECT id FROM chat_group WHERE platform_group_id={$group_id}");
$chat_group_group_id=$Dbreturn[0]['id'];
//先查询是否已经存在
$chat_group_member=Db::query("SELECT * FROM chat_group_member WHERE unique_id={$group_user} AND group_id={$chat_group_group_id}");
if($chat_group_member){
//var_dump($chat_group_group_id) ;
$msgModel = new ChatGroupMember();
$msgModel ->where(['unique_id'=>$group_user,'group_id'=>$chat_group_group_id])
->update(['type' => 0]);
}
return $this->response("200", "request success");
}else{
return $this->response("400", "添加失败!");
}
}
}
\ No newline at end of file
<?php
namespace app\chat\extend;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\consts\ConfigConst;
use app\chat\utils\CurlUtil;
use http\Exception;
use think\Cache;
use think\Controller;
use Think\Log;
use think\Request;
use think\Response;
class Basic extends Controller
{
/**
* 访问请求对象
* @var Request
*/
public $request;
/**
* 请求参数
* @var mixed|null
*/
public $params;
/**
* app通讯接口授权token
* @var
*/
public $accessToken;
/**
* 基础接口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;
}
$this->accessToken = Cache::get('access_token');
$expires_in = Cache::get('expires_in');
$application = Cache::get('application');
$accredit_time = Cache::get('accredit_time');
if (!$this->accessToken || !$expires_in || !$application || !$accredit_time || (time() - $accredit_time) > $expires_in) {
//todo 这里加个验证 多少时间内不能重复请求
$this->getToken();
if (Cache::get('access_token')) {
$this->accessToken = Cache::get('access_token');
} else {
echo json_encode(array( "code" => "300", "msg" => "accessToken拉取失败,请稍后再试!", "data" => [], "type" => "json" ));
exit;
}
}
}
/**
* 输出返回数据
* @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);
}
public function getApiPath()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME;
}
/**
* 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;
}
}
/**
* 获取调取接口的access_token
*/
public function getToken()
{
$url = "/token";
$data = [
"grant_type" => "client_credentials",
"client_id" => ConfigConst::CLIENT_ID,
"client_secret" => ConfigConst::CLIENT_SECRET
];
$curl = new CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$apiUrl = $this->getApiPath() . $url;
try {
$response = $curl->post($apiUrl, json_encode($data));
$response = json_decode($response,true);
if ($response) {
Cache::set('access_token', $response["access_token"]);
Cache::set('expires_in', $response["expires_in"]);
Cache::set('application', $response["application"]);
Cache::set('accredit_time', time());
}
} catch (Exception $e) {
Log::record('class:Basic,function:getToken get token ,Exception :' . $e, "error");
}
Log::record('class:Basic,function:getToken get token' , "info");
}
}
<?php
namespace app\chat\service;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use app\chat\utils\RegisterUtil;
use app\chat\utils\RPush;
use app\model\Agents;
use app\model\ChatMsg;
use app\model\ChatMsgExt;
use app\model\ChatMsgStatus;
use app\model\ChatRelation;
use app\model\ChatUser;
use app\model\HouseInfos;
use app\model\Users;
use http\Exception;
class ChatService
{
public $connection;
public $logs;
const MSG_CONTENT_TYPE_TEXT = 1; //文字
const MSG_CONTENT_TYPE_VOICE = 2; //语音
const MSG_CONTENT_TYPE_VIDEO = 3; //视频
const MSG_TYPE_USERS = "users"; //给用户发消息
const MSG_TYPE_CHAT_GROUPS = "chatgroups"; //给群发消息
const MSG_TYPE_CHAT_CHAT_ROOMS = "chatrooms"; //给聊天室发消息
const SOURCE_TYPE_APP = 'user_'; // 用户 c端
const SOURCE_TYPE_AGENT = 'agent_';//经纪人 b端
protected $userModel;
protected $agentsModel;
protected $chatUserModel;
public function __construct()
{
$this->userModel = new Users();
$this->agentsModel = new Agents();
$this->chatUserModel = new ChatUser();
}
/**
* @param $user_id
* @param $mobile
* @param $source
* @return array
*/
public function register($user_id, $mobile, $source)
{
//todo
$params["type"] = $source;
$params["user_id"] = $user_id;
$params["phone"] = $mobile;
$fields = "id,type,phone,only_id,password";
$chatUser = $this->chatUserModel->getChatUser($params, $fields);
if (count($chatUser) > 0) {
return [ "code" => "200", "only_id" => $chatUser[0]["only_id"] ];
} else {
$reg = new RegisterUtil();
$only_id = $this->createOnlyId($user_id, $source);
if (!$only_id) {
return [ "code" => "101", "msg" => "user msg not found" ];
}
$response = $reg->registerByCurl($only_id, $mobile);
if ($response) {
//todo insert
$this->insertChatUser($source, $user_id, $mobile, $only_id);
}
return [ "code" => 200, "only_id" => $only_id ];
}
}
/**
* 生成唯一id
* @param $userId integer 用户id
* @param $source integer 来源 '1经纪人 2用户'
* @return string
*/
public function createOnlyId($userId, $source)
{
$onlyId = "";
switch ($source) {
case 1:
$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId;
break;
case 2:
$userResult = $this->userModel->selectUser($userId);
if ($userResult->id)
$onlyId = self::SOURCE_TYPE_APP . $userResult->id;
break;
}
if (!$onlyId) {
//return array( "code" => 101, "msg" => "没找到用户信息" );
return null;
}
return $onlyId;
}
/**
* 删除注册用户
* @param $only_id
* @param $access_token
* @return bool
*/
public function deleteUser($only_id, $access_token)
{
$reg = new RegisterUtil();
$reg->deleteByCurl($only_id, $access_token);
return true;
}
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $source
* @param $is_user
* @param $type
* @param $msg_content
* @param $from
* @param $accessToken
* @return bool
*/
public function sendMsg($user_name,$target_type, $target, $source, $is_user, $type, $msg_content, $from, $accessToken)
{
//fixme 之后扩展 此处有bug
/* if ($type == 3) {
try {
$house_id = (integer)trim($msg_content);
$HouseInfoModel = new HouseInfos();
$houseResult = $HouseInfoModel->getHousepusmessage($house_id);
if (count($houseResult) == 0)
return false;
} catch (Exception $e) {
return false;
}
}
//todo 判断是否创建关系没有则保存
$this->verifyRelation($target, $from);*/
$this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush();
//todo 消息接收人必须是数据
$rPush->send($user_name,$target_type, [ $target ], $msg_content, $from, $type, $accessToken, [ $this, 'saveSendStatus' ]);
//返回消息发送成功
return true;
}
/**
* 保存推送到环信的消息状态 往msg_status中插入数据
* @param $response
* @param $target
* @param $from
* @param $msg_content
*/
public function saveSendStatus($response, $target, $from, $msg_content)
{
$response = json_decode($response, true);
//目前没有针对多人聊天
$status = isset($response["data"][$target[0]]) ? $response["data"][$target[0]] : "faild";
$error_reason = "";
if ($status != "success") {
$error_reason = "环信发送异常";
}
$this->insertPushLog($from, $target[0], $msg_content, $status, $error_reason);
}
/**
* 根据手机号或者onlyId获取用户信息
* @param $only_id
* @param $type 之后扩展
* @return array|false|\PDOStatement|string|\think\Model
*
*/
public function getUserInfo($only_id, $type)
{
$user_phone = $agent_phone = [];
$chat_user_arr = [];
if ($only_id) {
$only_id_arr = explode(",", $only_id);
$where_["only_id"] = array( "in", $only_id_arr );
$where_["status"] = 0;
$field = "type,user_id,phone,only_id";
$chat_user = $this->chatUserModel->getChatUser($where_, $field);
foreach ($chat_user as $v) {
if ($v["type"] == 1) {
array_push($agent_phone, $v["phone"]);
} else {
array_push($user_phone, $v["phone"]);
}
$chat_user_arr[$v["phone"]] = $v["only_id"];
}
}
$info_arr = [];
if (count($agent_phone) > 0) {
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
$where_agent["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1;
$where_agent["level"] = array( "in", [ 2, 5 ] );
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);
foreach ($agentsResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = TEST_ADMIN_URL_TL . 'user_header/' . $v["user_pic"];
}
$v["only_id"] = $chat_user_arr [$v["user_phone"]];
array_push($info_arr, $v);
}
}
if (count($user_phone) > 0) {
$fields = "id,user_nick,user_phone,user_pic";
$param["status"] = 0;
$param["user_phone"] = array( "in", $user_phone );
$userResult = $this->userModel->getUserByWhere($param, $fields);
foreach ($userResult as $v) {
if ($v["user_pic"]) {
$v["user_pic"] = HEADERIMGURL . $v["user_pic"];
}
$v["only_id"] = $chat_user_arr [$v["user_phone"]];
$v["shop_name"] = "";
array_push($info_arr, $v);
}
}
return $info_arr;
}
/**
* 保存用户发送的消息
* @param $target_type
* @param $target
* @param $source
* @param $is_user
* @param $type
* @param $msg_content
* @param $from
*/
private function insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from)
{
//todo
$params["msg_type"] = 1; //目前只用到了环信的文本消息
$params["to_id"] = $target;
$params["from_id"] = $from;
$params["is_group"] = $target_type == "users" ? 0 : 1;
$params["account_type"] = 1;
$params["source"] = $source;
$params["is_user"] = $is_user;
$params["created_at"] = date("Y-m-d H:i:s", time());
$params["updated_at"] = date("Y-m-d H:i:s", time());
$msgModel = new ChatMsg();
$id = $msgModel->addChatMsg($params);
if ($id > 0) {
//todo 插入msg_ext
$group_id = 0;
if ($target_type != "users") {
$group_id = $from;
}
$this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id);
}
}
/**
* @param $target
* @param $from
*/
private function verifyRelation($target, $from)
{
$chatRelationModel = new ChatRelation();
$params["target"] = $target;
$params["from"] = $from;
$relationResult = $chatRelationModel->getChatRelation($params);
if (count($relationResult) == 0) {
//如果没有记录则记录聊天关系
$chatRelationModel->addChatRelation($params);
}
}
/**
* 记录消息body
* @param $id
* @param $type
* @param $msg_content
* @param $is_group
* @param $group_id
*/
private function insetMsgExt($id, $type, $msg_content, $is_group, $group_id)
{
$param["msg_id"] = $id;
$param["type"] = $type;
$param["body"] = $msg_content;
$param["send_type"] = $is_group;
$param["group_id"] = $group_id;
$param["create_at"] = date("Y-m-d H:i:s", time());
$param["updated_at"] = date("Y-m-d H:i:s", time());
$msgExtModel = new ChatMsgExt();
$msgExtModel->addChatMsgExt($param);
}
/** 获取聊天记录
* @param $sender
* @param $start
* @param $limit
* @param $site_id
* @return array
*/
public function getHistoryChatList($sender, $start, $limit, $site_id)
{
//todo
}
/**
* 往chat_msg_status中插入数据,记录推送的状态
* @param $from
* @param $target
* @param $content
* @param $status
* @param $error_reason
* @return bool
*/
public function insertPushLog($from, $target, $content, $status, $error_reason)
{
$param["from"] = $from;
$param["target"] = $target;
$param["content"] = $content;
$param["status"] = $status;
$param["error_reason"] = $error_reason;
$param["create_time"] = date("Y-m-d H:i:s", time());
$model_ = new ChatMsgStatus();
$model_->addChatMsgStatus($param);
return true;
}
/**
* @param $type
* @param $user_id
* @param $phone
* @param $only_id
* @return bool
*/
public function insertChatUser($type, $user_id, $phone, $only_id)
{
$params["type"] = $type;
$params["user_id"] = $user_id;
$params["phone"] = $phone;
$params["only_id"] = $only_id;
$params["password"] = $phone;
$params["last_login_time"] = date("Y-m-d H:i:s", time());
$params["created_at"] = date("Y-m-d H:i:s", time());
$params["updated_at"] = date("Y-m-d H:i:s", time());
$this->chatUserModel->addChatUser($params);
return true;
}
}
\ No newline at end of file
<?php
namespace app\chat\service;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/23
* Time : 14:15
* Intro:
*/
class GroupService
{
//todo
}
\ No newline at end of file
<?php
namespace app\chat\utils;
/**
* Parses the response from a Curl request into an object containing
* the response body and an associative array of headers
*
* @author qianfunian <qianfunian@51jk.com>
**/
class CurlResponse {
/**
* The body of the response without the headers block
*
* @var string
**/
public $body = '';
/**
* An associative array containing the response's headers
*
* @var array
**/
public $headers = array();
/**
* Accepts the result of a curl request as a string
*
* <code>
* $response = new CurlResponse(curl_exec($curl_handle));
* echo $response->body;
* echo $response->headers['Status'];
* </code>
*
* @param string $response
**/
function __construct($response) {
# Headers regex
$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
# Extract headers from response
preg_match_all($pattern, $response, $matches);
$headers_string = array_pop($matches[0]);
$headers = explode("\r\n", str_replace("\r\n\r\n", '', $headers_string));
# Remove headers from the response body
$this->body = str_replace($headers_string, '', $response);
# Extract the version and status from the first header
$version_and_status = array_shift($headers);
preg_match('#HTTP/(\d\.\d)\s(\d\d\d)\s(.*)#', $version_and_status, $matches);
$this->headers['Http-Version'] = $matches[1];
$this->headers['Status-Code'] = $matches[2];
$this->headers['Status'] = $matches[2].' '.$matches[3];
# Convert headers into an associative array
foreach ($headers as $header) {
preg_match('#(.*?)\:\s(.*)#', $header, $matches);
$this->headers[$matches[1]] = $matches[2];
}
}
/**
* Returns the response body
*
* <code>
* $curl = new Curl;
* $response = $curl->get('google.com');
* echo $response; # => echo $response->body;
* </code>
*
* @return string
**/
function __toString() {
return $this->body;
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
/**
* A basic CURL wrapper
*
* @author qianfunian <qianfunian@51jk.com>
**/
class CurlUtil {
/**
* The file to read and write cookies to for requests
*
* @var string
**/
public $cookie_file;
/**
* Determines whether or not requests should follow redirects
*
* @var boolean
**/
public $follow_redirects = true;
/**
* An associative array of headers to send along with requests
*
* @var array
**/
public $headers = array();
/**
* An associative array of CURLOPT options to send along with requests
*
* @var array
**/
public $options = array();
/**
* The referer header to send along with requests
*
* @var string
**/
public $referer;
/**
* The user agent to send along with requests
*
* @var string
**/
public $user_agent;
/**
* Stores an error string for the last request if one occurred
*
* @var string
* @access protected
**/
protected $error = '';
/**
* Stores resource handle for the current CURL request
*
* @var resource
* @access protected
**/
protected $request;
/**
* Initializes a Curl object
*
* Sets the $cookie_file to "curl_cookie.txt" in the current directory
* Also sets the $user_agent to $_SERVER['HTTP_USER_AGENT'] if it exists, 'Curl/PHP '.PHP_VERSION.' (http://github.com/shuber/curl)' otherwise
**/
function __construct() {
$this->cookie_file = dirname(__FILE__).DIRECTORY_SEPARATOR.'curl_cookie.txt';
$this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Curl/PHP ' . PHP_VERSION;
}
/**
* Makes an HTTP DELETE request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse object
**/
function delete($url, $vars = array()) {
return $this->request('DELETE', $url, $vars);
}
/**
* Returns the error string of the current request if one occurred
*
* @return string
**/
function error() {
return $this->error;
}
/**
* Makes an HTTP GET request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse
**/
function get($url, $vars = array()) {
$vars['platform_type'] = 130;
if (!empty($vars)) {
$url .= (stripos($url, '?') !== false) ? '&' : '?';
$url .= (is_string($vars)) ? $vars : http_build_query($vars, '', '&');
}
$file = new LogsService(LOGS_PATH.'/curl_get/' . date('Y-m-d'));
$file->info($url);
return $this->request('GET', $url);
}
/**
* Makes an HTTP HEAD request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse
**/
function head($url, $vars = array()) {
return $this->request('HEAD', $url, $vars);
}
/**
* Makes an HTTP POST request to the specified $url with an optional array or string of $vars
*
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function post($url, $vars = array()) {
if (!is_string($vars)) {
$vars['platform_type'] = 130;
}
return $this->request('POST', $url, $vars);
}
/**
* Makes an HTTP PUT request to the specified $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function put($url, $vars = array()) {
return $this->request('PUT', $url, $vars);
}
/**
* Makes an HTTP request of the specified $method to a $url with an optional array or string of $vars
*
* Returns a CurlResponse object if the request was successful, false otherwise
*
* @param string $method
* @param string $url
* @param array|string $vars
* @return CurlResponse|boolean
**/
function request($method, $url, $vars = array()) {
$this->error = '';
$this->request = curl_init();
if (is_array($vars)) $vars = http_build_query($vars, '', '&');
$this->set_request_method($method);
$this->set_request_options($url, $vars);
$this->set_request_headers();
$response = curl_exec($this->request);
if ($response) {
$response = new CurlResponse($response);
} else {
$this->error = curl_errno($this->request).' - '.curl_error($this->request);
}
curl_close($this->request);
return $response;
}
/**
* Formats and adds custom headers to the current request
*
* @return void
* @access protected
**/
protected function set_request_headers() {
$headers = array();
foreach ($this->headers as $key => $value) {
$headers[] = $key.': '.$value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
}
/**
* Set the associated CURL options for a request method
*
* @param string $method
* @return void
* @access protected
**/
protected function set_request_method($method) {
switch (strtoupper($method)) {
case 'HEAD':
curl_setopt($this->request, CURLOPT_NOBODY, true);
break;
case 'GET':
curl_setopt($this->request, CURLOPT_HTTPGET, true);
break;
case 'POST':
curl_setopt($this->request, CURLOPT_POST, true);
break;
default:
curl_setopt($this->request, CURLOPT_CUSTOMREQUEST, $method);
}
}
/**
* Sets the CURLOPT options for the current request
*
* @param string $url
* @param string $vars
* @return void
* @access protected
**/
protected function set_request_options($url, $vars) {
/* echo $url;
dump($vars);
dump($this->options);
echo $this->request;
exit;*/
curl_setopt($this->request, CURLOPT_URL, $url);
if (!empty($vars)) curl_setopt($this->request, CURLOPT_POSTFIELDS, $vars);
# Set some default CURL options
curl_setopt($this->request, CURLOPT_HEADER, true);
curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->request, CURLOPT_USERAGENT, $this->user_agent);
if ($this->cookie_file) {
curl_setopt($this->request, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->request, CURLOPT_COOKIEJAR, $this->cookie_file);
}
if ($this->follow_redirects) curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, true);
if ($this->referer) curl_setopt($this->request, CURLOPT_REFERER, $this->referer);
# Set any custom CURL options
foreach ($this->options as $option => $value) {
curl_setopt($this->request, constant('CURLOPT_'.str_replace('CURLOPT_', '', strtoupper($option))), $value);
}
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use Think\Log;
use think\Cache;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 17:17
* Intro: 发送消息类
*/
class RPush
{
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $msg_content
* @param $from
* @param $type
* @param $access_token
* @param $callback
*/
public function send($user_name,$target_type, $target, $msg_content, $from, $type, $access_token, $callback)
{
//todo
if(Cache::get('save_message_num')){
$save_message_num=Cache::get('save_message_num');
if($save_message_num>10){
sleep(1);
Cache::set('save_message_num', 0);
}else{
$save_message_num=$save_message_num+1;
Cache::set('save_message_num', $save_message_num);
}
}else{
Cache::set('save_message_num', 0);
}
$response = $this->sendRequestByCurl($user_name,$target_type, $target, $msg_content, $from, $type, $access_token);
call_user_func_array([ $callback[0], $callback[1] ], [ $response, $target, $from, $msg_content ]);
}
/** curl参数拼凑
* @param $user_name
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* @param $type //目前只有文本的消息
* @param $msg_content
* @param $from
* @param $type
* @param $access_token
* @return \app\chat\utils\CurlResponse|bool
*/
public function sendRequestByCurl($user_name,$target_type, $target, $msg_content, $from, $type, $access_token)
{
$arr = array(
'target_type' => $target_type,
'target' => $target,
'msg' => [ "type" => "txt", "msg" => $msg_content ],
'from' => $from,
'ext' => [ "msg_type" => $type ,"user_name"=>$user_name]
);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
Log::record('info -------------' . json_encode($response), "info");
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME . "/messages";
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use app\chat\utils;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 14:47
* Intro: 注册环信用户
*/
class RegisterUtil
{
const IM_REGISTER_USER = "/users";
const IM_DELETE_USER = "/users";
/**
* @param $username
* @param $password
* @return CurlResponse|bool
*/
public function registerByCurl($username, $password)
{
$arr = array(
'username' => $username,
'password' => $password,
);
$data = json_encode($arr);
$curl = new CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl() . self::IM_REGISTER_USER;
$response = $curl->post($url, $data);
return $response;
}
/**
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function deleteByCurl($username, $access_token)
{
$arr = array(
'username' => $username,
);
$data = json_encode($arr);
$curl = new CurlUtil();
$curl->delete();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl() . self::IM_DELETE_USER;
$response = $curl->post($url, $data);
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME;
}
}
\ No newline at end of file
<?php
namespace app\chat\utils;
use app\chat\consts\ConfigConst;
use Think\Log;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 17:17
* Intro: 发送消息类
*/
class UGroup
{
/** 创建一个群
* 朱伟 2018年01月25日
*/
public function createGroup($group_name, $group_users, $group_users_admin='admin',$access_token)
{
$arr= array(
"groupname"=>$group_name, //群组名称,此属性为必须的
"desc"=>"good", //群组描述,此属性为必须的
"public"=>true, //是否是公开群,此属性为必须的
"maxusers"=>300, //群组成员最大数(包括群主),值为数值类型,默认值200,最大值2000,此属性为可选的
"members_only"=>true, // 加入群是否需要群主或者群管理员审批,默认是false
"allowinvites"=> true, //是否允许群成员邀请别人加入此群。 true:允许群成员邀请人加入此群,false:只有群主或者管理员才可以往群里加人。
"owner"=>$group_users_admin, //群组的管理员,此属性为必须的
"members"=>$group_users //群组成员,此属性为可选的,但是如果加了此项,数组元素至少一个(注:群主jma1不需要写入到members里面)
);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl();
$response = $curl->post($url, $data);
Log::record('------createGroup-------' . json_encode($response), "info");
return $response;
}
/** del一个群
* 朱伟 2018年01月25日
*/
public function deleteGroup($group_id,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id;
$response = $curl->delete($url, $data);
Log::record('-------deleteGroup------' . json_encode($response), "info");
return $response;
}
/** 获取群成员
* 朱伟 2018年01月26日
*/
public function getGroupUser($group_id,$pagenum,$pagesize,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'users?pagenum='.$pagenum.'&pagesize='.$pagesize;
$response = $curl->get($url, $data);
Log::record('-------deleteGroup------' . json_encode($response), "info");
return $response;
}
/** 添加群组成员
* 朱伟 2018年01月26日
*/
public function addGroupUserByIds($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'/users/'.$username;
$response = $curl->post($url, $data);
Log::record('-------addGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 移除群组成员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function delGroupUserByIds($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
$url = $this->buildSendUrl().$group_id.'/users/'.$username;
$response = $curl->post($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 添加群组管理员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function addGroupManage($group_id,$username,$access_token)
{
$arr= array("newadmin"=>$username);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//Path: /{org_name}/{app_name}/chatgroups/{group_id}/admin
$url = $this->buildSendUrl().$group_id.'/admin';
$response = $curl->delete($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 移除群组管理员
* 朱伟 2018年01月29日
* @param $group_id
* @param $username
* @param $access_token
* @return CurlResponse|bool
*/
public function delGroupManage($group_id,$username,$access_token)
{
$arr= array();
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
"Content-Type" => "application/json;charset=utf-8",
'Authorization' => "Bearer " . $access_token,
];
$curl->options = [
"CURLOPT_SSL_VERIFYPEER" => 0,
"CURLOPT_SSL_VERIFYHOST" => 2,
];
//
$url = $this->buildSendUrl().$group_id.'/admin/'.$username;
$response = $curl->delete($url, $data);
Log::record('-------delGroupUserByIds------' . json_encode($response), "info");
return $response;
}
/**
* 请求api
* @return string
*/
private function buildSendUrl()
{
return ConfigConst::API_PATH . ConfigConst::ORG_NAME . "/" . ConfigConst::APP_NAME.'/chatgroups/' ;
}
}
\ No newline at end of file
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1517538110 rememberMe deleteMe
......@@ -13,8 +13,10 @@ define('IMG_PATH','https://admin.tonglianjituan.com/houseImg/');
define('LOCAL_IMG_HOST','/resource/lib/Attachments/');
define('PAGESIZE', 15); //分页每页条数
define('ADMIN_URL_TL','https://admin.tonglianjituan.com/'); //B端网址
define('TEST_ADMIN_URL_TL','https://dev.tonglianjituan.com/'); //B端网址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].DS); //取当前域名地址
define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //头像地址
define('CHAT_IMG_URL', CURRENT_URL . 'static'. DS . 'chat_image/'); //聊天图片地址
define('CK_IMG_URL', CURRENT_URL . '/resource/lib/Attachments/'); //ck 资源文件
return [
// +----------------------------------------------------------------------
......
<?php
namespace app\extra;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/9
* Time : 15:20
* Intro: redis connect class
*/
class RedisPackage
{
protected static $handler = null;
protected $options = [
'host' => '101.132.186.250',
'port' => 6379,
'password' => '',
'select' => 0,
'timeout' => 0,
'expire' => 0,
'persistent' => false,
'prefix' => '',
];
public function __construct($options = [])
{
if (!extension_loaded('redis')) { //判断是否有扩展(如果你的apache没reids扩展就会抛出这个异常)
throw new \BadFunctionCallException('not support: redis');
}
if (!empty($options)) {
$this->options = array_merge($this->options, $options);
}
$func = $this->options['persistent'] ? 'pconnect' : 'connect'; //判断是否长连接
self::$handler = new \Redis;
self::$handler->$func($this->options['host'], $this->options['port'], $this->options['timeout']);
if ('' != $this->options['password']) {
self::$handler->auth($this->options['password']);
}
if (0 != $this->options['select']) {
self::$handler->select($this->options['select']);
}
}
/**
* 写入缓存
* @param string $key 键名
* @param string $value 键值
* @param int $exprie 过期时间 0:永不过期
* @return bool
*/
public static function set($key, $value, $exprie = 0)
{
if ($exprie == 0) {
$set = self::$handler->set($key, $value);
} else {
$set = self::$handler->setex($key, $exprie, $value);
}
return $set;
}
/**
* 读取缓存
* @param string $key 键值
* @return mixed
*/
public static function get($key)
{
$fun = is_array($key) ? 'Mget' : 'get';
return self::$handler->{$fun}($key);
}
/**
* 获取值长度
* @param string $key
* @return int
*/
public static function lLen($key)
{
return self::$handler->lLen($key);
}
/**
* 将一个或多个值插入到列表头部
* @param $key
* @param $value
* @return int
*/
public static function LPush($key, $value, $value2 = null, $valueN = null)
{
return self::$handler->lPush($key, $value, $value2, $valueN);
}
/**
* 移出并获取列表的第一个元素
* @param string $key
* @return string
*/
public static function lPop($key)
{
return self::$handler->lPop($key);
}
}
\ No newline at end of file
<?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
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: luofei614 <weibo.com/luofei614> 
// +----------------------------------------------------------------------
namespace app\index\untils;
use think\Db;
use think\Config;
use think\Session;
use think\Request;
use think\Loader;
/**
* 权限认证类
* 功能特性:
* 1,是对规则进行认证,不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。
* $auth=new Auth(); $auth->check('规则名称','用户id')
* 2,可以同时对多条规则进行认证,并设置多条规则的关系(or或者and)
* $auth=new Auth(); $auth->check('规则1,规则2','用户id','and')
* 第三个参数为and时表示,用户需要同时具有规则1和规则2的权限。 当第三个参数为or时,表示用户值需要具备其中一个条件即可。默认为or
* 3,一个用户可以属于多个用户组(think_auth_group_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think_auth_group 定义了用户组权限)
* 4,支持规则表达式。
* 在think_auth_rule 表中定义一条规则时,如果type为1, condition字段就可以定义规则表达式。 如定义{score}>5 and {score}<100
* 表示用户的分数在5-100之间时这条规则才会通过。
*/
//数据库
/*
-- ----------------------------
-- think_auth_rule,规则表,
-- id:主键,name:规则唯一标识, title:规则中文名称 status 状态:为1正常,为0禁用,condition:规则表达式,为空表示存在就验证,不为空表示按照条件验证
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_rule`;
CREATE TABLE `think_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` char(80) NOT NULL DEFAULT '',
`title` char(20) NOT NULL DEFAULT '',
`type` tinyint(1) NOT NULL DEFAULT '1',
`status` tinyint(1) NOT NULL DEFAULT '1',
`condition` char(100) NOT NULL DEFAULT '', # 规则附件条件,满足附加条件的规则,才认为是有效的规则
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group 用户组表,
-- id:主键, title:用户组中文名称, rules:用户组拥有的规则id, 多个规则","隔开,status 状态:为1正常,为0禁用
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group`;
CREATE TABLE `think_auth_group` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` char(100) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`rules` char(80) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group_access 用户组明细表
-- uid:用户id,group_id:用户组id
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group_access`;
CREATE TABLE `think_auth_group_access` (
`uid` mediumint(8) unsigned NOT NULL,
`group_id` mediumint(8) unsigned NOT NULL,
UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
KEY `uid` (`uid`),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
*/
class AuthUntils
{
/**
* @var object 对象实例
*/
protected static $instance;
/**
* 当前请求实例
* @var Request
*/
protected $request;
//默认配置
protected $config = [
'auth_on' => 1, // 权限开关
'auth_type' => 1, // 认证方式,1为实时认证;2为登录认证。
'auth_group' => 'auth_group', // 用户组数据表名
'auth_group_access' => 'auth_group_access', // 用户-用户组关系表
'auth_rule' => 'auth_rule', // 权限规则表
'auth_user' => 'agents', // 用户信息表
];
/**
* 类架构函数
* Auth constructor.
*/
public function __construct()
{
//可设置配置项 auth, 此配置项为数组。
if ($auth = Config::get('auth')) {
$this->config = array_merge($this->config, $auth);
}
// 初始化request
$this->request = Request::instance();
}
/**
* 初始化
* @access public
* @param array $options 参数
* @return \think\Request
*/
public static function instance($options = [])
{
if (is_null(self::$instance)) {
self::$instance = new static($options);
}
return self::$instance;
}
/**
* 检查权限
* @param $name string|array 需要验证的规则列表,支持逗号分隔的权限规则或索引数组
* @param $uid int 认证用户的id
* @param int $type 认证类型
* @param string $mode 执行check的模式
* @param string $relation 如果为 'or' 表示满足任一条规则即通过验证;如果为 'and'则表示需满足所有规则才能通过验证
* @return bool 通过验证返回true;失败返回false
*/
public function check($name, $uid, $type = 1, $mode = 'url', $relation = 'or')
{
if (!$this->config['auth_on']) {
return true;
}
$count = Db::name($this->config['auth_rule'])->where('name',$name)->count();
if ($count == 0) {
return true;
}
// 获取用户需要验证的所有有效规则列表
$authList = $this->getAuthList($uid, $type);
if (is_string($name)) {
$name = strtolower($name);
if (strpos($name, ',') !== false) {
$name = explode(',', $name);
} else {
$name = [$name];
}
}
$list = []; //保存验证通过的规则名
if ('url' == $mode) {
$REQUEST = unserialize(strtolower(serialize($this->request->param())));
}
foreach ($authList as $auth) {
$query = preg_replace('/^.+\?/U', '', $auth);
if ('url' == $mode && $query != $auth) {
parse_str($query, $param); //解析规则中的param
$intersect = array_intersect_assoc($REQUEST, $param);
$auth = preg_replace('/\?.*$/U', '', $auth);
if (in_array($auth, $name) && $intersect == $param) {
//如果节点相符且url参数满足
$list[] = $auth;
}
} else {
if (in_array($auth, $name)) {
$list[] = $auth;
}
}
}
if ('or' == $relation && !empty($list)) {
return true;
}
$diff = array_diff($name, $list);
if ('and' == $relation && empty($diff)) {
return true;
}
return false;
}
/**
* 根据用户id获取用户组,返回值为数组
* @param $uid int 用户id
* @return array 用户所属的用户组 array(
* array('uid'=>'用户id','group_id'=>'用户组id','title'=>'用户组名称','rules'=>'用户组拥有的规则id,多个,号隔开'),
* ...)
*/
public function getGroups($uid = '')
{
static $groups = [];
if (isset($groups[$uid])) {
return $groups[$uid];
}
// 转换表名
$auth_group_access = Loader::parseName($this->config['auth_group_access'], 0);
$auth_group = Loader::parseName($this->config['auth_group'], 0);
// 执行查询
// $user_groups = Db::view($auth_group_access, 'uid,group_id')
// ->view($auth_group, 'title,rules', "{$auth_group_access}.group_id={$auth_group}.id", 'LEFT')
// ->where("{$auth_group_access}.uid='{$uid}' and {$auth_group}.status='1'")
// ->select();
$user_groups = Db::name($auth_group_access)
->alias('a')
->where("a.uid='$uid' and g.status='1'")
->join($auth_group. ' g', 'a.group_id=g.id')
->select();
$groups[$uid] = $user_groups ?: [];
return $groups[$uid];
}
/**
* 获得权限列表
* @param integer $uid 用户id
* @param integer $type
* @return array
*/
protected function getAuthList($uid, $type)
{
static $_authList = []; //保存用户验证通过的权限列表
$t = implode(',', (array)$type);
if (isset($_authList[$uid . $t])) {
return $_authList[$uid . $t];
}
if (2 == $this->config['auth_type'] && Session::has('_auth_list_' . $uid . $t)) {
return Session::get('_auth_list_' . $uid . $t);
}
//读取用户所属用户组
$groups = $this->getGroups($uid);
$ids = []; //保存用户所属用户组设置的所有权限规则id
foreach ($groups as $g) {
$ids = array_merge($ids, explode(',', trim($g['rules'], ',')));
}
$ids = array_unique($ids);
if (empty($ids)) {
$_authList[$uid . $t] = [];
return [];
}
$map = [
'id' => ['in', $ids],
'type' => $type
];
//读取用户组所有权限规则
$rules = Db::name($this->config['auth_rule'])->where($map)->field('condition,name')->select();
//循环规则,判断结果。
$authList = []; //
foreach ($rules as $rule) {
if (!empty($rule['condition'])) {
//根据condition进行验证
$user = $this->getUserInfo($uid); //获取用户信息,一维数组
$command = preg_replace('/\{(\w*?)\}/', '$user[\'\\1\']', $rule['condition']);
@(eval('$condition=(' . $command . ');'));
if ($condition) {
$authList[] = strtolower($rule['name']);
}
} else {
//只要存在就记录
$authList[] = strtolower($rule['name']);
}
}
$_authList[$uid . $t] = $authList;
if (2 == $this->config['auth_type']) {
//规则列表结果保存到session
Session::set('_auth_list_' . $uid . $t, $authList);
}
return array_unique($authList);
}
/**
* 获得用户资料
* @param $uid
* @return mixed
*/
protected function getUserInfo($uid)
{
static $user_info = [];
$user = Db::name($this->config['auth_user']);
// 获取用户表主键
$_pk = is_string($user->getPk()) ? $user->getPk() : 'uid';
if (!isset($user_info[$uid])) {
$user_info[$uid] = $user->where($_pk, $uid)->find();
}
return $user_info[$uid];
}
}
{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
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="edit" />
<div id="page-content-wrapper">
<style type="text/css">
.form-group {
margin: 10px;
}
.input-100-width {
width: 100px!important;
}
.input-360-width {
width: 360px!important;
}
.textarea-500-width {
width: 500px!important;
}
.list-group-item>.full-width-100+.full-width-100 {
padding-top: 10px;
}
.list-group-item>.full-width-100>label {
width: 60px;
}
.list-group-item>.full-pic-area>label {
width: 120px;
}
.input-add-tel{
margin-top: 16px;
height: 20px;
}
.phone-list-container{
overflow: hidden;
width: 196px;
vertical-align: top!important;
position: relative;
}
.phone-list-container>label{
line-height: 30px;
}
.phone-list-container>input{
float: left;
}
.phone-list-container>ul{
width: 196px;
list-style: none;
padding-left: 0;
float: right;
border: 1px solid #ccc;
border-top: none;
background-color: white;
}
.phone-list-container>ul>li:hover{
background-color: #e0e0e0;
}
.phone-list-container>img{
position: absolute;
right: 5px;
top: 7px;
width: 20px;
}
/*获取百度经纬度样式*/
/*********************************************************百度定位页面iframe引入*************************************/
#position_box {
height: 750px;
background-color: #f0f0f0;
overflow: scroll;
position: relative;
}
div.address-header-bar {
overflow: hidden;
float: left;
}
#address_city_title {
float: left;
width: 150px;
line-height: 60px;
font-size: 30px;
color: #333;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.crile {
float: left;
width: 480px;
overflow: hidden;
position: relative;
}
.crile>input {
line-height: 60px;
box-sizing: border-box;
padding: 0;
border-width: 1px;
width: 100%;
display: block;
border-radius: 30px;
background: #f5f5f5 url('/resource/image/search_ic.png') no-repeat 30px center;
background-size: 28px;
text-indent: 60px;
font-size: 28px;
outline: none;
}
.crile>input::-webkit-search-cancel-button {
-webkit-appearance: none;
}
img.cancel-pic {
width: 28px;
height: 28px;
position: absolute;
right: 0;
top: 0;
box-sizing: content-box;
padding: 15px;
}
#main_ul {
padding: 0 30px;
background-color: white;
font-size: 30px;
}
#main_ul>ul {
padding-left: 0;
}
#main_ul>ul>li {
cursor: pointer;
list-style: none;
}
#main_ul>ul>li+li {
border-top: 1px solid #e0e0e0;
}
#main_ul>ul>li>p:nth-of-type(1) {
color: #333;
padding: 20px 0 10px;
margin: 0;
}
#main_ul>ul>li>p:nth-of-type(2) {
color: #999;
padding-bottom: 20px;
margin: 0;
}
.loading_pic {
font-size: 20px;
text-align: center;
width: 100%;
position: absolute;
top: 150px;
display: none;
}
.loading_pic>img {
width: 120px;
display: block;
margin: 0 auto;
}
.loading_pic>p {
font-size: 20px;
color: #333;
text-align: center;
margin-top: 10px;
color: rgb(51, 51, 51);
}
.no_more {
font-size: 30px;
height: 50px;
line-height: 50px;
text-align: center;
display: none;
}
/**/
#li_dujia_area{
/*display: none;*/
}
</style>
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-0">
<div class="panel panel-default">
<div class="panel-heading">新增商铺</div>
<div class="panel-body">
<form class="form-inline">
<ul class="list-group">
<li class="list-group-item">
<div class="form-group">
<label for="shangpuType">商铺类型</label>
<select class="form-control" name="shangpuType" id="shangpuType">
<option value="0">商场</option>
<option value="1">街铺</option>
</select>
</div>
<div class="form-group">
<label for="show_all">显示给C端用户看</label>
<select class="form-control" name="showCd" id="showCd">
<option value="0"></option>
<option value="1"></option>
</select>
</div>
<div class="form-group">
<label for="exclusiveType">是否独家</label>
<select class="form-control" name="exclusiveType" id="exclusiveType">
<option value="1"></option>
<option value="0"></option>
</select>
</div>
</li>
<li class="list-group-item" id="li_dujia_area">
<div class="form-group">
<label for="">独家代理有效期</label>
<div class="input-group">
<input type="date" class="form-control" id="exclusiveDate1" placeholder="请输入">
<div class="input-group-addon"></div>
<input type="date" class="form-control" id="exclusiveDate2" placeholder="请输入">
</div>
</div>
<div class="form-group phone-list-container" style="width: 45px;margin-right: 0;">
<label for="">独家方</label>
</div>
<div class="form-group phone-list-container">
<input type="tel" class="form-control phone_jia" id="exclusiveTel" placeholder="请输入">
<ul></ul>
</div>
</li>
<li class="list-group-item">
<div class="form-group phone-list-container" style="width: 70px;">
<label for="">案场人电话</label>
</div>
<div class="form-group phone-list-container">
<input type="tel" class="form-control phone_jia" placeholder="请输入">
<ul></ul>
</div>
<!--<div class="form-group phone-list-container">
<input type="tel" class="form-control phone_jia" placeholder="请输入">
<ul></ul>
<img src="/resource/image/search_gb.png" class="input-cancel-pic" />
</div>-->
<img src="/resource/image/jia2@2x.png" data-hideid='1' class="input-add-tel" id="acr_tel_jia" />
</li>
<li class="list-group-item">
<div class="form-group phone-list-container" style="width: 70px;">
<label for="">盘方</label>
</div>
<div class="form-group phone-list-container">
<input type="tel" class="form-control phone_jia" placeholder="请输入">
<ul></ul>
</div>
<img src="/resource/image/jia2@2x.png" data-hideid='0' class="input-add-tel" id="pf_tel_jia" />
</li>
<li class="list-group-item">
<div class="form-group phone-list-container" style="width: 70px;">
<label for="">案场权限人</label>
</div>
<div class="form-group phone-list-container">
<input type="tel" class="form-control phone_jia" placeholder="请输入">
<ul></ul>
</div>
<img src="/resource/image/jia2@2x.png" data-hideid='0' class="input-add-tel" id="acqx_tel_jia" />
</li>
<li class="list-group-item">
<div class="form-group">
<label for="internalName">对内商铺名称</label>
<input type="text" class="form-control" placeholder="请输入" name="internalName" id="internalName">
</div>
<div class="form-group">
<label for="foreignName">对外商铺名称</label>
<input type="text" class="form-control" placeholder="请输入" name="foreignName" id="foreignName">
</div>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="group">租金模式</label>
<select class="form-control" name="zujinType" id="zujinType">
<option value="1" selected="selected">月租金</option>
<option value="2">营业额扣点</option>
<option value="3">每平方米租金</option>
</select>
</div>
<div class="form-group">
<label class="" for="price">月租均价</label>
<div class="input-group">
<input type="number" class="form-control input-100-width" name="moonPrice" id="moonPrice" placeholder="请输入">
<div class="input-group-addon">元/月</div>
</div>
</div>
<div class="form-group">
<label for="management_fee">物业管理费</label>
<div class="input-group">
<input type="number" class="form-control input-100-width" name="wuyePrice" id="wuyePrice" placeholder="请输入">
<div class="input-group-addon">元/月</div>
</div>
</div>
<div class="form-group">
<label for="">进场费</label>
<div class="input-group">
<input type="number" class="form-control input-100-width" id="jinchangPrice" placeholder="请输入">
<div class="input-group-addon">元/月</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="">剩余铺数</label>
<input type="number" class="form-control input-100-width" id="roomShengyuNum" placeholder="请输入">
</div>
<div class="form-group">
<label for="">总铺数</label>
<input type="number" class="form-control input-100-width" id="roomAllNum" placeholder="请输入">
</div>
<div class="form-group">
<label for="">商铺面积</label>
<div class="input-group">
<input type="number" class="form-control input-100-width" id="roomArea1" placeholder="请输入">
<div class="input-group-addon"></div>
<input type="number" class="form-control input-100-width" id="roomArea2" placeholder="请输入">
<div class="input-group-addon"></div>
</div>
</div>
<div class="form-group">
<label for="">商业面积</label>
<div class="input-group">
<input type="number" class="form-control input-100-width" id="businessArea" placeholder="请输入">
<div class="input-group-addon"></div>
</div>
</div>
</li>
<li class="list-group-item">
<label for="">业态(可多选)</label>
<label class="checkbox-inline">
<input type="checkbox" class="yetai" id="" value="餐饮美食">餐饮美食
</label>
<label class="checkbox-inline">
<input type="checkbox" class="yetai" id="" value="百货零售">百货零售
</label>
<label class="checkbox-inline">
<input type="checkbox" class="yetai" id="" value="休闲娱乐">休闲娱乐
</label>
<label class="checkbox-inline">
<input type="checkbox" class="yetai" id="" value="其他">其他
</label>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="">对内地址</label>
<select class="form-control" id="province_internal" name="province_internal"></select>
<select class="form-control" id="city_internal" name="city_internal"></select>
<select class="form-control" id="disc_internal" name="disc_internal"></select>
<input type="text" class="form-control" id="address_internal" placeholder="请输入详细地址">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" id="position_btn">定位</button>
</div>
<div class="form-group">
<label for="longitude">经度</label>
<input type="text" class="form-control input-100-width" readonly="readonly" id="longitude" name="longitude">
</div>
<div class="form-group">
<label for="">纬度</label>
<input type="text" class="form-control input-100-width" readonly="readonly" id="latitude" name="latitude">
</div>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="">对外地址</label>
<input type="text" class="form-control input-100-width" title="与对内地址一致,请通过修改对内地址,来改变此值" readonly="readonly" id="province_external" value="上海" />
<input type="text" class="form-control input-100-width" title="与对内地址一致,请通过修改对内地址,来改变此值" readonly="readonly" id="city_external" value="上海" />
<input type="text" class="form-control input-100-width" title="与对内地址一致,请通过修改对内地址,来改变此值" readonly="readonly" id="disc_external" value="黄浦" />
<input type="text" class="form-control" id="address_external" placeholder="请输入详细地址">
</div>
</li>
<li class="list-group-item">
<div class="form-group full-width-100">
<label for="">交通</label>
<textarea class="form-control textarea-500-width" rows="3" id="traffic"></textarea>
</div>
<div class="form-group full-width-100">
<label for="">已入住</label>
<textarea class="form-control textarea-500-width" rows="3" id="hasMoved"></textarea>
</div>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="">营业时间</label>
<input type="text" class="form-control" id="yingyeTime">
</div>
<div class="form-group">
<label for="">开盘时间</label>
<input type="date" class="form-control" id="kaipanTime">
</div>
<div class="form-group">
<label for="">开业时间</label>
<input type="date" class="form-control" id="kaiyeTime">
</div>
<div class="form-group">
<label for="">是否有燃气</label>
<select class="form-control" id="hasGas">
<option value="0" selected="selected"></option>
<option value="1">没有</option>
</select>
</div>
</li>
<li class="list-group-item">
<div class="form-group">
<label for="">微楼书</label>
<div class="input-group">
<input type="text" class="form-control input-360-width" id="weilouLink" placeholder="请填入微楼书网页链接">
<div class="input-group-addon">如(https://www.fujuhaofang.com)</div>
</div>
</div>
</li>
<li class="list-group-item">
<div class="form-group" style="width: 100%;">
<label for="" style="width: 100%;">大讲堂</label>
<div class="input-group" style="width: 100%;" id="dajiangtang">
<?php
create_editor('describe');
?>
</div>
</div>
</li>
<li class="list-group-item">
<div class="form-group full-width-100">
<label for="">佣金规则</label>
<textarea class="form-control textarea-500-width" rows="3" id="yongjinRule"></textarea>
</div>
<div class="form-group full-width-100">
<label for="">对内项目优势</label>
<textarea class="form-control textarea-500-width" rows="3" id="internalYoushi"></textarea>
</div>
<div class="form-group full-width-100">
<label for="">对外项目优势</label>
<textarea class="form-control textarea-500-width" rows="3" id="foreignYoushi"></textarea>
</div>
<div class="form-group full-width-100">
<label for="">签约规则</label>
<textarea class="form-control textarea-500-width" rows="3" id="qianyueRule"></textarea>
</div>
</li>
<li class="list-group-item">
<label for="">商铺标签(可多选)</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="临近地铁" name="shangpu_tags[]">临近地铁
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="临街旺铺" name="shangpu_tags[]">临街旺铺
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="无进场费"name="shangpu_tags[]">无进场费
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="办公室配套" name="shangpu_tags[]">办公室配套
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="5A景区游客量大" name="shangpu_tags[]">5A景区游客量大
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="餐饮综合体" name="shangpu_tags[]">餐饮综合体
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="强大案场阵容"name="shangpu_tags[]">强大案场阵容
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="综合市场" name="shangpu_tags[]">综合市场
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="超高佣金" name="shangpu_tags[]">超高佣金
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="居民区十字路口" name="shangpu_tags[]">居民区十字路口
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="写字楼底商"name="shangpu_tags[]">写字楼底商
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="住宅配套" name="shangpu_tags[]">住宅配套
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="沿街一单收佣9.5w" name="shangpu_tags[]">沿街一单收佣9.5w
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="黄兴路1750" name="shangpu_tags[]">黄兴路1750
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="大学门口"name="shangpu_tags[]">大学门口
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="广灵二路" name="shangpu_tags[]">广灵二路
</label>
<label class="checkbox-inline">
<input type="checkbox" class="roomTag" id="" value="40831" name="shangpu_tags[]">40831
</label>
</li>
<li class="list-group-item">
<div class="form-group full-width-100 full-pic-area">
<label for="">列表页封面图(1张)</label>
<input readonly="readonly" type="text" name="liebiao_pic_pre" class="form-control" style="width: 150px !important;display: inline-block" id="liebiao_pic_pre" placeholder="请选择图片">
<button class="btn btn-default" id="liebiao_pic_btn" type="button">选择图片</button>
<span class="tip"></span>
</div>
</li>
<li class="list-group-item">
<div class="form-group full-width-100 full-pic-area">
<label for="">详情页轮播图(至少6张)</label>
<input readonly="readonly" type="text" name="xiangqing_pic_pre" class="form-control" style="width: 150px !important;display: inline-block" id="xiangqing_pic_pre" placeholder="请选择图片">
<button class="btn btn-default" id="xiangqing_pic_btn" type="button">选择图片</button>
<span class="tip"></span>
</div>
</li>
<li class="list-group-item">
<div class="form-group full-width-100 full-pic-area">
<label for="">楼层平面图(选填)</label>
<input readonly="readonly" type="text" name="louceng_pic_pre" class="form-control" style="width: 150px !important;display: inline-block" id="louceng_pic_pre" placeholder="请选择图片">
<button class="btn btn-default" id="louceng_pic_btn" type="button">选择图片</button>
<span class="tip"></span>
</div>
</li>
<li class="list-group-item">
<div class="form-group full-width-100 full-pic-area">
<label for="">附件上传(PDF格式)</label>
<input readonly="readonly" type="text" name="fujian_pre" class="form-control" style="width: 150px !important;display: inline-block" id="fujian_pre" placeholder="请选择图片">
<button class="btn btn-default" id="fujian_btn" type="button">选择图片</button>
<span class="tip"></span>
</div>
</li>
<li class="list-group-item"><button type="submit" class="btn btn-default" id="saveBtn">保存</button></li>
</ul>
</form>
</div>
</div>
</div>
</div>
</div>
<!--百度定位的弹出框更改-->
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content" style="width: 780px;">
<div class="modal-header" style="height: 88px;overflow: hidden;">
<div class="address-header-bar">
<div id="address_city_title">上海市</div>
<div class="crile">
<input class="main-input" id="search_input" type="search" placeholder="请输入地址" />
<img src="/resource/image/search_gb.png" class="cancel-pic" />
</div>
</div>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 42px;"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body" style="height: 780px;">
<div id="position_box">
<div id="main_ul">
<ul></ul>
</div>
<div id="loading_pic" class="loading_pic">
<img src="/resource/image/jz2.gif" />
<p>正在加载...</p>
</div>
<div id="no_more" class="no_more">没有更多了</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=RTimRTxtj23AYTCkSsPvNDuQkGpR2fPX"></script>
</div>
\ No newline at end of file
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="houseList" />
<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-add-do" data-toggle="modal" class="btn btn-default"><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="9">
<form id="form_search">
<select class="form-control btn2" id="is_carefully_chosen">
<option value="" class="successModel">是否显示在首页</option>
<option value="0"></option>
<option value="1"></option>
</select>
<select class="form-control btn2" id="is_show">
<option value="" class="successModel">C端是否显示</option>
<option value="0"></option>
<option value="1"></option>
</select>
<select class="form-control btn2" id="shop_type">
<option value="" class="successModel">商铺类型</option>
<option value="0">商场</option>
<option value="1">街铺</option>
</select>
<select class="form-control btn2" id="leased">
<option value="" class="successModel">商铺状态</option>
<option value="0">已租</option>
<option value="1">待租</option>
</select>
<select class="form-control btn2" id="rent_price">
<option value="" class="successModel">月租金</option>
<option value="2">10000以下</option>
<option value="1" >10000-30000</option>
<option value="0">30000以上</option>
</select>
<select class="form-control btn2" id="is_exclusive_type">
<option value="" class="successModel">是否独家</option>
<option value="1"></option>
<option value="0"></option>
</select>
<input class="form-control btn2" data-rule-phoneus="false" data-rule-required="false" id="internal_title" placeholder="商铺名称" type="text" value="">
<div class="row">
</div>
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="industry_type" placeholder="业态" type="text" value="">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="dish" placeholder="盘方" type="text" value="">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="id" placeholder="店铺编号" type="text" value="">
<span class="fore-span ld-Marheight">上传时间:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date">
<span class="fore-span ld-Marheight">-</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date">
<span class="btn btn-default btn3 ld-Marheight" id="search">搜索</span>
<span class="btn btn-default btn3 ld-Marheight" id="form_search_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">C端是否显示</th>
<th class="text-center">上传时间</th>
<th class="text-center">状态</th>
<th class="text-center">盘方</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody class="text-center" id="business_list">
<!--<tr>-->
<!--<td>212</td>-->
<!--<td>商场</td>-->
<!--<td>长兴</td>-->
<!--<td>1000</td>-->
<!--<td>是</td>-->
<!--<td>2018-01-16 17:02:00</td>-->
<!--<td>已租</td>-->
<!--<td>张娜张-->
<!--<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="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">编辑</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">推荐至首页</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">设置案场权限人</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">是否独家</a>-->
<!--<a class="btn1 btn-success " href="#modal-process" data-toggle="modal" data-id="77" onclick="alertFollow(this)">操作记录</a>-->
<!--<a data-toggle="modal" data-id="77" href="#modal-watch" class="btn1 btn-danger add_applies" onclick="delete_house(4720)">删除</a>-->
<!--</td>-->
<!--</tr>-->
</table>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
<div class="page-cla">
<ul class="pagination">
<li><a href="#">&laquo;</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">&raquo;</a></li>
</ul>
</div>
</div>
</div>
</div>
<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">
×
</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>
<!--设置案场权限人-->
<div class="modal fade" id="modal-anch" 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">
×
</button>
<h4 class="modal-title" id="myModalLabel">
设置案场权限人
</h4>
</div>
<div class="modal-body">
<form action="/Houseinfos/agent_prv" method="POST" id="submit_agent">
<div class="jian_class">
<input name="phone[]" placeholder="请输入" type="tel" value="" class="phone_jia">
<!--号码匹配名字-->
<ul class="phone_list"></ul>
</div>
<img src="/resource/image/jia2@2x.png" class="jia">
<input type="hidden" name="houseinfos_id" class="houseinfos_id">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" class="btn btn-primary" id="submit_follow">
提交
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
\ No newline at end of file
<?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
......@@ -7,9 +7,12 @@ use think\Db;
class Agents extends Model
{
protected $table = 'agents';
/**
* 查询经纪人
*
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
......@@ -18,28 +21,29 @@ class Agents extends Model
* @param type $house_id 查询该街铺和商铺的经纪人评论信息
* @return type
*/
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') {
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
if ($house_id == '') {
$data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->where($params)
->where('level=2 or level=5')
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->where($params)
->where('level=2 or level=5')
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
} else {
$data = $this->field($field)->alias('a')
->join('u_evaluate b','a.id = b.agents_id','left')
->where('find_in_set('.$house_id.', house_ids) or find_in_set('.$house_id.', house_ids2)')
->where($params)
->where('level=2 or level=5')
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->where('find_in_set(' . $house_id . ', house_ids) or find_in_set(' . $house_id . ', house_ids2)')
->where($params)
->where('level=2 or level=5')
->group('a.id')
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
return $data;
......@@ -47,25 +51,20 @@ class Agents extends Model
/**
* 经纪人详情
*
* @param $id
* @return array|bool|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentsDetail($id) {
public function agentsDetail($id)
{
if ($id) {
$result = $this->field('id,realname,created,sub_shopname,head_portrait')
->where('level=2 or level=5')
->where('id',$id)->find();
$result['head_portrait'] = 'user_header/'.$result['head_portrait']; //头像
$evaluate_grade = Db::table('u_evaluate')
->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num')
->where('agents_id',$id)->where('is_show',0)->find();
$result = $this->field('id,realname,created,sub_shopname,head_portrait')
->where('level=2 or level=5')
->where('id', $id)->find();
$result['head_portrait'] = 'user_header/' . $result['head_portrait']; //头像
$evaluate_grade = Db::table('u_evaluate')
->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num')
->where('agents_id', $id)->where('is_show', 0)->find();
if ($evaluate_grade['evaluate_grade']) {
$grade = floor(($evaluate_grade['evaluate_grade']/2)/$evaluate_grade['evaluate_num']);
$grade = floor(($evaluate_grade['evaluate_grade'] / 2) / $evaluate_grade['evaluate_num']);
} else {
$grade = 0;
}
......@@ -73,7 +72,7 @@ class Agents extends Model
$result['evaluate_grade'] = $grade; //评分等级
$result['evaluate_num'] = $evaluate_grade['evaluate_num']; //评论数量
$result['watch_shop'] = Db::table('u_appoint_watch_shop')
->where('agents_id',$id)->count(); //看铺
->where('agents_id', $id)->count(); //看铺
$result['head_portrait'] = ADMIN_URL_TL.$result['head_portrait'];
$remarks = new Remarks();
......@@ -85,24 +84,40 @@ class Agents extends Model
$current_time = time();
$user_time = strtotime($result['created']);
$year = date('Y', $current_time) - date('Y', $user_time);
$year = date('Y', $current_time) - date('Y', $user_time);
//入职年限
if ($year == 0) {
$result['created'] = $year .'个月以上';
$result['created'] = $year . '个月以上';
} else {
$result['created'] = $year . '年以上';
$result['created'] = $year . '年以上';
}
$result['label'] = array(0=>'待定标签数据',1=>'待定标签数据');
$data = $result;
$result['label'] = array( 0 => '待定标签数据', 1 => '待定标签数据' );
$data = $result;
} else {
$data = false;
}
return $data;
}
/**
* 获取经纪人 by zw
* @param $field
* @param $where_
* @return array|false|\PDOStatement|string|Model
*/
public function getAgentsById($field, $where_)
{
$data = $this
->field($field)
->where($where_)
->select();
return $data;
}
/**
* 查询经纪人列表
*
......@@ -117,7 +132,8 @@ class Agents extends Model
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgents($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') {
public function getAgents($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{
if ($house_id == '') {
$data = $this->field($field)
->where($params)
......@@ -128,7 +144,7 @@ class Agents extends Model
->select();
} else {
$data = $this->field($field)
->where('find_in_set('.$house_id.', house_ids) or find_in_set('.$house_id.', house_ids2)')
->where('find_in_set(' . $house_id . ', house_ids) or find_in_set(' . $house_id . ', house_ids2)')
->where($params)
->where('level=2 or level=5')
->order($order_)
......
<?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
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatGroup extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_group';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatGroupMember extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_group_member';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
}
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatMsg extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg';
protected $db;
public function __construct()
{
$this->db = Db($this->table);
}
public function addChatMsg($params)
{
Db::startTrans();
try {
$this->save($params);
$id = $this->id;
Db::commit();
return $id;
} catch (\Exception $e) {
Db::rollback();
}
return 0;
}
/**
* @param $params
* @param $field
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
*/
public function getChatHistory($params, $field, $page_no, $page_size)
{
if (isset($params["from"])) {
$where_["a.from_id"] = $params["from"];
$where_or["a.to_id"] = $params["from"];
}
if (isset($params["target"])) {
$where_["a.to_id"] = $params["target"];
$where_or["a.from_id"] = $params["target"];
}
if (isset($params["is_group"])) {
$where_["a.is_group"] = $params["is_group"];
}
if (isset($params["body"])) {
$where_["b.body"] = array( 'like', "%" . trim($params["body"]) . "%" );
}
$where_["a.is_del"] = 0;
$data = $this->field($field)
->alias("a")
->join('chat_msg_ext b', 'a.id = b.msg_id', 'LEFT')
->where($where_)
->whereOr(function ($query) use ($where_or) {
$query->where($where_or);
})
->order("a.created_at desc")
->limit($page_size)
->page($page_no)
->select();
return $data;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatMsgExt extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg_ext';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgExt($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
dump($e);
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/26
* Time : 16:08
* Intro:
*/
use think\Model;
use think\Db;
class ChatMsgStatus extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_msg_status';
protected $db;
public function __construct()
{
$this->db = Db::name($this->table);
}
public function addChatMsgStatus($params)
{
Db::startTrans();
try {
$this->db->insert($params);
Db::commit();
} catch (\Exception $e) {
dump($e);
Db::rollback();
}
return 0;
}
}
\ No newline at end of file
<?php
namespace app\model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/2/6
* Time : 16:07
* Intro:
*/
use think\Model;
use think\Db;
class ChatRelation extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_relation';
protected $db_;
public function __construct()
{
$this->db_ = Db($this->table);
}
/**
* 获取关系是否存在
* @param $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
*/
public function getChatRelation($params, $field = "id,to_id,from_id")
{
$where_ = $whereOr_ = [];
if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
$whereOr_["from_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["to_id"] = $params["from"];
$whereOr_["from_id"] = $params["from"];
}
$where_["disable"] = 0;
$whereOr_["disable"] = 0;
return $this->field($field)
->where($where_)
->whereOr(function ($query) use ($whereOr_) {
$query->where($whereOr_);
})
->select();
}
public function addChatRelation($params)
{
$where_ = [];
if (isset($params["target"])) {
$where_["to_id"] = $params["target"];
}
if (isset($params["from"])) {
$where_["from_id"] = $params["from"];
}
$where_["create_time"] = date("Y-m-d H:i:s",time());
$where_["update_time"] = date("Y-m-d H:i:s",time());
Db::startTrans();
try {
$this->insert($where_);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/18
* Time : 15:33
* Intro:
*/
namespace app\model;
use think\Model;
use think\Db;
class ChatUser extends Model
{
// 设置当前模型对应的完整数据表名称
protected $table = 'chat_user';
protected $db;
public function __construct()
{
$this->db = Db($this->table);
}
public function getChatUser($params, $field = "only_id,phone")
{
$data = $this->db->field($field)
->where($params)
->select();
return $data;
}
public function addChatUser($params)
{
Db::startTrans();
try {
$this->save($params);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
}
}
\ 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();
}
}
......@@ -31,4 +31,12 @@ class HouseImgs extends Model
->limit($limit_)
->select();
}
function getHouseImgs($id,$imgtype)
{
$HouseImgsre = $this->db ->where(['house_id'=>$id,'imgtype'=>$imgtype])
->field('id,imagename')
->select();
return $HouseImgsre;
}
}
......@@ -102,5 +102,15 @@ class HouseInfos extends Model
->select();
}
function getHousepusmessage($id)
{
$HouseInfosre = $this->dbHouseInfo ->where('id', $id)
->field('id,title,room_area,room_area2,price,rent_type')
->select();
return $HouseInfosre;
}
}
<?php
namespace app\model;
use think\Model;
class HouseinfoExts extends Model
{
protected $table = 'houseinfo_exts';
protected $HouseinfoExts;
function __construct()
{
$this->HouseinfoExts = Db($this->table);
}
function getHouse_ext($id)
{
$HouseinfoExtsInfosre = $this->HouseinfoExts
->where('house_id', $id)
//->field('id,house_id,foreign_name,address_detail_c,province_c,province_code,city_c,city_code,district_c,district_code,foreign_advantage,created,modified')
->select();
return $HouseinfoExtsInfosre;
}
}
......@@ -32,8 +32,14 @@ class Users extends Model
}
return $data;
}
/**
public function getUserByWhere($param, $fields = 'id,user_phone')
{
$data = $this
->field($fields)
->where($param)
->select();
return $data;
} /**
* 查询用户和经纪人
*
* @param int $pageNo
......
......@@ -138,8 +138,23 @@ Route::group('api', [
]);
Route::group('task',[
'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]] //独家过期时间
Route::group('chat', [
'index' => [ 'chat/AppChat/index', [ 'method' => 'get' ] ],
'userChat' => [ 'chat/AppChat/userChat', [ 'method' => 'post|get' ] ],
'pushMsg' => [ 'chat/AppChat/pushMsg', [ 'method' => 'post|get' ] ],
'getChatHistory' => [ 'chat/AppChat/getChatHistory', [ 'method' => 'post|get' ] ],
'getUserOrAgentInfo' => [ 'chat/AppChat/getUserOrAgentInfo', [ 'method' => 'post|get' ] ],
'uploadImg' => [ 'chat/AppChat/uploadImg', [ 'method' => 'post|get' ] ],
'createGroupByOnlyId' => [ 'chat/Group/createGroupByOnlyId', [ 'method' => 'post|get' ] ],
'delGroup' => [ 'chat/Group/delGroup', [ 'method' => 'post|get' ] ],
'getGroupUser' => [ 'chat/Group/getGroupUser', [ 'method' => 'post|get' ] ],
'addGroupUserByIds' => [ 'chat/Group/addGroupUserByIds', [ 'method' => 'post|get' ] ],
'delGroupUserByIds' => [ 'chat/Group/delGroupUserByIds', [ 'method' => 'post|get' ] ],
'addGroupManage' => [ 'chat/Group/addGroupManage', [ 'method' => 'post|get' ] ],
'delGroupManage' => [ 'chat/Group/delGroupManage', [ 'method' => 'post|get' ] ],
'pushMsg_gethouseinfo' => [ 'chat/AppChat/pushMsg_gethouseinfo', [ 'method' => 'post|get' ] ],
]);
//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
Route::group('task',[
'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]] //独家过期时间
]);//Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
......@@ -22,11 +22,10 @@ return [
'view' => ['index/index'],
],*/
// 其他更多的模块定义
'app' => [
'chat' => [
'__file__' => ['common.php'],
'__dir__' => ['behavior', 'controller', 'model', 'view'],
'controller' => ['Index', 'Test', 'UserType'],
'model' => ['User', 'UserType'],
'view' => ['index/index'],
'__dir__' => ['behavior', 'controller', 'service', 'utils'],
'controller' => ['Index'],
'service' => ['IndexService'],
],
];
......@@ -128,3 +128,211 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625080</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4796</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F413CF2011A6A1505C3B9F4FDD6A2258
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625090</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8999</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F41DBC75A64B489C3754C87B65A2E09E
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18205625070</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7889</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=905D65B26C5DEF1EC630B0F5AA17A509
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625060</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3182</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=76D08F08B4D1BAD08457BC638BBDB484
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18805625020</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>2071</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7058E44B5B45924D7B11C38F5D534306
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756252570</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>9183</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1A0FD455A35089B0EB5E6723190A15FB
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756258888</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7572</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1566AAB75F25B6DD28A4902FA26AEC0F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756259999</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3479</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=DE9865EE495BD9B0D85EDAF249CDA24F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756257777</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7094</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7977CEC21F534DD1E5D675D792595DC9
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15038133185</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>1323</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=A83C2D00731E2A9F65F7CAC298B44B09
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756256666</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3450</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=40EE1C43A1B08B698B610DC95026AF74
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756255555</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>5919</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=8DABD7C3A3D79365F4AA65E92613F6A1
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15032323232</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4355</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=157B3CA0CF0C1D232FE6D6758A6F9E77
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756254444</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8064</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=EA2BC31B5B5662AD292223DC686FA26D
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756253333</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7687</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=00F01FFDBFD51AA503BB5585E4D2DC21
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>13112341234</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8858</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=873B52C43862749A39926C652B5834DC
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
<?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
<?php
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 15:56
* 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
define (['doT', 'text!temp/business_district_template_tpl.html', 'css!style/home.css','pagination','bootstrapJs'], function (doT, template) {
business = {
pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/
id : '',
init: function () {
//初始化dot
$ ("body").append (template);
business.getList ();
business.event ();
},
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();
});
$("#add_business").click(function () {
var params = {};
params.province = $("#province").find("option:selected").text();
params.city = $("#city").find("option:selected").text();
params.disc = $("#disc").find("option:selected").text();
params.province_code = $("#province").val();
params.city_code = $("#city").val();
params.disc_code = $("#disc").val();
params.business = $("#business").val();
params.id = business.id;
$.ajax({
url : '/index/editBusinessDistrict.html',
type : 'POST',
async: true,
data : params,
dataType : 'json',
success : function (data) {
if (data.code == 200 ) {
if (business.id) {
alert('编辑成功');
} else {
alert('添加成功');
}
business.getList(1);
$("#modal_business").modal ('hide');
} else {
alert('添加失败');
}
}
});
});
$ (document).delegate (".edit_modal", "click", function () {
$("#title").html('编辑商圈');
business.id = $ (this).attr ("data-id");
$.ajax({
url : '/index/editBusinessDistrict.html',
type : 'GET',
async: true,
data: {"id":business.id},
dataType: 'json',
success : function (data) {
if (data.code == 200) {
$("#business").val(data.data.name);
business.getRegionsProvince(data.data.province_code,data.data.city_code,data.data.disc_code);
} else {
alert(data.msg);
}
}
});
});
$ (document).delegate (".del_modal", "click", function () {
business.id = $ (this).attr ("data-id");
});
$ (document).delegate ("#confirm_delete", "click", function () {
business.delBusiness();
});
$ (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('不显示');
}
$.ajax ({
url: '/index/editBusinessDistrict.html',
type: 'POST',
async: true,
data: params,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
business.getList (1);
} else {
alert('修改显示失败');
}
}
});
});
},
getList: function (pageNo) {
business.pageNo = pageNo;
var params = {};
params.pageNo = business.pageNo;
params.pageSize = business.pageSize;
params.name = $("#name").val();
$.ajax ({
url: '/index/BusinessList.html',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
var temp = document.getElementById ('business_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);
}
});
}
});
},
getRegionsProvince : function (code_province, code_city, code_disc) {
$.ajax ({
url: '/index/regions.html',
type: 'GET',
async: true,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var _html = '';
$.each(data.data, function (i,n) {
if (n.code == code_province) {
_html += '<option selected="selected" value="'+n.code+'">'+n.name+'</option>';
} else {
_html += '<option value="'+n.code+'">'+n.name+'</option>';
}
});
$("#province").html(_html);
business.getRegionsCity(code_city,code_disc);
} else {
alert('请求省市区错误');
}
}
});
},
getRegionsCity : function (code_city, code_disc) {
var params = {};
params.parent_code = $("#province").val();
if (params.parent_code == '请选择') {
params.parent_code = 310000;
}
$.ajax ({
url: '/index/regions.html',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var _html = '';
$.each(data.data, function (i,n) {
if (n.code == code_city) {
_html += '<option selected="selected" value="'+n.code+'">'+n.name+'</option>';
} else {
_html += '<option value="'+n.code+'">'+n.name+'</option>';
}
});
$("#city").html(_html);
business.getRegionsDisc(code_disc);
} else {
alert('请求省市区错误');
}
}
});
},
getRegionsDisc : function (code) {
var params = {};
params.parent_code = $("#city").val();
if (params.parent_code == '请选择') {
params.parent_code = 310100;
}
$.ajax ({
url: '/index/regions.html',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function (data) {
if (data.code == 200) {
var _html = '';
$.each(data.data, function (i,n) {
if (n.code == code) {
_html += '<option selected="selected" value="'+n.code+'">'+n.name+'</option>';
} else {
_html += '<option value="'+n.code+'">'+n.name+'</option>';
}
});
$("#disc").html(_html);
} else {
alert('请求省市区错误');
}
}
});
},
delBusiness : function () {
$.ajax({
url : '/index/delBusinessDistrict.html',
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
define (['css!style/home.css','ckfinder','ckfinderStart', 'bootstrapJs'], function () {
var user = {
init: function () {
//初始化dot
user.event ();
},
event: function () {
var _doc = $(document),
_shangpuTypeObj = $('#shangpuType'),//商铺类型
_showCdObj = $('#showCd'),//显示给C端用户看
_exclusiveTypeObj = $('#exclusiveType'),//是否独家
_exclusiveDate1Obj = $('#exclusiveDate1'),//独家代理有效期开始时间
_exclusiveDate2Obj = $('#exclusiveDate2'),//独家代理有效期结束时间
_exclusiveTelObj = $('#exclusiveTel'),//独家方电话
_internalNameObj = $('#internalName'),//对内商铺名称
_foreignNameObj = $('#foreignName'),//对外商铺名称
_zujinTypeObj = $('#zujinType'),//租金模式
_moonPriceObj = $('#moonPrice'),//月租均价
_wuyePriceObj = $('#wuyePrice'),//物业管理费
_jinchangPriceObj = $('#jinchangPrice'),//进场费
_roomShengyuNumObj = $('#roomShengyuNum'),//剩余铺数
_roomAllNumObj = $('#roomAllNum'),//总铺数
_roomArea1Obj = $('#roomArea1'),//商铺面积起始值
_roomArea2Obj = $('#roomArea2'),//商铺面积结束值
_businessAreaObj = $('#businessArea'),//商业面积
_yetaiObj = $('.yetai'),//业态
_provinceInternalObj = $('#province_internal'),//对内地址省
_cityInternalObj = $('#city_internal'),//对内地址市
_discInternalObj = $('#disc_internal'),//对内地址区
_addressInternalObj = $('#address_internal'),//对内地址详细地址
_longitudeObj = $('#longitude'),//经度
_latitudeObj = $('#latitude'),//纬度
_provinceExternalObj = $('#province_external'),//对外地址省
_cityExternalObj = $('#city_external'),//对外地址市
_discExternalObj = $('#disc_external'),//对外地址区
_addressExternalObj = $('#address_external'),//对外地址详细地址
_trafficObj = $('#traffic'),//交通
_hasMovedObj = $('#hasMoved'),//已入住
_yingyeTimeObj = $('#yingyeTime'),//营业时间
_kaipanTimeObj = $('#kaipanTime'),//开盘时间
_kaiyeTimeObj = $('#kaiyeTime'),//开业时间
_hasGasObj = $('#hasGas'),//是否有燃气
_weilouLinkObj = $('#weilouLink'),//微楼书
_dajiangtangObj = $('#dajiangtang'),//大讲堂
_yongjinRuleObj = $('#yongjinRule'),//佣金规则
_internalYoushiObj = $('#internalYoushi'),//对内项目优势
_foreignYoushiObj = $('#foreignYoushi'),//对外项目优势
_qianyueRuleObj = $('#qianyueRule'),//签约规则
_roomTagObj = $('.roomTag');//商铺标签
$ ('#liebiao_pic_btn').click (function () {
BrowseServer ('liebiao_pic_pre');
});
/************************************************百度地址定位相关*************************************************************/
//字符串格式化,参数为对象的形式 by xishifeng 2017-07-14
String.prototype.stringFormatObj = function(){
var formatted = this;
for(var i in arguments[0]){
formatted = formatted.replace(new RegExp('\\{'+ i + '\\}','gi'), arguments[0][i]);
};
return formatted;
};
//从baidu-position.js移过来
var ulHtml = $('#main_ul>ul'),
loadItem = $("#loading_pic"),
noMoreItem = $("#no_more"),
cityLimitItem = $('#address_city_title'),
_cityInputObj = $('#city_internal'),
_inputObj = $('#search_input'),
valueCurrent = '';
//初始化,百度地图相关对象
var LocalSearch = new BMap.LocalSearch(),
myGeo = new BMap.Geocoder();
$('#position_btn').click(function(){
$.each(_cityInputObj.find('option'), function(i,item) {
var _item = $(item);
if(_item.val() == _cityInputObj.val()){
cityLimitItem.html(_item.html());
return false;//jq跳出当前循环
};
});
});
//搜索地址的回调
LocalSearch.setSearchCompleteCallback(function(data) {
if(LocalSearch.getStatus() == BMAP_STATUS_SUCCESS) {
console.log(data);
var _html = "";
for (var i = 0; i < data.getCurrentNumPois(); i ++){
_html += '<li data-city="{2}" data-lat="{3}" data-lng="{4}" data-dismiss="modal"><p>{0}</p><p>{1}</p></li>'.stringFormatObj({
'0': data.getPoi(i)["title"],
'1': data.getPoi(i)["address"],
'2': data.getPoi(i)["city"],
'3': data.getPoi(i)["point"]["lat"],
'4': data.getPoi(i)["point"]["lng"]
});
};
ulHtml.html(_html);
loadItem.hide();
noMoreItem.show();
}
});
_inputObj.on('input', function(e) {
e.preventDefault();
e.stopPropagation();
valueCurrent = $(this).val();
if(valueCurrent != '') {
addressResetLoad();
addressLoadMain(valueCurrent);
} else {
ulHtml.html('');
loadItem.hide();
noMoreItem.show();
return false;
}
});
//key搜索
_doc.keydown(function(event) {
if(event.keyCode == '13') {
addressResetLoad();
addressLoadMain(valueCurrent);
return false;
};
});
//输入框的取消图标点击事件
$('.cancel-pic').click(function(e) {
e.preventDefault();
e.stopPropagation();
_inputObj.val('').focus();
addressResetLoad();
});
_doc.on('click', '#main_ul>ul>li', function(e) {
e.preventDefault();
e.stopPropagation();
var _this = $(this);
$('#longitude').val(Number(_this.data('lng')));
$('#latitude').val(Number(_this.data('lat')));
});
function addressResetLoad() {
ulHtml.html('');
loadItem.hide();
noMoreItem.show();
};
function addressLoadMain(keyword) {
loadItem.show();
noMoreItem.hide();
LocalSearch.setLocation(cityLimitItem.html());
LocalSearch.search(keyword);
};
/************************************************百度地址定位相关****结束*************************************************************/
/************省市区选择处理**************/
//自动获取省列表,并追加后面的市和区
getCityDisc({
'getType': 'province'
},function(_data){
var _htmlTemp = '';
$.each(_data, function(i, item) {
_htmlTemp += '<option value="{0}">{1}</option>'.stringFormatObj({
'0': item['code'],
'1': item['name']
});
});
_provinceInternalObj.html(_htmlTemp).val('310000');
getCityDisc({
'dom': _provinceInternalObj,
'getType': 'city'
}, function(){
getCityDisc({
'dom': _provinceInternalObj.next(),
'getType': 'disc'
});
});
});
//获取省市区输入时的真实值和所见值的对应
function getText(_domObj, fn){
var _arrTemp = _domObj.find('option');
if(_arrTemp.length > 0){
$.each(_arrTemp, function(i, item) {
var _item = $(item);
if(_item.val() == _domObj.val()){
fn(_item.html());
return false;//jq跳出当前循环
};
});
}else{
fn('');
};
};
function mapInput(){
getText(_provinceInternalObj, function(_text){
_provinceExternalObj.val(_text);
});
getText(_cityInternalObj, function(_text){
_cityExternalObj.val(_text);
});
getText(_discInternalObj, function(_text){
_discExternalObj.val(_text);
});
return false;
};
//获取省市区事件封装
function getCityDisc(_obj, fn){
var _data = {};
if(_obj['getType'] != 'province'){
if(!!_obj['dom'].val()){
_data['parent_code'] = Number(_obj['dom'].val())
}else{
//处理没有市选项,区选项的内容
_obj['dom'].next().html('');
fn && fn();
return false;
};
};
$.ajax({
type: 'GET',
url: '/index/regions.html',
timeout: 30000,
data: _data,
dataType: 'json',
beforeSend: function() {},
success: function(data) {
if(typeof data === 'object') {
if (data.code == 200) {
//如果是获取的省列表,直接直接返回数组
if(_obj['getType'] == 'province'){
fn(data['data']);
return false;
};
var _htmlTemp = '';
$.each(data['data'], function(i, item) {
_htmlTemp += '<option value="{0}">{1}</option>'.stringFormatObj({
'0': item['code'],
'1': item['name']
});
});
_obj['dom'].next().html(_htmlTemp);
_obj['getType'] == 'disc' && mapInput();
fn && fn();
}else {
alert(data['msg']);
};
}else{
alert('数据错误');
};
},
error: function() {
alert('error');
},
complete: function(xhr, textStatus){
if(textStatus === 'timeout'){
alert('请求超时');
};
}
});
};
//省选择框事件添加
_provinceInternalObj.change(function(){
var _this = $(this);
getCityDisc({
'dom': _this,
'getType': 'city'
}, function(){
getCityDisc({
'dom': _this.next(),
'getType': 'disc'
});
});
});
//市选择框事件添加
_cityInternalObj.change(function(){
var _this = $(this);
getCityDisc({
'dom': _this,
'getType': 'disc'
});
});
_discInternalObj.change(function(){
mapInput();
});
/***************************************************省市区选择处理结束************************************************************/
$('.input-add-tel').click(function(){
var _this = $(this);
if(_this.parent().find('.phone_jia').length < 5){
_this.before('<div class="form-group phone-list-container"><input type="tel" class="form-control phone_jia" placeholder="请输入"><ul></ul><img src="/resource/image/search_gb.png" class="input-cancel-pic" /></div>');
}else{
alert('最多添加5个');
};
});
_doc.on('click', '.input-cancel-pic', function(){
$(this).parent().remove();
});
_doc.on('click', '.phone-list-container>ul>li', function(){
var _this = $(this);
_this.parent().prev().val(_this.html());
_this.parent().html('');
});
var _ajaxObjTel = null;
_doc.on('input', '.phone_jia' ,function(){
var _this = $(this);
var _thisVal = $.trim(_this.val());
console.log(_thisVal);
if(_thisVal != ''){
_ajaxObjTel && _ajaxObjTel.abort();
_ajaxObjTel = $.ajax({
type: 'GET',
url: '/index/getBroker_new',
data: {
'phone': $.trim(_this.val())
},
timeout: 30000,
dataType: 'json',
beforeSend: function() {},
success: function(data) {
if(typeof data === 'object') {
if (data.code == 200) {
if(data['data'].length > 0){
var _htmlTemp = '';
$.each(data['data'], function(i, item) {
_htmlTemp += '<li>{2}{0}-{1}<li>'.stringFormatObj({
'0': item['name'],
'1': item['phone'],
'2': _this.parent().nextAll('.input-add-tel').data('hideid')?'':(item['id']+'-')
});
});
_this.next().html(_htmlTemp);
}else{
_this.next().html('');
};
}else {
alert(data['msg']);
};
}else{
alert('数据错误');
};
},
error: function() {
//alert('error');
},
complete: function(xhr, textStatus){
if(textStatus === 'timeout'){
alert('请求超时');
};
}
});
};
});
/***************************************************电话号码输入相关交互处理***************************************************/
_exclusiveTypeObj.change(function(){
if($(this).val() == '1'){
$('#li_dujia_area').slideDown();
}else{
$('#li_dujia_area').slideUp();
}
});
$('#saveBtn').click(function(e){
e.preventDefault();
e.stopPropagation();
console.log('save');
// var _data = {
// 'internal_title': $.trim($('#internal_name').val())
// };
var _data = {
'shop_type': 0,
'is_show': 0,
'phone': ['张三-18812345678','李四-18812345678'],
'agent_dish': ['1-张三-18812345678','2-李四-18812345678'],
'agent_data': ['1-张三-18812345678','2-李四-18812345678'],
'internal_title': '对内名称',
'external_title': '对外名称',
'rent_type': 1,
'rent_price': 500,
'slotting_fee': 499,
'residue_num': 0,
'total': 5,
'shop_area_start': 20,
'shop_area_end': 30,
'market_area': 100,
'industry_type': '',
'province': '上海',
'city': '上海',
'disc': '黄浦',
'external_address': '某某街道对内',
'longitude': 121.312255,
'latitude': 30.737202,
'external_address': '某某街对外',
'traffic': '交通内容',
'enter_num': '已入住内容',
'do_business_date': '营业时间文本',
'start_business_date': '2017-10-12',
'is_has_gas': 0,
'tiny_brochure_url': 'http://www.dd',
'auditorium': '<p>大讲堂内容</p>',
'fee_rule': '佣金规则',
'internal_item_advantage': '项目优势对内',
'external_item_advantage': '项目优势对外',
'singn_rule': '签约规则'
};
$.ajax({
type: 'POST',
url: '/index/houseEdit',
data: _data,
timeout: 30000,
traditional: true,
dataType: 'json',
beforeSend: function() {},
success: function(data) {
if(typeof data === 'object') {
if (data.code == 200) {
}else {
alert(data['msg']);
};
}else{
alert('数据错误');
};
},
error: function() {
alert('error');
},
complete: function(xhr, textStatus){
if(textStatus === 'timeout'){
alert('请求超时');
};
}
});
});
}
};
return user;
});
\ No newline at end of file
/**
* 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