script.html
951 字节
<script>
// 获取用户登陆,右上角内容、购物车数量显示变化
$.post("{:U('User/Index/is_login')}",{},function(data){
console.log(data);
if(data.status==1){
$(".toplinks .nickname").text(data.user.nickname!=""?data.user.nickname:data.user.mobile+',欢迎您');
$(".toplinks ul.login").show();
if(data.cart_count) {
$('.badge').text(data.cart_count);
} else {
$('.badge').hide();
}
}
if(data.status==0){
$('.badge').hide();
$(".toplinks ul.offline").show();
}
});
// 搜索功能查询
$('.h-button').click(function(){
var keyword = $('input[name=keyword]').val();
if(!keyword) {
alert('请输入查询内容');
} else {
location.href = "{:U('Portal/Goods/search')}"+'/keyword/'+keyword;
}
});
</script>