Commit 5aa54a93 by 施宇

3213

parent e0eaf2e3
......@@ -55,15 +55,9 @@
</div>
</div>
<div class="search_command clr">
<span class="fl comman_title">热门搜索:</span>
<div class="fl command_name">
<volist name="hot_goods" id="vo">
<a class="fl" href="{$vo.url}" title="{$vo.title}" target="_blank">{$vo.title}</a>
</volist>
</div>
</div>
</div>
<div class="my_xj">
<div class="my_xj_title xj_title">
<span class="lineBlock"></span>
......@@ -88,6 +82,16 @@
</div>
<include file="public/foot" />
<script src="__PUBLIC__/js/home/index.js"></script>
<script type="text/html" id="hotTpl">
{{# if(d.length != 0){ }}
<span class="fl comman_title">热门搜索:</span>
<div class="fl command_name">
{{# layui.each(d, function(index, item){ }}
<div class="fl hot_item" title="{{item.title}}">{{item.title}}</div>
{{# }); }}
</div>
{{# } }}
</script>
<script type="text/html" id="xjTpl">
<!-- 询价模板 -->
<div class="my_xj_list clr">
......
......@@ -110,14 +110,14 @@
color: #8A9299;
width: 625px;
}
.home_content .search_section .search_command .command_name a {
.home_content .search_section .search_command .command_name div {
margin-left: 20px;
cursor: pointer;
transition: all 0.2s ease-in-out;
display: block;
}
.home_content .search_section .search_command .command_name a.active,
.home_content .search_section .search_command .command_name a:hover {
.home_content .search_section .search_command .command_name div div.active,
.home_content .search_section .search_command .command_name div:hover {
color: #0D84D1;
}
.home_content .xj_title {
......@@ -257,4 +257,3 @@
.home_content .new_xj .new_xj_list .new_xj_item:hover {
box-shadow: 0px 5px 10px 0px rgba(216, 223, 230, 0.5);
}
/*# sourceMappingURL=home.css.map */
\ No newline at end of file
......@@ -136,13 +136,12 @@
color: #8A9299;
width: 625px;
a {
div {
margin-left: 20px;
cursor: pointer;
transition: all 0.2s ease-in-out;
display: block;
&.active ,&:hover{
div.active ,&:hover{
color: #0D84D1;
}
}
......
......@@ -61,6 +61,10 @@
* 获取会员认证信息
*/
authInfo: user_url + '/user/authinfo',
/****
* 获取热门搜索商品
*/
hotgoods: home_url + '/hotgoods',
/***
* 上传文件的接口
*/
......
!function () {
! function () {
window.IcController = {
init: function () {
this.created(this).mounted(this).handleBind(this);
......@@ -82,7 +82,9 @@
if ($('#head_pic').length > 0) {
//获取用户信息
this.getData(apis.userInfo, 'GET', {token: Util.getCookie('token') || ''}, function (res) {
this.getData(apis.userInfo, 'GET', {
token: Util.getCookie('token') || ''
}, function (res) {
if (res.errcode === 0) {
......@@ -114,13 +116,15 @@
//首页统计
if ($(".price_info").length > 0) {
IcController.getData(apis.countBusiness, 'GET', {token: Util.getCookie('token') || ''}, function (res) {
IcController.getData(apis.countBusiness, 'GET', {
token: Util.getCookie('token') || ''
}, function (res) {
$(".price_info").find('.xj').children('.xj_num').text(res.data.inquiry); //我的询价
$(".price_info").find('.hf').children('.hf_num').text(res.data.offer); //我的回复
$(".price_info").find('.sp').children('.sp_num').text(res.data.goods);//我的商品
$(".price_info").find('.sp').children('.sp_num').text(res.data.goods); //我的商品
});
......@@ -170,11 +174,11 @@
$('.xbj_li').find('.li_right').removeClass('iconjuxing15').addClass('iconjuxing12');
}
});
$('#nav_logo').on('click',function(){
$('#nav_logo').on('click', function () {
var token = Util.getCookie('token') || "";
if(token){
if (token) {
window.location.href = '/homes';
}else{
} else {
window.location.href = index_url;
}
})
......@@ -406,6 +410,98 @@
}
return m;
},
randomStr: function () { //随机生成八位字符串
var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var newStr = "";
for (var i = 0; i < 8; i++) {
var randomNum = parseInt(Math.random() * ((str.length - 1) + 1), 10);
newStr += str.substr(randomNum, 1)
}
return newStr
},
dataEncryption: function () { //数据加密
var timestamp = Date.parse(new Date()) / 1000;
var randomStr = this.randomStr();
var token = 'zbPx8gDXDfIh3ZoJcO4EH';
var arr = [timestamp, randomStr, token];
var singnatrueStr = this.sha1(this.sort(arr).join('')).toUpperCase();
return {
randomStr: randomStr,
singnatrueStr: singnatrueStr,
timestampStr:timestamp
}
},
sort: function (arr) { //数组排序
for (var j = 0; j < arr.length; j++) {
for (var i = 0; i < arr.length - 1 - j; i++) {
if (arr[i] > arr[i + 1]) {
[arr[i], arr[i + 1]] = [arr[i + 1], arr[i]]
}
}
}
return arr;
},
encodeUTF8: function (s) { //sha1的方法
var i, r = [],
c, x;
for (i = 0; i < s.length; i++)
if ((c = s.charCodeAt(i)) < 0x80) r.push(c);
else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F));
else {
if ((x = c ^ 0xD800) >> 10 == 0) //对四字节UTF-16转换为Unicode
c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000,
r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F));
else r.push(0xE0 + (c >> 12 & 0xF));
r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
};
return r;
},
sha1: function (s) { //sha1的方法
var data = new Uint8Array(this.encodeUTF8(s))
var i, j, t;
var l = ((data.length + 8) >>> 6 << 4) + 16,
s = new Uint8Array(l << 2);
s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer);
for (t = new DataView(s.buffer), i = 0; i < l; i++) s[i] = t.getUint32(i << 2);
s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
s[l - 1] = data.length << 3;
var w = [],
f = [
function () {
return m[1] & m[2] | ~m[1] & m[3];
},
function () {
return m[1] ^ m[2] ^ m[3];
},
function () {
return m[1] & m[2] | m[1] & m[3] | m[2] & m[3];
},
function () {
return m[1] ^ m[2] ^ m[3];
}
],
rol = function (n, c) {
return n << c | n >>> (32 - c);
},
k = [1518500249, 1859775393, -1894007588, -899497514],
m = [1732584193, -271733879, null, null, -1009589776];
m[2] = ~m[0], m[3] = ~m[1];
for (i = 0; i < s.length; i += 16) {
var o = m.slice(0);
for (j = 0; j < 80; j++)
w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1),
t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0,
m[1] = rol(m[1], 30), m.pop(), m.unshift(t);
for (j = 0; j < 5; j++) m[j] = m[j] + o[j] | 0;
};
t = new DataView(new Uint32Array(m).buffer);
for (var i = 0; i < 5; i++) m[i] = t.getUint32(i << 2);
var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
return (e < 16 ? "0" : "") + e.toString(16);
}).join("");
return hex;
}
};
if (typeof define === "function" && define.amd) {
......
......@@ -4,6 +4,35 @@ $(function () {
this.bindFun();
this.getXbData(1);
this.getNewXj();
this.getHotGoods()
},
getHotGoods: function () {
var obj = Util.dataEncryption();
IcController.getData(apis.hotgoods, 'GET', {
timestamp: obj.timestampStr,
random: obj.randomStr,
signature: obj.singnatrueStr
},
function (res) {
var hotHtml = hotTpl.innerHTML;
if (res.err_code === 0) {
if (res.data.length) {
layui.laytpl(hotHtml).render(res.data, function (html) {
$(".search_command").empty().html(html);
});
} else {
layui.laytpl(hotHtml).render([], function (html) {
$(".search_command").empty().html(html);
});
}
} else {
layui.laytpl(hotHtml).render([], function (html) {
$(".search_command").empty().html(html);
});
}
})
},
getXbData: function (type) { //1报价 2询价
var url;
......@@ -78,7 +107,7 @@ $(function () {
} else if (val.length < 3) {
layer.msg('请至少输入3个字符')
} else {
window.location.href = "/search?key=" + val+'&type=1&time=1';
window.location.href = "/search?key=" + val + '&type=1&time=1';
}
});
......@@ -97,7 +126,13 @@ $(function () {
var userid = $(this).attr('userid'),
offerid = $(this).attr('offerid')
window.location.href = "/quotedetail?id=" + userid + '&offerid=' + offerid
})
});
$('.search_command').on('click', '.hot_item', function () {
var title = $(this).attr('title');
window.location.href = "/search?key=" + title + '&type=1&time=1';
});
}
};
homeObj.init()
......
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