fix: bug修复
This commit is contained in:
@@ -10,7 +10,8 @@ use think\Cookie;
|
||||
use app\common\controller\BaseController as Controller;
|
||||
|
||||
//<!--#include file="([0-9a-zA-Z/._-]+?)\.html" -->
|
||||
class BaseController extends Controller {
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
||||
//当前用户
|
||||
protected $customer_id = 0;
|
||||
@@ -18,23 +19,30 @@ class BaseController extends Controller {
|
||||
# 当前国家编码
|
||||
protected $country_code = 'ZH';
|
||||
|
||||
public function __construct() {
|
||||
protected $customer_info = [];
|
||||
protected $categoryList = [];
|
||||
protected $country_list = [];
|
||||
protected $productCategory = [];
|
||||
|
||||
protected $nav_header = [];
|
||||
protected $nav_footer = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function _initialize() {
|
||||
protected function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
|
||||
if ($this->check_true_login())
|
||||
{
|
||||
if ($this->check_true_login()) {
|
||||
$customer_info = json_decode(Cookie::get('c'), true);
|
||||
$this->view->assign('customer_info', $customer_info);
|
||||
$this->customer_id = $customer_info['id'];
|
||||
$this->customer_id = $customer_info['id'];
|
||||
$this->customer_info = $customer_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->_logout();
|
||||
}
|
||||
|
||||
@@ -43,11 +51,67 @@ class BaseController extends Controller {
|
||||
$this->view->assign('seo_description', (string) Config::get('website_seo_description'));
|
||||
// $this->categoryList = $this->cacheGet('productCategoryList');
|
||||
if (empty($this->productCategory)) {
|
||||
$this->categoryList = Loader::model('ProductCategory')->getList(['stat' => 0, 'siteid' => $this->siteid,'isshow'=>1, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'asc'], ['id', 'pid', 'haschild', 'name', 'shortname', 'sort', 'description', 'isshow', 'recommend', 'picture', 'icon', 'image', 'm_icon', 'unique_id']);
|
||||
// $this->categoryList = Loader::model('ProductCategory')->getList(['stat' => 0, 'siteid' => $this->siteid, 'isshow' => 1, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'asc'], ['id', 'pid', 'haschild', 'name', 'shortname', 'sort', 'description', 'isshow', 'recommend', 'picture', 'icon', 'image', 'm_icon', 'unique_id']);
|
||||
$this->categoryList = \think\Db::name('product_category')->alias('pc')
|
||||
->field([
|
||||
'pc.id',
|
||||
'pc.pid',
|
||||
'pc.haschild',
|
||||
'pc.name',
|
||||
'pc.shortname',
|
||||
'pc.sort',
|
||||
'pc.description',
|
||||
'pc.isshow',
|
||||
'pc.recommend',
|
||||
'pc.picture',
|
||||
'pc.icon',
|
||||
'pc.image',
|
||||
'pc.m_icon',
|
||||
'pc.unique_id'
|
||||
])
|
||||
->where('pc.stat', '=', 0)
|
||||
->where('pc.siteid', '=', $this->siteid)
|
||||
->where('pc.isshow', '=', 1)
|
||||
->where('pc.haschild', '=', 0)
|
||||
->where('pc.country_code', '=', $this->country_code)
|
||||
->whereExists(function($query) {
|
||||
$query->name('product')->alias('p')
|
||||
->where('p.stat', '=', 0)
|
||||
->where('p.is_show', '=', 0)
|
||||
->where('p.country_code', '=', $this->country_code)
|
||||
->where('p.cid=pc.id');
|
||||
})
|
||||
->union(function($query) {
|
||||
$query->name('product_category')->alias('uni_pc')
|
||||
->field([
|
||||
'uni_pc.id',
|
||||
'uni_pc.pid',
|
||||
'uni_pc.haschild',
|
||||
'uni_pc.name',
|
||||
'uni_pc.shortname',
|
||||
'uni_pc.sort',
|
||||
'uni_pc.description',
|
||||
'uni_pc.isshow',
|
||||
'uni_pc.recommend',
|
||||
'uni_pc.picture',
|
||||
'uni_pc.icon',
|
||||
'uni_pc.image',
|
||||
'uni_pc.m_icon',
|
||||
'uni_pc.unique_id'
|
||||
])
|
||||
->where('uni_pc.stat', '=', 0)
|
||||
->where('uni_pc.siteid', '=', $this->siteid)
|
||||
->where('uni_pc.isshow', '=', 1)
|
||||
->where('uni_pc.haschild', '=', 1)
|
||||
->where('uni_pc.country_code', '=', $this->country_code);
|
||||
})
|
||||
->order(['sort' => 'asc', 'id' => 'asc'])
|
||||
->select();
|
||||
$this->cacheTag('ProductCategoryTag')->set('productCategoryList', $this->categoryList);
|
||||
}
|
||||
|
||||
$this->productCategory = $this->list_to_tree($this->categoryList);
|
||||
$this->categoryList = collection($this->categoryList);
|
||||
$this->productCategory = $this->buildTreeForCategory($this->categoryList, 0);
|
||||
|
||||
// tiaoshi($this->productCategory[0]['child'][0]['child']);die;
|
||||
if ($this->cacheHas('country_list')) {
|
||||
$this->country_list = $this->cacheGet('country_list');
|
||||
@@ -88,7 +152,27 @@ class BaseController extends Controller {
|
||||
$this->view->assign('productCategory', $this->productCategory);
|
||||
$this->view->assign('allCategoryList', $this->categoryList);
|
||||
}
|
||||
|
||||
|
||||
// 组装分类树状结构
|
||||
private function buildTreeForCategory($data, $pid=0)
|
||||
{
|
||||
$tree = [];
|
||||
foreach ($data as $val) {
|
||||
if ($val['pid'] == $pid) {
|
||||
$children = $this->buildTreeForCategory($data, $val['id']);
|
||||
if (!empty($children)) {
|
||||
$val['child'] = $children;
|
||||
}
|
||||
if (empty($children) && $val['haschild'] == 1) {
|
||||
continue;
|
||||
}
|
||||
$tree[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
protected function buildTree($data, $pid = 0)
|
||||
{
|
||||
$tree = [];
|
||||
@@ -131,7 +215,8 @@ class BaseController extends Controller {
|
||||
}
|
||||
|
||||
//导航初始化
|
||||
private function navInit(){
|
||||
private function navInit()
|
||||
{
|
||||
// 读取缓存数据
|
||||
//$header = $this->cacheGet('cache_common_nav_header_key');
|
||||
//$footer = $this->cacheGet('cache_common_nav_footer_key');
|
||||
@@ -142,34 +227,30 @@ class BaseController extends Controller {
|
||||
// 缓存没数据则从数据库重新读取,顶部菜单
|
||||
//if(empty($header))
|
||||
//{
|
||||
$headerData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'header', 'stat'=>0, 'pid'=>0, 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$header = self::navDataDealWith($headerData);
|
||||
if(!empty($header))
|
||||
{
|
||||
foreach($header as &$v)
|
||||
{
|
||||
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'header', 'stat'=>0, 'pid'=>$v['id'], 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$v['items'] = self::navDataDealWith($childData);
|
||||
}
|
||||
$headerData = Loader::model('Navigation')->field($field)->where(array('nav_type' => 'header', 'stat' => 0, 'pid' => 0, 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$header = self::navDataDealWith($headerData);
|
||||
if (!empty($header)) {
|
||||
foreach ($header as &$v) {
|
||||
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type' => 'header', 'stat' => 0, 'pid' => $v['id'], 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$v['items'] = self::navDataDealWith($childData);
|
||||
}
|
||||
//$this->cacheSet('cache_common_nav_header_key', $header, 3600);
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
//$this->cacheSet('cache_common_nav_header_key', $header, 3600);
|
||||
|
||||
//}
|
||||
|
||||
// 底部导航
|
||||
//if(empty($footer))
|
||||
//{
|
||||
$footerdata = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'footer', 'stat'=>0, 'pid'=>0, 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$footer = self::navDataDealWith($footerdata);
|
||||
if(!empty($footer))
|
||||
{
|
||||
foreach($footer as &$v)
|
||||
{
|
||||
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'footer', 'stat'=>0, 'pid'=>$v['id'], 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$v['items'] = self::navDataDealWith($childData);
|
||||
}
|
||||
}
|
||||
//$this->cacheSet('cache_common_nav_footer_key', $footer, 3600);
|
||||
$footerdata = Loader::model('Navigation')->field($field)->where(array('nav_type' => 'footer', 'stat' => 0, 'pid' => 0, 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$footer = self::navDataDealWith($footerdata);
|
||||
if (!empty($footer)) {
|
||||
foreach ($footer as &$v) {
|
||||
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type' => 'footer', 'stat' => 0, 'pid' => $v['id'], 'country_code' => $this->country_code))->order('sort')->select();
|
||||
$v['items'] = self::navDataDealWith($childData);
|
||||
}
|
||||
}
|
||||
//$this->cacheSet('cache_common_nav_footer_key', $footer, 3600);
|
||||
//}
|
||||
|
||||
return [
|
||||
@@ -187,13 +268,10 @@ class BaseController extends Controller {
|
||||
*/
|
||||
public function NavDataDealWith($data)
|
||||
{
|
||||
if(!empty($data) && is_array($data))
|
||||
{
|
||||
foreach($data as $k=>&$v)
|
||||
{
|
||||
if (!empty($data) && is_array($data)) {
|
||||
foreach ($data as $k => &$v) {
|
||||
// url处理
|
||||
switch($v['data_type'])
|
||||
{
|
||||
switch ($v['data_type']) {
|
||||
// 文章分类
|
||||
case 'article':
|
||||
$v['url'] = 'article/detail/'.$v['value'].'.html';
|
||||
@@ -208,12 +286,11 @@ class BaseController extends Controller {
|
||||
case 'goods_category':
|
||||
$category = Loader::model('ProductCategory')->getRow(['stat' => 0, 'id' => $v['value'], 'country_code' => $this->country_code], null, ['id' => 'asc']);
|
||||
//echo $category['pid']."<pre>=="; print_r($category);
|
||||
if($category['pid'] == 0) {
|
||||
$v['url'] = 'product/catelists/'.$v['value'].'.html';
|
||||
if ($category['pid'] == 0) {
|
||||
$v['url'] = 'product/catelists/' . $v['value'] . '.html';
|
||||
} else {
|
||||
$v['url'] = 'product/subcategory/' . $v['value'] . '.html';
|
||||
}
|
||||
else{
|
||||
$v['url'] = 'product/subcategory/'.$v['value'].'.html';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -263,12 +340,12 @@ class BaseController extends Controller {
|
||||
private function check_login_token($customer_id, $curr_time, $p)
|
||||
{
|
||||
$expire = 86400 * 30;
|
||||
if (time() - $curr_time > $expire)
|
||||
if (time() - $curr_time > $expire) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$temp_p = $this->make_pwd($customer_id, $curr_time);
|
||||
if ($temp_p !== $p)
|
||||
{
|
||||
if ($temp_p !== $p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -309,8 +386,7 @@ class BaseController extends Controller {
|
||||
protected function check_true_login()
|
||||
{
|
||||
// 校验用户是否登录,且校验cookie合法性
|
||||
if (!$this->check_login())
|
||||
{
|
||||
if (!$this->check_login()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -323,8 +399,9 @@ class BaseController extends Controller {
|
||||
|
||||
protected function _logout()
|
||||
{
|
||||
if (Cookie::has('c'))
|
||||
if (Cookie::has('c')) {
|
||||
Cookie::delete('c');
|
||||
}
|
||||
|
||||
$this->customer_id = 0;
|
||||
}
|
||||
|
||||
@@ -36,18 +36,16 @@ class Group extends BaseController
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function backup_treasure()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function backup_treasure()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function pssd()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function question()
|
||||
{
|
||||
$data = $this->request->param();
|
||||
@@ -57,33 +55,32 @@ class Group extends BaseController
|
||||
'a.country_code' => $this->country_code,
|
||||
];
|
||||
$cid = isset($data['cid']) ? $data['cid'] : 0;
|
||||
if ($cid)
|
||||
if ($cid) {
|
||||
$where['a.cid'] = $cid;
|
||||
}
|
||||
|
||||
$search['keyword'] = '';
|
||||
if (isset($data['keyword']) && $data['keyword'] != '')
|
||||
{
|
||||
$where['a.title'] = ['like', '%' . $data['keyword'] . '%'];
|
||||
if (isset($data['keyword']) && $data['keyword'] != '') {
|
||||
$where['a.title'] = ['like', '%' . $data['keyword'] . '%'];
|
||||
$search['keyword'] = $data['keyword'];
|
||||
}
|
||||
|
||||
$order = [
|
||||
'a.sort' => 'asc',
|
||||
'a.id' => 'desc'
|
||||
'a.sort' => 'asc',
|
||||
'a.id' => 'desc',
|
||||
];
|
||||
$field = ['a.*', 'b.name' => 'cate_name'];
|
||||
|
||||
|
||||
$question_list = model('question')->alias('a')->join('question_category b', 'a.cid = b.id', 'LEFT')->where($where)->order($order)->field($field)->paginate(4);
|
||||
// echo model('question')->getLastSql();die;
|
||||
// tiaoshi($question_list->items());die;
|
||||
$question_catelist = model('question_category')->where(['stat' => 0])->select();
|
||||
$value = [
|
||||
'question_list' => $question_list->isEmpty() ? null : $question_list->items(),
|
||||
'page' => $question_list->render(),
|
||||
'cid' => $cid,
|
||||
'search' => $search,
|
||||
'question_catelist' => $question_catelist
|
||||
$value = [
|
||||
'question_list' => $question_list->isEmpty() ? null : $question_list->items(),
|
||||
'page' => $question_list->render(),
|
||||
'cid' => $cid,
|
||||
'search' => $search,
|
||||
'question_catelist' => $question_catelist,
|
||||
];
|
||||
|
||||
$this->assign($value);
|
||||
@@ -104,7 +101,7 @@ class Group extends BaseController
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function responsibility()
|
||||
public function responsibility()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
@@ -128,7 +125,6 @@ class Group extends BaseController
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
@@ -139,7 +135,6 @@ class Group extends BaseController
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
public function headset()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
@@ -195,113 +190,127 @@ class Group extends BaseController
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function thunderbolt_3 ()
|
||||
public function thunderbolt_3()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function customized ()
|
||||
public function customized()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
/********20230720 顶部导航栏目************/
|
||||
public function blog2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function brand2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function brand(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function Contact2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function product2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function catelists2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function download(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function achievement(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function business2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function distributor2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function introduction2023(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function faq(){
|
||||
public function blog2023()
|
||||
{
|
||||
|
||||
$where = ['stat' => 0];
|
||||
$order = [
|
||||
'sort' => 'asc',
|
||||
'id' => 'desc'
|
||||
];
|
||||
$fq_list = model('fq')->where($where)->order($order)->paginate(6);
|
||||
// echo model('question')->getLastSql();die;
|
||||
// tiaoshi($question_list->items());die;
|
||||
|
||||
$value = [
|
||||
'fq_list' => $fq_list->isEmpty() ? null : $fq_list->items(),
|
||||
'page' => $fq_list->render(),
|
||||
|
||||
];
|
||||
$this->assign($value);
|
||||
return $this->view->fetch();
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function brand2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function brand()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function Contact2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function product2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function catelists2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function download()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function mileage(){
|
||||
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
|
||||
$arg_order = ['a.id' => 'desc'];
|
||||
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
|
||||
$dataObject = model('Article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 12);
|
||||
|
||||
$category = model('ArticleCategory')->getRow(1);
|
||||
|
||||
$value = [
|
||||
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
|
||||
'page' => $dataObject->render(),
|
||||
'category' => $category,
|
||||
];
|
||||
|
||||
|
||||
//echo "<pre>=="; print_r($category);
|
||||
$this->assign($value);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function guide(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function achievement()
|
||||
{
|
||||
|
||||
public function query(){
|
||||
|
||||
return $this->view->fetch();
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function contact(){
|
||||
public function business2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function distributor2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function introduction2023()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function faq()
|
||||
{
|
||||
|
||||
$where = ['stat' => 0];
|
||||
$order = [
|
||||
'sort' => 'asc',
|
||||
'id' => 'desc',
|
||||
];
|
||||
$fq_list = model('fq')->where($where)->order($order)->paginate(6);
|
||||
// echo model('question')->getLastSql();die;
|
||||
// tiaoshi($question_list->items());die;
|
||||
|
||||
$value = [
|
||||
'fq_list' => $fq_list->isEmpty() ? null : $fq_list->items(),
|
||||
'page' => $fq_list->render(),
|
||||
|
||||
];
|
||||
$this->assign($value);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function mileage()
|
||||
{
|
||||
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
|
||||
$arg_order = ['a.id' => 'desc'];
|
||||
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
|
||||
$dataObject = model('Article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 12);
|
||||
|
||||
$category = model('ArticleCategory')->getRow(1);
|
||||
|
||||
$value = [
|
||||
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
|
||||
'page' => $dataObject->render(),
|
||||
'category' => $category,
|
||||
];
|
||||
|
||||
//echo "<pre>=="; print_r($category);
|
||||
$this->assign($value);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function guide()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function query()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function contact()
|
||||
{
|
||||
$banners = Loader::model("Banner")->alias('b')->field([
|
||||
'b.id',
|
||||
'b.typeid',
|
||||
@@ -344,43 +353,47 @@ class Group extends BaseController
|
||||
];
|
||||
}
|
||||
$this->assign('data', $data);
|
||||
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function tutorial(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function distributor(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function business(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function introduction(){
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function test ()
|
||||
|
||||
public function tutorial()
|
||||
{
|
||||
$field = ['a.*', 'b.name', 'b.shortname', 'b.brand_id', 'b.url_tm', 'b.url_jd'];
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function distributor()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function business()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function introduction()
|
||||
{
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$field = ['a.*', 'b.name', 'b.shortname', 'b.brand_id', 'b.url_tm', 'b.url_jd'];
|
||||
$special_product_list = db('special_product_relation')->alias('a')->join('product b', 'a.product_id=b.id', 'LEFT')->where(['a.special_id' => 3, 'a.stat' => 0, 'b.stat' => 0])->field($field)->limit(8)->select();
|
||||
|
||||
$normal_product = [];
|
||||
$normal_product = [];
|
||||
$special_product = [];
|
||||
foreach ($special_product_list as $key => $value) {
|
||||
$product_two_img = model('product_two_img')->where(['stat' => 0, 'product_id' => $value['product_id']])->find();
|
||||
$value['img'] = $product_two_img['image_url'];
|
||||
if ($value['type'] == 0)
|
||||
$value['img'] = $product_two_img['image_url'];
|
||||
if ($value['type'] == 0) {
|
||||
array_push($normal_product, $value);
|
||||
else if ($value['type'] == 1)
|
||||
} else if ($value['type'] == 1) {
|
||||
array_push($special_product, $value);
|
||||
}
|
||||
|
||||
}
|
||||
// tiaoshi($normal_product);
|
||||
// tiaoshi($special_product);die;
|
||||
@@ -388,61 +401,75 @@ class Group extends BaseController
|
||||
$this->assign('normal_product', $normal_product);
|
||||
$this->assign('special_product', $special_product);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
public function report()
|
||||
}
|
||||
public function report()
|
||||
{
|
||||
if ($this->customer_id <= 0)
|
||||
if ($this->customer_id <= 0) {
|
||||
$this->redirect('/login.html');
|
||||
}
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function create_report()
|
||||
{
|
||||
if ($this->customer_id <= 0)
|
||||
if ($this->customer_id <= 0) {
|
||||
return $this->json(-100, '请先登录');
|
||||
}
|
||||
|
||||
$data = $this->request->post();
|
||||
if (empty($data) || !is_array($data))
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->json(-1, '数据错误');
|
||||
}
|
||||
|
||||
if ($data['product_name'] == '')
|
||||
if ($data['product_name'] == '') {
|
||||
return $this->json(-2, '产品名称不能为空');
|
||||
if ($data['product_model'] == '')
|
||||
}
|
||||
|
||||
if ($data['product_model'] == '') {
|
||||
return $this->json(-3, '产品型号不能为空');
|
||||
if ($data['product_manufacturer'] == '')
|
||||
}
|
||||
|
||||
if ($data['product_manufacturer'] == '') {
|
||||
return $this->json(-4, '厂商不能为空');
|
||||
}
|
||||
|
||||
// if ($data['buy_source'] == '')
|
||||
// return $this->json(-5, '购买渠道不能为空');
|
||||
|
||||
if ($data['customer_telephone'] != '' && !preg_match("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/", $data['customer_telephone']))
|
||||
if ($data['customer_telephone'] != '' && !preg_match("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/", $data['customer_telephone'])) {
|
||||
return $this->json(-6, '手机格式错误');
|
||||
if ($data['customer_email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['customer_email']))
|
||||
}
|
||||
|
||||
if ($data['customer_email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['customer_email'])) {
|
||||
return $this->json(-7, '邮箱格式错误');
|
||||
}
|
||||
|
||||
$insert_data = [
|
||||
'customer_id' => $this->customer_id,
|
||||
'product_name' => $data['product_name'],
|
||||
'product_model' => $data['product_model'],
|
||||
'product_manufacturer' => $data['product_manufacturer'],
|
||||
'buy_source' => $data['buy_source'],
|
||||
'product_price' => floatval($data['product_price']),
|
||||
'customer_name' => $data['customer_name'],
|
||||
'customer_email' => $data['customer_email'],
|
||||
'customer_telephone' => $data['customer_telephone'],
|
||||
'description' => $data['description'],
|
||||
'create_time' => time(),
|
||||
'customer_id' => $this->customer_id,
|
||||
'product_name' => $data['product_name'],
|
||||
'product_model' => $data['product_model'],
|
||||
'product_manufacturer' => $data['product_manufacturer'],
|
||||
'buy_source' => $data['buy_source'],
|
||||
'product_price' => floatval($data['product_price']),
|
||||
'customer_name' => $data['customer_name'],
|
||||
'customer_email' => $data['customer_email'],
|
||||
'customer_telephone' => $data['customer_telephone'],
|
||||
'description' => $data['description'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
|
||||
$result = model('report')->insert($insert_data);
|
||||
if (!$result)
|
||||
if (!$result) {
|
||||
return $this->json(-8, '提交失败');
|
||||
}
|
||||
|
||||
return $this->json(200, 'ok');
|
||||
}
|
||||
|
||||
public function job()
|
||||
{
|
||||
$sql = "SELECT * FROM cod_job
|
||||
$sql = "SELECT * FROM cod_job
|
||||
WHERE stat=0
|
||||
AND NOW() >= publish_time
|
||||
AND NOW() <= end_time
|
||||
@@ -457,16 +484,18 @@ class Group extends BaseController
|
||||
{
|
||||
$data = $this->request->post();
|
||||
//$this->verify_check($data['captcha'], 'authcode') || $this->error('验证码有误', url('group/test'));
|
||||
$sn = $data['sn'];//dump($sn);die;
|
||||
$sn = $this->https_request('http://mes.orico.com.cn:8084/api/values/',$sn);dump($sn);die;
|
||||
$sn = $data['sn']; //dump($sn);die;
|
||||
$sn = $this->https_request('http://mes.orico.com.cn:8084/api/values/', $sn);
|
||||
dump($sn);die;
|
||||
}
|
||||
|
||||
//CURL POST请求
|
||||
function https_request($url, $data = null) {
|
||||
$apiUrl = "$url$data";//print_r($apiUrl);die;
|
||||
$oCurl = curl_init();
|
||||
if(stripos($apiUrl,"https://")!==FALSE){
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
public function https_request($url, $data = null)
|
||||
{
|
||||
$apiUrl = "$url$data"; //print_r($apiUrl);die;
|
||||
$oCurl = curl_init();
|
||||
if (stripos($apiUrl, "https://") !== false) {
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
}
|
||||
curl_setopt($oCurl,CURLOPT_TIMEOUT,5);
|
||||
@@ -485,7 +514,8 @@ class Group extends BaseController
|
||||
}
|
||||
}
|
||||
//可以发送get和post的请求方式
|
||||
function curl_request($url,$method='get',$data=null,$https=true){
|
||||
public function curl_request($url, $method = 'get', $data = null, $https = true)
|
||||
{
|
||||
//1.初识化curl
|
||||
$ch = curl_init($url);
|
||||
//2.根据实际请求需求进行参数封装
|
||||
@@ -504,7 +534,8 @@ class Group extends BaseController
|
||||
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
|
||||
}
|
||||
//3.发送请求
|
||||
$result = curl_exec($ch);dump($result);die;
|
||||
$result = curl_exec($ch);
|
||||
dump($result);die;
|
||||
//4.返回返回值,关闭连接
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
@@ -519,12 +550,16 @@ class Group extends BaseController
|
||||
* @param int $flag 标志位
|
||||
* @return string 返回的资源内容
|
||||
*/
|
||||
public function post($url, $keysArr, $flag = 0){
|
||||
public function post($url, $keysArr, $flag = 0)
|
||||
{
|
||||
|
||||
$ch = curl_init();
|
||||
if(! $flag) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
if (!$flag) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $keysArr);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
$ret = curl_exec($ch);
|
||||
|
||||
@@ -107,6 +107,7 @@ class Product extends BaseController {
|
||||
$value['seo_title'] = $category['seo_title']? : config('website_seo_title');
|
||||
$value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword');
|
||||
$value['seo_description'] = $category['seo_description']? : config('website_seo_description');
|
||||
|
||||
$this->assign($value);
|
||||
return $this->fetch($template);
|
||||
}
|
||||
@@ -302,7 +303,7 @@ class Product extends BaseController {
|
||||
$this->assign('count',$count);
|
||||
$this->assign($value);
|
||||
$this->viewcount($id);
|
||||
|
||||
|
||||
$purchase_links = Db::name('product_purchase_links')->alias('links')
|
||||
->field(['links.id', 'platforms.platform', 'links.link'])
|
||||
->join('product_purchase_link_platforms platforms', 'platforms.id=links.platform_id')
|
||||
@@ -310,6 +311,7 @@ class Product extends BaseController {
|
||||
->where('links.country_code', '=', $this->country_code)
|
||||
->select();
|
||||
$this->assign('purchase_links', $purchase_links);
|
||||
|
||||
//dump($value['product_relateds']);die;
|
||||
return $this->fetch($template);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user