本文主要是介绍/search/index.php,mobile/index.php · 在你们人类愚蠢世界里流浪的逗比/bxup - Gitee.com,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
require_once 'dbconnect_utf.php';
?>
泉迈优惠折扣商城include ("header.html");
?>
function getCat()
{
$category = array();
$sql = "SELECT * FROM blog_category where pid=0 ORDER BY listorder, cid ASC";
$query = mysql_query($sql);
while ($rs = mysql_fetch_array($query))
{
$sql2=sprintf("select * from blog_category where pid=%d",$rs['cid']);
$query2 = mysql_query($sql2);
$tempRes = array();
//linwei
$category[$rs['cat_name']]['icon_url'] = $rs['icon_url'];
$category[$rs['cat_name']]['list'] = array();
while($rs2 = mysql_fetch_array($query2)){
$category[$rs['cat_name']]['list'][] = $rs2;
}
}
return $category;
}
// function getChild($pid){
// if(empty($cats[pid])){
//
// }
// foreach($cats as $c){
// $str.=''.$c['cat_name'].'';
// if(){
// $
// return $str;
// }
//
//
// }
// }
$cats=getCat();
// var_dump($cats);
// print_r($cats);
$i=1;
foreach($cats as $k=>$c){
if($i%2){
?>
}else{
?>
}
$i++;
}
// $sql="select * from blog_category where display=1 order by listorder asc limit 10";
// $q=mysql_query($sql);
// while($row=mysql_fetch_array($q)){
// echo ''.$row['cat_name'].'';
// }
?>
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write("
//搜索自动提示
sechSgst();
function check(){
//保存搜索关键字
saveSearchHistory();
var keyword=document.getElementById("keywordfoot").value;
keyword = keyword.replace(/\s/gi,"");
if(keyword==""){
// alert("搜索关键字不能为空");
return false;
}
url = "search.php?keyword="+keyword;
document.location = url;
}
//埋点统计公共方法
function commonStatistics(formName,typekey,typevalue,locationUrl){
addTrackPositionToCookie(typekey,typevalue);
if(locationUrl != null && locationUrl != ''){
window.location = locationUrl;
}else{
gotracker(typekey,typevalue,null);
}
}
//在与用户相关的链接后面加随机数
var myDate = new Date();
var now=myDate.getTime();
//我的购物车
var obj=document.getElementById("mycart");
if(obj!=null){
var href="/mw/cart?et="+now+"&er="+getRandomString(10);
obj.setAttribute('href', href);
}
//我的1号店
obj=document.getElementById("mystore");
if(obj!=null){
var href="/mw/mycenter?et="+now+"&er="+getRandomString(10);
obj.setAttribute('href', href);
}
//面包屑我的1号店
obj=document.getElementById("crumbsmystore");
if(obj!=null){
var href="/mw/mycenter?et="+now+"&er="+getRandomString(10);
obj.setAttribute('href', href);
}
//切换省份
obj=document.getElementById("changeprovince");
if(obj!=null){
var href="javascript:commonStatistics('','1','position','/mw/provice?et="+now+"&er="+getRandomString(10)+"')";
obj.setAttribute('href', href);
}
//1号商城订单
obj=document.getElementById("mallorder");
if(obj!=null){
var href=document.getElementById("mallorder").getAttribute("href")+"&et="+now+"&er="+getRandomString(10);
obj.setAttribute('href', href);
}
var wuserId = null;
userinfo();
function userinfo(){
var myDate = new Date();
var now=myDate.getTime();
$.ajax({
type: "POST",
url: "/mw/indexinfo?et="+now+"&er="+getRandomString(10),
data: "",
dataType : "",
success: function(backdata) {
var data = backdata;
var data = backdata.split("∑");
if(data[0]!=null&&data[0]!=''){
$("#qj").append(data[0]);
$("#qj").show();
}
$("#bquantity").append(data[1]);
$("#cprovincename").append(data[2]);
if(data[0] !=""){
$("#searchBtn").click();
}
//data[4]:token data[5]:sharetokenflag
if(data[4]== null || data[4]== "null" ){
data[4] ="";
}
if(data[5]== null || data[5]== "null" ){
data[5] ="";
}
if(data[4] !="" &&$('#logstatus').hasClass('noLog')){ //区分用户登录状态,登录后在我的1号店图标上加勾
$('#logstatus').removeClass('noLog');
}
}
});
}
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)){
return (arr[2]);
}
else{
return "";
}
}
function success_jsonpCallback(param){
//alert(param);
}
//清除yhdcomefromwebsite这个cookie
function backwap(url)
{
delCookie("yhdcomefromwebsite");
window.location.href =url+"?websiteflag=true";
}
function delCookie(name){//为了删除指定名称的cookie,可以将其过期时间设定为一个过去的时间
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=a; expires=" + date.toGMTString();
}
//保存用户搜索历史记录
function saveSearchHistory(){
var keyword=document.getElementById("keywordfoot").value.toString();
//将用户的搜索关键词保存到local storage中 ,不支持则保存到cookie中 ,最多保留20个 ,去重,且过滤掉空字符串
var shistory="";
var arrhistory="";
if(window.localStorage){
if(window.localStorage.getItem("historykeyword")!=null){
shistory = window.localStorage.getItem("historykeyword");
arrhistory = window.localStorage.getItem("historykeyword").split("|");
}
}else{
if(getCookie("historykeyword")!=null){
shistory = getCookie("historykeyword");
arrhistory = getCookie("historykeyword").split("|");
}
}
var isdiff = 0;
if(arrhistory!=""&&arrhistory.length>0){
$.each(arrhistory,function(index,item){
if(keyword==item){
isdiff = 1;
}
});
}
keyword=keyword.replace(/(^\s*)|(\s*$)/g, "");
if(keyword==""){ //搜索历史过滤空字符串
isdiff = 1;
}
if(isdiff==0){
if(arrhistory!=""&&arrhistory.length==20){
arrhistory.splice(0,1);
shistory = arrhistory.join("|");
shistory+="|"+keyword;
}else{
if(arrhistory.length<1){
shistory+=keyword;
}else{
shistory+="|"+keyword;
}
}
if(window.localStorage){
window.localStorage.setItem("historykeyword",shistory);
}else{
setCookie("historykeyword",shistory);
}
}
}
//type=1时,根据linktype拼链接广告的链接
function getlinkurl(linktype,linkid,title){
var href="";
linktype =parseInt(linktype);
switch(linktype){
case 1: //首页
href="/mw/index/"+1;
break;
case 2: //日历购首页
href="/mw/dailybuy"+linkid;
break;
case 3: //日历购详情页
href="/mw/dailyproduct/"+linkid+"/"+1;
break;
case 4: //品牌旗舰页(品牌店铺)
href="/mw/getBrand/1/"+linkid;
break;
case 5: //无栏目产品列表页 (包括普通列表,普通促销,普通团购,普通抵购卷,N元N件,满赠)
break;
case 6: //多栏目活动页面 (cms页)
href="/mw/oldcms/"+linkid;
break;
case 7: //cms活动广告聚合页
href="/mw/optionallist/"+linkid+"/"+1;
break;
case 8: //每日N款(N=1,2,..)(日历购详情页)
break;
case 9: //抵用券活动页
href="/mw/freecoupon/"+linkid;
break;
case 10: //团购产品列表页
href="/mw/grouplist/1/1/-1";
break;
case 11: //普通促销(landingpage)商品
break;
case 12: //品牌店铺页
href="/mw/getStore/1/"+linkid;
break;
case 13: //n元n件集合页
href="/mw/optionallist/"+linkid+"/1";
break;
case 14: //新cms
href="/mw/newcms/"+linkid;
break;
}
if(linktype==7||linktype==13){
href+="?promotiontitle="+title;
}
//linwei
href="";
return href;
}
function gettypeurl(type,linktype,linkid,title,promotionid,promotionlevel,statisticstype){
//调用统计
//commonStatistics('','1',statisticstype,'');
var href="";
switch(type){
case 1:
//href=getlinkurl(linktype,linkid,title);
href="";
break;
case 2:
href="javascript:searchkey('"+title+"',1,'search')";
break;
case 4: //商城店铺
href=linkid;
break;
case 5: //1号团
href="/mw/grouplist/1/1/-1";
break;
case 9: // 抵购卷列表活动 (通过后台读取的抵购卷数据,使用新接口)
href="/mw/freecoupon/"+linkid;
break;
case 10: // 积分兑换活动 (通过promptionid从pc后台读取的商品数据,使用新接口)
href="/mw/newcms/"+linkid;
break;
case 11: // 秒杀活动(通过promotionid从PC后台读取的商品数据,秒杀特殊流程,使用新接口)
href="/mw/newcms/"+linkid;
break;
case 12: //满赠
href="/mw/promotionprolist/"+promotionid+"/"+promotionlevel+"/1/1?promotiontitle="+title;
break;
case 13: //满减
href="/mw/promotionprolist/"+promotionid+"/"+promotionlevel+"/1/1?promotiontitle="+title;
break;
case 14: //满折
href="/mw/promotionprolist/"+promotionid+"/"+promotionlevel+"/1/1?promotiontitle="+title;
break;
case 16:
href="/mw/optionalprolist/"+promotionid+"/"+promotionlevel+"/1";
break;
case 18: //外链
href=linkid;
break;
}
//linwei
href="";
window.location.href=href;
}
function searchkey(keyword,cid) {
//调用统计
//commonStatistics('','1',statisticstype,'');
//window.location.href ="/mw/search?searchid=4&serchtype=1&keyword="+keyword;
window.location.href ="search.php?searchid="+cid+"&keyword="+keyword;
}
function checkInput(){
var keyword=document.getElementById("keyword").value;
keyword = keyword.replace(/\s/gi,"");
if(keyword==""){
// alert("搜索关键字不能为空");
return false;
}
//saveSearchHistory();
return SafeStirng(keyword);
}
getotherinfo();
function getotherinfo(){
var now = new Date()+getRandomString(32);
$.ajax({
type: "POST",
url: "/mw/geoareainfo?tt="+now,
data: "",
dataType : "",
success: function(backdata1) {
var data1 = backdata1.split("∑");
if(data1[2]== null || data1[2]== "null" || data1[2]== "" ){
data1[2] ="1";
}
if(data1[0] !='true' && data1[1] !='true'){
if (navigator.geolocation) {
//alert( ' 你的浏览器支持 geolocation ' );
var watchInterval = navigator.geolocation.getCurrentPosition(getPositionSuccess,getPositionError,{timeout:15000});
}else{
//alert( ' 你的浏览器不支持 geolocation ' );
}
}
}
});
}
function getPositionSuccess( position ){
var lat = position.coords.latitude;
var lng = position.coords.longitude;
// alert( "您所在的位置: 经度" + lat + ",纬度" + lng );
$.ajax({
type: "POST",
url: "/mw/getproidbygeo/"+lat+"/"+lng+"",
data: "",
dataType : "",
success: function(backdata) {
if(backdata!="上海,1,1"){
var back = backdata.split(",");
var data=back[0];
var answer=confirm("定位到你当前在"+data+",需要更换收货省份吗?");
var currentprovinceId = back[1];
if(answer==true){
window.location.href ="/mw/index/"+currentprovinceId+"/"+lat+"/"+lng;
}
}
}
});
}
var token = '';
if((token==null||token=="")&&window.localStorage!=null){
try{
window.localStorage.removeItem("cart_choosed_item");
}catch(e){}
}
function getPositionError(error){ }
$(function(){
(function(){
var index = 0;
var elem = $('.header_ads');
var ads_data = elem.attr('jsdata');
if(!ads_data){$('.header_ads img').hide();return;}
var ads_obj = JSON.parse(ads_data);
if(!ads_obj){
$('.header_ads img').hide();
$('.header_ads .index_box').hide();
return;
}
elem.attr('index',index);
elem.css('background-image','url(' + ads_obj[index].src + ')');
if(ads_obj.length <= 1){return;}
$('.header_ads .index').width(1/ads_obj.length * 100 + '%');
var moving = false;
var scrolling = false;
var _next;
var play_next = function(dir){
if(dir === undefined){return;}
var _target = elem.width() * (-dir);
//index++;
if(index+dir < 0){
_next = ads_obj.length -1;
}else if(index + dir >= ads_obj.length){
_next = 0;
}else{
_next = index + dir;
}
elem.css({'background-image':'url('+ads_obj[index].src+'),url('+ads_obj[_next].src+')','background-position':'0 0,'+ (-_target)+'px 0'});
scrolling = true;
sin(0,_target,500,function(_mid){
elem.css('background-position',_mid + 'px 0,'+ (-_target+_mid) +'px 0');
},function(){
scrolling = false;
elem.css({'background-image':'url('+ads_obj[_next].src+')','background-position':'0 0'});
index = _next;
$('.header_ads .index').css('left',index/ads_obj.length * 100 + '%');
});
}
var outTimer;
var auto_paly = function(){
if(!!outTimer){clearTimeout(outTimer);}
outTimer = setTimeout(function(){
play_next(1);
auto_paly();
},3000);
}
auto_paly();
iTouch({
element : document.querySelector('.header_ads'),
click : function(e){
window.location.href="javascript:gettypeurl("+ads_obj[index].link+")";
},
move : function(e,dir,disX,disY,x,y){
if(moving){return false;}
if(scrolling){return false;}
if(dir == 'lr' && Math.abs(disX) > 50){
play_next(-1);
}else if(dir == 'rl' && Math.abs(disX) > 50){
play_next(1);
}else{
return false;
}
moving = true;
auto_paly(1);
},
end : function(){
moving = false;
},
prevent : 'x'
});
})();
var nextFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) { return setTimeout(callback, 1); };
})();
var cancelFrame = (function () {
return window.cancelRequestAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout;
})();
var PI = Math.PI;
var timer;
function sin(start,end,time,callback,finish){
var _start = new Date().getTime();
var _end = _start + time;
function step() {
var _now = new Date().getTime();
var _mid = Math.sin((_now-_start)/(_end - _start) * PI / 2) * (end - start) + start;
callback && callback.apply(null,[_mid]);
if (_now > _end ){
cancelFrame(timer);
timer = null;
finish && finish.apply(null);
}else{
timer = nextFrame(step);
}
}
if(!!timer){
cancelFrame(timer);
timer = null;
}
timer = nextFrame(step);
}
});
一键复制
编辑
Web IDE
原始数据
按行查看
历史
这篇关于/search/index.php,mobile/index.php · 在你们人类愚蠢世界里流浪的逗比/bxup - Gitee.com的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!