market_906

This commit is contained in:
dengbw
2022-09-06 09:18:16 +08:00
committed by lccsw
parent 828a6a8f29
commit 97fd9e8d50
135 changed files with 16579 additions and 4 deletions
+104
View File
@@ -0,0 +1,104 @@
<?php
/**
* Notes:私域通
* Created on: 2020/11/30 17:00
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
require_once(COMMPATH . "/third_party/WeChat/WechatServer.php");
class Syt extends CI_Controller
{
private $log_file = 'plan_syt.log';
private $options;
public function __construct()
{
parent::__construct();
$this-> options = [
'token' => '',
'appid' => 'wxe66f905683582780',
'appsecret' => '9546cd4de877be13ce203f3e6140633f',
'encodingaeskey' => '',
'debug' => false
];
}
/**
* Notes:发送一次性订阅
* Created on: 2020/11/30 17:02
* Created by: dengbw
* https://hd-api-dev.xiaoyu.com/plan/syt/subscribemsg
* https://api.test.haodian.cn/plan/syt/subscribemsg
* https://api.haodian.cn/plan/syt/subscribemsg
*/
public function subscribemsg()
{
$this->load->model('market/market_sylive_subscribemsg_model','mdSytSubscribemsg');
$date = date('Y-m-d H:i:s', strtotime('+2 minute'));//提前2分钟发送
$where['s_time<='] = $date;
$where['status'] = 0;
$res = $this->mdSytSubscribemsg->select($where, 'id asc', 1, 200);
$log = array();
if ($res) {
$this->load->model('market/market_sylive_activity_model','mdSytActivity');
$wechatS = new WechatServer($this->options);
$wechatS->checkAuth();
foreach ($res as $key => $value) {
$re_a = $this->mdSytActivity->get(array("activityId" => $value['a_id'], "status" => 0));
if ($re_a) {
$content = '您预约“' . $re_a['title'] . '”直播已经开始啦!赶紧进入直播间观看直播领取福利吧~';
$temp_arr = array(
'touser' => $value['openid'],
'template_id' => $value['template_id'],
'url' => $value['url'],
'scene' => $value['scene'],
'title' => '开播提醒',
'data' => array(
'content' => array('value' => $content)
)
);
$re = $wechatS->subscribeTemplateMessage($temp_arr);
if ($re) {//errcode 0(发送成功) 43101(已发送过)
$this->mdSytSubscribemsg->update(['status' => 1], ['id' => $value['id']]);
if ($re['errcode'] == 0) {
$log[] = $value['a_id'] . '=' . $value['openid'];
}
}
}
}
}
echo '<br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
echo '<br><br>成功发送:';
$log && print_r($log);
$total = count($res);
$do = count($log);
debug_log("[info] " . __FUNCTION__ . "# date:{$date}; total:{$total}; do:{$do};", $this->log_file);
}
public function test(){
require_once(COMMPATH . "/third_party/WeChat/WechatServer.php");
$options = [
'token' => '',
'appid' => 'wxe66f905683582780',
'appsecret' => '9546cd4de877be13ce203f3e6140633f',
'encodingaeskey' => '',
'debug' => false
];
$wechatS = new WechatServer($options);
$token = $wechatS->checkAuth();
$content = '您预约直播已经开始啦!赶紧进入直播间观看直播领取福利吧~';
$temp_arr = array(
'touser' => 'ospBg6AXMlXNdgv_rzbFvBXAD4TU',
'template_id' => '4eHuGYK69_GTjOlzkp8HK8iJNFuKboTpO7Igc1CC_fQ',
'url' => 'https://liche-dev.xiaoyu.com/h5/market/sylive/act?skey=aWQ9MQ',
'scene' => 0,
'title' => '开播提醒',
'data' => array(
'content' => array('value' => $content)
)
);
$re = $wechatS->subscribeTemplateMessage($temp_arr);
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
/**
* 配置账号信息
*/
define('LICHE_APICLIENT_CERT',dirname(__FILE__).'/liche_cert/apiclient_cert.pem');
define('LICHE_APICLIENT_KEY',dirname(__FILE__).'/liche_cert/apiclient_key.pem');
class WxPayConfig
{
const APPID = 'wxe66f905683582780';
const APPSECRET = '9546cd4de877be13ce203f3e6140633f';
const MCHID = '1612289137';
const KEY = 'd1ddc03f6178767795dc283e68a80e81';
const SIGN_TYPE = 'MD5';
const NOTIFY_URL = '';
//=======【证书路径设置】=====================================
const SSLCERT_PATH = LICHE_APICLIENT_CERT;
const SSLKEY_PATH = LICHE_APICLIENT_KEY;
//=======【curl代理设置】===================================
const CURL_PROXY_HOST = "0.0.0.0";//"10.152.18.220";
const CURL_PROXY_PORT = 0;//8080;
//=======【上报信息配置】===================================
const REPORT_LEVENL = 1;
}
+1 -1
View File
@@ -2,7 +2,7 @@
"require": {
"gregwar/image": "^2.1",
"tencentcloud/ocr": "^3.0",
"wechatpay/wechatpay-guzzle-middleware": "^0.2.2",
"wechatpay/wechatpay-guzzle-middleware": "^0.2.2",
"mikehaertl/php-pdftk": "^0.11.0",
"lcobucci/jwt": "^3.4"
}
+2 -2
View File
@@ -1161,12 +1161,12 @@ if (!function_exists('is_product')) {
if (!function_exists('is_img')) {
function is_img($file_name)
{
$file_name_arr = explode('.',$file_name);
$file_name_arr = explode('.', $file_name);
$ext = end($file_name_arr);
$filetype = ['jpg', 'jpeg', 'gif', 'bmp', 'png'];
if (in_array($ext, $filetype)) {
return true;
}else{
} else {
return false;
}
}
+162
View File
@@ -0,0 +1,162 @@
<?php
/**
* 私域直播
*/
class Sylive_entity{
private $ci;
private $map_kpi_biz = [
'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch'
];
public function __construct(){
$this->ci = &get_instance();
$this->ci->load->model('market/market_sylive_user_model', 'user_model');
$this->ci->load->model('market/market_sylive_activity_model');
$this->ci->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz');
$this->ci->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$this->ci->load->model('market/market_sylive_organization_model');
}
/**
* @param $organizationId 机构id
* @param $level 0品牌-管理大区 1 督导-权限范围内所有门店 2 店长-门店所有权限 3 顾问-个人权限 4普通用户-没有权限
* @return int|mixed
*/
public function get_level($organizationId,$level=0){
if(!$organizationId){
return 4;
}
$row = $this->ci->market_sylive_organization_model->get(['organizationId'=>$organizationId],'organizationId,parentId');
if(!$row){
return 4;
}
if($row['parentId']){
$temp = $level+1;
return $this->get_level($row['parentId'],$temp);
}
return $level;
}
/**
* 获取等级数据
* @param $organizationId
* @param $data
* @return int
*/
public function get_level_lists($organizationId,$data=[]){
$this->ci->load->model('market/market_sylive_organization_model');
$row = $this->ci->market_sylive_organization_model->get(['organizationId'=>$organizationId],'organizationId,parentId,organizationName');
if(!$row){
return $data;
}else{
array_unshift($data,$row);
if($row['parentId']){
return $this->get_level_lists($row['parentId'],$data);
}else{
return $data;
}
}
}
/**
* Notes:添加kpi记录
* Created on: 2021/1/13 11:20
* Created by: dengbw
* @param $params
* @return array
*/
public function kpi_log($params)
{
if ($params['a_id'] && $params['uid'] && $params['cf_uid']) {
$user = $this->user_model->get(['userId'=>$params['cf_uid']]);
if(!$user){
return array('code' => 0, 'msg' => '顾问不存在');
}
$re_a = $this->ci->market_sylive_activity_model->get(array("activityId" => $params['a_id'], "status" => 0));
$now_time = time();
if(!in_array($params['kpi'],['subscribe','browse'])){ //无需活动开始
if ((!$re_a || $now_time < strtotime($re_a['timeStart']) || $now_time > strtotime($re_a['timeEnd']))) {
return array('code' => 0, 'msg' => '无活动或未在活动时间内');
}
}
$re_kpi = $this->ci->mdSytActivityKpiData->get(array("a_id" => $params['a_id'], 'uid' => $params['uid'], 'kpi' => $params['kpi']));
if ($re_kpi) {//已添加过活动kpi(访活动只记录一次用户kpi记录)
return array('code' => 0, 'msg' => '已添加过' . $params['kpi'] . '记录');
}
$level_lists = $this->get_level_lists($user['organizationId']);
if($level_lists){
//获取大区id
$area_id = $level_lists[1]['organizationId'];
//获取店铺id
$biz_id = $level_lists[2]['organizationId'];
}
//增加记录
$addData = [
'a_id' => $params['a_id'],
'uid' => $params['uid'],
'cf_uid' => $params['cf_uid'],
'kpi' => $params['kpi'],
'c_time' => time()
];
$area_id && $addData['area_id'] = $area_id;
$biz_id && $addData['biz_id'] = $biz_id;
$jsondata = array();
$jsondata && $addData['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$id = $this->ci->mdSytActivityKpiData->add($addData);
if (!$id) {
return array('code' => 0, 'msg' => '添加记录失败');
}
if($this->map_kpi_biz[$params['kpi']] && $biz_id){//更新门店统计数据
$up_key = $this->map_kpi_biz[$params['kpi']];
$update[$up_key] = $this->ci->mdSytActivityKpiData->count(['a_id'=>$params['a_id'],'biz_id'=>$biz_id,'kpi'=>$params['kpi']]);
$this->ci->mdSytActivityBiz->update($update,['activityId'=>$params['a_id'],'bizId'=>$biz_id]);
}
return array('code' => 1, 'msg' => '添加记录成功');
} else {
return array('code' => 0, 'msg' => '参数错误');
}
}
//排行数据
public function top_lists($aid,$type='browse',$page=1,$size=10,$biz_id=0){
$lists = [];
$where = [
'activityId' => $aid,
'status' => 0
];
$total = $this->ci->mdSytActivityBiz->count($where);
$field = $this->map_kpi_biz[$type];
if($total && $field){
$rows = $this->ci->mdSytActivityBiz->select($where,"{$field} desc",$page,$size);
$biz_ids = implode(',',array_column($rows,'bizId'));
$org_rows = [];
if($biz_ids){
$org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($biz_ids)"],'','','','organizationId,organizationName');
}
foreach ($rows as $key=>$val) {
$lists[] = [
'ranking' => $key+1,
'name' => $org_rows[$val['bizId']] ? $org_rows[$val['bizId']] : '',
'num' => $val[$this->map_kpi_biz[$type]].'人',
'tip' => $biz_id==$val['bizId'] ? '本店' : '',
];
}
}
$data = [
'total' => $total,
'lists' => $lists
];
return $data;
}
public function __get($name)
{
if ('_model' === substr($name, -6)) {
return $this->ci->$name;
} elseif ('load' == $name) {
return $this->ci->load;
}
return null;
}
}
@@ -0,0 +1,11 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Market_sylive_activity_biz_model extends HD_Model
{
private $table_name = 'lc_market_sylive_activity_biz';
public function __construct(){
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,12 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Market_sylive_activity_kpidata_model extends HD_Model
{
private $table_name = 'lc_market_sylive_activity_kpidata';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,18 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:私域直播_活动表
* Created on: 2022/09/22 14:52
* Created by: dengbw
*/
class Market_sylive_activity_model extends HD_Model
{
private $table_name = 'lc_market_sylive_activity';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,11 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Market_sylive_activity_user_model extends HD_Model
{
private $table_name = 'lc_market_sylive_activity_user';
public function __construct(){
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,35 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:私域直播_订单表
* Created on: 2022/09/26 14:52
* Created by: dengbw
*/
class Market_sylive_order_model extends HD_Model
{
private $table_name = 'lc_market_sylive_order';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:支付状态
* Created on: 2022/9/26 14:46
* Created by: dengbw
* @param string $status
* @return array|mixed
*/
public function statusAry($status = '')
{
$arr = [0 => '未支付', 1 => '已支付'];
if (strlen($status)) {
return $arr[$status];
} else {
return $arr;
}
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:私域直播_机构表
* Created on: 2022/09/16 14:52
* Created by: dengbw
*/
class Market_sylive_organization_model extends HD_Model
{
private $table_name = 'lc_market_sylive_organization';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,12 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Market_sylive_subscribemsg_model extends HD_Model
{
private $table_name = 'lc_market_sylive_subscribemsg';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:私域直播_用户表
* Created on: 2022/09/16 14:52
* Created by: dengbw
*/
class Market_sylive_user_model extends HD_Model
{
private $table_name = 'lc_market_sylive_user';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:用户角色
* Created on: 2022/9/20 11:04
* Created by: dengbw
* @param string $roleId
* @return array|mixed
*/
public function roleAry($roleId = '')
{
$arr = [1 => '品牌', 2 => '区域', 3 => '店长', 4 => '顾问'];
if (strlen($roleId)) {
return $arr[$roleId];
} else {
return $arr;
}
}
/**
* Notes:性别
* Created on: 2022/9/21 14:34
* Created by: dengbw
* @param string $sex
* @return array|mixed
*/
public function sexAry($sex = '')
{
$arr = [0 => '未知', 1 => '男', 2 => '女'];
if (strlen($sex)) {
return $arr[$sex];
} else {
return $arr;
}
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:管理员表
* Created on: 2022/08/31 14:52
* Created by: dengbw
*/
class Market_sys_admin_model extends HD_Model
{
private $table_name = 'lc_market_sys_admin';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:字典项表
* Created on: 2022/09/19 14:52
* Created by: dengbw
*/
class Market_sys_dictionary_data_model extends HD_Model
{
private $table_name = 'lc_market_sys_dictionary_data';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:字典表
* Created on: 2022/09/19 14:52
* Created by: dengbw
*/
class Market_sys_dictionary_model extends HD_Model
{
private $table_name = 'lc_market_sys_dictionary';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:登录日志表
* Created on: 2022/09/14 14:52
* Created by: dengbw
*/
class Market_sys_login_record_model extends HD_Model
{
private $table_name = 'lc_market_sys_login_record';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:菜单表
* Created on: 2022/09/09 14:52
* Created by: dengbw
*/
class Market_sys_menu_model extends HD_Model
{
private $table_name = 'lc_market_sys_menu';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:操作日志表
* Created on: 2022/09/15 14:52
* Created by: dengbw
*/
class Market_sys_operation_record_model extends HD_Model
{
private $table_name = 'lc_market_sys_operation_record';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
@@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Notes:角色表
* Created on: 2022/09/08 14:52
* Created by: dengbw
*/
class Market_sys_role_model extends HD_Model
{
private $table_name = 'lc_market_sys_role';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+3 -1
View File
@@ -9,4 +9,6 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//狸车-服务号
$config['liche']['appid'] = 'wxe66f905683582780';
$config['liche']['appSecret'] = '9546cd4de877be13ce203f3e6140633f';
$config['liche']['appSecret'] = '9546cd4de877be13ce203f3e6140633f';
$config['liche']['token'] = 'iuvkjhz457854';
$config['liche']['appsecret'] = 'Ay2qHzlKEpPxdMzUSy5bjJcyL5lZxotOf7JThlDKQdQ';
+336
View File
@@ -0,0 +1,336 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Common.php';
class Act extends Wx {
private $group_id;
public function __construct(){
parent::__construct();
$this->load->model('market/market_sylive_organization_model');
$this->load->model('market/market_sylive_activity_model');
$this->load->model('market/market_sylive_subscribemsg_model','mdSytSubscribemsg');
$this->load->model('market/market_sylive_order_model');
$this->load->library('market/sylive_entity');
$this->group_id = $this->sylive_entity->get_level($this->session['org_id']);
}
public function index(){
$skey = $this->input->get('skey');
if (!$skey) {
throw new Hd_exception("参数错误", 400);
}
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
if (!$a_id) {
throw new Hd_exception("参数错误", 400);
}
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row){
throw new Hd_exception('参数错误',400);
}
$timeStart = strtotime($row['timeStart']);
$info['s_time'] = time() < $timeStart ? $timeStart-time() : 0;
$info['bg'] = $row['bgImg'] ? build_qiniu_image_url($row['bgImg']) : '';
$info['content'] = $row['introduction'];
$act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
//一次性订阅
$re_s = $this->mdSytSubscribemsg->get(array('a_id' => $a_id, 'uid' => $this->uid));
if ($re_s) {
$subscribemsg = '已订阅直播';
} else {
$this->load->config('wechat');
$config = $this->config->item('liche');
$sub_redirect_url = urlencode(http_host_com('home') . '/h5/market/sylive/act/subscribemsg?skey=' . $skey
. '&s_time=' . $row['timeStart']);
$subscribemsg = "https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid={$config['appid']}&scene=0&template_id=sdJ4eXXA3OdMZVkJdOrzusYLGr0Jpz9I7WiZurgGLBs&redirect_url={$sub_redirect_url}&reserved=test#wechat_redirect";
}
//浏览
$params = array('a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'browse');
$this->sylive_entity->kpi_log($params);
$live_status = 0;
if(time()>strtotime($row['timeStart']) && time()<=strtotime($row['timeEnd'])){ //直播期间人数
$this->sylive_entity->kpi_log(['a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'watch']);
$row['liveStatus']!=1 && $this->market_sylive_activity_model->update(['liveStatus'=>1],['activityId'=>$a_id]); //更新直播间状态
$live_status = 1;
}
if(time()>strtotime($row['timeEnd'])){ //直播结束
$row['liveStatus']!=2 && $this->market_sylive_activity_model->update(['liveStatus'=>2],['activityId'=>$a_id]); //更新直播间状态
$live_status = 2;
}
$share_skey = "a_id=" . $a_id . "&cf_uid=" . $this->uid . "&cf_share=" . $this->myencryption->random_string(6);
//微信分享
$share_url = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode($share_skey);
$this->load->library('Jssdk');
$jssdk = new Jssdk('liche');
$sign_package = $jssdk->getSignPackage();
$share = array(
'title' => $row['title'],
"img" => $row['bgImg'] ? build_qiniu_image_url($row['bgImg']) : '',
"desc" => '分享描述',
"url" => $share_url
);
//直播参数
$live_user = ['userId' => 888888888, 'userName' => '私域直播', 'pic' => '//livestatic.videocc.net/assets/wimages/missing_face.png'];
$this->load->library('PolyvApi');
$polyv = new PolyvApi();
$liveSdk = $polyv->getLiveSdk();
$liveSdk['user'] = $live_user;
$info['live_status'] = $live_status;
$info['liveSdk'] = $liveSdk;
$info['skey'] = $this->myencryption->base64url_encode($share_skey);
$info['a_id'] = $a_id;
$info['org_id'] = $this->session['org_id'];
$info['subscribemsg'] = $subscribemsg;
$info['shareurl'] = $info['code'] = '';
if($this->group_id==3||$this->group_id==2){
$info['shareurl'] = '/h5/market/sylive/act/share?skey='.$info['skey'];
}
$info['statisticsurl'] = '/h5/market/sylive/stic?skey='.$info['skey'];
$info['channelImg'] = build_qiniu_image_url($row['channelImg']);
$this->data['info'] = $info;
$this->data['sign_package'] = $sign_package;
$this->data['share'] = $share;
$this->show_view('h5/market/sylive/act/index');
}
//获取最新订阅用户
public function subscribemsg_lists(){
$a_id = $this->input->get('a_id');
$field = '';
$lists = [];
$where = [
'a_id' => $a_id
];
$rows = $this->mdSytSubscribemsg->select($where,'id desc',0,30,$field);
if($rows){
foreach ($rows as $item) {
$lists[] = [
'name' => substr($item['openid'], 0, 3) . "****" . substr($item['openid'], 7, 4),
'tip' => friendly_date($item['c_time']).'订阅了直播提醒',
];
}
}
$data['lists'] = $lists;
$this->show_json($data,200);
}
/**
* Notes:获取授权发送一次性订阅接口
* Created on: 2020/11/26 17:11
* Created by: dengbw
*/
public function subscribemsg()
{
$skey = $this->input->get('skey');
$s_time = $this->input->get('s_time');//直播时间
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$action = $this->input->get('action');
if ($s_time && $action == "confirm") {
$add_data['a_id'] = $a_id;
$add_data['openid'] = $this->input->get('openid');
$add_data['scene'] = $this->input->get('scene');
$re_s = $this->mdSytSubscribemsg->get($add_data);
if (!$re_s) {
$add_data['uid'] = $this->uid;
$add_data['template_id'] = $this->input->get('template_id');
$add_data['url'] = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode("a_id=" . $a_id);;
$add_data['s_time'] = $s_time;
$add_data['c_time'] = time();
$add_data['status'] = 0;
$id = $this->mdSytSubscribemsg->add($add_data);
if ($id) {
$act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
//订阅用户加统计
$params = array('a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'subscribe');
$this->sylive_entity->kpi_log($params);
}
}
}
$url = http_host_com('home') . "/h5/market/sylive/act?skey={$skey}";
redirect($url);
}
public function share(){
if($this->group_id!=2 && $this->group_id!=3){
throw new Hd_exception("页面不存在", 400);
}
$skey = $this->input->get('skey');
if (!$skey) {
throw new Hd_exception("参数错误", 400);
}
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row){
throw new Hd_exception('参数错误',400);
}
$shareImg = json_decode($row['shareImg'],true);
$shareTitle = $row['shareTitle'] ? json_decode($row['shareTitle'],true) : [];
$lists = [];
if($shareImg){
$share_skey = "a_id=" . $a_id . "&cf_uid=" . $this->uid . "&cf_share=" . $this->myencryption->random_string(6);
$share_url = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode($share_skey);
$qr_code = '/h5/market/sylive/myqrcode/get?url=' . $share_url;
foreach ($shareImg as $item) {
$lists[] = [
"img" => build_qiniu_image_url($item),
"code" => $qr_code,
'width' => 750,
'height' => 1130,
];
}
}
$user = $this->user_model->get(['userId'=>$this->uid]);
$this->data['posterTip'] = '狸车集美店李菲菲诚挚邀请您参与';
$this->data['lists'] = $lists;
$this->data['shareTitle'] = $shareTitle;
$this->show_view('h5/market/sylive/act/share');
}
public function item(){
$skey = $this->input->get('skey');
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row){
throw new Hd_exception('参数错误',400);
}
$jsondata = json_decode($row['jsondata'],true);
$item = $jsondata['item'] ? $jsondata['item'] : [];
$is_pay = $this->market_sylive_order_model->count(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]);
$e_time = time() < strtotime($row['timeEnd']) ? strtotime($row['timeEnd']) - time() : 0;
$banner = [];
if($item['itemImg']){
foreach ($item['itemImg'] as $value) {
$banner[] = build_qiniu_image_url($value);
}
}
$info = [
'title' => $item['title'] ? $item['title'] : '',
'e_time' => $e_time,
'price' => $item['price'] ? $item['price'] : '',
'content' => $item['introduction'] ? $item['introduction'] : '',
'banner' => $banner,
'skey' => $skey,
'is_pay' => $is_pay
];
$this->data['info'] = $info;
$this->show_view('h5/market/sylive/act/item');
}
//支付
public function post_pay(){
$skey = $this->input->post('skey');
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row){
$this->show_json('',400,'参数错误');
}
$jsondata = json_decode($row['jsondata'],true);
$item = $jsondata['item'] ? $jsondata['item'] : [];
//判断是否已支付
$o_row = $this->market_sylive_order_model->get(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]);
if($o_row){
$this->show_json('',400,'已支付,请勿重复支付');
}
$pay_price = $item['price'];
if($pay_price<=0){
$this->show_json('',400,'无需支付');
}
$unpay = $this->market_sylive_order_model->get(['item_id'=>$a_id,'status'=>0,'uid'=>$this->uid,'expire_time>'=>time()]);
if(!$unpay){
$this->load->helper('order');
$unpay = [
'sid' => create_order_no(),
'uid' => $this->uid,
'item_id' => $a_id,
'item_title' => $item['title'],
'total_price' => $pay_price,
'expire_time' => time()+24*60*60,//订单过期时间
'createTime' => date('Y-m-d H:i:s')
];
$oid = $this->market_sylive_order_model->add($unpay);
if(!is_numeric($oid)){
$this->show_json('',400,'创建订单失败');
}
}
$user = $this->user_model->get(['userId'=>$this->uid]);
$notify_url = http_host_com('home').'//h5/market/sylive/notify';
$result = $this->pay($unpay['sid'],$unpay['total_price'],$user['openid'],$unpay['item_title'],$notify_url,$unpay['expire_time']);
if(!$result['code']){
$this->show_json('',400,$result['msg']);
}
$this->show_json($result['data'],200,'操作成功');
}
public function ucenter(){
$skey = $this->input->get('skey');
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row){
throw new Hd_exception('参数错误',400);
}
$jsondata = json_decode($row['jsondata'],true);
$item = $jsondata['item'] ? $jsondata['item'] : [];
$banner = [];
if($item['itemImg']){
foreach ($item['itemImg'] as $value) {
$banner[] = build_qiniu_image_url($value);
}
}
$order = $this->market_sylive_order_model->get(['uid'=>$this->uid,'status'=>1,'item_id'=>$a_id]);
$pay_text = $order ? '(已支付)' : '(未支付)';
$info = [
'title' => $item['title'].$pay_text,
'content' => $item['introduction'],
'banner' => $banner,
];
$this->data['info'] = $info;
$this->show_view('h5/market/sylive/act/ucenter');
}
/**
* 支付
* @param $trade_no
* @param $price
* @param $openid
* @param $body
* @param $notify_url 异步通知
* @param $expire_time 过期时间
* @param $attach
* @return bool|json数据,可直接填入js函数作为参数|mixed
* @throws WxPayException
*/
private function pay($trade_no,$price,$openid,$body,$notify_url,$expire_time,$attach=''){
if(!$body){return false;}
require_once APPPATH."../api/third_party/WXconfig/liche_home_WxPay.Config.php";
require_once APPPATH."../api/third_party/WXpay/WxPay.Api.php";
$config = new WxPayConfig();
$wxpay = new WxPayUnifiedOrder();
$wxpay->SetVersion('1.0');
$wxpay->SetBody($body); //简单描述
$attach && $wxpay->SetAttach($attach); //附加信息
$wxpay->SetNotify_url($notify_url);
$wxpay->SetOut_trade_no($trade_no); //订单号
$wxpay->SetTotal_fee($price * 100); //支付价格
$wxpay->SetTime_start(date("YmdHis")); //交易起始时间
$wxpay->SetTime_expire(date('YmdHis',$expire_time)); //交易结束时间
$wxpay->SetTrade_type("JSAPI"); //设置交易类型
$wxpay->SetOpenid($openid); //openid
$return = WxPayApi::unifiedOrder($config, $wxpay); //统一支付
if($return['result_code'] == 'SUCCESS') {
$wxpay_api = new WxPayJsApiPay();
$jsApiParameters = WxPayApi::GetJsApiParameters($return, $config, $wxpay_api);
$jsApiParameters = json_decode($jsApiParameters, true);
return ['code'=>1,'data'=>$jsApiParameters,'msg'=>'下单成功'];
}else{
$msg = $return['return_msg'] ? $return['return_msg'].$return['err_code_des'] : $return['return_msg'];
return ['code'=>0,'data'=>[],'msg'=>$msg];
}
}
}
+266
View File
@@ -0,0 +1,266 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Common.php';
class Biz extends Admin {
private $group_id;
private $liche_img = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-avatar.jpg';
public function __construct(){
parent::__construct();
$this->load->model('market/market_sylive_organization_model');
$this->load->model('market/market_sylive_activity_model');
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$this->load->library('market/sylive_entity');
$this->load->library('MyEncryption');
$this->group_id = $this->sylive_entity->get_level($this->session['org_id']);
}
public function index(){
if($this->group_id>3){
throw new Hd_exception('权限不足',400);
}
$this->data['area_id'] = $this->input->get('area_id');
$this->data['biz_id'] = $biz_id = $this->input->get('biz_id');
$this->data['group_id'] = $this->group_id;
$row = $this->market_sylive_organization_model->get(['organizationId'=>$biz_id]);
$this->data['headimg'] = $this->liche_img;
$this->data['biz_name'] = $row['organizationName'];
$this->show_view('h5/market/sylive/biz/index');
}
//店铺列表
public function lists(){
if($this->group_id>1){
throw new Hd_exception('权限不足',400);
}
$area_id = $this->input->get('area_id');
$this->data['area_id'] = $area_id;
$this->data['group_id'] = $this->group_id;
$this->show_view('h5/market/sylive/biz/lists');
}
//大区列表
public function brands(){
if($this->group_id!=0){
throw new Hd_exception('权限不足',400);
}
$this->show_view('h5/market/sylive/biz/brands');
}
//顾问
public function detail(){
if($this->group_id!=3){
throw new Hd_exception('权限不足',400);
}
$this->show_view('h5/market/sylive/biz/detail');
}
public function nav(){
if($this->group_id>1){
$this->show_json([],200);
}
$area_id = $this->input->get('area_id');
$user = $this->user_model->get(['userId'=>$this->uid]);
$data = [
'nickname' => $user['nickname'],
'headimg' => $this->liche_img
];
if($this->group_id==1 || $area_id){ //所有店铺
!$area_id && $area_id = $this->session['org_id'];
$where = [
'status' => 0,
"parentId" => $area_id
];
$count_biz = $this->market_sylive_organization_model->count($where); //门店
$where = [
'status' => 0,
"organizationId in (select organizationId from lc_market_sylive_organization where
parentId in (select organizationId from lc_market_sylive_organization where parentId={$area_id} and status=0)
)" => null
];
$count_gw = $this->user_model->count($where); //顾问
$where = [
'status' => 0,
"activityId in (select activityId from lc_market_sylive_activity_biz where areaId={$area_id})" => null
];
$count_live = $this->market_sylive_activity_model->count($where);
$where = [
'kpi' => 'order',
"area_id" => $area_id
];
$count_order = $this->mdSytActivityKpiData->count($where);
$count = [
['title' => '门店','num' => $count_biz,'icon' => 'icon-quyu'],
['title' => '顾问','num' => $count_gw,'icon' => 'icon-mendian'],
['title' => '活动','num' => $count_live,'icon' => 'icon-zhibo'],
['title' => '订单','num' => $count_order,'icon' => 'icon-dingdan'],
];
$tab = [
['id' => 1, 'title' => '门店',],
['id' => 2, 'title' => '活动',],
];
}else{ //所有大区
$count_dq = $this->market_sylive_organization_model->count(['parentId'=>$this->session['org_id'],'status'=>0]);
$where = [
'status' => 0,
"parentId in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0) and status=0" => null
];
$count_biz = $this->market_sylive_organization_model->count($where);
$where = [
'status' => 0,
"activityId in (select activityId from lc_market_sylive_activity_biz where
areaId in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)
)" => null
];
$count_live = $this->market_sylive_activity_model->count($where);
$where = [
'kpi' => 'order',
" area_id in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)" => null
];
$count_order = $this->mdSytActivityKpiData->count($where);
$count = [
['title' => '区域','num' => $count_dq],
['title' => '门店','num' => $count_biz],
['title' => '活动','num' => $count_live],
['title' => '订单','num' => $count_order],
];
$tab = [
['id' => 1, 'title' => '区域',],
['id' => 2, 'title' => '活动',],
];
}
$data['count'] = $count;
$data['tab'] = $tab;
$this->show_json($data,200);
}
//大区列表
public function area_lists(){
$page = $this->input->get('page');
!$page && $page = 1;
$size = 10;
$where = [
'parentId' => $this->session['org_id'],
'status' => 0,
];
$total = $this->market_sylive_organization_model->count($where);
$lists = [];
if($total){
$rows = $this->market_sylive_organization_model->select($where,'sortNumber desc',$page,$size,'organizationId,parentId,organizationName');
foreach ($rows as $val) {
$where = [
'status' => 0,
"activityId in (select activityId from lc_market_sylive_activity_biz where areaId={$val['organizationId']})" => null
];
$activitynum = $this->market_sylive_activity_model->count($where);
$temp = [
'title' => $val['organizationName'],
'storenum' => $this->market_sylive_organization_model->count(['parentId'=>$val['organizationId'],'status'=>0]),
'activitynum' => $activitynum,
'url' => '/h5/market/sylive/biz/lists?area_id='.$val['organizationId'],
'state' => [],
];
$lists[] = $temp;
}
}
$data['list'] = $lists;
$data['total'] = $total;
$this->show_json($data,200);
}
//门店列表
public function biz_lists(){
$area_id = $this->input->get('area_id');
!$area_id && $area_id = 0;
$page = $this->input->get('page');
!$page && $page = 1;
$size = 10;
$where = [
'status' => 0,
];
if($this->group_id==1){
$where['parentId'] = $this->session['org_id'];
}else{
$where['parentId'] = $area_id;
}
$total = $this->market_sylive_organization_model->count($where);
$lists = [];
if($total){
$rows = $this->market_sylive_organization_model->select($where,'sortNumber desc',$page,$size,'organizationId,parentId,organizationName');
foreach ($rows as $val) {
$where = [
'status' => 0,
"activityId in (select activityId from lc_market_sylive_activity_biz where bizId={$val['organizationId']})" => null
];
$activitynum = $this->market_sylive_activity_model->count($where);
$temp = [
'title' => $val['organizationName'],
'storenum' => $this->user_model->count(['organizationId'=>$val['organizationId'],'status'=>0]), //顾问
'activitynum' => $activitynum,
'url' => '/h5/market/sylive/biz?biz_id='.$val['organizationId'].'&area_id='.$area_id,
'state' => [],
];
$lists[] = $temp;
}
}
$data['list'] = $lists;
$data['total'] = $total;
$this->show_json($data,200);
}
//活动列表
public function act_list(){
$area_id = $this->input->get('area_id');
$biz_id = $this->input->get('biz_id');
$page = $this->input->get('page');
!$page && $page = 1;
$size = 10;
$where = [
'status' => 0,
];
if($this->group_id==3){ //顾问
$where["activityId in (select activityId from lc_market_sylive_activity_biz where
bizId in (select parentId from lc_market_sylive_organization where organizationId={$this->session['org_id']} and status=0)
)"] = null;
}elseif($this->group_id==2){ //当前店铺
$where["activityId in (select activityId from lc_market_sylive_activity_biz where bizId={$this->session['org_id']})"] = null;
}elseif($this->group_id==1) { //所有店铺
$where["activityId in (select activityId from lc_market_sylive_activity_biz where areaId={$this->session['org_id']})"] = null;
}elseif(!$this->group_id && $biz_id){
$where["activityId in (select activityId from lc_market_sylive_activity_biz where bizId={$biz_id})"] = null;
}elseif (!$this->group_id && $area_id) {
$where["activityId in (select activityId from lc_market_sylive_activity_biz where areaId={$area_id} and status=0)"] = null;
}else{ //所有大区
$where["activityId in (select activityId from lc_market_sylive_activity_biz where
areaId in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)
)"] = null;
}
$total = $this->market_sylive_activity_model->count($where);
$lists = [];
if($total){
$rows = $this->market_sylive_activity_model->select($where,'timeStart desc',$page,$size,'activityId,title,timeStart,timeEnd');
foreach ($rows as $val) {
$s_time = strtotime($val['timeStart']);
$e_time = strtotime($val['timeEnd']);
$n_time = time();
if($n_time>=$s_time&&$n_time<=$e_time){
$state = ['title'=>'活动进行中','class'=>'bg-fe9538'];
}elseif($n_time<$s_time){
$state = ['title'=>'活动预热中','class'=>'bg-ff5a5a'];
}else{
$state = ['title'=>'活动已结束','class'=>'bg-fccba0'];
}
$skey = $this->myencryption->base64url_encode("a_id=" . $val['activityId']);
$temp = [
'title' => $val['title'],
'time' => date('Y-m-d',$s_time).'~'.date('Y-m-d',$e_time),
'url' => '/h5/market/sylive/act?skey='.$skey,
'state' => $state,
];
$lists[] = $temp;
}
}
$data['list'] = $lists;
$data['total'] = $total;
$this->show_json($data,200);
}
}
@@ -0,0 +1,198 @@
<?php
defined('APPPATH') OR exit('No direct script access allowed');
/**
* User: lcc
* Date: 2022/09/18
* Time: 17:13
*/
abstract class Common extends CI_Controller{
protected $data;
protected $white_login_method=[]; //授权白名单
protected $uid;
protected $session;
protected $log_dir = 'market/sylive';
protected $secret = "market_sylive_h5_test";
public function __construct(){
parent::__construct();
$this->load->helper('cookie');
$this->load->model('market/market_sylive_user_model', 'user_model');
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
$this->load->library('hd_exception');
$this->load->library('MyEncryption');
$ukey = get_cookie('ukey');
if ($ukey) {
$this->session = json_decode(liche_authcode($ukey, 'DECODE', $this->secret), true);
$this->uid = $this->session['uid'];
}
}
/**
* @param $view
*/
protected function show_view($view){
$this->load->view('h5/market/sylive/header',$this->data);
$this->load->view($view);
$this->load->view('h5/market/sylive/footer');
}
/**
* @param $data
* @param int $code
* @param string $msg
* @param string $url
*/
protected function show_json($data, $code = 200, $msg = 'success', $url = '')
{
if(!isset($data['code'])){
$data = array('data' => $data, 'code' => $code, 'msg' => $msg, 'url' => $url);
}
exit(json_encode($data));
}
/**
* @param $url 回调url地址
* @param $auth 是否信息授权
* @return void
* @throws Hd_exception
*/
protected function set_auth($url='',$auth=0){
$this->load->helper('url');
$this->load->config('wechat');
$config = $this->config->item('liche');
$code = $this->input->get('code');
!$url && $url = http_host_com('home').$_SERVER['REQUEST_URI'];
$auth && $url = $_SERVER['QUERY_STRING'] ? $url."&auth={$auth}" : $url."?auth={$auth}";
if ($code) {//授权码获取微信信息
$auth_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$config['appid']}&secret={$config['appSecret']}&code={$code}&grant_type=authorization_code";
$res = file_get_contents($auth_url);
$ret = json_decode($res, true);
$access_token = $ret['access_token'];
$openid = $ret['openid'];
$unionid = $ret['unionid'];
if($this->input->get('auth') && $access_token){
$u_info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$access_token}&openid={$openid}&lang=zh_CN";
$u_ret = file_get_contents($u_info_url);
$ret = json_decode($u_ret,true);
}
if(!$openid){
debug_log("[error]# " . $res, __FUNCTION__, $this->log_dir);
throw new Hd_exception('获取用户信息失败', 400);
}
return $ret;
} elseif ($auth) {//信息授权获取用户微信昵称/头像
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect&forcePopup=true";
redirect($auth_url);
} elseif (!$this->session) {//静默授权获取用户openid
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['appid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
}
}
class Admin extends Common{
const WX_SESSION = "market_wx_info";
public function __construct(){
parent::__construct();
session_start();
}
public function _remap($method){
try{
if(!in_array($method,$this->white_login_method) && !$this->uid){
$ret = $this->set_auth('',1);
$openid = $ret['openid'];
$row_wechat = $this->user_model->get(['openid' => $openid,'organizationId>'=>0,'status>='=>0]);
if(!$row_wechat){
$_SESSION[self::WX_SESSION] = $ret;
header('Location:/h5/market/sylive/login');exit;
}
if($row_wechat['status']){
throw new Hd_exception('该账户禁用', 400);
}
$this->uid = $row_wechat['userId'];
$session = ['uid' => $this->uid,'org_id'=>$row_wechat['organizationId']];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->session = $session;
}
return $this->$method();
} catch(Hd_exception $e){//处理异常
// $code = $e->getCode();
$msg = $e->getMessage();
$data = array('heading' => 'Warning', 'message' => $msg);
return $this->load->view('errors/html/error_404',$data);
}
}
}
class Wx extends Common{
public function __construct(){
parent::__construct();
}
public function _remap($method){
try{
if(!in_array($method,$this->white_login_method) && !$this->uid){
$ret = $this->set_auth('',1);
$openid = $ret['openid'];
$row_wechat = $this->user_model->get(['openid' => $openid,'status>='=>0]);
if($row_wechat['status']){
throw new Hd_exception('该账户禁用', 400);
}
if(!$row_wechat){ //创建用户
$add = array(
"openid" => $openid,
"sex" => $ret['sex'] ? 1 : 0,
"createTime" => date('Y-m-d H:i:s')
);
$ret['nickname'] && $add['nickname'] = strval($ret['nickname']);
$ret['headimgurl'] && $add['headimg'] = strval($ret['headimgurl']);
$ret['unionid'] && $add['unionid'] = $ret['unionid'];
$this->uid = $this->user_model->add($add);
$row_wechat['organizationId'] = 0;
if (!$this->uid) {
debug_log("[error]# " . $this->mdWeixinUsers->db->last_query(), __FUNCTION__, $this->log_dir);
}
}else{
$this->uid = $row_wechat['userId'];
}
$skey = $this->input->get('skey');
$param = $this->myencryption->base64url_decode($skey);
$act_user = $this->act_user_model->get(['activityId'=>$param['a_id'],'userId'=>$this->uid]);
if(!$act_user && $param['a_id']){
$act_data = [
'activityId' => $param['a_id'],
'userId' => $this->uid,
"createTime" => date('Y-m-d H:i:s')
];
if($param['cf_uid']){
$p_user = $this->user_model->get(['userId'=>$param['cf_uid']],'userId,organizationId');
$p_act_user = $this->act_user_model->get(['userId'=>$param['cf_uid']],'userId,channelId');
$p_act_user['channelId'] && $act_data['channelId'] = $p_act_user['channelId'];
if(!$p_user['channelId'] && $p_user['organizationId']>0){
$act_data['channelId'] = $p_user['userId'];
}
$act_data['pid'] = $p_user['userId'];
}
$this->act_user_model->add($act_data);
}
$session = ['uid' => $this->uid,'org_id'=>$row_wechat['organizationId']];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->session = $session;
}
return $this->$method();
} catch(Hd_exception $e){//处理异常
// $code = $e->getCode();
$msg = $e->getMessage();
$data = array('heading' => 'Warning', 'message' => $msg);
return $this->load->view('errors/html/error_404',$data);
}
}
}
@@ -0,0 +1,99 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Login extends CI_Controller{
const WX_SESSION = "market_wx_info";
protected $secret = "market_sylive_h5";
public function __construct(){
parent::__construct();
session_start();
$this->load->helper('cookie');
$this->load->model('market/market_sylive_user_model', 'user_model');
}
public function index(){
if($this->input->is_ajax_request()){
$redis = &load_cache('redis');
$code = $this->input->post('code');
$mobile = $this->input->post('mobile');
$key = "sylive_login_code_".$mobile;
if(!$code || $code!=$redis->get($key)){
$this->show_json('',400,'请输入正确的验证码');
}
$user=$this->user_model->get(array('mobile' => $mobile,'organizationId>'=>0));
if($user['status']){
$this->show_json('',400,'用户已禁用');
}
$this->bind_openid($user);
$session = ['uid' => $user['userId'],'org_id'=>$user['organizationId']];
$ukey = liche_authcode(json_encode($session, JSON_UNESCAPED_UNICODE), 'ENCODE', $this->secret);
set_cookie("ukey", $ukey, 86400 * 30);
$this->show_json('',200,'登录成功');
}else{
$this->load->view('h5/market/sylive/login');
}
}
//绑定微信openid
private function bind_openid($user){
$wx_info = $_SESSION[self::WX_SESSION];
if(!$wx_info['openid']){
return ['code' => 0,'msg' => '不存在公众号信息,无需绑定'];
}
if($user['openid']){
return ['code' => 0,'msg' => '该用户已绑定公众号'];
}
$is_bind = $this->user_model->count(['openid'=>$wx_info['openid'],'organizationId>'=>0,'status>='=>0]); //是否绑定
if($is_bind){
return ['code' => 0,'msg' => '该公众号已存在绑定账号'];
}
$update = [
'openid' => $wx_info['openid']
];
$wx_info['nickname'] && $update['nickname'] = strval($wx_info['nickname']);
$wx_info['headimgurl'] && $update['headimg'] = strval($wx_info['headimgurl']);
$wx_info['unionid'] && $update['unionid'] = $wx_info['unionid'];
$this->user_model->update($update,['userId'=>$user['userId']]);
//删除普通账户
$this->user_model->update(['status'=>-1],['openid'=>$wx_info['openid'],'organizationId'=>0,'status>='=>0]);
return ['code' => 1,'msg' => '绑定成功'];
}
//获取验证码
public function get_code(){
$mobile = $this->input->post('mobile');
if(!mobile_valid($mobile)){
$this->show_json('',400,'请输入正确的手机号码');
}
$user=$this->user_model->get(array('mobile' => $mobile, 'status' => 0,'organizationId>'=>0));
if(!$user){
$this->show_json('',400,'用户不存在');
}
if($user['status']){
$this->show_json('',400,'用户已禁用');
}
$redis = &load_cache('redis');
$key = "sylive_login_code_".$mobile;
if(!$code = $redis->get($key)){
$this->load->helper('string');
$code = random_string('numeric', 4);
$redis->save($key, $code, 60*5);
}
send_sms($mobile, $code);
$this->show_json('',200, '验证码已发送');
}
private function show_json($data, $code = 200, $msg = 'success', $url = ''){
if(!isset($data['code'])){
$data = array('data' => $data, 'code' => $code, 'msg' => $msg, 'url' => $url);
}
exit(json_encode($data));
}
public function test(){
$this->load->library('market/sylive_entity');
$oid = 1;
$req = $this->sylive_entity->get_level($oid);
print_r($req);
}
}
@@ -0,0 +1,33 @@
<?php
ini_set('display_errors', 'On');
error_reporting(E_ERROR);
require_once 'Common.php';
require_once COMMPATH . 'third_party/phpqrcode/phpqrcode.php';
/**
* Notes:私或通专题页
* Created on: 2020/10/13 14:13
* Created by: dengbw
*/
class Myqrcode extends Wx
{
/**
* Notes:
* Created on: 2020/10/14 10:49
* Created by: dengbw
* https://liche-dev.xiaoyu.com/h5/syt/qrcode
*/
function get()
{
$url = $this->input->get('url');
if ($url) {
$errorCorrectionLevel = 'L'; //容错级别
$matrixPointSize = 5; //生成图片大小
//生成二维码图片
QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize, 1);
}
}
}
@@ -0,0 +1,67 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH."../api/third_party/WXpay/WxPay.Api.php";
require_once APPPATH."../api/third_party/WXconfig/liche_home_WxPay.Config.php";
class Notify extends CI_Controller {
private $log_dir = 'market/sylive';
private $log_file = 'wx_pay.log';
private $notify;
public function __construct(){
parent::__construct();
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
$this->load->model('market/market_sylive_order_model','order_model');
$this->load->library('market/sylive_entity');
try{
//如果返回成功则验证签名
$config = new WxPayConfig();
$input = file_get_contents("php://input");
$result = WxPayNotifyResults::Init($config, $input);
$this->notify = $result->GetValues();
debug_log("[info] ". __FUNCTION__ . "# notify:" . json_encode($this->notify,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir);
}catch (WxPayException $e){
debug_log("[error] ". __FUNCTION__ . ":".$e->getMessage(), $this->log_file,$this->log_dir);
exit();
}
}
//微信支付异步通知
public function index(){
try{
$sid = $this->notify['out_trade_no'];
if($sid){
debug_log("[start] ". __FUNCTION__ . ": out_trade_no:".$this->notify['out_trade_no'], $this->log_file,$this->log_dir);
$order = $this->order_model->get(array('sid'=>$sid));
if(!$order){
throw new Exception("{$sid}_订单不存在");
}
if($order['status']){
throw new Exception("{$sid}_订单已支付");
}
if($this->notify['result_code'] != 'SUCCESS'){ //支付失败
throw new Exception("支付失败,sid={$sid}");
}else{ //支付成功
$res = $this->order_model->update(['status'=>1,'pay_time'=>date('Y-m-d H:i:s')],['id'=>$order['id']]);
if($res){
$act_user = $this->act_user_model->get(['userId'=>$order['uid'],'activityId'=>$order['item_id']]);
$sy_res = $this->sylive_entity->kpi_log(['a_id' => $order['item_id'], 'uid' => $order['uid'],'cf_uid' => $act_user['channelId'], 'kpi' => 'order']);
debug_log("[info] ". __FUNCTION__ . ":私域通增加记录-".json_encode($sy_res,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir);
debug_log("[success] ". __FUNCTION__ . ":操作成功", $this->log_file,$this->log_dir);
}
}
}
}catch (Exception $e){
$msg = $e->getMessage();
debug_log("[error] ". __FUNCTION__ . ":{$msg}", $this->log_file,$this->log_dir);
}
if($sid){
debug_log("[finish] ". __FUNCTION__ . ": out_trade_no-".$this->notify['out_trade_no'], $this->log_file,$this->log_dir);
}else{
debug_log("[finish] ". __FUNCTION__ . ": 参数错误-".json_encode($this->notify,JSON_UNESCAPED_UNICODE), $this->log_file,$this->log_dir);
}
echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
}
}
+272
View File
@@ -0,0 +1,272 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Common.php';
class Stic extends Admin{
private $group_id;
public function __construct(){
parent::__construct();
$this->load->model('market/market_sylive_organization_model');
$this->load->model('market/market_sylive_activity_model');
$this->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz');
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$this->load->library('market/sylive_entity');
$this->group_id = $this->sylive_entity->get_level($this->session['org_id']);
$this->data['skey'] = $this->input->get('skey');
}
//顾问
public function index(){
if($this->group_id>3){
throw new Hd_exception('权限不足',400);
}
if($this->group_id==3){ //顾问
$param = $this->myencryption->base64url_decode($this->data['skey']);
$a_id = intval($param['a_id']);//活动id
$browse_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'browse','cf_uid'=>$this->uid]);
$subscribe_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'subscribe','cf_uid'=>$this->uid]);
$info['begin'] = [
['title' => '访问用户', 'num' => "{$browse_count}"],
['title' => '预约用户', 'num' => "{$subscribe_count}"],
['title' => '预约率', 'num' => $subscribe_count ? round($subscribe_count/$browse_count*100,2)."%" : 0],
];
$watch_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'watch','cf_uid'=>$this->uid]);
$order_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'order','cf_uid'=>$this->uid]);
$info['live'] = [
['title' => '观看用户', 'num' => "{$watch_count}"],
['title' => '下单用户', 'num' => "{$order_count}"],
['title' => '转化率', 'num' => $watch_count ? round($watch_count/$order_count*100,2)."%" : 0],
];
$this->data['info'] = $info;
$this->show_view('h5/market/sylive/stic/index');
}else{ //门店和大区
$this->show_view('h5/market/sylive/stic/area');
}
}
public function lists_ready(){
$skey = $this->input->get('skey');
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row && $this->group_id>=3){
$this->show_json([],200);
}
$cell2 = [];
if($this->group_id<2){ //所有大区
$where = [
'a_id' => $a_id,
'kpi' => 'browse',
];
if($this->group_id==1){
$org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId');
$org_id = $org_row['parentId'] ? $org_row['parentId'] : 0;
$where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$org_id} and status=0)"] = null;
}else{
$where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)"] = null;
}
$browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据
$where['kpi'] = 'subscribe';
$subscribe_count = $this->mdSytActivityKpiData->count($where); //预约用户
$sql = "select count(distinct areaId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$area_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$sql = "select count(distinct bizId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$biz_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$where = [
'status' => 0,
"organizationId in (select organizationId from lc_market_sylive_organization where
parentId in (select bizId from lc_market_sylive_activity_biz where activityId={$a_id} and status=0)
)" => null
];
$gw_count = $this->user_model->count($where); //顾问
$cell2 = [
['title' => '参与大区', 'num' => "{$area_count['total']}"],
['title' => '参与门店', 'num' => "{$biz_count['total']}"],
['title' => '参与人数', 'num' => "{$gw_count}"],
];
}else{ //门店
$where = [
'a_id' => $a_id,
'kpi' => 'browse',
'biz_id' => $this->session['org_id']
];
$browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据
$where['kpi'] = 'subscribe';
$subscribe_count = $this->mdSytActivityKpiData->count($where); //浏览数据
}
$cell1 = [
['title' => '访问用户', 'num' => "{$browse_count}"],
['title' => '预约用户', 'num' => "{$subscribe_count}"],
['title' => '预约率', 'num' => $subscribe_count ? round($subscribe_count/$browse_count*100,2)."%" : 0],
];
$biz_id = $this->group_id==3 ? $this->session['org_id'] : 0;
$browse_lists = $this->sylive_entity->top_lists($a_id,'browse',1,10,$biz_id);
$browse = [
'title' => '门店<span class="color-fe9538">浏览</span>排行',
'url' => '/h5/market/sylive/stic/rank?type=browse&skey='.$skey,
'list' => $browse_lists['lists']
];
$book_lists = $this->sylive_entity->top_lists($a_id,'subscribe',1,10,$biz_id);
$book = [
'title' => '门店<span class="color-fe9538">预约</span>排行',
'url' => '/h5/market/sylive/stic/rank?type=subscribe&skey='.$skey,
'list' => $book_lists['lists']
];
$data = [
'cell1' => $cell1,
'cell2' => $cell2,
'browse' => $browse,
'book' => $book
];
$this->show_json($data,200);
}
//直播统计数据
public function lists_live(){
$skey = $this->input->get('skey');
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
if(!$row && $this->group_id>=3){
$this->show_json([],200);
}
$cell3 = [];
if($this->group_id<2){ //所有大区
$where = [
'a_id' => $a_id,
'kpi' => 'watch',
];
if($this->group_id==1){
$org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId');
$org_id = $org_row['parentId'] ? $org_row['parentId'] : 0;
$where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$org_id} and status=0)"] = null;
}else{
$where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)"] = null;
}
$view_count = $this->mdSytActivityKpiData->count($where); //浏览数据
$where['kpi'] = 'order';
$order_count = $this->mdSytActivityKpiData->count($where); //预约用户
$sql = "select count(distinct areaId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$area_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$sql = "select count(distinct bizId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$biz_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$where = [
'status' => 0,
"organizationId in (select organizationId from lc_market_sylive_organization where
parentId in (select bizId from lc_market_sylive_activity_biz where activityId={$a_id} and status=0)
)" => null
];
$gw_count = $this->user_model->count($where); //顾问
$cell3 = [
['title' => '参与大区', 'num' => "{$area_count['total']}"],
['title' => '参与门店', 'num' => "{$biz_count['total']}"],
['title' => '参与人数', 'num' => "{$gw_count}"],
];
}else{ //门店
$where = [
'a_id' => $a_id,
'kpi' => 'watch',
'biz_id' => $this->session['org_id']
];
$view_count = $this->mdSytActivityKpiData->count($where); //观看数据
$where['kpi'] = 'order';
$order_count = $this->mdSytActivityKpiData->count($where); //下单数据
}
$cell1 = [
['title' => '观看用户', 'num' => "{$view_count}"],
['title' => '下单用户', 'num' => "{$order_count}"],
['title' => '转化率', 'num' => $order_count ? round($order_count/$view_count*100,2)."%" : 0],
];
$cell2 = [
['title' => '直播时长', 'num' => "0分钟"],
['title' => '人均观看', 'num' => "0秒"],
['title' => '观看次数', 'num' => "0次"],
];
$biz_id = $this->group_id==3 ? $this->session['org_id'] : 0;
$watch_lists = $this->sylive_entity->top_lists($a_id,'watch',1,10,$biz_id);
$view = [
'title' => '门店<span class="color-fe9538">观看</span>排行',
'url' => '/h5/market/sylive/stic/rank?type=watch&skey='.$skey,
'list' => $watch_lists['lists']
];
$order_lists = $this->sylive_entity->top_lists($a_id,'order',1,10,$biz_id);
$order = [
'title' => '门店<span class="color-fe9538">订单</span>排行',
'url' => '/h5/market/sylive/stic/rank?type=order&skey='.$skey,
'list' => $order_lists['lists']
];
$data = [
'cell1' => $cell1,
'cell2' => $cell2,
'cell3' => $cell3,
'view' => $view,
'order' => $order
];
$this->show_json($data,200);
}
//排名列表
public function rank(){
$title_arr = [
'browse' => '门店<span class="color-fe9538">浏览</span>排行',
'subscribe' => '门店<span class="color-fe9538">预约</span>排行',
'watch' => '门店<span class="color-fe9538">观看</span>排行',
'order' => '门店<span class="color-fe9538">订单</span>排行'
];
$params = $this->input->get();
if($this->input->is_ajax_request()){
$page = $params['page'] ? intval($params['page']) : 1;
$info = $this->myencryption->base64url_decode($params['skey']);
$a_id = intval($info['a_id']);//活动id
$biz_id = $this->group_id==3 ? $this->session['org_id'] : 0;
$type = $params['type'] ? $params['type'] : 'browse';
$data = $this->sylive_entity->top_lists($a_id,$type,$page,10,$biz_id);
$data['title'] = $title_arr[$type];
$this->show_json($data,200);
}
$this->data['params'] = $params;
$this->show_view('h5/market/sylive/stic/rank');
}
public function event(){
$map_kpi_name = [
'browse' => '浏览了直播间', 'subscribe' => '订阅了直播间', 'order' => '直播间下单','watch' => '进入了直播间'
];
$skey = $this->input->get('skey');
$page = $this->input->get('page');
!$page && $page=10;
$param = $this->myencryption->base64url_decode($skey);
$a_id = intval($param['a_id']);//活动id
$where = [
'a_id'=>$a_id,
// 'kpi'=>'watch',
'cf_uid'=>$this->uid
];
$total = $this->mdSytActivityKpiData->count($where);
$lists = [];
if($total){
$rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,10,'uid,kpi,c_time');
$users = [];
$uids = implode(',',array_unique(array_column($rows,'uid')));
if($uids){
$where = [
"userId in ($uids)" => null,
];
$users = $this->user_model->map('userId','nickname',$where,'','','','userId,nickname');
}
foreach ($rows as $key => $val) {
$nickname = $users[$val['uid']] ? $users['uid'] : "用户{$val['uid']}";
$lists[] = [
'nickname' => $nickname,
'action' => $map_kpi_name[$val['kpi']],
'time' => friendly_date($val['c_time']),
];
}
}
$data = [
'lists' => $lists,
'total' => $total
];
$this->show_json($data,200);
}
}
@@ -0,0 +1,23 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Common.php';
class Welcome extends Admin {
public function __construct(){
parent::__construct();
$this->load->library('market/sylive_entity');
}
public function index(){
$group_id = $this->sylive_entity->get_level($this->session['org_id']);
if($group_id==2 || $group_id==3){ //顾问和店长 店铺首页
header('Location:/h5/market/sylive/biz');exit;
}elseif($group_id==1){ //店铺列表
header('Location:/h5/market/sylive/biz/lists');exit;
}else{ // 大区列表
header('Location:/h5/market/sylive/biz/brands');exit;
}
}
}
+306
View File
@@ -0,0 +1,306 @@
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/md5.min.js"></script>
<script type="text/javascript" src="//player.polyv.net/livesdk/polyv-live.min.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<body class="bg-fff">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pb150" :style="'background-image:url('+info.bg+')'">
<div class="absolute top-0 right-0 mt15 mr10 ulib-r750 fn-flex overflowhidden line-height-20 space-nowrap">
<a class="fn-flex-item bg-000-op50 pl20 pr20 font-22 color-fff" v-if="info.shareurl" :href="info.shareurl">
<i class="iconfont icon-fenxiang text-middle"></i><span class="text-middle ml10">分享</span></a>
<a class="fn-flex-item bg-000-op50 ml1 pl20 pr20 font-22 color-fff" v-if="info.org_id>0" :href="info.statisticsurl">
<i class="iconfont icon-shuju text-middle"></i><span class="text-middle ml10">数据</span></a>
</div>
<div class="h-260"></div>
<div class="pl25 pr25">
<div class="relative ml60 mr180 pl200 bg-ad4635 line-height-63 font-22 color-fff" v-if="info.e_time>0" v-html="showTime"></div>
<div id="player" class="player pt30 pb30">
<template v-if="info.live_status==2">
<div class="pv-ppt-layout pv-ppt-normal" style="width:100%;height:100%">
<div class="pv-player-layout pv-player-zh_CN">
<div class="plwrap" style="width: 100%; height: 100%;">
<div class="plv_mask" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 3;background: url(<?=$info['channelImg']?>) 0% 0% / 100% 100% no-repeat;"></div>
</div>
</div>
</div>
</template>
</div>
<div class="mt10 pl30 pr30 font-22 line-height-17 color-666" v-html="info.content"></div>
</div>
<div class="fixed left-0 bottom-0 right-0 inner30 bg-fff z-index-4" >
<template v-if="info.live_status<2">
<a class="block bg-fe9538 pt20 pb20 text-center font-36 color-fff ulib-r10" v-if="info.live_status==1" href="/h5/market/sylive/act/item?skey=<?=$info['skey']?>">立即抢购</a>
<a class="block bg-fe9538 pt20 pb20 text-center font-36 color-fff ulib-r10" v-else href="javascript:;" @click="showCode">开播提醒</a>
</template>
<template v-else>
<a class="block bg-999 pt20 pb20 text-center font-36 color-fff ulib-r10" href="javascript:;">活动已结束</a>
</template>
</div>
<a class="bottom-opt pt15 bg-fe9538 ulib-r750 text-center color-fff" href="/h5/market/sylive/act/ucenter?skey=<?=$info['skey']?>">
<i class="iconfont icon-wode text-middle font-36"></i>
<div class="font-22">我的</div>
</a>
<!--直播字幕-->
<div>
<div class="notice bg-000-op10 pl20 pr20 line-height-17 font-28 ulib-r750 z-index-1" :style="'animation-delay:'+item.delay+'s;'" v-for="(item,index) in notice1">
<span class="color-fe9538">{{item.name}}</span>
<span class="ml10">{{item.tip}}</span>
</div>
<div class="notice bg-000-op10 pl20 pr20 line-height-17 font-28 ulib-r750 z-index-1" :style="'animation-delay:'+item.delay+'s;'" v-for="(item,index) in notice2">
<span class="color-fe9538">{{item.name}}</span>
<span class="ml10">{{item.tip}}</span>
</div>
</div>
</div>
<div class="msg fn-hide" :style="msgisShowCode?'display:block':'display:none'" v-if="msgisShowCode">
<div class="msgBg" @click="closeCode"></div>
<div class="msgMain">
<div class="content">
<div class="word">
<div class="pt10 text-center">
<img class='inline-block img-220x220' :src='info.code' />
</div>
<div class="pt30 pb20 pl20 pr20 font-24 color-666 line-height-15">长按识别二维码,关注狸车服务号。即可接收直播提醒,还有更多福利不定期放送哦~</div>
</div>
<div class="opt pl40 pr40">
<a class="block bg-fe9538 pt25 pb25 text-center font-32 color-fff ulib-r750" @click="closeCode" href="javascript:" >知道了</a>
</div>
</div>
</div>
</div>
</div>
<?if($info['live_status']<2){?>
<script>
var chatroom = null;
var liveSdk = null;
window.onload = function () {
var liveSdk = new PolyvLiveSdk({
channelId: "<?= $info['liveSdk']['channelId'] ?>",
sign: "<?= $info['liveSdk']['sign'] ?>", // 频道验证签名
timestamp: "<?= $info['liveSdk']['timestamp'] ?>", // 毫秒级时间戳
appId: "<?= $info['liveSdk']['appId'] ?>", // polyv 后台的appId
user: {
userId: "<?= $info['liveSdk']['user']['userId'] ?>",
userName: "<?= $info['liveSdk']['user']['userName'] ?>",
pic: "<?= $info['liveSdk']['user']['pic'] ?>",
},
});
// 第四步:监听频道信息读取完成事件,初始化播放器
liveSdk.on(PolyvLiveSdk.EVENTS.CHANNEL_DATA_INIT, (event, data) => {
liveSdk.setupPlayer({
el: "#player",
type: "auto",
autoplay: true, // 设置自动播放
});
console.log('---频道信息---')
console.log(data)
});
/******函数*******/
};
</script>
<?}?>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
info:'',
bundleIntervalEvent: '',//倒计时
page:1,
notice1:[],
notice2:[],
code:'',
msgisShowCode: false,
},
created(){
},
computed: {
//用计算属性显示结果
showTime() {
//剩余秒数<=0
if (this.info.e_time <= 0) {
return "";
}
// 剩余秒数>0
else {
let day = Math.floor(this.info.e_time / 86400);
let hour = Math.floor((this.info.e_time % 86400) / 3600);
let min = Math.floor(((this.info.e_time % 86400) % 3600) / 60);
let sec = Math.floor(((this.info.e_time % 86400) % 3600) % 60);
if(day>0){
return ("<span class='inline-block absolute top-0 left-0 bottom-0 bg-333 pl30 pr30'>距开播还有</span><em class='text-middle pl5 pr5'>"+day+ "</em><em class='text-middle'>天</em><em class='text-middle pl5 pr5'>"+(hour < 10 ? "0" : "") + hour + "</em><em class='text-middle'>时</em><em class='text-middle pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(hour>0){
return ("<span class='inline-block absolute top-0 left-0 bottom-0 bg-333 pl30 pr30'>距开播还有</span><em class='text-middle color-ff7200 pl5 pr5'>"+(hour < 10 ? "0" : "") + hour + "</em><em class='text-middle'>时</em><em class='text-middle color-ff7200 pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(min>0){
return ("<span class='inline-block absolute top-0 left-0 bottom-0 bg-333 pl30 pr30'>距开播还有</span><em class='text-middle color-ff7200 pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(sec>0){
return ("<span class='inline-block absolute top-0 left-0 bottom-0 bg-333 pl30 pr30'>距开播还有</span><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}
}
}
},
mounted() {
//倒计时
this.bundleIntervalEvent = setInterval(this.intervalEvent, 1000);
this.getInfo()
this.getNotice()
},
beforeDestroy() {
clearInterval(this.bundleIntervalEvent);
},
methods: {
showCode: function() {
let that = this;
if (that.info.subscribemsg == '已订阅直播') {
mDialog.msg({content: that.info.subscribemsg});
return;
}
if (!that.mp_app_id) {
window.location.href = "" + that.info.subscribemsg;
return;
}
},
closeCode: function() {
this.msgisShowCode = false
},
//直播倒计时
intervalEvent() {
if (this.info.e_time > 0) {
this.info.e_time--;
} else {
clearInterval(this.bundleIntervalEvent);
}
},
//获取基础信息
getInfo(){
//this.info = {
// bg:"<?//=$info['bg']?>//",
// e_time: <?//=$info['s_time']?>//,//距离开始时间
// shareurl:'<?//=$info['shareurl']?>//',
// statisticsurl:'/h5/market/sylive/stic?skey=<?//=$info['skey']?>//',
// code:'',
// content:'<?//=$info['content']?>//',
// a_id:'<?//=$info['a_id']?>//',
// skey:'<?//=$info['skey']?>//',
// subscribemsg:'<?//=$info['subscribemsg']?>//',
// org_id:'<?//=$info['org_id']?>//',
//}
this.info = <?=json_encode($info,JSON_UNESCAPED_UNICODE)?>
},
//获取底部订阅提示
getNotice(){
let that = this
if(that.info.e_time<=0){
return '';
}
$.get('/h5/market/sylive/act/subscribemsg_lists',{'a_id':that.info.a_id},function (result){
that.notice = result.data.lists
console.log(result.data.lists);
that.page = that.page + 1
alldelay = 0
that.notice.forEach(item => {
item.delay = alldelay + Math.floor(Math.random() * (3))/10 + 1
alldelay = item.delay
})
if(that.page%2 ==0){
that.notice2 = that.notice
setTimeout(function () {
that.notice1= []
}, 6000);
}else{
that.notice1 = that.notice
setTimeout(function () {
that.notice2= []
}, 6000);
}
if(alldelay>10){
setTimeout(function () {
that.getNotice()
}, alldelay*1000);
}
},'json')
// let notice = [
// {
// name:'刘*',
// tip:'刚刚订阅了直播提醒',
// },
// ]
},
}
})
</script>
<script type="text/javascript">
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
appId: "<?=$sign_package['appId']?>", // 必填,公众号的唯一标识
timestamp: "<?=$sign_package['timestamp']?>", // 必填,生成签名的时间戳
nonceStr: "<?=$sign_package['nonceStr']?>", // 必填,生成签名的随机串
signature: "<?=$sign_package['signature']?>",// 必填,签名
jsApiList: ["openLocation", "updateAppMessageShareData", "updateTimelineShareData"], // 必填,需要使用的JS接口列表
openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
});
wx.ready(function () {
//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容
wx.updateTimelineShareData({
title: '<?=$share['title']?>', // 分享标题
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
desc: '<?=$share['desc']?>', // 分享描述
success: function () {
// 用户成功分享后执行的回调函数
alert(option.title);
option.success()
},
cancel: function () {
// 用户取消分享后执行的回调函数
option.error()
}
});
//自定义“分享给朋友”及“分享到QQ”按钮的分享内容
wx.updateAppMessageShareData({
title: '<?=$share['title']?>', // 分享标题
desc: '<?=$share['desc']?>', // 分享描述
link: '<?=$share['url']?>', // 分享链接
imgUrl: '<?=$share['img']?>', // 分享图标
success: function () {
// 用户成功分享后执行的回调函数
alert(option.title);
option.success()
},
cancel: function () {
// 用户取消分享后执行的回调函数
option.error()
}
});
});
wx.error(function (res) {
console.log('res', res);
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
});
</script>
</body>
+158
View File
@@ -0,0 +1,158 @@
<body class="bg-f6">
<div id="app">
<div class="container relative pb130">
<!--轮播-->
<div class="goods-banner relative imgsize-750X680 z-index-0">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="item in info.banner">
<img class="imgsize-750X680" :src="item" alt="#" />
</div>
</div>
</div>
<div class="swiper-pagination ulib-rl750 font-22 color-fff"></div>
</div>
<!--end 轮播-->
<div class="relative pl30 pr30 pb30 z-index-1 goods-con">
<div class="relative bg-fff mb30 ml30 mr30 inner40 pr220 ulib-r20 box-shadow-darkGray">
<div class="font-36">{{info.title}}</div>
<div class="mt10 font-22 color-999" v-if="info.e_time>0" v-html="showTime"></div>
<div class="absolute right-0 box-middle mr30 color-fe9538">
<span class="font-28">¥</span>
<span class="font-64">{{info.price}}</span>
</div>
</div>
<div class="relative bg-fff mb30 ml30 mr30 inner40 ulib-r20 box-shadow-darkGray">
<div class="line-height-17 font-28 color-666 text-break" v-html="info.content"></div>
</div>
</div>
<div class="fixed left-0 bottom-0 right-0 inner30 bg-fff z-index-2" >
<a class="block bg-999 pt20 pb20 text-center font-36 color-fff ulib-r10" href="javascript:void(0)" v-if="info.is_pay">已支付</a>
<a @click="toPay" class="block bg-fe9538 pt20 pb20 text-center font-36 color-fff ulib-r10" href="javascript:void(0)" v-else>立即支付</a>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
// info:{
// title:"纳米Box 轻Young空间",
// e_time: 5000,
// price:9.9,
// content:'纳米BOX充分考虑到了用户的用车续航焦虑问题,新车采用了高密度电池组,CLTC续航331km。此外,纳米BOX全系支持快充、慢充功能,快充30分钟可以完成30~80%的补电,慢充4小时即可满电,轻松覆盖日常用车需求。纳米BOX充分考虑到了用户的用车续航焦虑问题,新车采用了高密度电池组,CLTC续航331km。此外,纳米BOX全系支持快充、慢充功能,快充30分钟可以完成30~80%的补电,慢充4小时即可满电,轻松覆盖日常用车需求。',
// "banner": [
// "https://img.zcool.cn/community/0144975f5d8a2711013e3187fe2bb7.jpg@1280w_1l_2o_100sh.jpg",
// "https://qs.haodian.cn/web/images/project/H5-ShiYu/upload/v-5.jpg",
// ],
// },
info : <?=json_encode($info)?>,
bundleIntervalEvent: '',//倒计时
},
created(){
},
computed: {
//用计算属性显示结果
showTime() {
//剩余秒数<=0
if (this.info.e_time <= 0) {
return "已过期";
}
// 剩余秒数>0
else {
let day = Math.floor(this.info.e_time / 86400);
let hour = Math.floor((this.info.e_time % 86400) / 3600);
let min = Math.floor(((this.info.e_time % 86400) % 3600) / 60);
let sec = Math.floor(((this.info.e_time % 86400) % 3600) % 60);
if(day>0){
return ("<span class='text-middle'>距抢购结束还有</span><em class='text-middle pl5 pr5'>"+day+ "</em><em class='text-middle'>天</em><em class='text-middle pl5 pr5'>"+(hour < 10 ? "0" : "") + hour + "</em><em class='text-middle'>时</em><em class='text-middle pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(hour>0){
return ("<span class='text-middle'>距抢购结束还有</span><em class='text-middle color-ff7200 pl5 pr5'>"+(hour < 10 ? "0" : "") + hour + "</em><em class='text-middle'>时</em><em class='text-middle color-ff7200 pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(min>0){
return ("<span class='text-middle'>距抢购结束还有</span><em class='text-middle color-ff7200 pl5 pr5'>" + (min < 10 ? "0" : "") + min + "</em><em class='text-middle'>分</em><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}else if(sec>0){
return ("<span class='text-middle'>距抢购结束还有</span><em class='text-middle color-ff7200 pl5 pr5'>" + (sec <
10 ? "0" : "") + sec+"</em><em class='text-middle'>秒</em>");
}
}
}
},
mounted() {
let that = this
let swiper = new Swiper('.goods-banner .swiper-container', {
//loop: true,
//autoHeight: true,
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
on: {
slideChangeTransitionEnd: function(){
that.activeIndex = this.activeIndex
},
},
});
//倒计时
this.bundleIntervalEvent = setInterval(this.intervalEvent, 1000);
},
beforeDestroy() {
clearInterval(this.bundleIntervalEvent);
},
methods: {
//直播倒计时
intervalEvent() {
if (this.info.e_time > 0) {
this.info.e_time--;
} else {
clearInterval(this.bundleIntervalEvent);
}
},
//支付
toPay(){
$.post('/h5/market/sylive/act/post_pay',{'skey':'<?=$info['skey']?>'},function (res){
if(res.code==200){
var jsondata = res.data;
WeixinJSBridge.invoke(
'getBrandWCPayRequest',
jsondata,
function(res){
if(res.err_msg == "get_brand_wcpay_request:ok" ){//前端返回成功支付
mDialog.msg({
duration: 250,
pause: 2000,
content: "恭喜您购买成功",
onClose:function(){
location.reload();
}
});
}else{
mDialog.msg({content: "支付失败"});
}
}
);
}else{
mDialog.msg({content: res.msg});
}
},'json')
}
},
})
</script>
</body>
+146
View File
@@ -0,0 +1,146 @@
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/clipboard.min.js"></script>
<body>
<div id="app">
<div class="poster">
<div class="detail-banner relative p-swiper">
<div class="swiper-container left-0 top-0">
<div class="swiper-wrapper">
<div class="swiper-slide bg-size-cover" v-for="item in list" >
<div class="relative">
<img class="wp100 block" style="pointer-events:none;" :src="item.img" />
<div class="absolute left-0 right-0 bottom-0 mb30 text-center font-22 color-fff">{{posterTip}}</div>
<img class="absolute right-0 bottom-0 mr40 mb80 imgsize-160X160" style="pointer-events:none;" :src="item.code" />
</div>
</div>
</div>
</div>
<div class="swiper-pagination ulib-rl750"></div>
</div>
</div>
<div class="bts-1-eee inner30">
<div class="text-center">分享文案</div>
<div class="mt30 bds-1-eee inner30 ulib-r20 font-28" v-for="(item,index) in shareTx">
<span>{{item}}</span>
<div class="text-right"><a class="inline-block pl30 pr30 line-height-17 bg-eee ulib-r750 J_copy" :data-clipboard-text="item">复制</a></div>
</div>
</div>
<div @click="showPoster">
<div style="height:70px;"></div>
<div class="fixed left-0 bottom-0 right-0 bg-000-op80 pl30 pr30 text-center z-index-4" style="height:65px;padding-top:10px;">
<div style="width:100%;height:45px;background-color:#f55537;-webkit-border-radius:750px;border-radius:750px;">
<button style="width:100%;height:45px;background-color:#f55537;border:none;line-height:45px;font-size:16px;color:#fff;-webkit-border-radius:750px;border-radius:750px;">生成海报</button>
</div>
</div>
</div>
<div class="msg fn-hide" :style="msgisShowPoster?'display:block':'display:none'">
<div class="msgBgPoster" @click="closePoster"></div>
<div class="msgMain">
<i @click="closePoster" class="posterClose" v-if="posterSrc"><span></span></i>
<div class="msgPoster">
<div class="postercon overflowhidden ulib-r20">
<div style="display:none;">
<canvas id="canvas"></canvas>
</div>
<div v-if="posterSrc"><img class="wp100 ulib-r20" :src='posterSrc' alt="" /></div>
</div>
<div class="pt30 pb10 text-center text-center font-30 color-fff" v-if="posterSrc">
<img class="inline-block imgsize-42X42 text-middle" src="https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-finger.png" alt="" />
<span class="ml10 text-middle">长按图片保存到手机发送给好友</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
list:<?=json_encode($lists,JSON_UNESCAPED_UNICODE)?>,
msgisShowPoster: false,
canW:750,
canH:0,
activeIndex:0,
posterSrc:'',
posterTip:'<?=$posterTip?>',
shareTx:<?=json_encode($shareTitle,JSON_UNESCAPED_UNICODE)?>,
},
mounted() {
//复制文字
let clipboardDemos = new ClipboardJS('.J_copy');
clipboardDemos.on('success', function (e) {
e.clearSelection();
var msgDia = mDialog.msg({
duration: 250,
pause: 2000,
content: "复制成功!"
});
});
let that = this
let swiper = new Swiper('.p-swiper .swiper-container', {
//loop: true,
//autoHeight: true,
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
on: {
slideChangeTransitionEnd: function(){
that.activeIndex = this.activeIndex
},
},
});
},
methods: {
showPoster: function() {
this.msgisShowPoster = true
this.posterSrc= ''
this.draw()
},
closePoster: function() {
this.msgisShowPoster = false
},
//海报生成
draw() {
let that = this
that.canH = that.list[that.activeIndex].height/that.list[that.activeIndex].width*that.canW
$("#canvas").attr({
'width': that.canW,
'height': that.canH,
});
let canvas = document.getElementById('canvas');
let ctx = canvas.getContext("2d");
let imgBg = new Image();
imgBg.setAttribute("crossOrigin",'Anonymous')//如果二维码图片域名跨域,则保留此代码
imgBg.src = that.list[that.activeIndex].img
imgBg.onload = function () {
ctx.drawImage(imgBg, 0, 0, that.list[that.activeIndex].width, that.list[that.activeIndex].height, 0, 0, that.canW, that.canH)
let codeimg = new Image();
codeimg.setAttribute("crossOrigin",'Anonymous')//如果二维码图片域名跨域,则保留此代码
codeimg.src = that.list[that.activeIndex].code
codeimg.onload = function () {
ctx.fillStyle="#fff";
ctx.textAlign="center";
ctx.font="22px Georgia";
ctx.fillText(that.posterTip,that.canW/2,that.canH-34,);
ctx.drawImage(codeimg,that.canW-200, that.canH-240, 160, 160)
that.posterSrc = canvas.toDataURL("image/jpg");
}
}
}
},
})
</script>
</body>
@@ -0,0 +1,79 @@
<body class="bg-f6">
<div id="app">
<div class="container relative pb130">
<!--轮播-->
<div class="goods-banner relative imgsize-750X680 z-index-0">
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" v-for="item in info.banner">
<img class="imgsize-750X680" :src="item" alt="#" />
</div>
</div>
</div>
<div class="swiper-pagination ulib-rl750 font-22 color-fff"></div>
</div>
<!--end 轮播-->
<div class="relative pl30 pr30 pb30 z-index-1 goods-con" v-if="info.title">
<div class="relative bg-fff mb30 ml30 mr30 inner40 ulib-r20 box-shadow-darkGray">
<div class="text-center">{{info.title}}</div>
<div class="mt20 line-height-17 font-28 color-666 text-break" v-html="info.content"></div>
</div>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
// info:{
// title:"2022-08-19 直播间活动权益",
// content:'纳米BOX充分考虑到了用户的用车续航焦虑问题,新车采用了高密度电池组,CLTC续航331km。此外,纳米BOX全系支持快充、慢充功能,快充30分钟可以完成30~80%的补电,慢充4小时即可满电,轻松覆盖日常用车需求。纳米BOX充分考虑到了用户的用车续航焦虑问题,新车采用了高密度电池组,CLTC续航331km。此外,纳米BOX全系支持快充、慢充功能,快充30分钟可以完成30~80%的补电,慢充4小时即可满电,轻松覆盖日常用车需求。',
// "banner": [
// "https://img.zcool.cn/community/0144975f5d8a2711013e3187fe2bb7.jpg@1280w_1l_2o_100sh.jpg",
// "https://qs.haodian.cn/web/images/project/H5-ShiYu/upload/v-5.jpg",
// ],
// },
info:<?=json_encode($info,JSON_UNESCAPED_UNICODE)?>,
},
created(){
},
computed: {
},
mounted() {
let that = this
let swiper = new Swiper('.goods-banner .swiper-container', {
//loop: true,
//autoHeight: true,
pagination: {
el: '.swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
on: {
slideChangeTransitionEnd: function(){
that.activeIndex = this.activeIndex
},
},
});
},
beforeDestroy() {
},
methods: {
},
})
</script>
</body>
+192
View File
@@ -0,0 +1,192 @@
<body class="bg-f6">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top" style="background-image:url(https://qs.haodian.cn/web/images/project/H5-ShiYu/theme-bg.png)">
<div class="pt30 pb30">
<div class="pl30 pr30">
<img class="text-middle imgsize-35X35 ulib-r750" :src="info.headimg" alt="#" />
<span class="text-middle font-22 color-fff">{{info.nickname}}</span>
</div>
<div class="fn-flex mt40 text-center color-fff">
<div class="fn-flex-item" v-for="item in info.count">
<div class="font-40">{{item.num}}</div>
<div class="mt15 font-28">
<i :class="'iconfont font-24 text-middle ' + item.icon"></i><span class="ml5 text-middle">{{item.title}}</span>
</div>
</div>
</div>
</div>
<div id="main" class="bg-fff mt10 ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:75vh;">
<div v-if="tabFixed">
<div class="height-60"></div>
<div class="fixed top-0 left-0 right-0 z-index-10 bg-fff pl30 pr30 pt20 pb20">
<div class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</div>
</div>
<div v-else class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
<div class="pt30">
<!--大区列表-->
<div v-if="tabid==1">
<a class="block relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list" :href="item.url">
<div class="font-32">{{item.title}}</div>
<div class="mt20 font-22 color-999">
<span><i class="iconfont icon-mendian text-middle"></i><span class="text-middle ml10 fongt-22">门店</span><span class="text-middle ml10 fongt-22">{{item.storenum}}</span></span>
<span class="ml20"><i class="iconfont icon-huodong text-middle"></i><span class="text-middle ml10 fongt-22">活动</span><span class="text-middle ml10 fongt-22">{{item.activitynum}}</span></span>
</div>
<div class="absolute right-0 box-middle pr30">
<span :class="'inline-block pl10 pr10 line-height-15 text-middle ulib-r750 font-22 color-fff '+item.state.class" v-if="item.state.title">{{item.state.title}}</span>
<i class="text-middle iconfont icon-gengduo text-middle font-28 color-666"></i>
</div>
</a>
</div>
<!--end大区列表-->
<!--活动列表列表-->
<div v-if="tabid==2">
<a class="block relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list" :href="item.url">
<div class="font-32">{{item.title}}</div>
<div class="mt20 font-22 color-999">{{item.time}}</div>
<div class="absolute right-0 box-middle pr30">
<span :class="'inline-block pl10 pr10 line-height-15 text-middle ulib-r750 font-22 color-fff '+item.state.class" v-if="item.state.title">{{item.state.title}}</span>
<i class="text-middle iconfont icon-gengduo text-middle font-28 color-666"></i>
</div>
</a>
</div>
<!--end活动列表-->
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle fongt-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle fongt-22">请稍等...</span></div>
<div class="pt20 pb20 text-center fongt-22 color-ccc" v-else-if="isDataEnd">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
tabFixed:false,
tabIndex:0,
tabid:'1',//1大区列表 /2活动列表
info:'',//基础信息
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
list:[],
},
created(){
},
computed: {
},
mounted() {
window.addEventListener('scroll', this.handleScroll, true)
this.getInfo()
},
beforeDestroy() {
},
//离开页面时
destroyed () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
//获取基础信息
getInfo(){
var that = this;
$.get('/h5/market/sylive/biz/nav',function (result) {
that.info = result.data
},'json')
},
//tab切换
changeTab(id,index){
if(id != this.tabid&&!this.loading){
if(this.tabFixed){
let mainoffsetTop = document.querySelector('#main').offsetTop
$('html,body').animate({scrollTop: mainoffsetTop+5},500);
}
this.tabid = id
this.tabIndex = index
this.isDataEnd = false
this.isNoData = false
this.page = 1
this.list = []
if(this.tabid == 1){
this.getRegionList()
}else if(this.tabid == 2){
this.getActivityList()
}
}
},
//判断导航是否需要吸顶
handleScroll () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
let mainoffsetTop = document.querySelector('#main').offsetTop
if (scrollTop > mainoffsetTop) {
this.tabFixed = true
} else {
this.tabFixed = false
}
},
//拉取数据
fetchData: function() {
if(this.tabid == 1){
this.getRegionList()
}else if(this.tabid == 2){
this.getActivityList()
}
},
//获取大区列表
getRegionList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
$.get('/h5/market/sylive/biz/area_lists',{'page':that.page},function (result) {
that.loading = false;
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
},'json')
}
},
//获取活动列表
getActivityList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/biz/act_list',{'page':that.page},function (result) {
that.loading = false;
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
},'json')
}
},
},
})
</script>
</body>
+103
View File
@@ -0,0 +1,103 @@
<body class="bg-f6">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pb50" style="background-image:url(https://qs.haodian.cn/web/images/project/H5-ShiYu/theme-bg.png)">
<div class="pt30 pb60">
<div class="relative pl30 pr30 fn-clear">
<?if($group_id<2){?>
<a class="fn-fr font-22 color-fff bg-000-op50 ulib-r750 pt5 pb5 pl10 pr10" href="/h5/market/sylive/biz/lists?area_id=<?=$area_id?>">
<i class="iconfont icon-qiehuan text-middle"></i><span class="text-middle ml10">切换门店</span>
</a>
<?}?>
</div>
</div>
<div class="relative bg-fff mt10 ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:75vh;">
<img class="absolute top--60 box-center bds-1-fff imgsize-120X120 ulib-r750 z-index-1" :src="info.logo" alt="#" />
<div class="pt50 font-36 text-center">{{info.title}}</div>
<div class="pt50">
<!--活动列表列表-->
<a class="block relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list" :href="item.url">
<div class="font-32">{{item.title}}</div>
<div class="mt20 font-22 color-999">{{item.time}}</div>
<div class="absolute right-0 box-middle pr30">
<span :class="'inline-block pl10 pr10 line-height-15 text-middle ulib-r750 font-22 color-fff '+item.state.class" v-if="item.state.title">{{item.state.title}}</span>
<i class="text-middle iconfont icon-gengduo text-middle font-28 color-666"></i>
</div>
</a>
<!--end活动列表-->
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle fongt-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle fongt-22">请稍等...</span></div>
<div class="pt20 pb20 text-center fongt-22 color-ccc" v-else-if="isDataEnd">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
info:'',//基础信息
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
list:[],
},
created(){
},
computed: {
},
mounted() {
this.getInfo()
},
beforeDestroy() {
},
//离开页面时
destroyed () {
},
methods: {
//获取基础信息
getInfo(){
this.info = {
title:"<?=$biz_name?>",
logo:"<?=$headimg?>",
}
},
//拉取数据
fetchData: function() {
this.getActivityList()
},
//获取大区列表
getActivityList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
//请求接口
$.get('/h5/market/sylive/biz/act_list',{'biz_id':<?=$biz_id ? $biz_id : 0?>,'page':that.page},function (result) {
that.loading = false;
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
},'json')
}
},
},
})
</script>
</body>
+199
View File
@@ -0,0 +1,199 @@
<body class="bg-f6">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pb50" style="background-image:url(https://qs.haodian.cn/web/images/project/H5-ShiYu/theme-bg.png)">
<div class="pt30 pb30">
<div class="relative pl30 pr30 fn-clear">
<div class="fn-fl">
<img class="text-middle imgsize-35X35 ulib-r750" :src="info.headimg" alt="#" />
<span class="text-middle font-22 color-fff">{{info.nickname}}</span>
</div>
<?if(!$group_id){?>
<a class="fn-fr font-22 color-fff bg-000-op50 ulib-r750 pt5 pb5 pl10 pr10" href="/h5/market/sylive/biz/brands">
<i class="iconfont icon-qiehuan text-middle"></i><span class="text-middle ml10">切换区域</span>
</a>
<?}?>
</div>
<div class="fn-flex mt40 text-center color-fff">
<div class="fn-flex-item" v-for="item in info.count">
<div class="font-40">{{item.num}}</div>
<i :class="'iconfont font-24 text-middle ' + item.icon"></i><span class="ml5 text-middle">{{item.title}}</span>
</div>
</div>
</div>
<div id="main" class="bg-fff mt10 ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:75vh;">
<div v-if="tabFixed">
<div class="height-60"></div>
<div class="fixed top-0 left-0 right-0 z-index-10 bg-fff pl30 pr30 pt20 pb20">
<div class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</div>
</div>
<div v-else class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
<div class="pt30">
<!--大区列表-->
<div v-if="tabid==1">
<a class="block relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list" :href="item.url">
<div class="font-32">{{item.title}}</div>
<div class="mt20 font-22 color-999">
<span><i class="iconfont icon-wode text-middle"></i><span class="text-middle ml10 fongt-22">顾问</span><span class="text-middle ml10 fongt-22">{{item.storenum}}</span></span>
<span class="ml20"><i class="iconfont icon-huodong text-middle"></i><span class="text-middle ml10 fongt-22">活动</span><span class="text-middle ml10 fongt-22">{{item.activitynum}}</span></span>
</div>
<div class="absolute right-0 box-middle pr30">
<span :class="'inline-block pl10 pr10 line-height-15 text-middle ulib-r750 font-22 color-fff '+item.state.class" v-if="item.state.title">{{item.state.title}}</span>
<i class="text-middle iconfont icon-gengduo text-middle font-28 color-666"></i>
</div>
</a>
</div>
<!--end大区列表-->
<!--活动列表列表-->
<div v-if="tabid==2">
<a class="block relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list" :href="item.url">
<div class="font-32">{{item.title}}</div>
<div class="mt20 font-22 color-999">{{item.time}}</div>
<div class="absolute right-0 box-middle pr30">
<span :class="'inline-block pl10 pr10 line-height-15 text-middle ulib-r750 font-22 color-fff '+item.state.class" v-if="item.state.title">{{item.state.title}}</span>
<i class="text-middle iconfont icon-gengduo text-middle font-28 color-666"></i>
</div>
</a>
</div>
<!--end活动列表-->
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle fongt-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle fongt-22">请稍等...</span></div>
<div class="pt20 pb20 text-center fongt-22 color-ccc" v-else-if="isDataEnd">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
tabFixed:false,
tabIndex:0,
tabid:'1',//1大区列表 /2活动列表
info:'',//基础信息
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
list:[],
},
created(){
},
computed: {
},
mounted() {
window.addEventListener('scroll', this.handleScroll, true)
this.getInfo()
},
beforeDestroy() {
},
//离开页面时
destroyed () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
//获取基础信息
getInfo(){
var that = this;
$.get('/h5/market/sylive/biz/nav',{'area_id':<?=$area_id ? $area_id : 0?>},function (result) {
that.info = result.data
},'json')
},
//tab切换
changeTab(id,index){
if(id != this.tabid&&!this.loading){
if(this.tabFixed){
let mainoffsetTop = document.querySelector('#main').offsetTop
$('html,body').animate({scrollTop: mainoffsetTop+5},500);
}
this.tabid = id
this.tabIndex = index
this.isDataEnd = false
this.isNoData = false
this.page = 1
this.list = []
if(this.tabid == 1){
this.getRegionList()
}else if(this.tabid == 2){
this.getActivityList()
}
}
},
//判断导航是否需要吸顶
handleScroll () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
let mainoffsetTop = document.querySelector('#main').offsetTop
if (scrollTop > mainoffsetTop) {
this.tabFixed = true
} else {
this.tabFixed = false
}
},
//拉取数据
fetchData: function() {
if(this.tabid == 1){
this.getRegionList()
}else if(this.tabid == 2){
this.getActivityList()
}
},
//获取大区列表
getRegionList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/biz/biz_lists',{'area_id':<?=$area_id ? $area_id : 0?>},function (result) {
that.loading = false;
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
},'json')
}
},
//获取大区列表
getActivityList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/biz/act_list',{'area_id':<?=$area_id ? $area_id : 0?>,'page':that.page},function (result) {
that.loading = false;
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
},'json')
}
},
},
})
</script>
</body>
+1
View File
@@ -0,0 +1 @@
</html>
+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?=$_title?></title>
<link rel="stylesheet" href="/css/h5/market/sylive/h5.css?20220928">
<link rel="stylesheet" href="https://qs.haodian.cn/web/javascript/swiper/css/swiper.min.css">
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/mDialog.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/swiper/js/swiper.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript//vue-mugen-scroll.js"></script>
</head>
+165
View File
@@ -0,0 +1,165 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?=$_title?></title>
<link rel="stylesheet" href="/css/h5/market/sylive/h5.css?2022">
<link rel="stylesheet" href="https://qs.haodian.cn/web/javascript/swiper/css/swiper.min.css">
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/mDialog.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/swiper/js/swiper.min.js"></script>
</head>
<body class="bg-fff">
<div id="app" class="login">
<div class="container relative bg-repeat-y bg-size-fullwidth bg-pos-center" style="background-image:url(https://qs.haodian.cn/web/images/project/H5-ShiYu/loginbg.jpg)">
<div class="absolute box-middle left-0 right-0 pl40 pr40 pb220">
<div class="pb50 color-fff">
<div class="font-64">您好!</div>
<div class="mt20 font-36">欢迎来到东风EV</div>
</div>
<div class="bg-fff pl50 pr50 pt60 pb60 ulib-r20">
<div class="text-center font-56">登录</div>
<div class="relative mt40 bg-f6 ulib-r10">
<input class="wp100 pt30 pb30 pl20 pr20 bg-f6 border-none font-32 ulib-r10" type="tel" v-model="telPhone" placeholder="请输入手机号" />
</div>
<div class="relative mt30 pr120 bg-f6 ulib-r10">
<input class="wp100 pt30 pb30 pl20 pr20 bg-f6 border-none font-32 ulib-r10" type="number" v-model="vCode" placeholder="请输入验证码" />
<button class="absolute right-0 box-middle mr15 bg-f6 border-none font-32 color-fe9538" :disabled="!codeState" @click="getcode()">{{codeTx}}</button>
</div>
<!--
<div class="mt30 fn-clear font-28">
<div class="fn-fl">
<label>
<input type="checkbox" class="checkbox-input" v-model="rememberMe" />
<span>记住账号</span>
</label>
</div>
</div>
-->
<button class="mt40 wp100 bg-fe9538 border-none pt30 pb30 font-32 color-fff ulib-r10" @click="submit()">登录</button>
</div>
</div>
<div class="absolute bottom-0 left-0 right-0 pl40 pr40 pb80 text-center color-fff">
<div class="font-22">联系我们</div>
<div class="mt10 font-28">400-5555-888</div>
</div>
</div>
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
telPhone:'',
vCode:'',
codeState:true,
codeTx:'获取验证码',
isSubmiting: false,
rememberMe: true,
},
computed: {
},
mounted() {
var Timer;
},
beforeDestroy() {
},
methods: {
countDownTime(time) {
let that = this;
if (time > 1) {
time--;
this.codeState = false;
this.codeTx = time + "s后重新获取";
Timer = setTimeout(function() {
that.countDownTime(time);
}, 1000)
} else {
clearTimeout(Timer);
that.codeState = true;
that.codeTx = "获取验证码";
}
},
getcode() {
if (!/^1[3456789]\d{9}$/.test(this.telPhone)) {
//alert('请输入正确手机号')
mDialog.msg({
duration: 250,
pause: 2000,
content: "请输入正确手机号"
});
} else {
//按钮倒计时
var that = this;
$.post('/h5/market/sylive/login/get_code',{'mobile':this.telPhone},function (response){
mDialog.msg({
duration: 250,
pause: 2000,
content: response.msg
});
if(response.code==200){
that.countDownTime(61)
}
},'json')
}
},
submit() {
console.log(this.rememberMe)
if (this.isSubmiting) return;
if (!/^1[3456789]\d{9}$/.test(this.telPhone)) {
mDialog.msg({
duration: 250,
pause: 2000,
content: "请输入正确手机号"
});
}else if (!this.vCode) {
mDialog.msg({
duration: 250,
pause: 2000,
content: "请输入验证码"
});
}else{
// this.isSubmiting = true
$.post('/h5/market/sylive/login',{'mobile':this.telPhone,'code':this.vCode,'remember':this.rememberMe},function (response){
if(response.code==200){
mDialog.msg({
duration: 250,
pause: 2000,
content: response.msg,
onClose:function(){
window.location = '/h5/market/sylive'
}
});
}else{
mDialog.msg({
duration: 250,
pause: 2000,
content: response.msg
});
}
},'json')
}
},
},
})
</script>
</body>
</html>
+294
View File
@@ -0,0 +1,294 @@
<body class="bg-fff">
<div id="app">
<div class="container bg-size-fullwidth bg-no-repeat bg-pos-top pb130" :style="'background-image:url('+info.theme+')'">
<div class="h-290"></div>
<div id="main" class="bg-fff mb30 ml30 mr30 inner30 box-shadow-lightGray ulib-r20" style="min-height:72vh;">
<div v-if="tabFixed">
<div class="height-60"></div>
<div class="fixed top-0 left-0 right-0 z-index-10 bg-fff pl30 pr30 pt20 pb20">
<div class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</div>
</div>
<div v-else class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
<!--预热阶段-->
<div v-if="tabid==1">
<div class="mt30 overflowhidden ulib-r20">
<div class="bg-fff5ec fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in begin.cell1">
<div class="font-32 color-fe9538">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
<div class="bg-f6 fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in begin.cell2">
<div class="font-32">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
</div>
<div class="mt30 bg-f9 inner40 overflowhidden ulib-r20">
<div class="pb20 fn-clear">
<b class="fn-fl font-40 text-italic" v-html="begin.browse.title"></b>
<a class="mt5 fn-fr font-28" :href="begin.browse.url">查看更多<i class="iconfont icon-gengduo"></i></a>
</div>
<div v-if="begin.browse.list.length>0">
<div class="font-32 color-666" v-for="(item,index) in begin.browse.list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp70 text-nowrap">
<img class="imgsize-42X42 text-middle" v-if="item.ranking<4" :src="'https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-ranking-'+item.ranking+'.png'" alt="#" />
<span class="inline-block w-50 text-center text-middle" v-else>{{item.ranking}}</span>
<span class="text-middle">{{item.name}}</span>
<span class="inline-block pl10 pr10 line-height-15 text-middle bg-fe9538 font-22 color-fff ulib-r750" v-if="item.tip">{{item.tip}}</span>
</div>
<div class="fn-fr">{{item.num}}</div>
</div>
</div>
</div>
<div class="pt100 pb100 text-center font-32 color-666" v-else>暂时无数据</div>
</div>
<div class="mt30 bg-f9 inner40 overflowhidden ulib-r20">
<div class="pb20 fn-clear">
<b class="fn-fl font-40 text-italic" v-html="begin.book.title"></b>
<a class="mt5 fn-fr font-28" :href="begin.book.url">查看更多<i class="iconfont icon-gengduo"></i></a>
</div>
<div v-if="begin.book.list.length>0">
<div class="font-32 color-666" v-for="(item,index) in begin.book.list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp70 text-nowrap">
<img class="imgsize-42X42 text-middle" v-if="item.ranking<4" :src="'https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-ranking-'+item.ranking+'.png'" alt="#" />
<span class="inline-block w-50 text-center text-middle" v-else>{{item.ranking}}</span>
<span class="text-middle">{{item.name}}</span>
<span class="inline-block pl10 pr10 line-height-15 text-middle bg-fe9538 font-22 color-fff ulib-r750" v-if="item.tip">{{item.tip}}</span>
</div>
<div class="fn-fr">{{item.num}}</div>
</div>
</div>
</div>
<div class="pt100 pb100 text-center font-32 color-666" v-else>暂时无数据</div>
</div>
</div>
<!-- end 预热阶段-->
<!--直播阶段-->
<div v-if="tabid==2">
<div class="mt30 overflowhidden ulib-r20">
<div class="bg-fff5ec fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in live.cell1">
<div class="font-32 color-fe9538">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
<div class="bg-f6 fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in live.cell2">
<div class="font-32">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
<div class="bg-fff5ec fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in live.cell3">
<div class="font-32">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
</div>
<div class="mt30 bg-f9 inner40 overflowhidden ulib-r20">
<div class="pb20 fn-clear">
<b class="fn-fl font-40 text-italic" v-html="live.view.title"></b>
<a class="mt5 fn-fr font-28" :href="live.view.url">查看更多<i class="iconfont icon-gengduo"></i></a>
</div>
<div v-if="live.view.list.length>0">
<div class="font-32 color-666" v-for="(item,index) in live.view.list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp70 text-nowrap">
<img class="imgsize-42X42 text-middle" v-if="item.ranking<4" :src="'https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-ranking-'+item.ranking+'.png'" alt="#" />
<span class="inline-block w-50 text-center text-middle" v-else>{{item.ranking}}</span>
<span class="text-middle">{{item.name}}</span>
<span class="inline-block pl10 pr10 line-height-15 text-middle bg-fe9538 font-22 color-fff ulib-r750" v-if="item.tip">{{item.tip}}</span>
</div>
<div class="fn-fr">{{item.num}}</div>
</div>
</div>
</div>
<div class="pt100 pb100 text-center font-32 color-666" v-else>暂时无数据</div>
</div>
<div class="mt30 bg-f9 inner40 overflowhidden ulib-r20">
<div class="pb20 fn-clear">
<b class="fn-fl font-40 text-italic" v-html="live.order.title"></b>
<a class="mt5 fn-fr font-28" :href="live.order.url">查看更多<i class="iconfont icon-gengduo"></i></a>
</div>
<div v-if="live.order.list.length>0">
<div class="font-32 color-666" v-for="(item,index) in live.order.list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp70 text-nowrap">
<img class="imgsize-42X42 text-middle" v-if="item.ranking<4" :src="'https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-ranking-'+item.ranking+'.png'" alt="#" />
<span class="inline-block w-50 text-center text-middle" v-else>{{item.ranking}}</span>
<span class="text-middle">{{item.name}}</span>
<span class="inline-block pl10 pr10 line-height-15 text-middle bg-fe9538 font-22 color-fff ulib-r750" v-if="item.tip">{{item.tip}}</span>
</div>
<div class="fn-fr">{{item.num}}</div>
</div>
</div>
</div>
<div class="pt100 pb100 text-center font-32 color-666" v-else>暂时无数据</div>
</div>
</div>
<!-- end 直播阶段-->
</div>
<div class="fixed left-0 bottom-0 right-0 inner30 bg-fff" ><a class="block bg-fe9538 pt20 pb20 text-center font-36 color-fff ulib-r10" :href="info.url">进入活动</a></div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
tabFixed:false,
tabIndex:0,
tabid:'1',//1预热阶段 /2直播阶段
info:'',
loading: false,
begin:{
cell1:[],
cell2:[],
browse:{
title:'',
url:'',
list:[],
},
book:{
title:'',
url:'',
list:[],
}
},
live:{
cell1:[],
cell2:[],
cell3:[],
view:{
title:'',
url:'',
list:[],
},
order:{
title:'',
url:'',
list:[],
}
},
},
created(){
},
computed: {
},
mounted() {
window.addEventListener('scroll', this.handleScroll, true)
this.getInfo()
this.getBegin()
},
beforeDestroy() {
},
//离开页面时
destroyed () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
//判断导航是否需要吸顶
handleScroll () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
let mainoffsetTop = document.querySelector('#main').offsetTop
if (scrollTop > mainoffsetTop) {
this.tabFixed = true
} else {
this.tabFixed = false
}
},
//获取基础信息
getInfo(){
this.info = {
theme:'https://qs.haodian.cn/web/images/project/H5-ShiYu/upload/upload-1.jpg',
tab:[
{
id:'1',
title:'预热阶段',
},
{
id:'2',
title:'直播阶段',
},
],
url:'/h5/market/sylive/act?skey=<?=$skey?>',
}
},
//tab切换
changeTab(id,index){
if(id != this.tabid&&!this.loading){
if(this.tabFixed){
let mainoffsetTop = document.querySelector('#main').offsetTop
$('html,body').animate({scrollTop: mainoffsetTop+5},500);
}
this.tabid = id
this.tabIndex = index
if(this.tabid == 1){
this.getBegin()
}else if(this.tabid == 2){
this.getLive()
}
}
},
//预热阶段数据
getBegin(){
let that=this;
if (!that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/stic/lists_ready',{'skey':'<?=$skey?>'},function (result){
that.loading = false;
if(result.data){
that.begin = result.data
}
console.dir(that.begin)
},'json');
}
},
//直播阶段数据
getLive(){
let that=this;
if (!that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/stic/lists_live',{'skey':'<?=$skey?>'},function (result){
that.loading = false;
if(result.data){
that.live = result.data
}
},'json');
}
},
},
})
</script>
</body>
+222
View File
@@ -0,0 +1,222 @@
<body class="bg-fff">
<div id="app">
<div class="container bg-size-fullwidth bg-no-repeat bg-pos-top pb130" :style="'background-image:url('+info.theme+')'">
<div class="h-290"></div>
<div id="main" class="bg-fff mb30 ml30 mr30 inner30 box-shadow-lightGray ulib-r20" style="min-height:72vh;">
<div v-if="tabFixed">
<div class="height-60"></div>
<div class="fixed top-0 left-0 right-0 z-index-10 bg-fff pl30 pr30 pt20 pb20">
<div class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</div>
</div>
<div v-else class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in info.tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
<!--预热阶段-->
<div v-if="tabid==1">
<div class="mt30 overflowhidden ulib-r20">
<div class="bg-fff5ec fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in begin.cell1">
<div class="font-32 color-fe9538">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
</div>
</div>
<!-- end 预热阶段-->
<!--直播阶段-->
<div v-if="tabid==2">
<div class="mt30 overflowhidden ulib-r20">
<div class="bg-fff5ec fn-flex text-center">
<div class="fn-flex-item pt40 pb40" v-for="item in live.cell1">
<div class="font-32 color-fe9538">{{item.num}}</div>
<div class="mt10 font-22 color-666">{{item.title}}</div>
</div>
</div>
</div>
</div>
<!-- end 直播阶段-->
<!--实时动态-->
<div class="mt30 bg-f9 inner40 overflowhidden ulib-r20">
<div class="pb20 fn-clear">
<b class="fn-fl font-40 text-italic" v-html="dynamic.title"></b>
</div>
<div class="font-28" v-for="(item,index) in dynamic.list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp60 text-nowrap">
<span class="text-middle">{{item.nickname}}</span>
<span class="text-middle color-666">{{item.action}}</span>
</div>
<div class="fn-fr">{{item.time}}</div>
</div>
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle fongt-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle fongt-22">请稍等...</span></div>
<div class="pt20 pb20 text-center fongt-22 color-ccc" v-else-if="isDataEnd">我们是有底线的</div>
</mugen-scroll>
</div>
<!-- end 实时动态-->
</div>
<div class="fixed left-0 bottom-0 right-0 inner30 bg-fff" ><a class="block bg-fe9538 pt20 pb20 text-center font-36 color-fff ulib-r10" :href="info.url">进入活动</a></div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
tabFixed:false,
tabIndex:0,
tabid:'1',//1预热阶段 /2直播阶段
info:{
theme:'',
tab:[],
},
loading: false,
begin:{
cell1:<?=json_encode($info['begin'])?>,
},
live:{
cell1:<?=json_encode($info['live'])?>,
},
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
dynamic:{
title:'',
list:[],
},
},
created(){
},
computed: {
},
mounted() {
window.addEventListener('scroll', this.handleScroll, true)
this.getInfo()
},
beforeDestroy() {
},
//离开页面时
destroyed () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
//判断导航是否需要吸顶
handleScroll () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
let mainoffsetTop = document.querySelector('#main').offsetTop
if (scrollTop > mainoffsetTop) {
this.tabFixed = true
} else {
this.tabFixed = false
}
},
//获取基础信息
getInfo(){
this.info = {
theme:'https://qs.haodian.cn/web/images/project/H5-ShiYu/upload/upload-1.jpg',
tab:[
{
id:'1',
title:'预热阶段',
},
{
id:'2',
title:'直播阶段',
},
],
url:'/h5/market/sylive/act?skey=<?=$skey?>',
}
},
//tab切换
changeTab(id,index){
if(id != this.tabid&&!this.loading){
if(this.tabFixed){
let mainoffsetTop = document.querySelector('#main').offsetTop
$('html,body').animate({scrollTop: mainoffsetTop+5},500);
}
this.tabid = id
this.tabIndex = index
// if(this.tabid == 1){
// this.getBegin()
// }else if(this.tabid == 2){
// this.getLive()
// }
}
},
//预热阶段数据
getBegin(){
let that=this;
if (!that.loading) {
that.loading = true;
//请求接口
//请求接口成功后
that.loading = false;
that.begin = {
cell1:<?=json_encode($info['begin'])?>,
}
}
},
//直播阶段数据
getLive(){
let that=this;
if (!that.loading) {
that.loading = true;
//请求接口
//请求接口成功后
that.loading = false;
that.live = {
cell1:<?=json_encode($info['live'])?>,
}
}
},
//拉取数据
fetchData: function() {
this.getDynamicList()
},
//获取实时动态
getDynamicList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/stic/event',{'skey':'<?=$skey?>','page':that.page},function (res){
that.loading = false;
that.page = that.page + 1;
that.dynamic.title = '实时<span class="color-fe9538">动态</span>';
that.dynamic.list = that.dynamic.list.concat(res.data.lists);
if (res.data.total == 0) {
that.isNoData = true;
} else if (that.dynamic.list.length == res.data.total) {
that.isDataEnd = true;
}
console.dir(that.begin)
},'json');
}
},
},
})
</script>
</body>
+83
View File
@@ -0,0 +1,83 @@
<body class="bg-f6">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pt30 pb50">
<div class="relative bg-fff ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:90vh;">
<div class="pt10 pb20 text-center"><b class="font-40 text-italic" v-html="title"></b></div>
<div class="font-32 color-666" v-for="(item,index) in list">
<div class="pt20 pb20 fn-clear">
<div class="fn-fl wp70 text-nowrap">
<img class="imgsize-42X42 text-middle" v-if="item.ranking<4" :src="'https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-ranking-'+item.ranking+'.png'" alt="#" />
<span class="inline-block w-50 text-center text-middle" v-else>{{item.ranking}}</span>
<span class="text-middle">{{item.name}}</span>
<span class="inline-block pl10 pr10 line-height-15 text-middle bg-fe9538 font-22 color-fff ulib-r750" v-if="item.tip">{{item.tip}}</span>
</div>
<div class="fn-fr">{{item.num}}</div>
</div>
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle fongt-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle fongt-22">请稍等...</span></div>
<div class="pt20 pb20 text-center fongt-22 color-ccc" v-else-if="isDataEnd">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
</div>
<script>
let hostUrl = ''
var app = new Vue({
el: '#app',
data: {
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
title:'',
list:[],
},
created(){
},
computed: {
},
mounted() {
},
beforeDestroy() {
},
//离开页面时
destroyed () {
},
methods: {
//拉取数据
fetchData: function() {
this.getMoreList()
},
//获取大区列表
getMoreList(){
let that=this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/stic/rank',{'skey':'<?=$params['skey']?>','type':'<?=$params['type']?>','page':that.page},function (res){
that.loading = false;
that.page = that.page + 1;
that.title = res.data.title
that.list = that.list.concat(res.data.lists);
if (res.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == res.data.total) {
that.isDataEnd = true;
}
},'json');
}
},
},
})
</script>
</body>
+6
View File
@@ -0,0 +1,6 @@
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* Created by PhpStorm.
* User: linfan
* Date: 2018-12-04
* Time: 15:51
*/
defined('BASEPATH') OR exit('No direct script access allowed');
$config = array(
'liche' => array(
'id' => 1,
'app_id' => 1,
'name' => '狸车',
'sign_key' => 'bcdb554f61e320e1d1c2e858c147e83c',
'wx' => array(
'appid' => 'wx98e64c11aac45966',
'secret' => 'f8eec7be1c87a1c8e40213e144821ec3',
),
'model' => array('user_model' => 'app/liche/app_liche_users_model')
),
'licheb' => array(
'id' => 2,
'app_id' => 2,
'name' => '狸车宝',
'sign_key' => '71fd71173b776766a2ae1209d9a2c2ed',
'wx' => array(
'appid' => 'wx71095d4049de3ed1',
'secret' => 'a80eb6ed68d7bae2d804fe507a4522f7',
),
'model' => array('user_model' => 'app/licheb/app_licheb_users_model')
),
);
+135
View File
@@ -0,0 +1,135 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| AUTO-LOADER
| -------------------------------------------------------------------
| This file specifies which systems should be loaded by default.
|
| In order to keep the framework as light-weight as possible only the
| absolute minimal resources are loaded by default. For example,
| the database is not connected to automatically since no assumption
| is made regarding whether you intend to use it. This file lets
| you globally define which systems you would like loaded with every
| request.
|
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Drivers
| 4. Helper files
| 5. Custom config files
| 6. Language files
| 7. Models
|
*/
/*
| -------------------------------------------------------------------
| Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in system/libraries/ or your
| application/libraries/ directory, with the addition of the
| 'database' library, which is somewhat of a special case.
|
| Prototype:
|
| $autoload['libraries'] = array('database', 'email', 'session');
|
| You can also supply an alternative library name to be assigned
| in the controller:
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('database');
/*
| -------------------------------------------------------------------
| Auto-load Drivers
| -------------------------------------------------------------------
| These classes are located in system/libraries/ or in your
| application/libraries/ directory, but are also placed inside their
| own subdirectory and they extend the CI_Driver_Library class. They
| offer multiple interchangeable driver options.
|
| Prototype:
|
| $autoload['drivers'] = array('cache');
|
| You can also supply an alternative property name to be assigned in
| the controller:
|
| $autoload['drivers'] = array('cache' => 'cch');
|
*/
$autoload['drivers'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('comm', 'url', 'array','order','authorization');
/*
| -------------------------------------------------------------------
| Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array('jwt');
/*
| -------------------------------------------------------------------
| Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file. For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array();
/*
| -------------------------------------------------------------------
| Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['model'] = array('first_model', 'second_model');
|
| You can also supply an alternative model name to be assigned
| in the controller:
|
| $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array();
+523
View File
@@ -0,0 +1,523 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'http://market.dev.liche.cn/';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string. The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI' Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING' Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO' Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
$config['uri_protocol'] = 'REQUEST_URI';
/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| https://codeigniter.com/user_guide/general/urls.html
*/
$config['url_suffix'] = '';
/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = 'english';
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
| See http://php.net/htmlspecialchars for a list of supported charsets.
|
*/
$config['charset'] = 'UTF-8';
/*
|--------------------------------------------------------------------------
| Enable/Disable System Hooks
|--------------------------------------------------------------------------
|
| If you would like to use the 'hooks' feature you must enable it by
| setting this variable to TRUE (boolean). See the user guide for details.
|
*/
$config['enable_hooks'] = TRUE;
/*
|--------------------------------------------------------------------------
| Class Extension Prefix
|--------------------------------------------------------------------------
|
| This item allows you to set the filename/classname prefix when extending
| native libraries. For more information please see the user guide:
|
| https://codeigniter.com/user_guide/general/core_classes.html
| https://codeigniter.com/user_guide/general/creating_libraries.html
|
*/
$config['subclass_prefix'] = 'HD_';
/*
|--------------------------------------------------------------------------
| Composer auto-loading
|--------------------------------------------------------------------------
|
| Enabling this setting will tell CodeIgniter to look for a Composer
| package auto-loader script in application/vendor/autoload.php.
|
| $config['composer_autoload'] = TRUE;
|
| Or if you have your vendor/ directory located somewhere else, you
| can opt to set a specific path as well:
|
| $config['composer_autoload'] = '/path/to/vendor/autoload.php';
|
| For more information about Composer, please visit http://getcomposer.org/
|
| Note: This will NOT disable or override the CodeIgniter-specific
| autoloading (application/config/autoload.php)
*/
$config['composer_autoload'] = COMMPATH.'/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify which characters are permitted within your URLs.
| When someone tries to submit a URL with disallowed characters they will
| get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| The configured value is actually a regular expression character group
| and it will be executed as: ! preg_match('/^[<permitted_uri_chars>]+$/i
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
/*
|--------------------------------------------------------------------------
| Enable Query Strings
|--------------------------------------------------------------------------
|
| By default CodeIgniter uses search-engine friendly segment based URLs:
| example.com/who/what/where/
|
| You can optionally enable standard query string based URLs:
| example.com?who=me&what=something&where=here
|
| Options are: TRUE or FALSE (boolean)
|
| The other items let you set the query string 'words' that will
| invoke your controllers and its functions:
| example.com/index.php?c=controller&m=function
|
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
|
*/
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
/*
|--------------------------------------------------------------------------
| Allow $_GET array
|--------------------------------------------------------------------------
|
| By default CodeIgniter enables access to the $_GET array. If for some
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
| WARNING: This feature is DEPRECATED and currently available only
| for backwards compatibility purposes!
|
*/
$config['allow_get_array'] = TRUE;
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
| array(2) = Debug Messages, without Error Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 1;
/*
|--------------------------------------------------------------------------
| Error Logging Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/logs/ directory. Use a full server path with trailing slash.
|
*/
$config['log_path'] = '';
/*
|--------------------------------------------------------------------------
| Log File Extension
|--------------------------------------------------------------------------
|
| The default filename extension for log files. The default 'php' allows for
| protecting the log files via basic scripting, when they are to be stored
| under a publicly accessible directory.
|
| Note: Leaving it blank will default to 'php'.
|
*/
$config['log_file_extension'] = '';
/*
|--------------------------------------------------------------------------
| Log File Permissions
|--------------------------------------------------------------------------
|
| The file system permissions to be applied on newly created log files.
|
| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
| integer notation (i.e. 0700, 0644, etc.)
*/
$config['log_file_permissions'] = 0644;
/*
|--------------------------------------------------------------------------
| Date Format for Logs
|--------------------------------------------------------------------------
|
| Each item that is logged has an associated date. You can use PHP date
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';
/*
|--------------------------------------------------------------------------
| Error Views Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/views/errors/ directory. Use a full server path with trailing slash.
|
*/
$config['error_views_path'] = '';
/*
|--------------------------------------------------------------------------
| Cache Directory Path
|--------------------------------------------------------------------------
|
| Leave this BLANK unless you would like to set something other than the default
| application/cache/ directory. Use a full server path with trailing slash.
|
*/
$config['cache_path'] = '';
/*
|--------------------------------------------------------------------------
| Cache Include Query String
|--------------------------------------------------------------------------
|
| Whether to take the URL query string into consideration when generating
| output cache files. Valid options are:
|
| FALSE = Disabled
| TRUE = Enabled, take all query parameters into account.
| Please be aware that this may result in numerous cache
| files generated for the same page over and over again.
| array('q') = Enabled, but only take into account the specified list
| of query parameters.
|
*/
$config['cache_query_string'] = FALSE;
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class, you must set an encryption key.
| See the user guide for more info.
|
| https://codeigniter.com/user_guide/libraries/encryption.html
|
*/
$config['encryption_key'] = 'market.ai';
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sess_driver'
|
| The storage driver to use: files, database, redis, memcached
|
| 'sess_cookie_name'
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
| 'sess_expiration'
|
| The number of SECONDS you want the session to last.
| Setting to 0 (zero) means expire when the browser is closed.
|
| 'sess_save_path'
|
| The location to save sessions to, driver dependent.
|
| For the 'files' driver, it's a path to a writable directory.
| WARNING: Only absolute paths are supported!
|
| For the 'database' driver, it's a table name.
| Please read up the manual for the format with other session drivers.
|
| IMPORTANT: You are REQUIRED to set a valid save path!
|
| 'sess_match_ip'
|
| Whether to match the user's IP address when reading the session data.
|
| WARNING: If you're using the database driver, don't forget to update
| your session table's PRIMARY KEY when changing this setting.
|
| 'sess_time_to_update'
|
| How many seconds between CI regenerating the session ID.
|
| 'sess_regenerate_destroy'
|
| Whether to destroy session data associated with the old session ID
| when auto-regenerating the session ID. When set to FALSE, the data
| will be later deleted by the garbage collector.
|
| Other session cookie settings are shared with the rest of the application,
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path' = Typically will be a forward slash
| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists.
| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
|
| Note: These settings (with the exception of 'cookie_prefix' and
| 'cookie_httponly') will also affect sessions.
|
*/
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
/*
|--------------------------------------------------------------------------
| Standardize newlines
|--------------------------------------------------------------------------
|
| Determines whether to standardize newline characters in input data,
| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value.
|
| WARNING: This feature is DEPRECATED and currently available only
| for backwards compatibility purposes!
|
*/
$config['standardize_newlines'] = FALSE;
/*
|--------------------------------------------------------------------------
| Global XSS Filtering
|--------------------------------------------------------------------------
|
| Determines whether the XSS filter is always active when GET, POST or
| COOKIE data is encountered
|
| WARNING: This feature is DEPRECATED and currently available only
| for backwards compatibility purposes!
|
*/
$config['global_xss_filtering'] = FALSE;
/*
|--------------------------------------------------------------------------
| Cross Site Request Forgery
|--------------------------------------------------------------------------
| Enables a CSRF cookie token to be set. When set to TRUE, token will be
| checked on a submitted form. If you are accepting user data, it is strongly
| recommended CSRF protection be enabled.
|
| 'csrf_token_name' = The token name
| 'csrf_cookie_name' = The cookie name
| 'csrf_expire' = The number in seconds the token should expire.
| 'csrf_regenerate' = Regenerate token on every submission
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
*/
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
/*
|--------------------------------------------------------------------------
| Output Compression
|--------------------------------------------------------------------------
|
| Enables Gzip output compression for faster page loads. When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| Only used if zlib.output_compression is turned off in your php.ini.
| Please do not use it together with httpd-level output compression.
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts. For
| compression to work, nothing can be sent before the output buffer is called
| by the output class. Do not 'echo' any values with compression enabled.
|
*/
$config['compress_output'] = FALSE;
/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are 'local' or any PHP supported timezone. This preference tells
| the system whether to use your server's local time as the master 'now'
| reference, or convert it to the configured one timezone. See the 'date
| helper' page of the user guide for information regarding date handling.
|
*/
$config['time_reference'] = 'local';
/*
|--------------------------------------------------------------------------
| Rewrite PHP Short Tags
|--------------------------------------------------------------------------
|
| If your PHP installation does not have short tag support enabled CI
| can rewrite the tags on-the-fly, enabling you to utilize that syntax
| in your view files. Options are TRUE or FALSE (boolean)
|
| Note: You need to have eval() enabled for this to work.
|
*/
$config['rewrite_short_tags'] = FALSE;
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy
| IP addresses from which CodeIgniter should trust headers such as
| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
| the visitor's IP address.
|
| You can use both an array or a comma-separated list of proxy addresses,
| as well as specifying whole subnets. Here are a few examples:
|
| Comma-separated: '10.0.1.200,192.168.5.0/24'
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
$config['proxy_ips'] = '';
+109
View File
@@ -0,0 +1,109 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Display Debug backtrace
|--------------------------------------------------------------------------
|
| If set to TRUE, a backtrace will be displayed along with php errors. If
| error_reporting is disabled, the backtrace will not display, regardless
| of this setting
|
*/
defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system. The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in
| certain environments (Apache running a separate process for each
| user, PHP under CGI with Apache suEXEC, etc.). Octal values should
| always be used to set the mode correctly.
|
*/
defined('FILE_READ_MODE') OR define('FILE_READ_MODE', 0644);
defined('FILE_WRITE_MODE') OR define('FILE_WRITE_MODE', 0666);
defined('DIR_READ_MODE') OR define('DIR_READ_MODE', 0755);
defined('DIR_WRITE_MODE') OR define('DIR_WRITE_MODE', 0755);
/*
|--------------------------------------------------------------------------
| File Stream Modes
|--------------------------------------------------------------------------
|
| These modes are used when working with fopen()/popen()
|
*/
defined('FOPEN_READ') OR define('FOPEN_READ', 'rb');
defined('FOPEN_READ_WRITE') OR define('FOPEN_READ_WRITE', 'r+b');
defined('FOPEN_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE') OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
defined('FOPEN_WRITE_CREATE') OR define('FOPEN_WRITE_CREATE', 'ab');
defined('FOPEN_READ_WRITE_CREATE') OR define('FOPEN_READ_WRITE_CREATE', 'a+b');
defined('FOPEN_WRITE_CREATE_STRICT') OR define('FOPEN_WRITE_CREATE_STRICT', 'xb');
defined('FOPEN_READ_WRITE_CREATE_STRICT') OR define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
/*
|--------------------------------------------------------------------------
| Exit Status Codes
|--------------------------------------------------------------------------
|
| Used to indicate the conditions under which the script is exit()ing.
| While there is no universal standard for error codes, there are some
| broad conventions. Three such conventions are mentioned below, for
| those who wish to make use of them. The CodeIgniter defaults were
| chosen for the least overlap with these conventions, while still
| leaving room for others to be defined in future versions and user
| applications.
|
| The three main conventions used for determining exit status codes
| are as follows:
|
| Standard C/C++ Library (stdlibc):
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
| (This link also contains other GNU-specific conventions)
| BSD sysexits.h:
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
| Bash scripting:
| http://tldp.org/LDP/abs/html/exitcodes.html
|
*/
defined('EXIT_SUCCESS') OR define('EXIT_SUCCESS', 0); // no errors
defined('EXIT_ERROR') OR define('EXIT_ERROR', 1); // generic error
defined('EXIT_CONFIG') OR define('EXIT_CONFIG', 3); // configuration error
defined('EXIT_UNKNOWN_FILE') OR define('EXIT_UNKNOWN_FILE', 4); // file not found
defined('EXIT_UNKNOWN_CLASS') OR define('EXIT_UNKNOWN_CLASS', 5); // unknown class
defined('EXIT_UNKNOWN_METHOD') OR define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
defined('EXIT_USER_INPUT') OR define('EXIT_USER_INPUT', 7); // invalid user input
defined('EXIT_DATABASE') OR define('EXIT_DATABASE', 8); // database error
defined('EXIT__AUTO_MIN') OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
define('ERR_SYS_SUCCESS',0);
define('ERR_SYS_FAIL', 9999);
define('ERR_SYS_INVAL_PARAM', 9998);
define('ERR_USER_NOT_LOGIN', 1001);
/*edit by xuxianbin 这边应该是多写了一个*/
//define('ERR_USER_NOT_LOGIN', 1001);
/*edit end*/
define('ERR_USER_LOGIN_FAIL', 1002);
define('ERR_ACCOUNT_NOT_EXISTS', 1021);
define('ERR_PARAMS_ERROR', 1017);
define('TEMP_PATH', APPPATH.'../www/market/api/');
//新的api接口code规定
defined('API_CODE_SUCCESS') OR define('API_CODE_SUCCESS', 200);//成功
defined('API_CODE_FAIL') OR define('API_CODE_FAIL', 400);//请求失败
defined('API_CODE_NONE') OR define('API_CODE_FORB', 403);//禁止访问
defined('API_CODE_NONE') OR define('API_CODE_NONE', 404);//页面不存在
defined('API_CODE_LOGOUT') OR define('API_CODE_LOGOUT', 408);//未登录
defined('API_CODE_INVILD_PARAM') OR define('API_CODE_INVILD_PARAM', 401);//非法参数
defined('API_CODE_USER_FULL') OR define('API_CODE_USER_FULL', 417);//完善用户资料
defined('API_CODE_ORC_FAIL') OR define('API_CODE_ORC_FAIL', 418);//图片识别失败
+96
View File
@@ -0,0 +1,96 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| This file will contain the settings needed to access your database.
|
| For complete instructions please consult the 'Database Connection'
| page of the User Guide.
|
| -------------------------------------------------------------------
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
| ['database'] The name of the database you want to connect to
| ['dbdriver'] The database driver. e.g.: mysqli.
| Currently supported:
| cubrid, ibase, mssql, mysql, mysqli, oci8,
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
| ['dbprefix'] You can add an optional prefix, which will be added
| to the table name when using the Query Builder class
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
| ['cachedir'] The path to the folder where cache files should be stored
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
| (and in table creation queries made with DB Forge).
| There is an incompatibility in PHP with mysql_real_escape_string() which
| can make your site vulnerable to SQL injection if you are using a
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
| ['encrypt'] Whether or not to use an encrypted connection.
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
| 'ssl_key' - Path to the private key file
| 'ssl_cert' - Path to the public key certificate file
| 'ssl_ca' - Path to the certificate authority file
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not ('mysqli' only)
|
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
| - good for ensuring strict SQL while developing
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
| NOTE: Disabling this will also effectively disable both
| $this->db->last_query() and profiling of DB queries.
| When you run a query, with this setting set to TRUE (default),
| CodeIgniter will store the SQL statement for debugging purposes.
| However, this may cause high memory usage, especially if you run
| a lot of SQL queries ... disable this to avoid that problem.
|
| The $active_group variable lets you choose which connection group to
| make active. By default there is only one group (the 'default' group).
|
| The $query_builder variables lets you determine whether or not to load
| the query builder class.
*/
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'mysql:host=192.168.0.11:3308;dbname=lichedb',
'username' => 'devuser',
'password' => '123456',
'database' => 'lichedb',
'dbdriver' => 'pdo',
'dbprefix' => 'lc_',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
+24
View File
@@ -0,0 +1,24 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$_doctypes = array(
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
);
+103
View File
@@ -0,0 +1,103 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| Foreign Characters
| -------------------------------------------------------------------
| This file contains an array of foreign characters for transliteration
| conversion used by the Text helper
|
*/
$foreign_characters = array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
'/Б/' => 'B',
'/б/' => 'b',
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
'/ç|ć|ĉ|ċ|č/' => 'c',
'/Д/' => 'D',
'/д/' => 'd',
'/Ð|Ď|Đ|Δ/' => 'Dj',
'/ð|ď|đ|δ/' => 'dj',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
'/Ф/' => 'F',
'/ф/' => 'f',
'/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
'/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
'/Ĥ|Ħ/' => 'H',
'/ĥ|ħ/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
'/Ĵ/' => 'J',
'/ĵ/' => 'j',
'/Ķ|Κ|К/' => 'K',
'/ķ|κ|к/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
'/М/' => 'M',
'/м/' => 'm',
'/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
'/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
'/П/' => 'P',
'/п/' => 'p',
'/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
'/ŕ|ŗ|ř|ρ|р/' => 'r',
'/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
'/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T',
'/ț|ţ|ť|ŧ|т/' => 't',
'/Þ|þ/' => 'th',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
'/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
'/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
'/В/' => 'V',
'/в/' => 'v',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž|Ζ|З/' => 'Z',
'/ź|ż|ž|ζ|з/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/' => 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f',
'/ξ/' => 'ks',
'/π/' => 'p',
'/β/' => 'v',
'/μ/' => 'm',
'/ψ/' => 'ps',
'/Ё/' => 'Yo',
'/ё/' => 'yo',
'/Є/' => 'Ye',
'/є/' => 'ye',
'/Ї/' => 'Yi',
'/Ж/' => 'Zh',
'/ж/' => 'zh',
'/Х/' => 'Kh',
'/х/' => 'kh',
'/Ц/' => 'Ts',
'/ц/' => 'ts',
'/Ч/' => 'Ch',
'/ч/' => 'ch',
'/Ш/' => 'Sh',
'/ш/' => 'sh',
'/Щ/' => 'Shch',
'/щ/' => 'shch',
'/Ъ|ъ|Ь|ь/' => '',
'/Ю/' => 'Yu',
'/ю/' => 'yu',
'/Я/' => 'Ya',
'/я/' => 'ya'
);
+20
View File
@@ -0,0 +1,20 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| https://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['post_controller_constructor'] = array(
'class' => 'ApiAuthHook',
'function' => 'index',
'filename' => 'ApiAuthHook.php',
'filepath' => 'hooks',
'params' => []
);
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['jwt_key'] = 'yourjwtkey4CITutorial';
$config['jwt_algorithm'] = 'HS256';
+19
View File
@@ -0,0 +1,19 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Memcached settings
| -------------------------------------------------------------------------
| Your Memcached servers can be specified below.
|
| See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
*/
$config = array(
'default' => array(
'hostname' => '192.168.0.16',
'port' => '12001',
'weight' => '1',
),
);
+84
View File
@@ -0,0 +1,84 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Enable/Disable Migrations
|--------------------------------------------------------------------------
|
| Migrations are disabled by default for security reasons.
| You should enable migrations whenever you intend to do a schema migration
| and disable it back when you're done.
|
*/
$config['migration_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
| Migration Type
|--------------------------------------------------------------------------
|
| Migration file names may be based on a sequential identifier or on
| a timestamp. Options are:
|
| 'sequential' = Sequential migration naming (001_add_blog.php)
| 'timestamp' = Timestamp migration naming (20121031104401_add_blog.php)
| Use timestamp format YYYYMMDDHHIISS.
|
| Note: If this configuration value is missing the Migration library
| defaults to 'sequential' for backward compatibility with CI2.
|
*/
$config['migration_type'] = 'timestamp';
/*
|--------------------------------------------------------------------------
| Migrations table
|--------------------------------------------------------------------------
|
| This is the name of the table that will store the current migrations state.
| When migrations runs it will store in a database table which migration
| level the system is at. It then compares the migration level in this
| table to the $config['migration_version'] if they are not the same it
| will migrate up. This must be set.
|
*/
$config['migration_table'] = 'migrations';
/*
|--------------------------------------------------------------------------
| Auto Migrate To Latest
|--------------------------------------------------------------------------
|
| If this is set to TRUE when you load the migrations class and have
| $config['migration_enabled'] set to TRUE the system will auto migrate
| to your latest migration (whatever $config['migration_version'] is
| set to). This way you do not have to call migrations anywhere else
| in your code to have the latest migration.
|
*/
$config['migration_auto_latest'] = FALSE;
/*
|--------------------------------------------------------------------------
| Migrations version
|--------------------------------------------------------------------------
|
| This is used to set migration version that the file system should be on.
| If you run $this->migration->current() this is the version that schema will
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 0;
/*
|--------------------------------------------------------------------------
| Migrations Path
|--------------------------------------------------------------------------
|
| Path to your migrations folder.
| Typically, it will be within your application path.
| Also, writing permission is required within the migrations path.
|
*/
$config['migration_path'] = APPPATH.'migrations/';
+184
View File
@@ -0,0 +1,184 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| MIME TYPES
| -------------------------------------------------------------------
| This file contains an array of mime types. It is used by the
| Upload class to help identify allowed file types.
|
*/
return array(
'hqx' => array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
'bin' => array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => array('application/octet-stream', 'application/x-msdownload'),
'class' => 'application/octet-stream',
'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
'ai' => array('application/pdf', 'application/postscript'),
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
'pptx' => array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'php' => array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => array('application/x-javascript', 'text/plain'),
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
'z' => 'application/x-compress',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
'rar' => array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
'aif' => array('audio/x-aiff', 'audio/aiff'),
'aiff' => array('audio/x-aiff', 'audio/aiff'),
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
'bmp' => array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'jp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'j2k' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpf' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpg2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpx' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'jpm' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => array('text/css', 'text/plain'),
'html' => array('text/html', 'text/plain'),
'htm' => array('text/html', 'text/plain'),
'shtml' => array('text/html', 'text/plain'),
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => array('application/xml', 'text/xml', 'text/plain'),
'xsl' => array('application/xml', 'text/xsl', 'text/xml'),
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
'movie' => 'video/x-sgi-movie',
'doc' => array('application/msword', 'application/vnd.ms-office'),
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
'dot' => array('application/msword', 'application/vnd.ms-office'),
'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822',
'json' => array('application/json', 'text/json'),
'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
'p10' => array('application/x-pkcs10', 'application/pkcs10'),
'p12' => 'application/x-pkcs12',
'p7a' => 'application/x-pkcs7-signature',
'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
'p7r' => 'application/x-pkcs7-certreqresp',
'p7s' => 'application/pkcs7-signature',
'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
'crl' => array('application/pkix-crl', 'application/pkcs-crl'),
'der' => 'application/x-x509-ca-cert',
'kdb' => 'application/octet-stream',
'pgp' => 'application/pgp',
'gpg' => 'application/gpg-keys',
'sst' => 'application/octet-stream',
'csr' => 'application/octet-stream',
'rsa' => 'application/x-pkcs7',
'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'),
'3g2' => 'video/3gpp2',
'3gp' => array('video/3gp', 'video/3gpp'),
'mp4' => 'video/mp4',
'm4a' => 'audio/x-m4a',
'f4v' => array('video/mp4', 'video/x-f4v'),
'flv' => 'video/x-flv',
'webm' => 'video/webm',
'aac' => 'audio/x-acc',
'm4u' => 'application/vnd.mpegurl',
'm3u' => 'text/plain',
'xspf' => 'application/xspf+xml',
'vlc' => 'application/videolan',
'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'),
'au' => 'audio/x-au',
'ac3' => 'audio/ac3',
'flac' => 'audio/x-flac',
'ogg' => array('audio/ogg', 'video/ogg', 'application/ogg'),
'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
'ics' => 'text/calendar',
'ical' => 'text/calendar',
'zsh' => 'text/x-scriptzsh',
'7z' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'7zip' => array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'),
'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
'svg' => array('image/svg+xml', 'application/xml', 'text/xml'),
'vcf' => 'text/x-vcard',
'srt' => array('text/srt', 'text/plain'),
'vtt' => array('text/vtt', 'text/plain'),
'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
'odc' => 'application/vnd.oasis.opendocument.chart',
'otc' => 'application/vnd.oasis.opendocument.chart-template',
'odf' => 'application/vnd.oasis.opendocument.formula',
'otf' => 'application/vnd.oasis.opendocument.formula-template',
'odg' => 'application/vnd.oasis.opendocument.graphics',
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
'odi' => 'application/vnd.oasis.opendocument.image',
'oti' => 'application/vnd.oasis.opendocument.image-template',
'odp' => 'application/vnd.oasis.opendocument.presentation',
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
'odt' => 'application/vnd.oasis.opendocument.text',
'odm' => 'application/vnd.oasis.opendocument.text-master',
'ott' => 'application/vnd.oasis.opendocument.text-template',
'oth' => 'application/vnd.oasis.opendocument.text-web'
);
+11
View File
@@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: linfan
* Date: 2018/11/2
* Time: 14:38
*/
defined('BASEPATH') OR exit('No direct script access allowed');
$config['host'] = '192.168.0.16';
$config['port'] = 27017;
+14
View File
@@ -0,0 +1,14 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Profiler Sections
| -------------------------------------------------------------------------
| This file lets you determine whether or not various sections of Profiler
| data are displayed when the Profiler is enabled.
| Please see the user guide for info:
|
| https://codeigniter.com/user_guide/general/profiling.html
|
*/
+26
View File
@@ -0,0 +1,26 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['access_key'] = 'Pn60lJXcaOGKvMjn5qv-OMr7wR1lp1p8QG7Ul6NK';
$config['secret_key'] = '83YE_xcHLuejVvbnCiMrMr-CYR7QshBfGgmPSknP';
$config['bucket'] = 'img-liche';
$config['region'] = '华南';
$config['is_https'] = 'https';
$config['domain'] = 'img.liche.cn';
$config['attch'] = 'liche/';
$config['img']['access_key'] = 'Pn60lJXcaOGKvMjn5qv-OMr7wR1lp1p8QG7Ul6NK';
$config['img']['secret_key'] = '83YE_xcHLuejVvbnCiMrMr-CYR7QshBfGgmPSknP';
$config['img']['bucket'] = 'img-liche';
$config['img']['region'] = '华南';
$config['img']['is_https'] = 'https';
$config['img']['domain'] = 'img.liche.cn';
$config['img']['attch'] = 'liche/';
$config['video']['access_key'] = 'Pn60lJXcaOGKvMjn5qv-OMr7wR1lp1p8QG7Ul6NK';
$config['video']['secret_key'] = '83YE_xcHLuejVvbnCiMrMr-CYR7QshBfGgmPSknP';
$config['video']['bucket'] = 'media-liche';
$config['video']['region'] = '华南';
$config['video']['is_https'] = 'https';
$config['video']['domain'] = 'media.liche.cn';
$config['video']['attch'] = 'liche/';
+11
View File
@@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: linfan
* Date: 2018/11/2
* Time: 14:38
*/
defined('BASEPATH') OR exit('No direct script access allowed');
$config['host'] = '192.168.0.16';
$config['port'] = 6379;
+605
View File
@@ -0,0 +1,605 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| HTTP protocol
|--------------------------------------------------------------------------
|
| Set to force the use of HTTPS for REST API calls
|
*/
$config['force_https'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Output Format
|--------------------------------------------------------------------------
|
| The default format of the response
|
| 'array': Array data structure
| 'csv': Comma separated file
| 'json': Uses json_encode(). Note: If a GET query string
| called 'callback' is passed, then jsonp will be returned
| 'html' HTML using the table library in CodeIgniter
| 'php': Uses var_export()
| 'serialized': Uses serialize()
| 'xml': Uses simplexml_load_string()
|
*/
$config['rest_default_format'] = 'json';
/*
|--------------------------------------------------------------------------
| REST Supported Output Formats
|--------------------------------------------------------------------------
|
| The following setting contains a list of the supported/allowed formats.
| You may remove those formats that you don't want to use.
| If the default format $config['rest_default_format'] is missing within
| $config['rest_supported_formats'], it will be added silently during
| REST_Controller initialization.
|
*/
$config['rest_supported_formats'] = [
'json',
'array',
'csv',
'html',
'jsonp',
'php',
'serialized',
'xml',
];
/*
|--------------------------------------------------------------------------
| REST Status Field Name
|--------------------------------------------------------------------------
|
| The field name for the status inside the response
|
*/
$config['rest_status_field_name'] = 'status';
/*
|--------------------------------------------------------------------------
| REST Message Field Name
|--------------------------------------------------------------------------
|
| The field name for the message inside the response
|
*/
$config['rest_message_field_name'] = 'error';
/*
|--------------------------------------------------------------------------
| Enable Emulate Request
|--------------------------------------------------------------------------
|
| Should we enable emulation of the request (e.g. used in Mootools request)
|
*/
$config['enable_emulate_request'] = TRUE;
/*
|--------------------------------------------------------------------------
| REST Realm
|--------------------------------------------------------------------------
|
| Name of the password protected REST API displayed on login dialogs
|
| e.g: My Secret REST API
|
*/
$config['rest_realm'] = 'REST API';
/*
|--------------------------------------------------------------------------
| REST Login
|--------------------------------------------------------------------------
|
| Set to specify the REST API requires to be logged in
|
| FALSE No login required
| 'basic' Unsecured login
| 'digest' More secured login
| 'session' Check for a PHP session variable. See 'auth_source' to set the
| authorization key
|
*/
$config['rest_auth'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Login Source
|--------------------------------------------------------------------------
|
| Is login required and if so, the user store to use
|
| '' Use config based users or wildcard testing
| 'ldap' Use LDAP authentication
| 'library' Use a authentication library
|
| Note: If 'rest_auth' is set to 'session' then change 'auth_source' to the name of the session variable
|
*/
$config['auth_source'] = 'ldap';
/*
|--------------------------------------------------------------------------
| Allow Authentication and API Keys
|--------------------------------------------------------------------------
|
| Where you wish to have Basic, Digest or Session login, but also want to use API Keys (for limiting
| requests etc), set to TRUE;
|
*/
$config['allow_auth_and_keys'] = TRUE;
/*
|--------------------------------------------------------------------------
| REST Login Class and Function
|--------------------------------------------------------------------------
|
| If library authentication is used define the class and function name
|
| The function should accept two parameters: class->function($username, $password)
| In other cases override the function _perform_library_auth in your controller
|
| For digest authentication the library function should return already a stored
| md5(username:restrealm:password) for that username
|
| e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2'
|
*/
$config['auth_library_class'] = '';
$config['auth_library_function'] = '';
/*
|--------------------------------------------------------------------------
| Override auth types for specific class/method
|--------------------------------------------------------------------------
|
| Set specific authentication types for methods within a class (controller)
|
| Set as many config entries as needed. Any methods not set will use the default 'rest_auth' config value.
|
| e.g:
|
| $config['auth_override_class_method']['deals']['view'] = 'none';
| $config['auth_override_class_method']['deals']['insert'] = 'digest';
| $config['auth_override_class_method']['accounts']['user'] = 'basic';
| $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic';
|
| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name)
| Acceptable values are; 'none', 'digest' and 'basic'.
|
*/
// $config['auth_override_class_method']['deals']['view'] = 'none';
// $config['auth_override_class_method']['deals']['insert'] = 'digest';
// $config['auth_override_class_method']['accounts']['user'] = 'basic';
// $config['auth_override_class_method']['dashboard']['*'] = 'basic';
// ---Uncomment list line for the wildard unit test
// $config['auth_override_class_method']['wildcard_test_cases']['*'] = 'basic';
/*
|--------------------------------------------------------------------------
| Override auth types for specific 'class/method/HTTP method'
|--------------------------------------------------------------------------
|
| example:
|
| $config['auth_override_class_method_http']['deals']['view']['get'] = 'none';
| $config['auth_override_class_method_http']['deals']['insert']['post'] = 'none';
| $config['auth_override_class_method_http']['deals']['*']['options'] = 'none';
*/
// ---Uncomment list line for the wildard unit test
// $config['auth_override_class_method_http']['wildcard_test_cases']['*']['options'] = 'basic';
/*
|--------------------------------------------------------------------------
| REST Login Usernames
|--------------------------------------------------------------------------
|
| Array of usernames and passwords for login, if ldap is configured this is ignored
|
*/
$config['rest_valid_logins'] = ['admin' => '1234'];
/*
|--------------------------------------------------------------------------
| Global IP White-listing
|--------------------------------------------------------------------------
|
| Limit connections to your REST server to White-listed IP addresses
|
| Usage:
| 1. Set to TRUE and select an auth option for extreme security (client's IP
| address must be in white-list and they must also log in)
| 2. Set to TRUE with auth set to FALSE to allow White-listed IPs access with no login
| 3. Set to FALSE but set 'auth_override_class_method' to 'white-list' to
| restrict certain methods to IPs in your white-list
|
*/
$config['rest_ip_whitelist_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Handle Exceptions
|--------------------------------------------------------------------------
|
| Handle exceptions caused by the controller
|
*/
$config['rest_handle_exceptions'] = TRUE;
/*
|--------------------------------------------------------------------------
| REST IP White-list
|--------------------------------------------------------------------------
|
| Limit connections to your REST server with a comma separated
| list of IP addresses
|
| e.g: '123.456.789.0, 987.654.32.1'
|
| 127.0.0.1 and 0.0.0.0 are allowed by default
|
*/
$config['rest_ip_whitelist'] = '';
/*
|--------------------------------------------------------------------------
| Global IP Blacklisting
|--------------------------------------------------------------------------
|
| Prevent connections to the REST server from blacklisted IP addresses
|
| Usage:
| 1. Set to TRUE and add any IP address to 'rest_ip_blacklist'
|
*/
$config['rest_ip_blacklist_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST IP Blacklist
|--------------------------------------------------------------------------
|
| Prevent connections from the following IP addresses
|
| e.g: '123.456.789.0, 987.654.32.1'
|
*/
$config['rest_ip_blacklist'] = '';
/*
|--------------------------------------------------------------------------
| REST Database Group
|--------------------------------------------------------------------------
|
| Connect to a database group for keys, logging, etc. It will only connect
| if you have any of these features enabled
|
*/
$config['rest_database_group'] = 'default';
/*
|--------------------------------------------------------------------------
| REST API Keys Table Name
|--------------------------------------------------------------------------
|
| The table name in your database that stores API keys
|
*/
$config['rest_keys_table'] = 'keys';
/*
|--------------------------------------------------------------------------
| REST Enable Keys
|--------------------------------------------------------------------------
|
| When set to TRUE, the REST API will look for a column name called 'key'.
| If no key is provided, the request will result in an error. To override the
| column name see 'rest_key_column'
|
| Default table schema:
| CREATE TABLE `keys` (
| `id` INT(11) NOT NULL AUTO_INCREMENT,
| `user_id` INT(11) NOT NULL,
| `key` VARCHAR(40) NOT NULL,
| `level` INT(2) NOT NULL,
| `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0',
| `is_private_key` TINYINT(1) NOT NULL DEFAULT '0',
| `ip_addresses` TEXT NULL DEFAULT NULL,
| `date_created` INT(11) NOT NULL,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
*/
$config['rest_enable_keys'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Table Key Column Name
|--------------------------------------------------------------------------
|
| If not using the default table schema in 'rest_enable_keys', specify the
| column name to match e.g. my_key
|
*/
$config['rest_key_column'] = 'key';
/*
|--------------------------------------------------------------------------
| REST API Limits method
|--------------------------------------------------------------------------
|
| Specify the method used to limit the API calls
|
| Available methods are :
| $config['rest_limits_method'] = 'IP_ADDRESS'; // Put a limit per ip address
| $config['rest_limits_method'] = 'API_KEY'; // Put a limit per api key
| $config['rest_limits_method'] = 'METHOD_NAME'; // Put a limit on method calls
| $config['rest_limits_method'] = 'ROUTED_URL'; // Put a limit on the routed URL
|
*/
$config['rest_limits_method'] = 'ROUTED_URL';
/*
|--------------------------------------------------------------------------
| REST Key Length
|--------------------------------------------------------------------------
|
| Length of the created keys. Check your default database schema on the
| maximum length allowed
|
| Note: The maximum length is 40
|
*/
$config['rest_key_length'] = 40;
/*
|--------------------------------------------------------------------------
| REST API Key Variable
|--------------------------------------------------------------------------
|
| Custom header to specify the API key
| Note: Custom headers with the X- prefix are deprecated as of
| 2012/06/12. See RFC 6648 specification for more details
|
*/
$config['rest_key_name'] = 'X-API-KEY';
/*
|--------------------------------------------------------------------------
| REST Enable Logging
|--------------------------------------------------------------------------
|
| When set to TRUE, the REST API will log actions based on the column names 'key', 'date',
| 'time' and 'ip_address'. This is a general rule that can be overridden in the
| $this->method array for each controller
|
| Default table schema:
| CREATE TABLE `logs` (
| `id` INT(11) NOT NULL AUTO_INCREMENT,
| `uri` VARCHAR(255) NOT NULL,
| `method` VARCHAR(6) NOT NULL,
| `params` TEXT DEFAULT NULL,
| `api_key` VARCHAR(40) NOT NULL,
| `ip_address` VARCHAR(45) NOT NULL,
| `time` INT(11) NOT NULL,
| `rtime` FLOAT DEFAULT NULL,
| `authorized` VARCHAR(1) NOT NULL,
| `response_code` smallint(3) DEFAULT '0',
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
*/
$config['rest_enable_logging'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST API Logs Table Name
|--------------------------------------------------------------------------
|
| If not using the default table schema in 'rest_enable_logging', specify the
| table name to match e.g. my_logs
|
*/
$config['rest_logs_table'] = 'logs';
/*
|--------------------------------------------------------------------------
| REST Method Access Control
|--------------------------------------------------------------------------
| When set to TRUE, the REST API will check the access table to see if
| the API key can access that controller. 'rest_enable_keys' must be enabled
| to use this
|
| Default table schema:
| CREATE TABLE `access` (
| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
| `key` VARCHAR(40) NOT NULL DEFAULT '',
| `all_access` TINYINT(1) NOT NULL DEFAULT '0',
| `controller` VARCHAR(50) NOT NULL DEFAULT '',
| `date_created` DATETIME DEFAULT NULL,
| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
*/
$config['rest_enable_access'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST API Access Table Name
|--------------------------------------------------------------------------
|
| If not using the default table schema in 'rest_enable_access', specify the
| table name to match e.g. my_access
|
*/
$config['rest_access_table'] = 'access';
/*
|--------------------------------------------------------------------------
| REST API Param Log Format
|--------------------------------------------------------------------------
|
| When set to TRUE, the REST API log parameters will be stored in the database as JSON
| Set to FALSE to log as serialized PHP
|
*/
$config['rest_logs_json_params'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Enable Limits
|--------------------------------------------------------------------------
|
| When set to TRUE, the REST API will count the number of uses of each method
| by an API key each hour. This is a general rule that can be overridden in the
| $this->method array in each controller
|
| Default table schema:
| CREATE TABLE `limits` (
| `id` INT(11) NOT NULL AUTO_INCREMENT,
| `uri` VARCHAR(255) NOT NULL,
| `count` INT(10) NOT NULL,
| `hour_started` INT(11) NOT NULL,
| `api_key` VARCHAR(40) NOT NULL,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| To specify the limits within the controller's __construct() method, add per-method
| limits with:
|
| $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR];
|
| See application/controllers/api/example.php for examples
*/
$config['rest_enable_limits'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST API Limits Table Name
|--------------------------------------------------------------------------
|
| If not using the default table schema in 'rest_enable_limits', specify the
| table name to match e.g. my_limits
|
*/
$config['rest_limits_table'] = 'limits';
/*
|--------------------------------------------------------------------------
| REST Ignore HTTP Accept
|--------------------------------------------------------------------------
|
| Set to TRUE to ignore the HTTP Accept and speed up each request a little.
| Only do this if you are using the $this->rest_format or /format/xml in URLs
|
*/
$config['rest_ignore_http_accept'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST AJAX Only
|--------------------------------------------------------------------------
|
| Set to TRUE to allow AJAX requests only. Set to FALSE to accept HTTP requests
|
| Note: If set to TRUE and the request is not AJAX, a 505 response with the
| error message 'Only AJAX requests are accepted.' will be returned.
|
| Hint: This is good for production environments
|
*/
$config['rest_ajax_only'] = FALSE;
/*
|--------------------------------------------------------------------------
| REST Language File
|--------------------------------------------------------------------------
|
| Language file to load from the language directory
|
*/
$config['rest_language'] = 'english';
/*
|--------------------------------------------------------------------------
| CORS Check
|--------------------------------------------------------------------------
|
| Set to TRUE to enable Cross-Origin Resource Sharing (CORS). Useful if you
| are hosting your API on a different domain from the application that
| will access it through a browser
|
*/
$config['check_cors'] = TRUE;
/*
|--------------------------------------------------------------------------
| CORS Allowable Headers
|--------------------------------------------------------------------------
|
| If using CORS checks, set the allowable headers here
|
*/
$config['allowed_cors_headers'] = [
'Origin',
'X-Requested-With',
'Content-Type',
'Accept',
'Access-Control-Request-Method'
];
/*
|--------------------------------------------------------------------------
| CORS Allowable Methods
|--------------------------------------------------------------------------
|
| If using CORS checks, you can set the methods you want to be allowed
|
*/
$config['allowed_cors_methods'] = [
'GET',
'POST',
'OPTIONS',
'PUT',
'PATCH',
'DELETE'
];
/*
|--------------------------------------------------------------------------
| CORS Allow Any Domain
|--------------------------------------------------------------------------
|
| Set to TRUE to enable Cross-Origin Resource Sharing (CORS) from any
| source domain
|
*/
$config['allow_any_cors_domain'] = TRUE;
/*
|--------------------------------------------------------------------------
| CORS Allowable Domains
|--------------------------------------------------------------------------
|
| Used if $config['check_cors'] is set to TRUE and $config['allow_any_cors_domain']
| is set to FALSE. Set all the allowable domains within the array
|
| e.g. $config['allowed_origins'] = ['http://www.example.com', 'https://spa.example.com']
|
*/
$config['allowed_cors_origins'] = [];
+54
View File
@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| https://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are three reserved routes:
|
| $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
| $route['404_override'] = 'errors/page_missing';
|
| This route will tell the Router which controller/method to use if those
| provided in the URL cannot be matched to a valid route.
|
| $route['translate_uri_dashes'] = FALSE;
|
| This is not exactly a route, but allows you to automatically route
| controller and method names that contain dashes. '-' isn't a valid
| class or method name character, so it requires translation.
| When you set this option to TRUE, it will replace ALL dashes in the
| controller and method URI segments.
|
| Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method
*/
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
+64
View File
@@ -0,0 +1,64 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| SMILEYS
| -------------------------------------------------------------------
| This file contains an array of smileys for use with the emoticon helper.
| Individual images can be used to replace multiple smileys. For example:
| :-) and :) use the same image replacement.
|
| Please see user guide for more info:
| https://codeigniter.com/user_guide/helpers/smiley_helper.html
|
*/
$smileys = array(
// smiley image name width height alt
':-)' => array('grin.gif', '19', '19', 'grin'),
':lol:' => array('lol.gif', '19', '19', 'LOL'),
':cheese:' => array('cheese.gif', '19', '19', 'cheese'),
':)' => array('smile.gif', '19', '19', 'smile'),
';-)' => array('wink.gif', '19', '19', 'wink'),
';)' => array('wink.gif', '19', '19', 'wink'),
':smirk:' => array('smirk.gif', '19', '19', 'smirk'),
':roll:' => array('rolleyes.gif', '19', '19', 'rolleyes'),
':-S' => array('confused.gif', '19', '19', 'confused'),
':wow:' => array('surprise.gif', '19', '19', 'surprised'),
':bug:' => array('bigsurprise.gif', '19', '19', 'big surprise'),
':-P' => array('tongue_laugh.gif', '19', '19', 'tongue laugh'),
'%-P' => array('tongue_rolleye.gif', '19', '19', 'tongue rolleye'),
';-P' => array('tongue_wink.gif', '19', '19', 'tongue wink'),
':P' => array('raspberry.gif', '19', '19', 'raspberry'),
':blank:' => array('blank.gif', '19', '19', 'blank stare'),
':long:' => array('longface.gif', '19', '19', 'long face'),
':ohh:' => array('ohh.gif', '19', '19', 'ohh'),
':grrr:' => array('grrr.gif', '19', '19', 'grrr'),
':gulp:' => array('gulp.gif', '19', '19', 'gulp'),
'8-/' => array('ohoh.gif', '19', '19', 'oh oh'),
':down:' => array('downer.gif', '19', '19', 'downer'),
':red:' => array('embarrassed.gif', '19', '19', 'red face'),
':sick:' => array('sick.gif', '19', '19', 'sick'),
':shut:' => array('shuteye.gif', '19', '19', 'shut eye'),
':-/' => array('hmm.gif', '19', '19', 'hmmm'),
'>:(' => array('mad.gif', '19', '19', 'mad'),
':mad:' => array('mad.gif', '19', '19', 'mad'),
'>:-(' => array('angry.gif', '19', '19', 'angry'),
':angry:' => array('angry.gif', '19', '19', 'angry'),
':zip:' => array('zip.gif', '19', '19', 'zipper'),
':kiss:' => array('kiss.gif', '19', '19', 'kiss'),
':ahhh:' => array('shock.gif', '19', '19', 'shock'),
':coolsmile:' => array('shade_smile.gif', '19', '19', 'cool smile'),
':coolsmirk:' => array('shade_smirk.gif', '19', '19', 'cool smirk'),
':coolgrin:' => array('shade_grin.gif', '19', '19', 'cool grin'),
':coolhmm:' => array('shade_hmm.gif', '19', '19', 'cool hmm'),
':coolmad:' => array('shade_mad.gif', '19', '19', 'cool mad'),
':coolcheese:' => array('shade_cheese.gif', '19', '19', 'cool cheese'),
':vampire:' => array('vampire.gif', '19', '19', 'vampire'),
':snake:' => array('snake.gif', '19', '19', 'snake'),
':exclaim:' => array('exclaim.gif', '19', '19', 'exclaim'),
':question:' => array('question.gif', '19', '19', 'question')
);
+6
View File
@@ -0,0 +1,6 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['host'] = '192.168.0.16';
$config['port'] = 9512;
$config['SPHINX_MAX_MATCHES'] = '2000';
+214
View File
@@ -0,0 +1,214 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| USER AGENT TYPES
| -------------------------------------------------------------------
| This file contains four arrays of user agent data. It is used by the
| User Agent Class to help identify browser, platform, robot, and
| mobile device data. The array keys are used to identify the device
| and the array values are used to set the actual name of the item.
*/
$platforms = array(
'windows nt 10.0' => 'Windows 10',
'windows nt 6.3' => 'Windows 8.1',
'windows nt 6.2' => 'Windows 8',
'windows nt 6.1' => 'Windows 7',
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.1' => 'Windows XP',
'windows nt 5.0' => 'Windows 2000',
'windows nt 4.0' => 'Windows NT 4.0',
'winnt4.0' => 'Windows NT 4.0',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows phone' => 'Windows Phone',
'windows' => 'Unknown Windows OS',
'android' => 'Android',
'blackberry' => 'BlackBerry',
'iphone' => 'iOS',
'ipad' => 'iOS',
'ipod' => 'iOS',
'os x' => 'Mac OS X',
'ppc mac' => 'Power PC Mac',
'freebsd' => 'FreeBSD',
'ppc' => 'Macintosh',
'linux' => 'Linux',
'debian' => 'Debian',
'sunos' => 'Sun Solaris',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'gnu' => 'GNU/Linux',
'unix' => 'Unknown Unix OS',
'symbian' => 'Symbian OS'
);
// The order of this array should NOT be changed. Many browsers return
// multiple browser types so we want to identify the sub-type first.
$browsers = array(
'OPR' => 'Opera',
'Flock' => 'Flock',
'Edge' => 'Edge',
'Chrome' => 'Chrome',
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
'Opera.*?Version' => 'Opera',
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Trident.* rv' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Safari' => 'Safari',
'Mozilla' => 'Mozilla',
'Konqueror' => 'Konqueror',
'icab' => 'iCab',
'Lynx' => 'Lynx',
'Links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
'Maxthon' => 'Maxthon',
'Ubuntu' => 'Ubuntu Web Browser'
);
$mobiles = array(
// legacy array, old values commented out
'mobileexplorer' => 'Mobile Explorer',
// 'openwave' => 'Open Wave',
// 'opera mini' => 'Opera Mini',
// 'operamini' => 'Opera Mini',
// 'elaine' => 'Palm',
'palmsource' => 'Palm',
// 'digital paths' => 'Palm',
// 'avantgo' => 'Avantgo',
// 'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
// 'nokia' => 'Nokia',
// 'ericsson' => 'Ericsson',
// 'blackberry' => 'BlackBerry',
// 'motorola' => 'Motorola'
// Phones and Manufacturers
'motorola' => 'Motorola',
'nokia' => 'Nokia',
'palm' => 'Palm',
'iphone' => 'Apple iPhone',
'ipad' => 'iPad',
'ipod' => 'Apple iPod Touch',
'sony' => 'Sony Ericsson',
'ericsson' => 'Sony Ericsson',
'blackberry' => 'BlackBerry',
'cocoon' => 'O2 Cocoon',
'blazer' => 'Treo',
'lg' => 'LG',
'amoi' => 'Amoi',
'xda' => 'XDA',
'mda' => 'MDA',
'vario' => 'Vario',
'htc' => 'HTC',
'samsung' => 'Samsung',
'sharp' => 'Sharp',
'sie-' => 'Siemens',
'alcatel' => 'Alcatel',
'benq' => 'BenQ',
'ipaq' => 'HP iPaq',
'mot-' => 'Motorola',
'playstation portable' => 'PlayStation Portable',
'playstation 3' => 'PlayStation 3',
'playstation vita' => 'PlayStation Vita',
'hiptop' => 'Danger Hiptop',
'nec-' => 'NEC',
'panasonic' => 'Panasonic',
'philips' => 'Philips',
'sagem' => 'Sagem',
'sanyo' => 'Sanyo',
'spv' => 'SPV',
'zte' => 'ZTE',
'sendo' => 'Sendo',
'nintendo dsi' => 'Nintendo DSi',
'nintendo ds' => 'Nintendo DS',
'nintendo 3ds' => 'Nintendo 3DS',
'wii' => 'Nintendo Wii',
'open web' => 'Open Web',
'openweb' => 'OpenWeb',
// Operating Systems
'android' => 'Android',
'symbian' => 'Symbian',
'SymbianOS' => 'SymbianOS',
'elaine' => 'Palm',
'series60' => 'Symbian S60',
'windows ce' => 'Windows CE',
// Browsers
'obigo' => 'Obigo',
'netfront' => 'Netfront Browser',
'openwave' => 'Openwave Browser',
'mobilexplorer' => 'Mobile Explorer',
'operamini' => 'Opera Mini',
'opera mini' => 'Opera Mini',
'opera mobi' => 'Opera Mobile',
'fennec' => 'Firefox Mobile',
// Other
'digital paths' => 'Digital Paths',
'avantgo' => 'AvantGo',
'xiino' => 'Xiino',
'novarra' => 'Novarra Transcoder',
'vodafone' => 'Vodafone',
'docomo' => 'NTT DoCoMo',
'o2' => 'O2',
// Fallback
'mobile' => 'Generic Mobile',
'wireless' => 'Generic Mobile',
'j2me' => 'Generic Mobile',
'midp' => 'Generic Mobile',
'cldc' => 'Generic Mobile',
'up.link' => 'Generic Mobile',
'up.browser' => 'Generic Mobile',
'smartphone' => 'Generic Mobile',
'cellphone' => 'Generic Mobile'
);
// There are hundreds of bots but these are the most common.
$robots = array(
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'yandex' => 'YandexBot',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'ia_archiver' => 'Alexa Crawler',
'MJ12bot' => 'Majestic-12',
'Uptimebot' => 'Uptimebot'
);
+16
View File
@@ -0,0 +1,16 @@
<?php
//ini_set("display_errors", "On");//打开错误提示
//ini_set("error_reporting",E_ALL);//显示所有错误
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
public function test(){
echo '11';
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'libraries/REST_Controller.php';
use Restserver\Libraries\REST_Controller;
/**
* Notes:基本控制器
* Created on: 2022/9/2 16:57
* Created by: dengbw
*/
abstract class BaseController extends REST_Controller
{
protected $inputs;
protected $start_time;
public function __construct()
{
parent::__construct();
$this->input_param();
$this->start_time = microtime(true);
}
/**
* Notes:获取参数
* Created on: 2022/9/2 16:57
* Created by: dengbw
* @param string $key
* @return mixed
*/
function input_param($key = '')
{
if ($key) {
return $this->inputs[$key];
}
$request = $this->input->method();
switch ($request) {
case 'post':
case 'put':
case 'delete':
$input = json_decode(file_get_contents('php://input'), true);
break;
default:
$input = $this->input->get();
}
$this->inputs = $input;
return $this->inputs;
}
/**
* Notes:返回json
* Created on: 2022/9/8 15:35
* Created by: dengbw
* @param string $message
* @param int $code
*/
public function return_json($message = '', $code = 1)
{
header('Content-Type:application/json; charset=utf-8');
echo json_encode(['code' => $code, 'message' => $message], JSON_UNESCAPED_UNICODE);
exit();
}
/**
* Notes:返回response
* Created on: 2022/9/9 15:39
* Created by: dengbw
* @param array $data
*/
public function return_response_list($data = [])
{
$this->return_response($data, '操作成功', 0, 1);
}
/**
* Notes:返回response
* Created on: 2022/9/8 15:21
* Created by: dengbw
* @param array $data
* @param string $message
* @param int $code
* @param int $if_list
* @param int $http_code
*/
public function return_response($data = [], $message = '操作成功', $code = 0, $if_list = 0, $http_code = REST_Controller::HTTP_OK)
{
$set_data = ['code' => $code, 'message' => $message];
if ($if_list) {//列表显示空数据
$set_data['data'] = $data;
} else {
$data && $set_data['data'] = $data;
}
if ($_SESSION['operation_description']) {//添加操作日志
$this->load->library('api/record');
$method = lcfirst(get_class($this));
$end_time = microtime(true);
$spendTime = ($end_time - $this->start_time) * 1000; //计算差值 毫秒
$this->record->operationRecord(['userId' => $_SESSION['userId'], 'username' => $_SESSION['username']
, 'nickname' => $_SESSION['nickname'], 'method' => $method, 'spendTime' => $spendTime
, 'module' => $_SESSION['operation_module'], 'description' => $_SESSION['operation_description']
, 'params' => json_encode($this->inputs, JSON_UNESCAPED_UNICODE)
, 'result' => json_encode($set_data, JSON_UNESCAPED_UNICODE)]);
}
$this->response($set_data, $http_code, TRUE);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:生成验证码
* Created on: 2022/8/29 17:15
* Created by: dengbw
*/
class Captcha extends BaseController
{
private $redis;
public function __construct()
{
parent::__construct();
$this->redis = &load_cache('redis');
}
public function index_get()
{
$this->load->library('MyCaptcha');
$myCaptcha = new MyCaptcha();
$re = $myCaptcha->create(5, ['width' => 16, 'height' => 20, 'pnum' => 50, 'base64' => 1]);
$code_key = $this->generateSign();
$this->redis->save($code_key, $re['text'], 5 * 60);
$data = ['base64' => $re['base64'], 'code_key' => $code_key];
$this->return_response($data);
}
function generateSign()
{
$sign = md5(mt_rand() . 'mycaptchamarket');
// 拼接上签名作为 Redis 的 key
$key = 'code_' . $sign;
if ($this->redis->exists($key)) {
// 如果生成的 Sign 已存在,就进行递归,直到生成出一个不存在的。
return $this->generateSign();
}
return $key;
}
}
+122
View File
@@ -0,0 +1,122 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:登录操作
* Created on: 2022/8/29 17:15
* Created by: dengbw
*/
class Login extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_admin_model', 'mdSysAdmin');
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
$this->load->model('market/Market_sys_menu_model', 'mdSysMenu');
$this->load->model('market/Market_sys_login_record_model', 'mdSysLoginRecord');
}
/**
* Notes:用户登录
* Created on: 2022/9/8 14:49
* Created by: dengbw
*/
public function index_post()
{
$username = $this->input_param('username');
$password = $this->input_param('password');
$code = $this->input_param('code');
$code_key = $this->input_param('code_key');
if (!$username) {
$this->return_json('请输入登录账号');
}
if (!$password) {
$this->return_json('请输入登录密码');
}
if (!$code) {
$this->return_json('请输入验证码');
}
$redis = &load_cache('redis');
if (!$redis->get($code_key)) {
$this->return_json('验证码已过期');
}
if ($redis->get($code_key) != $code) {
$this->return_json('验证码错误');
}
$re = $this->mdSysAdmin->get(["username like '{$username}'" => null, 'status' => 0]);
if (!$re) {
$this->return_json('账号不存在');
return;
}
$this->load->library('api/record');
if (!password_verify($password, $re['password'])) {
$message = '密码错误';
$this->record->loginRecord(['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname']
, 'loginType' => 1, 'comments' => $message]);
$this->return_json($message);
}
$user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'], 'avatar' => "https://cdn.eleadmin.com/20200610/avatar.jpg"
, 'sex' => $re['sex'], 'phone' => $re['phone'], 'introduction' => $re['introduction'], 'email' => $re['email']
, 'enabled' => true, 'accountNonLocked' => true, 'credentialsNonExpired' => true, 'accountNonExpired' => true];
$roles = $authorities = [];
if ($re['roleId']) {
$re_ro = $this->mdSysRole->get(['roleId' => $re['roleId'], 'status' => 0]);
if ($re_ro) {
$re_ro['userId'] = $re['userId'];
$roles[] = $re_ro;
if ($re_ro['menuIds']) {
$authorities = $this->mdSysMenu->select(["menuId in({$re_ro['menuIds']})" => null, 'status' => 0]
, 'sortNumber asc,menuId desc');
foreach ($authorities as $k => $v) {
$authorities[$k]['menuId'] = intval($v['menuId']);
$authorities[$k]['parentId'] = intval($v['parentId']);
$authorities[$k]['menuType'] = intval($v['menuType']);
$authorities[$k]['openType'] = intval($v['openType']);
$authorities[$k]['sortNumber'] = intval($v['sortNumber']);
$authorities[$k]['hide'] = intval($v['hide']);
$authorities[$k]['meta'] = json_decode($v['meta'], true);
}
}
}
}
$user['roles'] = $roles;
$user['authorities'] = $authorities;
// $user['authorities'] = [
// ['menuId' => 1, 'parentId' => 0, 'title' => "系统管理", 'path' => '/system', 'component' => null, 'menuType' => 0, 'sortNumber' => 1, 'authority' => null, 'icon' => 'el-icon-setting', 'hide' => 0, 'meta' => ['badge' => 'New', 'badgeColor' => 'warning'], 'deleted' => 0, 'createTime' => '2020-02-26 12:51:23', 'updateTime' => '2022-03-11 16:46:28', 'children' => null, 'checked' => null],
// ['menuId' => 2, 'parentId' => 1, 'title' => "用户管理", 'path' => '/system/user', 'component' => '/system/user', 'menuType' => 0, 'sortNumber' => 1, 'authority' => null, 'icon' => 'el-icon-_user-group', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-02-26 12:51:55', 'updateTime' => '2021-05-21 17:56:28', 'children' => null, 'checked' => null],
// ['menuId' => 7, 'parentId' => 1, 'title' => "角色管理", 'path' => '/system/role', 'component' => '/system/role', 'menuType' => 0, 'sortNumber' => 2, 'authority' => null, 'icon' => 'el-icon-postcard', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-03-13 13:29:08', 'updateTime' => '2021-05-21 17:56:34', 'children' => null, 'checked' => null],
// ['menuId' => 12, 'parentId' => 1, 'title' => "菜单管理", 'path' => '/system/menu', 'component' => '/system/menu', 'menuType' => 0, 'sortNumber' => 3, 'authority' => null, 'icon' => 'el-icon-s-operation', 'hide' => 0, 'meta' => null, 'deleted' => 0, 'createTime' => '2020-03-21 01:07:13', 'updateTime' => '2021-05-21 17:56:39', 'children' => null, 'checked' => null]
// ];
$data['access_token'] = Authorization::generateToken($re['userId']);
$data['user'] = $user;
$this->record->loginRecord(['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname']]);
$redis->delete($code_key);//删除验证码
$this->return_response($data, '登录成功');
}
/**
* Notes:
* Created on: 2022/8/29 17:06
* Created by: dengbw
* http://market.dev.liche.cn/api/login/test
* http://market.liche.cn/api/login/test
*/
public function test()
{
//echo config('ele_admin.API_KEY');
$mobile = '13860164563';
$signer = new Lcobucci\JWT\Signer\Hmac\Sha256();//加密算法
$time = time();
$key = new Lcobucci\JWT\Signer\Key('market');
$token = (new Lcobucci\JWT\Builder())->issuedBy('http://market.dev.liche.cn')
->identifiedBy('4f1g23a12aa', true)//身份验证
->issuedAt($time)//签发时间
->expiresAt($time + 60)//多长时间以后才能用token,60秒以后才能用
->withClaim('mobile', $mobile)
->getToken($signer, $key);//配置项
echo 'token=' . $token;
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:上传图片
* Created on: 2022/9/21 17:15
* Created by: dengbw
*/
class Upload extends BaseController
{
public function __construct()
{
parent::__construct();
}
public function index_post()
{
$file = $_FILES['file'];
if (!$file) {
$this->return_json('请选择图片');
}
if (!$file['tmp_name']) {//太大的图片上传,这个参数会变成空的
$this->return_json('参数错误');
}
if (!file_exists(TEMP_PATH)) {
$oldumask = umask(0);
mkdir(TEMP_PATH, 0777, true);
umask($oldumask);
}
$tmp = TEMP_PATH . md5($file['name'] . uniqid()) . substr($file['name'], strpos($file['name'], '.', strlen($file['name']) - 1));
move_uploaded_file($file['tmp_name'], $tmp);
if (!filesize($tmp)) {
$this->return_json('图片有点问题,换个小的试试');
}
//上传图片到FTP
$res = $this->upload_img_qiniu($tmp, "market/");
if (!$res) {
$this->return_json('上传失败');
}
$data['full_url'] = build_qiniu_image_url($res['photo']);
$data['url'] = $res['photo'];
$this->return_response($data);
}
/**
* @param string $file 上传的文件
* @param string $path 要保存的目录
* @param string $filename 原始文件名称
* @return array
* @throws Exception
*/
private function upload_img_qiniu($file, $path = '', $filename = '')
{
$phoId = md5(uniqid() . mt_rand(0, 10000) . time());
$filename = $filename ? $filename : $file;
$ext_arr = explode(".", $filename);
$ext = count($ext_arr) > 1 ? $ext_arr[count($ext_arr) - 1] : 'jpg';
if (is_uploaded_file($file)) {
//上传图片
$oriPath = TEMP_PATH . '/p_' . $phoId . '_ori.' . $ext;
move_uploaded_file($file, $oriPath);
} else {
$oriPath = $file;
}
$oriKey = 'p_' . $phoId . '.' . $ext;
// 上传到七牛后保存的文件名
$photo = $path . date('Ym') . "/" . $oriKey;
//上传图片到FTP
$this->load->library('qiniu');
$res = $this->qiniu->save($photo, file_get_contents($oriPath));
$img_size = getimagesize($oriPath);
$file_size = filesize($oriPath);
$size = "{$img_size[0]},{$img_size[1]},{$file_size}";
unlink($oriPath);
if ($res) {
$size = getimagesize($res['url']);
return array('photo' => $res['file'], 'size' => $size);
} else {
return array();
}
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:修改密码
* Created on: 2022/9/05 17:15
* Created by: dengbw
*/
class Password extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_admin_model', 'mdSysAdmin');
}
/**
* Notes:修改密码
* Created on: 2022/9/16 11:11
* Created by: dengbw
*/
public function index_put()
{
$oldPassword = $this->input_param('oldPassword');
$password = $this->input_param('password');
$password2 = $this->input_param('password2');
if (!$oldPassword) {
$this->return_json('请输入旧密码');
}
if (!$password) {
$this->return_json('请输入新密码');
}
if (!$password2) {
$this->return_json('请再次输入新密码');
}
if (mb_strlen($password) < 4) {
$this->return_json('请输入至少4个字符的新密码');
}
if ($password != $password2) {
$this->return_json('两次输入密码不一致');
}
if (!password_verify($oldPassword, $_SESSION['password'])) {
$this->return_json('旧密码错误');
}
$upDate['password'] = password_hash($password, PASSWORD_BCRYPT);
$this->mdSysAdmin->update($upDate, ['userId' => $_SESSION['userId']]);
$this->return_response();
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:获取用户信息
* Created on: 2022/9/05 17:15
* Created by: dengbw
*/
class User extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
$this->load->model('market/Market_sys_menu_model', 'mdSysMenu');
}
public function index_get()
{
$re = $_SESSION;
$user = ['userId' => $re['userId'], 'username' => $re['username'], 'nickname' => $re['nickname'], 'avatar' => "https://cdn.eleadmin.com/20200610/avatar.jpg"
, 'sex' => $re['sex'], 'phone' => $re['phone'], 'introduction' => $re['introduction'], 'email' => $re['email']
, 'enabled' => true, 'accountNonLocked' => true, 'credentialsNonExpired' => true, 'accountNonExpired' => true];
$roles = $authorities = [];
if ($re['roleId']) {
$re_ro = $this->mdSysRole->get(['roleId' => $re['roleId'], 'status' => 0]);
if ($re_ro) {
$re_ro['userId'] = $re['userId'];
$roles[] = $re_ro;
if ($re_ro['menuIds']) {
$authorities = $this->mdSysMenu->select(["menuId in({$re_ro['menuIds']})" => null, 'status' => 0]
, 'sortNumber asc,menuId desc');
foreach ($authorities as $k => $v) {
$authorities[$k]['menuId'] = intval($v['menuId']);
$authorities[$k]['parentId'] = intval($v['parentId']);
$authorities[$k]['menuType'] = intval($v['menuType']);
$authorities[$k]['openType'] = intval($v['openType']);
$authorities[$k]['sortNumber'] = intval($v['sortNumber']);
$authorities[$k]['hide'] = intval($v['hide']);
$authorities[$k]['meta'] = json_decode($v['meta'], true);
}
}
}
}
$user['roles'] = $roles;
$user['authorities'] = $authorities;
$this->return_response($user);
}
}
+483
View File
@@ -0,0 +1,483 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:私域直播_活动管理
* Created on: 2022/9/19 17:15
* Created by: dengbw
*/
class Activity extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_activity_model', 'mdSyliveActivity');
$this->load->model('market/Market_sylive_activity_biz_model', 'mdSyliveActivityBiz');
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
}
/**
* Notes:活动管理列表
* Created on: 2022/9/20 14:48
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$title = $this->input_param('title');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'activityId desc';
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$list = [];
$where['status>='] = 0;
$title && $where['title LIKE "%' . trim($title) . '%"'] = null;
$count = $this->mdSyliveActivity->count($where);
if ($count) {
$this->load->library('MyEncryption');
$res = $this->mdSyliveActivity->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$dateRange = [$v['timeStart'], $v['timeEnd']];
$status = intval($v['status']);
$activityId = intval($v['activityId']);
$bgImg = $channelImg = $shareImg = $shareTitle = $bizIds = [];
$item = ['activityId' => $activityId, 'itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'dateRange' => ''];
$v['shareTitle'] && $shareTitle = json_decode($v['shareTitle'], true);
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
if ($jsondata['item']) {
$getItem = $jsondata['item'];
$item['title'] = $getItem['title'];
$item['introduction'] = $getItem['introduction'];
$item['price'] = $getItem['price'];
$item['dateRange'] = [$getItem['timeStart'], $getItem['timeEnd']];
if ($getItem['itemImg']) {
$itemImg = [];
foreach ($getItem['itemImg'] as $k2 => $v2) {
$itemImg[] = ['uid' => $k2, 'fileUrl' => $v2, 'url' => build_qiniu_image_url($v2), 'status' => 'done'];
}
$item['itemImg'] = $itemImg;
}
}
if ($v['bgImg']) {
$bgImg = [['uid' => 1, 'fileUrl' => $v['bgImg'], 'url' => build_qiniu_image_url($v['bgImg']), 'status' => 'done']];
}
if ($v['channelImg']) {
$channelImg = [['uid' => 1, 'fileUrl' => $v['channelImg'], 'url' => build_qiniu_image_url($v['channelImg']), 'status' => 'done']];
}
if ($v['shareImg']) {
$getShareImg = json_decode($v['shareImg'], true);
foreach ($getShareImg as $k2 => $v2) {
$shareImg[] = ['uid' => $k2, 'fileUrl' => $v2, 'url' => build_qiniu_image_url($v2), 'status' => 'done'];
}
}
$res_biz = $this->mdSyliveActivityBiz->select(['activityId' => $activityId, 'status' => 0], 'id desc', 0, 0, 'bizId');
if ($res_biz) {
foreach ($res_biz as $k2 => $v2) {
$bizIds[] = intval($v2['bizId']);
}
}
$url = http_host_com('home') . "/h5/market/sylive?skey=" . $this->myencryption->base64url_encode("id=" . $activityId);
$list[] = [
'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'bizIds' => $bizIds,
'introduction' => $v['introduction'], 'shareTitle' => $shareTitle, 'dateRange' => $dateRange
, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url
, 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'createTime' => $v['createTime']];
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
/**
* Notes:添加活动
* Created on: 2022/9/21 16:46
* Created by: dengbw
*/
public function index_post()
{
$title = $this->input_param('title');
$channelId = $this->input_param('channelId');
$dateRange = $this->input_param('dateRange');
$introduction = $this->input_param('introduction');
$shareTitle = $this->input_param('shareTitle');
$shareImg = $this->input_param('shareImg');
$bgImg = $this->input_param('bgImg');
$channelImg = $this->input_param('channelImg');
$bizIds = $this->input_param('bizIds');
if (!$title) {
$this->return_json('请输入活动标题');
}
if (!$bizIds) {
$this->return_json('请选择所属门店');
}
if (!$bgImg[0]['fileUrl']) {
$this->return_json('请选择背景图');
}
if (!$channelId) {
$this->return_json('请输入直播频道');
}
if (!$dateRange) {
$this->return_json('请选择直播时间');
}
if (!$introduction) {
$this->return_json('请输入活动简介');
}
$bgImg = $bgImg[0]['fileUrl'];
$channelImg = $channelImg[0]['fileUrl'] ? $channelImg[0]['fileUrl'] : '';
$shareTitle && $shareTitle = json_encode($shareTitle, JSON_UNESCAPED_UNICODE);
$setShareImg = '';
if ($shareImg) {
foreach ($shareImg as $v) {
$setShareImg[] = $v['fileUrl'];
}
$setShareImg = json_encode($setShareImg, JSON_UNESCAPED_UNICODE);
}
$addDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId
, 'introduction' => $introduction, 'shareTitle' => $shareTitle, 'shareImg' => $setShareImg, 'timeStart' => $dateRange[0]
, 'timeEnd' => $dateRange[1], 'status' => 1, 'createTime' => date('Y-m-d H:i:s')];
$activityId = $this->mdSyliveActivity->add($addDate);
if (!$activityId) {
$this->return_json('添加活动失败');
}
$bizIds = implode(',', $bizIds);
$res_org = $this->mdSyliveOrganization->select(["organizationId in({$bizIds})" => null, 'organizationType' => 3]
, 'organizationId desc', 0, 0, 'organizationId,parentId');
$add_biz = [];
if ($res_org) {
$this->mdSyliveActivityBiz->update(['status' => -1], ["bizId not in({$bizIds})" => null, 'activityId' => $activityId, 'status' => 0]);
foreach ($res_org as $v) {
$add_biz[] = ['activityId' => $activityId, 'areaId' => $v['parentId']
, 'bizId' => $v['organizationId'], 'createTime' => date('Y-m-d H:i:s')];
}
//增加活动商家
$add_biz && $this->mdSyliveActivityBiz->add_batch($add_biz);
}
$this->return_response();
}
/**
* Notes:活动详情
* Created on: 2022/9/29 10:37
* Created by: dengbw
* @param null $activityId
*/
public function index_get($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
if (!$re) {
$this->return_json('活动不存在');
}
$this->return_response($re);
}
/**
* Notes:修改活动
* Created on: 2022/9/21 14:48
* Created by: dengbw
*/
public function index_put()
{
$activityId = intval($this->input_param('activityId'));
$title = $this->input_param('title');
$channelId = $this->input_param('channelId');
$dateRange = $this->input_param('dateRange');
$introduction = $this->input_param('introduction');
$shareTitle = $this->input_param('shareTitle');
$shareImg = $this->input_param('shareImg');
$bgImg = $this->input_param('bgImg');
$channelImg = $this->input_param('channelImg');
$bizIds = $this->input_param('bizIds');
if (!$activityId) {
$this->return_json('参数错误');
}
if (!$title) {
$this->return_json('请输入活动标题');
}
if (!$bizIds) {
$this->return_json('请选择所属门店');
}
if (!$bgImg[0]['fileUrl']) {
$this->return_json('请选择背景图');
}
if (!$channelId) {
$this->return_json('请输入直播频道');
}
if (!$dateRange) {
$this->return_json('请选择直播时间');
}
if (!$introduction) {
$this->return_json('请输入活动简介');
}
$bizIds = implode(',', $bizIds);
$res_org = $this->mdSyliveOrganization->select(["organizationId in({$bizIds})" => null, 'organizationType' => 3]
, 'organizationId desc', 0, 0, 'organizationId,parentId');
$add_biz = [];
if ($res_org) {
$this->mdSyliveActivityBiz->update(['status' => -1], ["bizId not in({$bizIds})" => null, 'activityId' => $activityId, 'status' => 0]);
foreach ($res_org as $v) {
$re_org = $this->mdSyliveActivityBiz->get(['activityId' => $activityId, 'bizId' => $v['organizationId']]);
if (!$re_org) {
$add_biz[] = ['activityId' => $activityId, 'areaId' => $v['parentId']
, 'bizId' => $v['organizationId'], 'createTime' => date('Y-m-d H:i:s')];
} else if ($re_org['status'] == -1) {
$this->mdSyliveActivityBiz->update(['status' => 0], ['id' => $re_org['id']]);
}
}
//增加活动商家
$add_biz && $this->mdSyliveActivityBiz->add_batch($add_biz);
}
$bgImg = $bgImg[0]['fileUrl'];
$channelImg = $channelImg[0]['fileUrl'] ? $channelImg[0]['fileUrl'] : '';
$shareTitle && $shareTitle = json_encode($shareTitle, JSON_UNESCAPED_UNICODE);
$setShareImg = '';
if ($shareImg) {
foreach ($shareImg as $v) {
$setShareImg[] = $v['fileUrl'];
}
$setShareImg = json_encode($setShareImg, JSON_UNESCAPED_UNICODE);
}
$upDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'introduction' => $introduction,
'shareTitle' => $shareTitle, 'shareImg' => $setShareImg, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1]];
$this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:修改商品
* Created on: 2022/9/28 15:09
* Created by: dengbw
*/
public function item_put()
{
$activityId = intval($this->input_param('activityId'));
$title = $this->input_param('title');
$price = $this->input_param('price');
$itemImg = $this->input_param('itemImg');
$dateRange = $this->input_param('dateRange');
$introduction = $this->input_param('introduction');
if (!$activityId) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
if (!$re) {
$this->return_json('活动不存在');
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$item = ['title' => $title, 'price' => $price, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'introduction' => $introduction];
if ($itemImg) {
$setItemImg = [];
foreach ($itemImg as $v) {
$setItemImg[] = $v['fileUrl'];
}
$item['itemImg'] = $setItemImg;
}
$jsondata['item'] = $item;
$upDate = ['jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)];
$this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:删除活动
* Created on: 2022/9/21 16:10
* Created by: dengbw
* @param null $activityId
*/
public function index_delete($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => -1], ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:批量删除用户
* Created on: 2022/9/8 17:11
* Created by: dengbw
*/
public function batch_delete()
{
$ids = $this->inputs;
if (!$ids) {
$this->return_json('参数错误');
}
$str_ids = implode(',', $ids);
if ($str_ids) {
$this->mdSyliveActivity->update(['status' => -1], ["activityId in($str_ids)" => null]);
}
$this->return_response();
}
/**
* Notes:修改状态
* Created on: 2022/9/8 16:10
* Created by: dengbw
*/
public function status_put()
{
$activityId = $this->input_param('activityId');
$status = $this->input_param('status');
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => $status], ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:活动统计
* Created on: 2022/9/27 10:02
* Created by: dengbw
* @param null $activityId
*/
public function statistics_get($activityId = null)
{
$activityId = intval($activityId);
if (!$activityId) {
$this->return_json('参数错误');
}
$this->load->model('market/Market_sylive_activity_kpidata_model', 'mdSyliveActivityKpidata');
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
$this->load->model('live/Live_polyv_session_model', 'mdPolyvSession');
$title = '';
$activityData = $areaData = $bizData = $consultantData = $areaAry = [];
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
if ($re) {
$title = $re['title'];
$res_biz = $this->mdSyliveActivityBiz->select(['activityId' => $activityId, 'status' => 0], 'browse desc');
foreach ($res_biz as $k => $v) {
$areaId = intval($v['areaId']);
$bizId = intval($v['bizId']);
$re_biz = $this->mdSyliveOrganization->get(['organizationId' => $bizId]);
if ($re_biz) {
$consultant = $this->mdSyliveActivityKpidata->count(['biz_id' => $bizId, 'a_id' => $activityId], 'distinct(cf_uid)');
$bizData[] = ['areaId' => $areaId, 'bizId' => $bizId,
'bizName' => $re_biz['organizationName'], 'consultant' => $consultant, 'browse' => $v['browse'], 'subscribe' => $v['subscribe']
, 'watch' => $v['watch'], 'order' => $v['orderTotal'], 'livePV' => 35, 'watchDuration' => 10];
if (!$areaAry[$areaId]) {//大区
$areaAry[$areaId] = 1;
} else {
$areaAry[$areaId] += 1;
}
}
}
foreach ($areaAry as $k => $v) {
$areaId = intval($k);
$re_area = $this->mdSyliveOrganization->get(['organizationId' => $areaId]);
if ($re_area) {
$consultant = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId], 'distinct(cf_uid)');
$browse = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'browse']);
$subscribe = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'subscribe']);
$watch = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'watch']);
$order = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'a_id' => $activityId, 'kpi' => 'order']);
$areaData[] = ['areaName' => $re_area['organizationName'], 'biz' => $v, 'consultant' => $consultant
, 'browse' => $browse, 'subscribe' => $subscribe, 'watch' => $watch, 'order' => $order
, 'livePV' => 35, 'watchDuration' => 10];
}
}
$res_user = $this->mdSyliveActivityKpidata->select(['a_id' => $activityId], 'id desc', 0, 0, 'distinct(cf_uid) as userId');
foreach ($res_user as $k => $v) {
$userId = intval($v['userId']);
$re_user = $this->mdSyliveUser->get(['userId' => $v['userId']]);
if ($re_user) {
$consultantName = $re_user['uname'] ? $re_user['uname'] : $re_user['nickname'];
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'browse']);
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'subscribe']);
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'watch']);
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'kpi' => 'order']);
$consultantData = [['consultantName' => $consultantName, 'browse' => $browse, 'subscribe' => $subscribe, 'watch' => $watch
, 'order' => $order, 'livePV' => 35, 'watchDuration' => 10]];
}
}
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'browse']);
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'subscribe']);
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'watch']);
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'kpi' => 'order']);
$activityData = [['name' => '参与区域数', 'value' => count($areaData)], ['name' => '参与门店数', 'value' => count($bizData)]
, ['name' => '参与顾问数', 'value' => count($res_user)], ['name' => '浏览人数', 'value' => $browse], ['name' => '预约人数', 'value' => $subscribe]
, ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order], ['name' => '直播时长', 'value' => 8]
, ['name' => '观看次数', 'value' => 10], ['name' => '人均观看', 'value' => 9]];
}
$data = ['activityId' => $activityId, 'title' => $title, 'activityData' => $activityData, 'areaData' => $areaData
, 'bizData' => $bizData, 'consultantData' => $consultantData];
$this->return_response($data);
}
/**
* Notes:活动订单列表
* Created on: 2022/9/29 9:53
* Created by: dengbw
* @param null $activityId
*/
public function order_get()
{
$this->load->model('market/Market_sylive_order_model', 'mdSyliveOrder');
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
$activityId = intval($this->input_param('activityId'));
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$item_title = $this->input_param('item_title');
$mobile = $this->input_param('mobile');
$name = $this->input_param('name');
$status = $this->input_param('status');
$sid = $this->input_param('sid');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'id desc';
if ($sort && $order) {
if ($sort == 'statusName') {
$sort_order = 'status ' . $order;
} else {
$sort_order = $sort . ' ' . $order;
}
}
$list = [];
if (!strlen($status)) {
$status = 1;
}
$where['status'] = $status;
$activityId && $where['item_id'] = $activityId;
$item_title && $where['item_title'] = $item_title;
$sid && $where['sid'] = $sid;
$str_user_ids = 0;
if ($name || $mobile) {
$where_user['status>='] = 0;
$name && $where_user["(uname LIKE '%{$name}%' OR mobile LIKE '%{$name}%')"] = null;
$mobile && $where_user['mobile'] = $mobile;
$res_user = $this->mdSyliveUser->select($where_user, 'userId desc', 0, 0, 'userId');
$res_user && $str_user_ids = implode(',', array_unique(array_column($res_user, 'userId')));
$where["u_id in($str_user_ids)"] = null;
}
$count = $this->mdSyliveOrder->count($where);
if ($count) {
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
$str_user_ids = implode(',', array_unique(array_column($res, 'uid')));
$map_users = $this->mdSyliveUser->map('userId', 'uname,nickname,mobile', ["userId in({$str_user_ids})" => null]);
foreach ($res as $v) {
$name = $map_users[$v['uid']]['uname'] ? $map_users[$v['uid']]['uname'] : $map_users[$v['uid']]['nickname'];
$mobile = $map_users[$v['uid']]['mobile'];
$list[] = [
'id' => $v['id'], 'sid' => $v['sid'], 'name' => $name, 'mobile' => $mobile, 'item_title' => $v['item_title']
, 'total_price' => $v['total_price'], 'pay_time' => $v['pay_time'] != '0000-00-00 00:00:00' ? $v['pay_time'] : ''
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'createTime' => $v['createTime']];
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:私域直播_订单管理
* Created on: 2022/9/19 17:15
* Created by: dengbw
*/
class Order extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_order_model', 'mdSyliveOrder');
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
}
/**
* Notes:订单管理列表
* Created on: 2022/9/20 14:48
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$item_title = $this->input_param('item_title');
$mobile = $this->input_param('mobile');
$name = $this->input_param('name');
$status = $this->input_param('status');
$sid = $this->input_param('sid');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'id desc';
if ($sort && $order) {
if ($sort == 'statusName') {
$sort_order = 'status ' . $order;
} else {
$sort_order = $sort . ' ' . $order;
}
}
$list = [];
if (!strlen($status)) {
$status = 1;
}
$where['status'] = $status;
$item_title && $where['item_title'] = $item_title;
$sid && $where['sid'] = $sid;
$str_user_ids = 0;
if ($name || $mobile) {
$where_user['status>='] = 0;
$name && $where_user["(uname LIKE '%{$name}%' OR mobile LIKE '%{$name}%')"] = null;
$mobile && $where_user['mobile'] = $mobile;
$res_user = $this->mdSyliveUser->select($where_user, 'userId desc', 0, 0, 'userId');
$res_user && $str_user_ids = implode(',', array_unique(array_column($res_user, 'userId')));
$where["u_id in($str_user_ids)"] = null;
}
$count = $this->mdSyliveOrder->count($where);
if ($count) {
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
$str_user_ids = implode(',', array_unique(array_column($res, 'uid')));
$map_users = $this->mdSyliveUser->map('userId', 'uname,nickname,mobile', ["userId in({$str_user_ids})" => null]);
foreach ($res as $v) {
$name = $map_users[$v['uid']]['uname'] ? $map_users[$v['uid']]['uname'] : $map_users[$v['uid']]['nickname'];
$mobile = $map_users[$v['uid']]['mobile'];
$list[] = [
'id' => $v['id'], 'sid' => $v['sid'],'name' => $name, 'mobile' => $mobile, 'item_title' => $v['item_title']
, 'total_price' => $v['total_price'], 'pay_time' => $v['pay_time'] != '0000-00-00 00:00:00' ? $v['pay_time'] : ''
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'createTime' => $v['createTime']];
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
/**
* Notes:修改订单
* Created on: 2022/9/21 14:48
* Created by: dengbw
*/
public function index_put()
{
$userId = intval($this->input_param('userId'));
$organizationId = intval($this->input_param('organizationId'));
$sex = intval($this->input_param('sex'));
$uname = $this->input_param('uname');
if (!$userId) {
$this->return_json('参数错误');
}
if (!$organizationId) {
$this->return_json('请选择所属机构');
}
if (!$uname) {
$this->return_json('请输入姓名');
}
$upDate = ['organizationId' => $organizationId, 'sex' => $sex, 'uname' => $uname];
$this->mdSyliveOrder->update($upDate, ['userId' => $userId]);
$this->return_response();
}
}
@@ -0,0 +1,116 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:私域直播_机构管理
* Created on: 2022/9/16 17:15
* Created by: dengbw
*/
class Organization extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
}
/**
* Notes:获取机构
* Created on: 2022/9/16 11:11
* Created by: dengbw
*/
public function index_get()
{
$unOrganizationType = $this->input_param('unOrganizationType');
$where['status>='] = 0;
$unOrganizationType && $where['organizationType<>'] = $unOrganizationType;
$sort_order = 'sortNumber asc,organizationId desc';
$res = $this->mdSyliveOrganization->select($where, $sort_order);
foreach ($res as $k => $v) {
$res[$k]['organizationId'] = intval($v['organizationId']);
$res[$k]['parentId'] = intval($v['parentId']);
$res[$k]['sortNumber'] = intval($v['sortNumber']);
}
$this->return_response_list($res);
}
/**
* Notes:添加机构
* Created on: 2022/9/19 16:43
* Created by: dengbw
*/
public function index_post()
{
$parentId = intval($this->input_param('parentId'));
$organizationName = $this->input_param('organizationName');
$organizationFullName = $this->input_param('organizationFullName');
$organizationType = $this->input_param('organizationType');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
if (!$organizationName) {
$this->return_json('请输入机构名称');
}
if (!$organizationType) {
$this->return_json('请选择机构类型');
}
!$comments && $comments = '';
$addDate = ['parentId' => $parentId, 'organizationName' => $organizationName, 'organizationFullName' => $organizationFullName
, 'organizationType' => $organizationType, 'sortNumber' => $sortNumber, 'comments' => $comments
, 'createTime' => date('Y-m-d H:i:s')];
$id = $this->mdSyliveOrganization->add($addDate);
if (!$id) {
$this->return_json('添加机构失败');
}
$this->return_response();
}
/**
* Notes:修改机构
* Created on: 2022/9/19 17:29
* Created by: dengbw
*/
public function index_put()
{
$organizationId = intval($this->input_param('organizationId'));
$parentId = intval($this->input_param('parentId'));
$organizationName = $this->input_param('organizationName');
$organizationFullName = $this->input_param('organizationFullName');
$organizationType = $this->input_param('organizationType');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
!$comments && $comments = '';
if (!$organizationId) {
$this->return_json('参数错误');
}
if (!$organizationName) {
$this->return_json('请输入机构名称');
}
if (!$organizationType) {
$this->return_json('请选择机构类型');
}
!$comments && $comments = '';
$upDate = ['parentId' => $parentId, 'organizationName' => $organizationName, 'organizationFullName' => $organizationFullName
, 'organizationType' => $organizationType, 'sortNumber' => $sortNumber, 'comments' => $comments];
$this->mdSyliveOrganization->update($upDate, ['organizationId' => $organizationId]);
$this->return_response();
}
/**
* Notes:删除机构
* Created on: 2022/9/19 11:08
* Created by: dengbw
* @param null $organizationId
*/
public function index_delete($organizationId = null)
{
$organizationId = intval($organizationId);
if (!$organizationId) {
$this->return_json('参数错误');
}
$this->mdSyliveOrganization->update(['status' => -1], ['organizationId' => $organizationId]);
$this->return_response();
}
}
+169
View File
@@ -0,0 +1,169 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:私域直播_用户管理
* Created on: 2022/9/19 17:15
* Created by: dengbw
*/
class User extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
}
/**
* Notes:用户管理列表
* Created on: 2022/9/20 14:48
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$uname = $this->input_param('uname');
$nickname = $this->input_param('nickname');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$organizationId = intval($this->input_param('organizationId'));
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'userId desc';
if ($sort && $order) {
if ($sort == 'sexName') {
$sort_order = 'sex ' . $order;
} else {
$sort_order = $sort . ' ' . $order;
}
}
$list = [];
$where['status>='] = 0;
$organizationId && $where['organizationId'] = $organizationId;
$uname && $where['uname'] = $uname;
$nickname && $where['nickname'] = $nickname;
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
$organizationType = 0;
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $organizationId]);
$re_org && $organizationType = $re_org['organizationType'];
$roleName = $this->mdSyliveUser->roleAry($organizationType);
$count = $this->mdSyliveUser->count($where);
if ($count) {
$res = $this->mdSyliveUser->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$sexName = $this->mdSyliveUser->sexAry($v['sex']);
$status = intval($v['status']);
$list[] = [
'userId' => $v['userId'], 'uname' => $v['uname'], 'nickname' => $v['nickname'], 'mobile' => $v['mobile']
, 'roleName' => $roleName, 'organizationId' => $organizationId, 'status' => $status
, 'sex' => $v['sex'], 'sexName' => $sexName, 'createTime' => $v['createTime']];
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
/**
* Notes:添加用户
* Created on: 2022/9/21 16:46
* Created by: dengbw
*/
public function index_post()
{
$mobile = $this->input_param('mobile');
$organizationId = intval($this->input_param('organizationId'));
$sex = intval($this->input_param('sex'));
$uname = $this->input_param('uname');
if (!$mobile) {
$this->return_json('请输入手机号');
}
if (!$organizationId) {
$this->return_json('请选择所属机构');
}
if (!$uname) {
$this->return_json('请输入姓名');
}
$re = $this->mdSyliveUser->get(['mobile' => $mobile]);
if ($re['organizationId']) {
$this->return_json('手机号已存在');
}
$addDate = ['organizationId' => $organizationId, 'sex' => $sex, 'uname' => $uname];
if ($re['userId']) {
$this->mdSyliveUser->update($addDate, ['userId' => $re['userId']]);
$this->return_response([], '绑定用户成功');
} else {
$addDate['mobile'] = $mobile;
$addDate['createTime'] = date('Y-m-d H:i:s');
$id = $this->mdSyliveUser->add($addDate);
if (!$id) {
$this->return_json('添加用户失败');
}
$this->return_response();
}
}
/**
* Notes:修改用户
* Created on: 2022/9/21 14:48
* Created by: dengbw
*/
public function index_put()
{
$userId = intval($this->input_param('userId'));
$organizationId = intval($this->input_param('organizationId'));
$sex = intval($this->input_param('sex'));
$uname = $this->input_param('uname');
if (!$userId) {
$this->return_json('参数错误');
}
if (!$organizationId) {
$this->return_json('请选择所属机构');
}
if (!$uname) {
$this->return_json('请输入姓名');
}
$upDate = ['organizationId' => $organizationId, 'sex' => $sex, 'uname' => $uname];
$this->mdSyliveUser->update($upDate, ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:删除用户
* Created on: 2022/9/21 16:10
* Created by: dengbw
* @param null $userId
*/
public function index_delete($userId = null)
{
if (!$userId) {
$this->return_json('参数错误');
}
$this->mdSyliveUser->update(['status' => -1], ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:栓验字段
* Created on: 2022/9/21 15:52
* Created by: dengbw
*/
public function existence_get()
{
$field = $this->input_param('field');
$value = $this->input_param('value');
$id = $this->input_param('id');
if (!$id) {
$where = [$field => $value];
$field == 'mobile' && $where['organizationId>'] = 0;
$re = $this->mdSyliveUser->get([$field => $value]);
if ($re) {
$this->return_json('已存在', 0);
}
}
$this->return_json('不存在', 1);
}
}
@@ -0,0 +1,105 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:字典管理
* Created on: 2022/9/19 17:15
* Created by: dengbw
*/
class Dictionary extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_dictionary_model', 'mdSysDictionary');
}
/**
* Notes:获取字典
* Created on: 2022/9/19 11:11
* Created by: dengbw
*/
public function index_get()
{
$where['status>='] = 0;
$sort_order = 'sortNumber asc,dictId desc';
$res = $this->mdSysDictionary->select($where, $sort_order);
foreach ($res as $k => $v) {
$res[$k]['dictId'] = intval($v['dictId']);
}
$this->return_response_list($res);
}
/**
* Notes:添加字典
* Created on: 2022/9/19 11:01
* Created by: dengbw
*/
public function index_post()
{
$dictName = $this->input_param('dictName');
$dictCode = $this->input_param('dictCode');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
if (!$dictName) {
$this->return_json('请输入字典名称');
}
if (!$dictCode) {
$this->return_json('请输入字典值');
}
!$comments && $comments = '';
$addDate = ['dictName' => $dictName, 'dictCode' => $dictCode, 'sortNumber' => $sortNumber, 'comments' => $comments
, 'createTime' => date('Y-m-d H:i:s')];
$id = $this->mdSysDictionary->add($addDate);
if (!$id) {
$this->return_json('添加字典失败');
}
$this->return_response();
}
/**
* Notes:修改字典
* Created on: 2022/9/19 11:05
* Created by: dengbw
*/
public function index_put()
{
$dictId = intval($this->input_param('dictId'));
$dictName = $this->input_param('dictName');
$dictCode = $this->input_param('dictCode');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
if (!$dictId) {
$this->return_json('参数错误');
}
if (!$dictName) {
$this->return_json('请输入字典名称');
}
if (!$dictCode) {
$this->return_json('请输入字典值');
}
!$comments && $comments = '';
$upDate = ['dictName' => $dictName, 'dictCode' => $dictCode, 'sortNumber' => $sortNumber, 'comments' => $comments];
$this->mdSysDictionary->update($upDate, ['dictId' => $dictId]);
$this->return_response();
}
/**
* Notes:删除字典
* Created on: 2022/9/19 11:08
* Created by: dengbw
* @param null $dictId
*/
public function index_delete($dictId = null)
{
$dictId = intval($dictId);
if (!$dictId) {
$this->return_json('参数错误');
}
$this->mdSysDictionary->update(['status' => -1], ['dictId' => $dictId]);
$this->return_response();
}
}
@@ -0,0 +1,169 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:机构管理
* Created on: 2022/9/16 17:15
* Created by: dengbw
*/
class DictionaryData extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_dictionary_data_model', 'mdSysDictionaryData');
}
/**
* Notes:字典项列表
* Created on: 2022/9/16 11:11
* Created by: dengbw
*/
public function page_get()
{
$dictId = $this->input_param('dictId');
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$keywords = $this->input_param('keywords');
!$page && $page = 1;
!$limit && $limit = 10;
if (!$dictId) {
$this->return_json('参数错误');
}
$res = [];
$sort_order = 'sortNumber asc,dictDataId desc';
$where = ['status>=' => 0, 'dictId' => $dictId];
if ($keywords) {
$where["dictDataName = '{$keywords}' OR dictDataCode = '{$keywords}'"] = null;
}
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$count = $this->mdSysDictionaryData->count($where);
if ($count) {
$res = $this->mdSysDictionaryData->select($where, $sort_order, $page, $limit);
foreach ($res as $k => $v) {
$res[$k]['dictDataId'] = intval($v['dictDataId']);
$res[$k]['dictId'] = intval($v['dictId']);
$res[$k]['sortNumber'] = intval($v['sortNumber']);
}
}
$date = ['list' => $res, 'count' => $count];
$this->return_response_list($date);
}
public function index_get()
{
$dictCode = $this->input_param('dictCode');
if (!$dictCode) {
$this->return_json('参数错误');
}
$this->load->model('market/Market_sys_dictionary_model', 'mdSysDictionary');
$re = $this->mdSysDictionary->get(['status>=' => 0, 'dictCode' => $dictCode]);
$res = [];
if ($re) {
$dictId = $re['dictId'];
$sort_order = 'sortNumber asc,dictDataId desc';
$where = ['status>=' => 0, 'dictId' => $dictId];
$res = $this->mdSysDictionaryData->select($where, $sort_order, 0, 0);
foreach ($res as $k => $v) {
$res[$k]['dictDataId'] = intval($v['dictDataId']);
$res[$k]['dictId'] = intval($v['dictId']);
$res[$k]['dictCode'] = $re['dictCode'];
$res[$k]['dictName'] = $re['dictName'];
}
}
$this->return_response_list($res);
}
/**
* Notes:添加字典项
* Created on: 2022/9/19 11:01
* Created by: dengbw
*/
public function index_post()
{
$dictId = intval($this->input_param('dictId'));
$dictDataName = $this->input_param('dictDataName');
$dictDataCode = $this->input_param('dictDataCode');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
if (!$dictDataName) {
$this->return_json('请输入字典项名称');
}
if (!$dictDataCode) {
$this->return_json('请输入字典项值');
}
!$comments && $comments = '';
$addDate = ['dictId' => $dictId, 'dictDataName' => $dictDataName, 'dictDataCode' => $dictDataCode,
'sortNumber' => $sortNumber, 'comments' => $comments, 'createTime' => date('Y-m-d H:i:s')];
$id = $this->mdSysDictionaryData->add($addDate);
if (!$id) {
$this->return_json('添加字典项失败');
}
$this->return_response();
}
/**
* Notes:修改字典项
* Created on: 2022/9/19 11:05
* Created by: dengbw
*/
public function index_put()
{
$dictDataId = intval($this->input_param('dictDataId'));
$dictDataName = $this->input_param('dictDataName');
$dictDataCode = $this->input_param('dictDataCode');
$sortNumber = intval($this->input_param('sortNumber'));
$comments = $this->input_param('comments');
if (!$dictDataName) {
$this->return_json('请输入字典项名称');
}
if (!$dictDataCode) {
$this->return_json('请输入字典项值');
}
!$comments && $comments = '';
$upDate = ['dictDataName' => $dictDataName, 'dictDataCode' => $dictDataCode, 'sortNumber' => $sortNumber, 'comments' => $comments];
$this->mdSysDictionaryData->update($upDate, ['dictDataId' => $dictDataId]);
$this->return_response();
}
/**
* Notes:删除字典项
* Created on: 2022/9/19 11:08
* Created by: dengbw
* @param null $dictDataId
*/
public function index_delete($dictDataId = null)
{
$dictDataId = intval($dictDataId);
if (!$dictDataId) {
$this->return_json('参数错误');
}
$this->mdSysDictionaryData->update(['status' => -1], ['dictDataId' => $dictDataId]);
$this->return_response();
}
/**
* Notes:批量删除字典项
* Created on: 2022/9/19 15:35
* Created by: dengbw
*/
public function batch_delete()
{
$ids = $this->inputs;
if (!$ids) {
$this->return_json('参数错误');
}
$str_ids = implode(',', $ids);
if ($str_ids) {
$this->mdSysDictionaryData->update(['status' => -1], ["dictDataId in($str_ids)" => null]);
}
$this->return_response();
}
}
@@ -0,0 +1,58 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:登录日志
* Created on: 2022/9/14 17:15
* Created by: dengbw
*/
class LoginRecord extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_login_record_model', 'mdSysLoginRecord');
}
/**
* Notes:登录日志列表
* Created on: 2022/9/14 16:28
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$username = $this->input_param('username');
$nickname = $this->input_param('nickname');
$createTimeStart = $this->input_param('createTimeStart');
$createTimeEnd = $this->input_param('createTimeEnd');
!$page && $page = 1;
!$limit && $limit = 10;
$where = $list = [];
$createTimeStart && $where['createTime>='] = $createTimeStart;
$createTimeEnd && $where['createTime<='] = $createTimeEnd;
$username && $where['username'] = $username;
$nickname && $where['nickname'] = $nickname;
$sort_order = 'createTime desc';
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$count = $this->mdSysLoginRecord->count($where);
if ($count) {
$list = $this->mdSysLoginRecord->select($where, $sort_order, $page, $limit);
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
public function index_get()
{
$date = [];
$this->return_response_list($date);
}
}
+136
View File
@@ -0,0 +1,136 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:菜单管理
* Created on: 2022/9/09 17:15
* Created by: dengbw
*/
class Menu extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_menu_model', 'mdSysMenu');
}
/**
* Notes菜单管理
* Created on: 2022/9/9 14:48
* Created by: dengbw
*/
public function index_get()
{
$title = $this->input_param('title');
$path = $this->input_param('path');
$authority = $this->input_param('authority');
$where['status>='] = 0;
$sort_order = 'sortNumber asc,menuId desc';
$title && $where['title'] = $title;
$path && $where['path'] = $path;
$authority && $where['authority'] = $authority;
$res = $this->mdSysMenu->select($where, $sort_order);
foreach ($res as $k => $v) {
$res[$k]['menuId'] = intval($v['menuId']);
$res[$k]['parentId'] = intval($v['parentId']);
$res[$k]['menuType'] = intval($v['menuType']);
$res[$k]['openType'] = intval($v['openType']);
$res[$k]['sortNumber'] = intval($v['sortNumber']);
$res[$k]['hide'] = intval($v['hide']);
$res[$k]['meta'] = json_decode($v['meta'], true);
}
$this->return_response_list($res);
}
/**
* Notes:修改菜单
* Created on: 2022/9/9 17:58
* Created by: dengbw
*/
public function index_put()
{
$menuId = $this->input_param('menuId');
$parentId = intval($this->input_param('parentId'));
$menuType = intval($this->input_param('menuType'));
$title = $this->input_param('title');
$openType = intval($this->input_param('openType'));
$icon = $this->input_param('icon');
$path = $this->input_param('path');
$component = $this->input_param('component');
$authority = $this->input_param('authority');
$sortNumber = intval($this->input_param('sortNumber'));
$hide = intval($this->input_param('hide'));
$meta = $this->input_param('meta');
if (!$menuId) {
$this->return_json('参数错误');
}
if (!$title) {
$this->return_json('请输入菜单名称');
}
!$icon && $icon = '';
!$path && $path = '';
!$component && $component = '';
!$authority && $authority = '';
$upDate = ['parentId' => $parentId, 'menuType' => $menuType, 'title' => $title, 'openType' => $openType,
'icon' => $icon, 'path' => $path, 'component' => $component, 'authority' => $authority,
'sortNumber' => $sortNumber, 'hide' => $hide];
$upDate['meta'] = $meta ? json_encode($meta, JSON_UNESCAPED_UNICODE) : null;
$this->mdSysMenu->update($upDate, ['menuId' => $menuId]);
$this->return_response();
}
/**
* Notes:添加菜单
* Created on: 2022/9/9 11:47
* Created by: dengbw
*/
public function index_post()
{
$parentId = intval($this->input_param('parentId'));
$menuType = intval($this->input_param('menuType'));
$title = $this->input_param('title');
$openType = intval($this->input_param('openType'));
$icon = $this->input_param('icon');
$path = $this->input_param('path');
$component = $this->input_param('component');
$authority = $this->input_param('authority');
$sortNumber = intval($this->input_param('sortNumber'));
$hide = intval($this->input_param('hide'));
$meta = $this->input_param('meta');
if (!$title) {
$this->return_json('请输入菜单名称');
}
!$icon && $icon = '';
!$path && $path = '';
!$component && $component = '';
!$authority && $authority = '';
$addDate = ['parentId' => $parentId, 'menuType' => $menuType, 'title' => $title, 'openType' => $openType,
'icon' => $icon, 'path' => $path, 'component' => $component, 'authority' => $authority,
'sortNumber' => $sortNumber, 'hide' => $hide, 'createTime' => date('Y-m-d H:i:s')];
$meta && $addDate['meta'] = json_encode($meta, JSON_UNESCAPED_UNICODE);
$id = $this->mdSysMenu->add($addDate);
if (!$id) {
$this->return_json('添加菜单失败');
}
$this->return_response();
}
/**
* Notes:删除菜单
* Created on: 2022/9/9 16:10
* Created by: dengbw
* @param null $menuId
*/
public function index_delete($menuId = null)
{
$menuId = intval($menuId);
if (!$menuId) {
$this->return_json('参数错误');
}
$this->mdSysMenu->update(['status' => -1], ['menuId' => $menuId]);
$this->return_response();
}
}
@@ -0,0 +1,100 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:操作日志
* Created on: 2022/9/15 17:15
* Created by: dengbw
*/
class operationRecord extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_operation_record_model', 'mdSysOperationRecord');
}
/**
* Notes:操作日志列表
* Created on: 2022/9/15 16:28
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$username = $this->input_param('username');
$module = $this->input_param('module');
$createTimeStart = $this->input_param('createTimeStart');
$createTimeEnd = $this->input_param('createTimeEnd');
!$page && $page = 1;
!$limit && $limit = 10;
$where = $list = [];
$createTimeStart && $where['createTime>='] = $createTimeStart;
$createTimeEnd && $where['createTime<='] = $createTimeEnd;
$username && $where['username'] = $username;
$module && $where['module'] = $module;
$sort_order = 'createTime desc';
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$count = $this->mdSysOperationRecord->count($where);
if ($count) {
$list = $this->mdSysOperationRecord->select($where, $sort_order, $page, $limit);
foreach ($list as $k => $v) {
$list[$k]['params'] = json_decode($v['params'], true);
$list[$k]['result'] = json_decode($v['result'], true);
$list[$k]['error'] = json_decode($v['error'], true);
$list[$k]['status'] = intval($v['status']);
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
private function dataSelect($params)
{
$page = $params['page'];
$limit = $params['limit'];
$limit = $this->input_param('limit');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$username = $this->input_param('username');
$module = $this->input_param('module');
$createTimeStart = $this->input_param('createTimeStart');
$createTimeEnd = $this->input_param('createTimeEnd');
!$page && $page = 1;
!$limit && $limit = 10;
$where = $list = [];
$createTimeStart && $where['createTime>='] = $createTimeStart;
$createTimeEnd && $where['createTime<='] = $createTimeEnd;
$username && $where['username'] = $username;
$module && $where['module'] = $module;
$sort_order = 'createTime desc';
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$count = $this->mdSysOperationRecord->count($where);
if ($count) {
$list = $this->mdSysOperationRecord->select($where, $sort_order, $page, $limit);
foreach ($list as $k => $v) {
$list[$k]['params'] = json_decode($v['params'], true);
$list[$k]['result'] = json_decode($v['result'], true);
$list[$k]['error'] = json_decode($v['error'], true);
$list[$k]['status'] = intval($v['status']);
}
}
}
public function index_get()
{
$date = [];
$this->return_response_list($date);
}
}
+135
View File
@@ -0,0 +1,135 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:角色管理
* Created on: 2022/9/05 17:15
* Created by: dengbw
*/
class Role extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
}
/**
* Notes角色管理
* Created on: 2022/9/8 14:48
* Created by: dengbw
*/
public function index_get()
{
$page = intval($this->input_param('page'));
$limit = intval($this->input_param('limit'));
$roleName = $this->input_param('roleName');
$roleCode = $this->input_param('roleCode');
$comments = $this->input_param('comments');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
$date = $where = [];
if (!$page) {
$where['status'] = 0;
} else {
$where['status>='] = 0;
}
$sort_order = 'roleId desc';
if ($sort && $order) {
$sort_order = $sort . ' ' . $order;
}
$roleName && $where['roleName'] = $roleName;
$roleCode && $where['roleCode'] = $roleCode;
$comments && $where['comments'] = $comments;
$res = $this->mdSysRole->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$date[] = $v;
}
$this->return_response_list($date);
}
/**
* Notes:修改角色
* Created on: 2022/9/8 17:58
* Created by: dengbw
*/
public function index_put()
{
$roleId = $this->input_param('roleId');
$roleName = $this->input_param('roleName');
$roleCode = $this->input_param('roleCode');
$comments = $this->input_param('comments');
if (!$roleId) {
$this->return_json('参数错误');
}
if (!$roleName) {
$this->return_json('请输入角色名称');
}
if (!$roleCode) {
$this->return_json('请输入角色标识');
}
$upDate = ['roleName' => $roleName, 'roleCode' => $roleCode, 'comments' => $comments];
$this->mdSysRole->update($upDate, ['roleId' => $roleId]);
$this->return_response();
}
/**
* Notes:添加角色
* Created on: 2022/9/9 11:47
* Created by: dengbw
*/
public function index_post()
{
$roleName = $this->input_param('roleName');
$roleCode = $this->input_param('roleCode');
$comments = $this->input_param('comments');
if (!$roleName) {
$this->return_json('请输入角色名称');
}
if (!$roleCode) {
$this->return_json('请输入角色标识');
}
$addDate = ['roleName' => $roleName, 'roleCode' => $roleCode, 'comments' => $comments, 'createTime' => date('Y-m-d H:i:s')];
$id = $this->mdSysRole->add($addDate);
if (!$id) {
$this->return_json('添加角色失败');
}
$this->return_response();
}
/**
* Notes:删除用户
* Created on: 2022/9/9 16:10
* Created by: dengbw
* @param null $roleId
*/
public function index_delete($roleId = null)
{
if (!$roleId) {
$this->return_json('参数错误');
}
$this->mdSysRole->update(['status' => -1], ['roleId' => $roleId]);
$this->return_response();
}
/**
* Notes:批量删除用户
* Created on: 2022/9/9 17:11
* Created by: dengbw
*/
public function batch_delete()
{
$roleIds = $this->inputs;
if (!$roleIds) {
$this->return_json('参数错误');
}
$str_roleIds = implode(',', $roleIds);
if ($str_roleIds) {
$this->mdSysRole->update(['status' => -1], ["roleId in($str_roleIds)" => null]);
}
$this->return_response();
}
}
@@ -0,0 +1,65 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:角色分配的菜单
* Created on: 2022/9/09 17:15
* Created by: dengbw
*/
class RoleMenu extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
$this->load->model('market/Market_sys_menu_model', 'mdSysMenu');
}
/**
* Notes:获取角色分配的菜单 (ele-admin/system/role-menu)
* Created on: 2022/9/13 9:47
* Created by: dengbw
* @param $roleId
*/
public function index_get($roleId)
{
if (!$roleId) {
$this->return_json('参数错误');
}
$re_ro = $this->mdSysRole->get(['roleId' => $roleId, 'status' => 0]);
$menuIds = $re_ro ? $re_ro['menuIds'] . ',' : '';
$where['status>='] = 0;
$res = $this->mdSysMenu->select($where, 'sortNumber asc,menuId desc');
foreach ($res as $k => $v) {
$res[$k]['menuId'] = intval($v['menuId']);
$res[$k]['parentId'] = intval($v['parentId']);
$res[$k]['menuType'] = intval($v['menuType']);
$res[$k]['openType'] = intval($v['openType']);
$res[$k]['sortNumber'] = intval($v['sortNumber']);
$res[$k]['hide'] = intval($v['hide']);
$res[$k]['meta'] = json_decode($v['meta'], true);
$res[$k]['children'] = '';
$res[$k]['checked'] = strstr($menuIds, "{$v['menuId']},") ? true : false;
}
$this->return_response_list($res);
}
/**
* Notes:修改角色菜单(ele-admin/system/role-menu)
* Created on: 2022/9/13 11:50
* Created by: dengbw
* @param $roleId
*/
public function index_put($roleId)
{
if (!$roleId) {
$this->return_json('参数错误');
}
$menuIds = $this->inputs;
$menuIds = $menuIds ? implode(',', $menuIds) : '';
$this->mdSysRole->update(['menuIds' => $menuIds], ['roleId' => $roleId]);
$this->return_response();
}
}
+271
View File
@@ -0,0 +1,271 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . 'controllers/api/BaseController.php';
/**
* Notes:用户管理
* Created on: 2022/9/05 17:15
* Created by: dengbw
*/
class User extends BaseController
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sys_admin_model', 'mdSysAdmin');
$this->load->model('market/Market_sys_role_model', 'mdSysRole');
}
/**
* Notes:用户管理列表
* Created on: 2022/9/8 14:48
* Created by: dengbw
*/
public function page_get()
{
$page = $this->input_param('page');
$limit = $this->input_param('limit');
$username = $this->input_param('username');
$nickname = $this->input_param('nickname');
$sex = $this->input_param('sex');
$sort = $this->input_param('sort');
$order = $this->input_param('order');
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'userId desc';
if ($sort && $order) {
if ($sort == 'sexName') {
$sort_order = 'sex ' . $order;
} else {
$sort_order = $sort . ' ' . $order;
}
}
$where = $list = [];
$where['status>='] = 0;
$username && $where['username'] = $username;
$nickname && $where['nickname'] = $nickname;
$sex && $where['sex'] = $sex;
$count = $this->mdSysAdmin->count($where);
if ($count) {
$res = $this->mdSysAdmin->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$sexName = $v['sex'] == 2 ? '女' : '男';
$status = intval($v['status']);
$roles = [];
if ($v['roleId']) {
$re_ro = $this->mdSysRole->get(['roleId' => $v['roleId']]);
if ($re_ro) {
$re_ro['userId'] = $v['userId'];
$re_ro['deleted'] = 0;
$roles[] = $re_ro;
}
}
$list[] = [
'userId' => $v['userId'], 'username' => $v['username'], 'nickname' => $v['nickname'], 'phone' => $v['phone']
, 'status' => $status, 'sex' => $v['sex'], 'sexName' => $sexName, 'birthday' => $v['birthday']
, 'introduction' => $v['introduction'], 'email' => $v['email'], 'createTime' => $v['createTime'], 'roles' => $roles,
];
}
}
$date = ['list' => $list, 'count' => $count];
$this->return_response_list($date);
}
/**
* Notes:用户详情
* Created on: 2022/9/21 16:15
* Created by: dengbw
* @param null $userId
*/
public function index_get($userId = null)
{
if (!$userId) {
$this->return_json('参数错误');
}
$re = $this->mdSysAdmin->get(['userId' => $userId]);
if (!$re) {
$this->return_json('用户不存在');
}
$re['sexName'] = $re['sex'] == 2 ? '女' : '男';
$re['status'] = intval($re['status']);
$roles = [];
if ($re['roleId']) {
$re_ro = $this->mdSysRole->get(['roleId' => $re['roleId']]);
$re_ro && $roles[] = $re_ro;
}
$re['roles'] = $roles;
$this->return_response($re);
}
/**
* Notes:修改用户
* Created on: 2022/9/8 14:48
* Created by: dengbw
*/
public function index_put()
{
$userId = $this->input_param('userId');
$nickname = $this->input_param('nickname');
$phone = $this->input_param('phone');
$sex = $this->input_param('sex');
$birthday = $this->input_param('birthday');
$introduction = $this->input_param('introduction');
$email = $this->input_param('email');
$roleIds = $this->input_param('roleIds');
if (!$userId) {
$this->return_json('参数错误');
}
if (!$nickname) {
$this->return_json('请输入用户名');
}
if (!$sex) {
$this->return_json('请选择性别');
}
if (!$roleIds) {
$this->return_json('请选择角色');
}
$roleId = intval($roleIds[0]);
$upDate = ['nickname' => $nickname, 'phone' => $phone, 'sex' => $sex, 'birthday' => $birthday,
'introduction' => $introduction, 'email' => $email, 'roleId' => $roleId];
$this->mdSysAdmin->update($upDate, ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:添加用户
* Created on: 2022/9/8 16:46
* Created by: dengbw
*/
public function index_post()
{
$username = $this->input_param('username');
$nickname = $this->input_param('nickname');
$phone = $this->input_param('phone');
$sex = $this->input_param('sex');
$birthday = $this->input_param('birthday');
$introduction = $this->input_param('introduction');
$email = $this->input_param('email');
$roleIds = $this->input_param('roleIds');
$password = $this->input_param('password');
if (!$username) {
$this->return_json('请输入用户帐户');
}
if (!$nickname) {
$this->return_json('请输入用户名');
}
if (!$sex) {
$this->return_json('请选择性别');
}
if (!$password) {
$this->return_json('请输入登录密码');
}
if (!$roleIds) {
$this->return_json('请选择角色');
}
$re = $this->mdSysAdmin->get(['username' => $username]);
if ($re) {
$this->return_json('用户帐号已存在');
}
$roleId = intval($roleIds[0]);
$password = password_hash($password, PASSWORD_BCRYPT);
$addDate = ['username' => $username, 'nickname' => $nickname, 'phone' => $phone, 'sex' => $sex, 'birthday' => $birthday
, 'password' => $password, 'introduction' => $introduction, 'email' => $email, 'roleId' => $roleId, 'createTime' => date('Y-m-d H:i:s')];
$id = $this->mdSysAdmin->add($addDate);
if (!$id) {
$this->return_json('添加用户失败');
}
$this->return_response();
}
/**
* Notes:修改状态
* Created on: 2022/9/8 16:10
* Created by: dengbw
*/
public function status_put()
{
$userId = $this->input_param('userId');
$status = $this->input_param('status');
if (!$userId) {
$this->return_json('参数错误');
}
$this->mdSysAdmin->update(['status' => $status], ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:修改密码
* Created on: 2022/9/8 16:11
* Created by: dengbw
*/
public function password_put()
{
$userId = $this->input_param('userId');
$password = $this->input_param('password');
if (!$userId) {
$this->return_json('参数错误');
}
if (!$password) {
$this->return_json('请输入重置密码');
}
$password = password_hash($password, PASSWORD_BCRYPT);
$this->mdSysAdmin->update(['password' => $password], ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:删除用户
* Created on: 2022/9/8 16:10
* Created by: dengbw
* @param null $userId
*/
public function index_delete($userId = null)
{
if (!$userId) {
$this->return_json('参数错误');
}
$this->mdSysAdmin->update(['status' => -1], ['userId' => $userId]);
$this->return_response();
}
/**
* Notes:批量删除用户
* Created on: 2022/9/8 17:11
* Created by: dengbw
*/
public function batch_delete()
{
$ids = $this->inputs;
if (!$ids) {
$this->return_json('参数错误');
}
$str_ids = implode(',', $ids);
if ($str_ids) {
$this->mdSysAdmin->update(['status' => -1], ["userId in($str_ids)" => null]);
}
$this->return_response();
}
/**
* Notes:栓验字段
* Created on: 2022/9/8 15:52
* Created by: dengbw
*/
public function existence_get()
{
$field = $this->input_param('field');
$value = $this->input_param('value');
$id = $this->input_param('id');
if (!$id) {
$re = $this->mdSysAdmin->get([$field => $value]);
if ($re) {
$this->return_json('已存在', 0);
}
}
$this->return_json('不存在', 1);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* Created by PhpStorm.
* User: windows
* Date: 2018/11/20
* Time: 17:25
*/
class HD_Controller extends CI_Controller
{
//返回json数据
public function success($returnData, $msg = 'success', $code = 200)
{
header('Content-Type:application/json; charset=utf-8');
echo json_encode(array('data' => $returnData, 'code' => $code, 'msg' => $msg), JSON_UNESCAPED_UNICODE);
exit();
}
public function fail($returnData, $msg = 'fail', $code = 400)
{
header('Content-Type:application/json; charset=utf-8');
echo json_encode(array('data' => $returnData, 'code' => $code, 'msg' => $msg), JSON_UNESCAPED_UNICODE);
exit();
}
}
File diff suppressed because it is too large Load Diff
+606
View File
@@ -0,0 +1,606 @@
<?php
/**
* Created by PhpStorm.
* User: linfan
* Date: 2018/11/1
* Time: 15:10
*/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class HD_Model extends CI_Model {
private $table_name;
private $mc_cache_expire = '600';
private $file_cache_expire = '86400';
public $db;
static $dbs = array();
public function __construct($table_name = '', $db_group = 'default')
{
//走自定义db
$app_db = $GLOBALS['app_db'];
if($app_db && "default" == $db_group){
$this->load->config("dbtable", true, true);
$dbtable = $this->config->item($app_db, "dbtable");
if(is_array($dbtable) && in_array($table_name, $dbtable)){
$db_group = $GLOBALS['app_db'];
}
}
$this->set_db($db_group);
$this->set_table_name($table_name);
}
public function set_db($db_group = 'default')
{
if(!isset(self::$dbs[$db_group]))
{
self::$dbs[$db_group] = $this->load->database($db_group, true);
}
$this->db = self::$dbs[$db_group];
}
/**
* 根据app应用表设置库
* @param $db_group
* @param $apptabs
*/
public function set_appdb($db_group, $apptabs){
$table_name = $this->table_name;
if(is_array($apptabs) && in_array($table_name, $apptabs)){
$this->set_db($db_group);
}
}
public function set_table_name($table_name)
{
$this->table_name = $table_name;
}
/**
* 表字段列表
* @return mixed
*/
public function fields(){
return $this->db->list_fields($this->table_name);
}
/**
* 添加单条数据
* @param $data
* @return mixed
*/
public function add($data)
{
$result = $this->db->insert($this->table_name, $data);
return $this->db->insert_id() ? $this->db->insert_id() : $result;
}
/**
* 添加多条数据
* @param $data_array
* @return mixed
*/
public function add_batch($data_array)
{
if(is_array($data_array))
{
return $this->db->insert_batch($this->table_name, $data_array);
}
return false;
}
/**
* 修改数据
* @param $data
* @param $where
* @return mixed
*/
public function update($data, $where)
{
foreach($data as $k => $v)
{
if($v == null) {
if(strstr($k, ' = ')) {
$field = explode(' = ', $k);
$this->db->set($field[0], $field[1], FALSE);
unset($data[$k]);
}
}
}
$result = $this->db->update($this->table_name, $data, $where);
return $this->db->affected_rows() ? $this->db->affected_rows() : $result;
}
/**
* 修改数据2:支持order与limit
* @param $data
* @param $where
* @param $order
* @param $limit
* @return mixed
*/
public function update2($data, $where, $order = '', $limit = 0)
{
foreach($data as $k => $v)
{
if($v == null) {
if(strstr($k, ' = ')) {
$field = explode(' = ', $k);
$this->db->set($field[0], $field[1], FALSE);
unset($data[$k]);
}
}
}
if($order){
$this->db->order_by($order);
}
if($limit) {
$this->db->limit($limit);
}
$result = $this->db->update($this->table_name, $data, $where);
return $this->db->affected_rows() ? $this->db->affected_rows() : $result;
}
/**
* 更新或插入数据
* @param $data
* @return mixed
*/
public function replace($data)
{
if($data)
{
$result = $this->db->replace($this->table_name, $data);
return $this->db->affected_rows() ? $this->db->affected_rows() : $result;
}
return false;
}
/**
* 批量插入
* @param $data
* @return CI_DB_active_record
*/
public function replace_batch($data)
{
if($data && is_array($data[0]))
{
$keys = array_keys($data[0]);
$keys = implode(',', $keys);
$values = array();
foreach($data as $item)
{
$item_values = array_values($item);
foreach($item_values as &$v)
{
if(!is_numeric($v))
{
$v = addslashes($v);
$v = "'{$v}'";
}
}
$item_values = implode(',', $item_values);
$values[] = "({$item_values})";
}
$values = implode(',', $values);
$sql = "REPLACE {$this->table_name}({$keys}) VALUES {$values}";
return $this->db->query($sql);
}
}
/**
* 获取单条数据
* @param $where
* @param string $select
* @param object $obj 自定义结果对象
* @return mixed
*/
public function get($where, $select = '', $obj = '')
{
if($select)
{
$this->db->select($select, false);
}
if($obj && file_exists($class = COMMPATH.'libraries/entity/'.ucfirst($obj).'.php'))
{
require_once $class;
if (class_exists(ucfirst($obj)))
{
return $this->db->get_where($this->table_name, $where)->custom_row_object(0, $obj);
}
}
return $this->db->get_where($this->table_name, $where)->row_array();
}
/**
* 获取多条数据集
* @param array $where
* @param string $order
* @param int $page
* @param int $page_size
* @param string $select
* @param object obj
* @return mixed
*/
public function select($where = array(), $order = '', $page = 0, $page_size = 20, $select = '', $obj = '')
{
if($select)
{
$this->db->select($select, false);
}
if($where)
{
$this->db->where($where);
}
if($order)
{
$this->db->order_by($order);
}
if($page)
{
$offset = ($page - 1) * $page_size;
$limit = $page_size;
}
else
{
$offset = null;
$limit = null;
}
$this->db->from($this->table_name);
$this->db->limit($limit, $offset);
$query = $this->db->get();
$result = $query ? $query->result_array() : [];
if($obj && file_exists($class = APPPATH.'libraries/entity/'.ucfirst($obj).'.php'))
{
require_once $class;
if(class_exists($obj))
{
$result = $this->db->get($this->table_name, $limit, $offset)->custom_result_object($obj);
}
}
return $result;
}
/**
* @param $groupby
* @param array $where
* @param string $order
* @param int $page
* @param int $page_size
* @param string $select
* @param string $obj
* @return mixed
*/
public function select_groupby($groupby, $where = array(), $order = '', $page = 0, $page_size = 20, $select = '', $obj = ''){
$this->db->group_by($groupby);
return $this->select($where, $order, $page, $page_size, $select, $obj);
}
/**
* 获取最大值
* @param $field
* @param array $where
* @return mixed
*/
public function max($field, $where=array())
{
if($where)
{
$this->db->where($where);
}
if(is_array($field))
{
foreach($field as $v)
{
$this->db->select_max($v);
}
}
else
{
$this->db->select_max($field);
}
return $this->db->get($this->table_name)->row_array();
}
/**
* 删除
* @param array $where
* @return mixed
*/
public function delete($where = array())
{
$result = $this->db->delete($this->table_name, $where);
return $this->db->affected_rows() ? $this->db->affected_rows() : $result;
}
/**
* 将获取的数据集组装成map类型
* @param string $map_key
* @param string $map_value
* @param array $where
* @param string $order
* @param int $page
* @param int $page_size
* @param string $select
* @return array
*/
public function map($map_key = 'id', $map_value = '', $where = array(), $order = '', $page = 0, $page_size = 20, $select = '')
{
$map = array();
$list = $this->select($where, $order, $page, $page_size, $select);
if($list)
{
foreach($list as $item)
{
//指定列, map格式为{k:v}
if($map_value)
{
//指定列存在取具体值,格式为{k:v},指定列不存在取全部列,格式为{k:{k1:v1,k2:v2}}
$map[$item[$map_key]] = null !== $item[$map_value] ? $item[$map_value] : $item;
}
else
{//不指定列,表示一个k对应多个v,格式为{k:[{k1:v1,k2:v2},{k1:v1,k2:v2}]}
$map[$item[$map_key]][] = $item;
}
}
}
return $map;
}
/**
* 获取总条数
* @param array $where
* @param string $distinct
* @return mixed
*/
public function count($where = array(), $distinct = '')
{
if($where)
{
$this->db->where($where);
}
if($distinct)
{
$this->db->distinct();
$this->db->select($distinct, false);
}
return $this->db->count_all_results($this->table_name);
}
/**
* 获取某字段总和
* @param $field
* @param array $where
* @return mixed
*/
public function sum($field, $where = array())
{
if(is_array($field))
{
foreach($field as $v)
{
$this->select_sum($v);
}
}
else
{
$this->db->select_sum($field);
}
if($where)
{
$this->db->where($where);
}
return $this->db->get($this->table_name)->row_array();
}
/**
* 对方法的某个结果集做mc缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @param string $ttl
* @return mixed
*/
public function mc_cache($func, $param = array(), $ttl = 0, $skey = '')
{
if(IF_MC_CACHE)
{
$cache = & load_cache('mc');
$cache_key = MC_CACHE_PREFIX.md5(get_called_class().'.'.$func.json_encode($param));
$ttl = is_numeric($ttl) ? $ttl : $this->mc_cache_expire;
$result = $cache->get($cache_key);
if($result === FALSE )
{
$result = call_user_func_array(array($this, $func), $param);
$cache->save($cache_key, $result, $ttl);
$this->add_cache_key(get_called_class(), $func, 'mc', $cache_key, $ttl, $skey);
}
return $result;
}
return call_user_func_array(array($this, $func), $param);
}
/**
* 删除某方法某个结果集的mc缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @return mixed
*/
public function un_mc_cache($func, $param = array())
{
if(IF_MC_CACHE)
{
$cache = & load_cache('mc');
$cache_key = MC_CACHE_PREFIX.md5(get_called_class().'.'.$func.json_encode($param));
return $cache->delete($cache_key);
}
return false;
}
/**
* 对方法的某个结果集做redis缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @param bool $force
* @return array|mixed
*/
public function redis_cache($func,$param = array())
{
if(IF_REDIS_CACHE)
{
$cache = & load_cache('redis');
$cache_key = REDIS_CACHE_PREFIX.md5(get_called_class().'.'.$func.json_encode($param));
if(!$result = $cache->get($cache_key))
{
$result = call_user_func_array(array($this, $func), $param);
$cache->save($cache_key, $result);
$this->add_cache_key(get_called_class(), $func, 'redis', $cache_key);
}
return $result;
}
return call_user_func_array(array($this, $func), $param);
}
/**
* 删除某方法某个结果集的redis缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @return mixed
*/
public function un_redis_cache($func, $param = array())
{
if(IF_REDIS_CACHE)
{
$cache = & load_cache('redis');
$cache_key = REDIS_CACHE_PREFIX.md5(get_called_class().'.'.$func.json_encode($param));
return $cache->delete($cache_key);
}
return false;
}
/**
* 对某方法某个结果集的file缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @return mixed
*/
public function file_cache($func, $param = array())
{
if(IF_FILE_CACHE)
{
$cache = & load_cache('file');
$cache_key = FILE_CACHE_PREFIX.get_called_class().'.'.$func.'_'.md5($param);
if(!$result = $cache->get($cache_key))
{
$result = call_user_func_array(array($this, $func), $param);
$cache->save($cache_key, $result, $this->file_cache_expire);
$this->add_cache_key(get_called_class(), $func, 'file', $cache_key);
}
return $result;
}
return call_user_func_array(array($this, $func), $param);
}
/**
* 删除某方法某个结果集的file缓存【结果集为非对象数组】
* @param $func
* @param array $param
* @return mixed
*/
public function un_file_cache($func, $param =array())
{
if(IF_FILE_CACHE)
{
$cache = & load_cache('file');
$cache_key = FILE_CACHE_PREFIX.get_called_class().'.'.$func.'_'.md5($param);
return $cache->delete($cache_key);
}
}
/**
* 清除cache
* @param $method
* @param $type
* @return bool
*/
public function del_cache($method, $type, $skey = '')
{
$cache = & load_cache($type);
$db = $this->load->database('default', true);
$where = $skey ? array("skey like '{$skey}'" => null) : array('class' => get_called_class(), 'method' => $method, 'cache_type' => $type);
$db->where($where);
$cache_list = $db->get('hd_cache_key')->result_array();
if($cache_list)
{
foreach($cache_list as $v)
{
$cache->delete($v['cache_key']);
}
}
$db->delete('hd_cache_key', $where);
return true;
}
private function add_cache_key($class, $method, $type, $key, $expire_time = 0, $skey = '')
{
$db = $this->load->database('default', true);
$data = array(
'class' => $class,
'method' => $method,
'cache_type' => $type,
'cache_key' => $key,
'expire_time' => time() + $expire_time,
'skey' => $skey ? $skey : ''
);
$result = $db->insert('hd_cache_key', $data);
return $this->db->insert_id() ? $this->db->insert_id() : $result;
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: lcc
* Date: 2020/3/24
* Time: 15:10
*/
class HD_Service
{
public $CI;
protected $log_dir;
public function __construct()
{
$this->CI = & get_instance();
$this->log_dir = lcfirst(get_class($this));
}
function __get($name){
if('_model' === substr($name, -6)){
return $this->CI->$name;
} elseif('_service' === substr($name, -8)){
return $this->CI->$name;
} elseif('load' == $name){
return $this->CI->load;
} elseif('config' == $name){
return $this->CI->config;
} elseif(isset($this->CI->$name)){
return $this->CI->$name;
}
return null;
}
}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+28
View File
@@ -0,0 +1,28 @@
<?php
require_once APPPATH . 'libraries/JWT.php';
use \Firebase\JWT\JWT;
class Authorization
{
public static function validateToken($token)
{
$CI =& get_instance();
$key = $CI->config->item('jwt_key');
$algorithm = $CI->config->item('jwt_algorithm');
return JWT::decode($token, $key, array($algorithm));
}
public static function generateToken($data)
{
$CI =& get_instance();
$key = $CI->config->item('jwt_key');
return JWT::encode($data, $key);
}
}
+358
View File
@@ -0,0 +1,358 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: shenab
* Date: 2019/3/15
* Time: 15:39
*/
//根据某个字段排序
if (!function_exists('arraySequence')) {
function arraySequence($array, $field, $sort = 'SORT_DESC')
{
$arrSort = array();
foreach ($array as $uniqid => $row) {
foreach ($row as $key => $value) {
$arrSort[$key][$uniqid] = $value;
}
}
array_multisort($arrSort[$field], constant($sort), $array);
return $array;
}
}
//post请求
if(!function_exists('httpPostForm')){
/**
* 表单提交数据
* @param $url
* @param $data
* @return array
*/
function httpPostForm($url, $data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//https
if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($error = curl_error($ch)) {
die($error);
}
curl_close($ch);
return array($httpCode, $response);
}
}
if (!function_exists('httpPostJson')) {
/**
* @param string $url
* @param string $jsonStr
* @return array
*/
function httpPostJson($url, $jsonStr)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//https
if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($jsonStr)
)
);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($error = curl_error($ch)) {
die($error);
}
curl_close($ch);
return array($httpCode, $response);
}
}
//request 请求
if (!function_exists('httpRequest')) {
function httpRequest($sUrl, $data = array())
{
$header = array('X-AUTH-APP-ID:a2nkCKjTJJNSVaeQITwmV/1zw9Dpn56Acr2Z81MOkkJ/8VapjA6oPA==', 'X-AUTH-KEY:89c9c457-7fff-41f8-9ba5-1e9154a7b972', 'companyUuid:haixifangchan_company8fee8cd09');
if ($data) {
$sUrl = $sUrl . '?' . http_build_query($data);
}
$ch = curl_init();
if (substr($sUrl, 0, 5) == 'https') {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// 从证书中检查SSL加密算法是否存在
}
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $sUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, false);
$response = curl_exec($ch);
$request_header = curl_getinfo($ch, CURLINFO_HEADER_OUT);
//print_r($request_header);exit();
if ($error = curl_error($ch)) {
die($error);
}
curl_close($ch);
return json_decode($response, 1);
}
}
//
if (!function_exists('uploadImg')) {
//上传图片
function uploadImg($url, $path = 'wx/fn/')
{
//$path = 'img/wechatapp/fn/'; 路径
if (!is_dir($path)){
$oldumask = umask(0);
mkdir($path, 0777,true);
umask($oldumask);
}
//对照片处理
$url = mb_substr($url, 0, -4);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
$file = curl_exec($ch);
curl_close($ch);
$filename = pathinfo($url, PATHINFO_BASENAME);
$filename = strtolower($filename);
$resource = fopen($path . $filename, 'a');
fwrite($resource, $file);
fclose($resource);
$name = $path . $filename;
return $name;
}
}
/**
* 图片压缩处理
* @param string $sFile 源图片路径
* @param int $iWidth 自定义图片宽度
* @param int $iHeight 自定义图片高度
* @return string 压缩后的图片路径
*/
if (!function_exists('getThumb')) {
function getThumb($sFile, $iWidth, $iHeight)
{
//图片公共路径
//判断该图片是否存在
if (!file_exists($sFile)) return $sFile;
//判断图片格式(图片文件后缀)
$extend = explode(".", $sFile);
$attach_fileext = strtolower($extend[count($extend) - 1]);
if (!in_array($attach_fileext, array('jpg', 'png', 'jpeg'))) {
return '';
}
//压缩图片文件名称
$sFileNameS = str_replace("." . $attach_fileext, "_" . $iWidth . '_' . $iHeight . '.' . $attach_fileext, $sFile);
//判断是否已压缩图片,若是则返回压缩图片路径
if (file_exists($sFileNameS)) {
return $sFileNameS;
}
//生成压缩图片,并存储到原图同路径下
resizeImage($sFile, $sFileNameS, $iWidth, $iHeight);
if (!file_exists($sFileNameS)) {
return $sFile;
}
return $sFileNameS;
}
}
/**
* 生成图片
* @param string $im 源图片路径
* @param string $dest 目标图片路径
* @param int $maxwidth 生成图片宽
* @param int $maxheight 生成图片高
*/
if (!function_exists('resizeImage')) {
function resizeImage($im, $dest, $maxwidth, $maxheight)
{
$img = getimagesize($im);
switch ($img[2]) {
case 1:
$im = @imagecreatefromgif($im);
break;
case 2:
$im = @imagecreatefromjpeg($im);
break;
case 3:
$im = @imagecreatefrompng($im);
break;
}
$pic_width = imagesx($im);
$pic_height = imagesy($im);
$resizewidth_tag = false;
$resizeheight_tag = false;
if (($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) {
if ($maxwidth && $pic_width > $maxwidth) {
$widthratio = $maxwidth / $pic_width;
$resizewidth_tag = true;
}
if ($maxheight && $pic_height > $maxheight) {
$heightratio = $maxheight / $pic_height;
$resizeheight_tag = true;
}
if ($resizewidth_tag && $resizeheight_tag) {
if ($widthratio < $heightratio)
$ratio = $widthratio;
else
$ratio = $heightratio;
}
if ($resizewidth_tag && !$resizeheight_tag)
$ratio = $widthratio;
if ($resizeheight_tag && !$resizewidth_tag)
$ratio = $heightratio;
$newwidth = $pic_width * $ratio;
$newheight = $pic_height * $ratio;
if (function_exists("imagecopyresampled")) {
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $pic_width, $pic_height);
} else {
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $pic_width, $pic_height);
}
imagejpeg($newim, $dest);
imagedestroy($newim);
} else {
imagejpeg($im, $dest);
}
}
}
//巧房房源图片处理
if (!function_exists('editPhoto')) {
//图片处理
function editPhoto($community_list)
{
foreach ($community_list as $key => $value) {
foreach ($value as $k => $item) {
if (empty($item) || is_null($item)) {
$community_list[$key][$k] = '';
}
//图片处理,取室内图,取不到再用户型图
if ($value['photoList']) {
foreach ($value['photoList'] as $v) {
if ($v['categoryName'] == 'shinei' || $v['categoryName'] == '室内图' || $v['categoryCnName'] == '室内图') {
$community_list[$key]['photoList'] = 'http://uyu.xmfish.com/thumb2/byurl/?url=' . str_replace('https://', '', $v['photoUrl']) . '|300';
break;
} else {
$community_list[$key]['photoList'] = 'http://uyu.xmfish.com/thumb2/byurl/?url=' . str_replace('https://', '', $v['photoUrl']) . '|300';
}
}
}
}
//photoList原先就是数组,清空获取不到值,只能进行转换
$community_list[$key]['photo_list'][0] = $community_list[$key]['photoList'];
$community_list[$key]['photoList'] = $community_list[$key]['photo_list'];
unset($community_list[$key]['photo_list']);
//计算单价
$community_list[$key]['unitPrice'] = str_replace(',', '', number_format($value['sellPrice'] / $value['square'], 2));
}
return $community_list;
}
}
//二维数组去重
if (!function_exists('moreArrayUnique')) {
function moreArrayUnique($arr = array())
{
foreach ($arr[0] as $k => $v) {
$arr_inner_key[] = $k;
}
foreach ($arr as $k => $v) {
$v = join(",", $v);
$temp[$k] = $v;
}
$temp = array_unique($temp);
foreach ($temp as $k => $v) {
$a = explode(",", $v);
$arr_after[$k] = array_combine($arr_inner_key, $a);
}
$arr_after = array_values($arr_after);
return $arr_after;
}
}
if (!function_exists('msectime')) {
//时间转换成毫秒
function msectime()
{
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
return $msectime;
}
}
if ( ! function_exists('friendly_time') )
{
/**
* @param $time
* @return false|string
*/
function friendly_time($time)
{
$surplus = time() - $time;
switch (true)
{
case $surplus < 60:
return $surplus . '秒前';
case $surplus < 3600:
return ceil($surplus / 60) . '分钟前';
case $surplus < 3600 * 24:
return ceil($surplus / 3600) . '小时前';
case $surplus < 3600 * 24 * 7:
return ceil($surplus / (3600 * 24)) . '天前';
default:
return date('m月d日', $time);
}
}
}
+101
View File
@@ -0,0 +1,101 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
//todo:暂用,需重构
/**
* 成功数据重构
* @param $data
* @return array
*/
if(!function_exists('info_format'))
{
function info_format($data)
{
$data = _clean($data);
is_bool($data) && $data = array('status' => $data);
is_numeric($data) && $data = array('count' => $data);
is_string($data) && $data = array('result' => $data);
if(is_array($data) && array_search(current($data), $data) === 0)
{
$data = array('list' => $data);
}
if(empty($data))
{
$data = array('result' => array());
}
return array('errCode' => '0', 'data' => $data);
}
}
/**
* 过滤空字符
* @param $array
* @return array
*/
if(!function_exists('_clean'))
{
function _clean($array)
{
if(!is_array($array))
{
return $array;
}
foreach($array as $k => $v)
{
if($v === '' || $v === null || $v === array())
{
unset($array[$k]);
}
elseif(is_array($v))
{
$array[$k] = _clean($v);
}
}
return $array;
}
}
/**
* API 输出
* @param $result
* @param bool $ifgzip
*/
if(!function_exists('print_result'))
{
function print_result($result, $ifgzip = false)
{
if(!isset($result['errCode']))
{
$data = info_format($result);
}
else
{
$data = $result;
}
if($ifgzip)
{
header('Content-Type: application/json');
header('Content-Encoding: gzip');
echo gzencode(json_encode($data, JSON_UNESCAPED_UNICODE), 6);
exit;
}
else
{
$result = json_encode($data, JSON_UNESCAPED_UNICODE);
echo $result;
exit;
}
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* Created by PhpStorm.
* User: linfan
* Date: 2018-12-03
* Time: 21:39
*/
if (! function_exists('upload_net_image'))
{
/**
* 保存网络图片,如果图片保存失败返回空字符串
* @param $srcs ['src1', 'src2', 'src3']
* @param $path (保存的分类目录)
* @return array ['url1', '', 'url3']
*/
function upload_net_image($srcs, $path = '')
{
$path && $path = '/' === substr($path, -1) ? $path : $path . '/';
$urls = array();
if($srcs)
{
$ci = & get_instance();
$ci->load->library('qiniu');
foreach ($srcs as $key => $val)
{
$filename = $ci->qiniu->getFileName($val);
$filename = $path . date('Y/m').'/'.$filename;
$file = $ci->qiniu->fetch($val, $filename);
if (!$file)
{
$urls[$key] = '';
continue;
}
else
{
$urls[$key] = $file['file'];
}
}
}
return $urls;
}
}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+178
View File
@@ -0,0 +1,178 @@
<?php
class ApiAuthHook
{
// CI instance
private $CI;
// 需要加入钩子函数保护的路由
private $route;
private $auth;//验证身份,不需要验访问权限
private $route_un;//不需要验证token
public function __construct()
{
$this->CI = &get_instance();
// 保护路由为 /api/* 或者 /Api/*
$this->route = '/^api/i';
$this->auth = ',api/auth';
$this->route_un = ['api/captcha', 'api/login', 'api/upload'];
}
/**
* 钩子主函数
*/
public function index()
{
$this->CI->load->helper('url');
// $route 正则匹配是否符合 /api/* 或者 /Api/*
if (preg_match($this->route, uri_string())) {
if (!in_array(uri_string(), $this->route_un)) {
// 获取整个 request headers
$headers = $this->CI->input->request_headers();
// headers 中是否存在 Authorization
if ($this->tokenIsExist($headers)) {
$userId = $this->validateToken($headers['Authorization']);
$this->set_session($userId);
} else {
$this->httpBadResponse(
'The request lacks the authorization token'
);
}
}
}
}
private function set_session($userId)
{
$_SESSION['userId'] = intval($userId);
$this->CI->load->model('market/Market_sys_admin_model');
$re_admin = $this->CI->Market_sys_admin_model->get(['userId' => $userId, 'status' => 0]);
if ($re_admin) {
$_SESSION = $re_admin;
}
$route = uri_string();
if (strstr(',' . $route, $this->auth)) {
return;
}
$request = $this->CI->input->method();
$authorityAry = explode('/', $route); //api/system/user/
$authority_set = '';
if ($request == 'post') {
$authority_set = 'save';
} else if ($request == 'put') {
$authority_set = 'update';
} else if ($request == 'delete') {
$authority_set = 'remove';
} else if (strstr($route, '/page')) {//列表搜索权限
$authority_set = 'list';
}
if ($authority_set) {
$show = true;
$authority = $authorityAry[1] . ':' . $authorityAry[2] . ':' . $authority_set;//system:user:save
if ($re_admin['roleId']) {
$this->CI->load->model('market/Market_sys_role_model');
$re_role = $this->CI->Market_sys_role_model->get(['roleId' => $re_admin['roleId'], 'status' => 0]);
if ($re_role['menuIds']) {
if (strstr($route, '/roleMenu')) {//角色分配权限
$authority = 'system:role:' . $authority_set;
} else if (strstr($route, '/dictionaryData')) {//字典项权限
$authority = 'system:dictionary:' . $authority_set;
} else if (strstr($route, '/sylive/user')) {//机构用户权限
$authority = 'sylive:organization:' . $authority_set;
}
$this->CI->load->model('market/Market_sys_menu_model');
$re_menu = $this->CI->Market_sys_menu_model->get(["menuId in({$re_role['menuIds']})" => null, 'status' => 0
, 'authority' => $authority]);
if ($re_menu) {
$show = false;
if ($re_menu['title'] == '登录日志' || $re_menu['title'] == '操作日志') {
} else {
$_SESSION['operation_description'] = $re_menu['title'];//操作功能
$re_menu2 = $this->CI->Market_sys_menu_model->get(["menuId" => $re_menu['parentId'], 'status' => 0]);
$_SESSION['operation_module'] = $re_menu2['title'] ? $re_menu2['title'] : $re_menu['title'];//操作模块
}
}
}
}
$show && $this->return_json('没有访问权限', 403);
}
}
public function return_json($message = '', $code = 1)
{
header('Content-Type:application/json; charset=utf-8');
echo json_encode(['code' => $code, 'message' => $message], JSON_UNESCAPED_UNICODE);
exit();
}
/**
* 判断 headers 中是否含有 Authorization 字段
*
* @param type $headers
* @return type boolean
*/
public function tokenIsExist($headers = array())
{
return (
array_key_exists('Authorization', $headers) &&
!empty($headers['Authorization'])
);
}
/**
* Authorization 中是否有 json web token 值
*
* @param type $headers
* @return type
*/
public function jwtIsExist($headers)
{
list($jwt) = sscanf($headers['Authorization'], 'market.com %s');
return $jwt;
}
/**
* 校验 json web token 的合法性
*
* @param type $jwt
* @return boolean
*/
public function validateToken($jwt)
{
if ($jwt) {
try {
$token = Authorization::validateToken($jwt);
return $token;
} catch (Exception $ex) {
$this->httpUnauthorizedResponse($ex->getMessage());
}
} else {
$this->httpBadResponse(
'the token is unauthorized'
);
}
}
/**
* http code 400 response
*
* @param type $msg
*/
public function httpBadResponse($msg = NULL)
{
set_status_header(400, $msg);
exit(1);
}
/**
* http code 401 response
*
* @param type $msg
*/
public function httpUnauthorizedResponse($msg = NULL)
{
set_status_header(401, $msg);
exit(1);
}
}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
@@ -0,0 +1,18 @@
<?php
/*
* English language
*/
$lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Invalid credentials';
$lang['text_rest_ip_denied'] = 'IP denied';
$lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
$lang['text_rest_unauthorized'] = 'Unauthorized';
$lang['text_rest_ajax_only'] = 'Only AJAX requests are allowed';
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
$lang['text_rest_ip_address_time_limit'] = 'This IP Address has reached the time limit for this method';
$lang['text_rest_unknown_method'] = 'Unknown method';
$lang['text_rest_unsupported'] = 'Unsupported protocol';

Some files were not shown because too many files have changed in this diff Show More