Commit 55cddd21 by 施宇

Merge branch 'master' of http://119.23.72.7/shiyu/icsales

parents df3c95cb ea59284c
......@@ -411,3 +411,39 @@ function S_cms($key, $field='', $column='', $sort='', $limit='')
return $datas;
}
//随机生成字符串
function createNonceStr($length = 8)
{
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$str = "";
for ($i = 0; $i < $length; $i++) {
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $str;
}
/**
* 生成签名
* @param $timeStamp 时间戳
* @param $randomStr 随机字符串
* @return string 返回签名
*/
function createSignature($timestamp, $random)
{
$arr['timestamp'] = $timestamp;
$arr['random'] = $random;
$arr['token'] = C('API_TOKEN'); // token
sort($arr, SORT_STRING); // 按照首字母大小写顺序排序
$str = implode($arr); // 拼接成字符串
$signature = sha1($str); // 进行加密
return strtoupper($signature); // 转换成大写
}
......@@ -37,4 +37,5 @@ return array(
'HOME_TEMPLATE_REDIS' => 'home_template_datas',
'H5_HOME_TEMPLATE_REDIS' => 'h5_home_template_datas',
'API_TOKEN' => 'zbPx8gDXDfIh3ZoJcO4EH', // api接口token
);
\ No newline at end of file
......@@ -54,4 +54,24 @@ class BaseController extends Controller
return $data;exit;
}
}
// 校验接口
protected function checkApi($request)
{
$timestamp = I('request.timestamp', '');
$random = I('request.random', '');
$signature = I('request.signature', '');
if (!$timestamp && !$random && !$signature) return false;
if ($timestamp < time() - 300) return false;
$sign = createSignature($timestamp, $random);
if ($signature != $sign) return false;
return true;
}
}
\ No newline at end of file
......@@ -8,6 +8,10 @@ class CmsController extends BaseController
// 获取热门商品
public function getHotGoods()
{
$res = $this->checkApi(); // 接口校验
if ($res === false) return $this->jsonReturn(11001, '接口校验失败');
$datas = $this->apiBaseCache('pc_hot_goods', '', 5); // 热门商品
return $this->jsonReturn(0, '', $datas['data']);
......@@ -27,7 +31,7 @@ class CmsController extends BaseController
'err_msg' => $msg,
'data' => $extend,
);
if(isset($_GET['callback']) && !empty($_GET['callback'])){
echo $_GET['callback'].'('.json_encode($data).')';exit;
}else{
......
......@@ -105,7 +105,7 @@
--
{{# } }}
</span>
<div class="fl name ellipsis">{{item.company_name || '--'}}</div>
<div class="fl name ellipsis">{{item.company || ''}}</div>
</div>
</div>
{{# }); }}
......
......@@ -24,7 +24,7 @@
<span class="li_right icon iconfont">
</a>
<dl <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail') || (ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')">style="display:block"</if>>
<dd <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')">class="active"</if>><a href="/inquiry">我的询价</a></dd>
<dd <if condition="(ACTION_NAME eq 'inquiry') || (ACTION_NAME eq 'releaseinquiry') || (ACTION_NAME eq 'inquirydetail')">class="active"</if>><a href="homeicsales/inquiry">我的询价</a></dd>
<dd <if condition="(ACTION_NAME eq 'quote') || (ACTION_NAME eq 'quotedetail')">class="active"</if>><a href="homeicsales/quote">我的报价</a></dd>
</dl>
</li>
......
......@@ -181,11 +181,7 @@
/**
* 标记会员通知(已读)
*/
userMarkmsg: user_url + '/user/markmsg',
/***
* 热门搜索
*/
hotgoods:home_url+'/hotgoods'
userMarkmsg: user_url + '/user/markmsg'
};
if (typeof define === "function" && define.amd) {
return apis;
......
......@@ -4,19 +4,6 @@ $(function () {
this.bindFun();
this.getXbData(1);
this.getNewXj();
this.getHot();
},
getHot:function(){
IcController.getData(apis.hotgoods, 'GET', {},
function (res) {
if (res.errcode === 0) {
} else{
}
})
},
getXbData: function (type) { //1报价 2询价
var url;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment