1//url åæ°ä½¿ç¨ 2 3 4//追å å°ååæ°ï¼åæ°ä¸åå¨å追å ï¼åæ°åå¨åä¿®æ¹ï¼ 5/** 6 *åæ° _name:åæ°å _value:åæ°å¼ 7 @ps æ¤å½æ°é»è®¤ä½¿ç¨çurl模å¼ä¸ºæ®é模å¼ï¼å¨ä½¿ç¨thinkphpçæ¯æpathinfo urlå°å模å¼çæ¡æ¶æ¶ï¼è¯·å¡«åä¸ç¬¬ä¸ä¸ªåæ°'/' 8 @ps2 2014/5/26 å¢å æåç®å½çpathinfoå°åçæ¯æ(å¶ä½è±æçå¯ä»¥ä¼ç¨å°)ï¼ç¬¬åä¸ªåæ°ä¸ºåç®å½ï¼å¦ï¼"/en" 9 @ä¾å¦ js_aup('p','3','/','/en'); 10 */ 11function js_aup(_name, _value) { 12 var delimter = arguments[2] || '&'; 13 var subcatalog = arguments[3] || ''; 14 var just_return = arguments[4] || false; 15 var location_search = arguments[5] || location.search; 16 var newurl = ''; 17 if (delimter == '/') { //pathinfoæ¨¡å¼ 18 var query_string = location.pathname.replace(subcatalog, ''); 19 var arr = query_string.split('/'); 20 var paremters_obj = {}; 21 for (var i = 4; i < arr.length; i += 2) { 22 paremters_obj[arr[i]] = arr[i + 1]; 23 } 24 if (_value === null) { 25 delete (paremters_obj[_name]); 26 } else { 27 paremters_obj[_name] = _value; 28 } 29 for (var key in paremters_obj) { 30 newurl += key + '/' + paremters_obj[key] + '/'; 31 } 32 newurl = subcatalog + '/' + arr[1] + '/' + arr[2] + '/' + arr[3] + '/' + newurl.substr(0, newurl.length - 1); 33 } else { //æ®éæ¨¡å¼ 34 var paramters = location_search.getQuery(); 35 if (paramters == false) { 36 newurl = '?' + _name + '=' + _value; 37 } else { 38 if (_value === null) { 39 delete (paramters[_name]); 40 } else { 41 paramters[_name] = _value; 42 } 43 for (var key in paramters) { 44 newurl += key + '=' + paramters[key] + '&'; 45 } 46 newurl = '?' + newurl.substr(0, newurl.length - 1); 47 } 48 } 49 50 if (newurl == '?') { 51 newurl = document.url || location.href; 52 newurl = newurl.replace(location.search, ''); 53 } 54 55 if (just_return) { 56 return newurl; 57 } else { 58 location.href = newurl; 59 } 60} 61 62//å¤éç追å å°å忰彿° Create By TuJia @2014/10/27 63/** 64 *åæ° _name:åæ°å _value:åæ°å¼ 65 */ 66function js_aup2(_name, _value) { 67 var the_value = location.search.getQuery(_name) || '';//è·åå°ååæ° 68 var value_arr = the_value ? the_value.split(',') : [];//è½¬æ¢ææ°ç» 69 if (value_arr.find(_value) < 0) { //ä¸åå¨ï¼è¿½å 70 value_arr.push(_value); 71 the_value = value_arr.join(','); 72 } 73 js_aup(_name, the_value); 74} 75 76 77//交æ¢ç追å å°å忰彿° Create By TuJia @2014/10/27 78/** 79 *åè½ åå¨åå»é¤ï¼ä¸åå¨å°±æ·»å 80 *åæ° _name:åæ°å _value:åæ°å¼ 81 */ 82function js_aup3(_name, _value, just_return, location_search) { 83 var the_value = location.search.getQuery(_name) || '';//è·åå°ååæ° 84 if (the_value == '') return false; 85 if (the_value) _value = null; 86 87 if (just_return) { 88 return js_aup(_name, _value, '', '', true, location_search); 89 } else { 90 js_aup(_name, _value); 91 } 92} 93 94 95//åæ¶å¤éå°ååæ° Create By TuJia @2014/11/9 96/** 97 *åè½ js_aup2对åºç忶彿° 98 *åæ° _name:åæ°å _value:åæ°å¼ 99 */ 100function js_aup4(_name, _value) { 101 var the_value = location.search.getQuery(_name) || '';//è·åå°ååæ° 102 if (the_value == _value) {//åªå©ä¸å¯ä¸å¼ 103 js_aup3(_name, _value); 104 return false; 105 } 106 var value_arr = the_value ? the_value.split(',') : [];//è½¬æ¢ææ°ç» 107 var _index = value_arr.find(_value); 108 if (_index < 0) {//ä¸åå¨ï¼è¿½å 109 value_arr.push(_value); 110 } else { 111 value_arr.remove(_index); 112 } 113 the_value = value_arr.join(','); 114 js_aup(_name, the_value); 115} 116 117 118//追å å¤ä¸ªåæ° 119function js_aup5(param) { 120 var newurl = ''; 121 for (var i = 0, len = param.length; i < len; i++) { 122 newurl = js_aup(param[i]['_name'], param[i]['_value'], '&', '', true, newurl); 123 } 124 location.href = newurl; 125} 126 127 128//å é¤æä¸ªåæ°å追å 129function js_aup6(_name, _value, _cancel) { 130 var location_search = js_aup3(_cancel, '', true); 131 js_aup(_name, _value, '', '', '', location_search); 132} 133 134 135//å é¤å¤ä¸ªåæ° 136function js_aup7() { 137 var len = arguments.length; 138 var location_search = ''; 139 for (var i = 0; i < len; i++) { 140 if (location.search.getQuery(arguments[i]) == undefined) continue; 141 location_search = js_aup3(arguments[i], '', true, location_search); 142 } 143 location.href = location_search; 144} 145//å é¤å¤ä¸ªåæ° ä¸é®æ¸ 空ç鿡件 146function js_aup8(){ 147 var name,value; 148 var location_search = ''; 149 var str=location.href; //å徿´ä¸ªå°åæ 150 var num=str.indexOf("?") 151 str=str.substr(num+1); //å徿æåæ° stringvar.substr(start [, length ] 152 var arr=str.split("&"); //åä¸ªåæ°æ¾å°æ°ç»é 153 // console.log(arr);return false;
154 for(var i=0;i < arr.length;i++){ 155 num=arr[i].indexOf("="); 156 if(num>0){ 157 name=arr[i].substring(0,num); 158 value=arr[i].substr(num+1); 159 location_search = js_aup3(name,'',true,location_search); 160 // this[name]=value; 161 } 162 } 163 location.href = location_search; 164} 165//è·åå符串éçåæ° 166//ä¾å¦:var id = location.search.getQuery('id'); 167/** 168 *åæ° _name:åæ°åï¼éå¡«ï¼ä¸å¡«è¿åææåæ°) 169 */ 170String.prototype.getQuery = function () { 171 var url = this; 172 var offset = url.indexOf('?'); 173 if (offset == -1) return false; 174 offset += 1; 175 url = url.substr(offset); 176 var arr = url.split('&'); 177 var args = new Object(); 178 arr.forEach(function (_this) { 179 var arr2 = _this.split('='); 180 args[arr2[0]] = UrlDecode(arr2[1]); 181 }); 182 183 var _name = arguments[0] || null; 184 return _name ? args[_name] : args; 185} 186 187 188//å 餿°ç»å ç´ 189/** 190 *åæ° dx:æ°ç»ç´¢å¼ 191 */ 192Array.prototype.remove = function (dx) { 193 if (isNaN(dx) || dx > this.length) { 194 return false; 195 } 196 for (var i = 0, n = 0; i < this.length; i++) { 197 if (this[i] != this[dx]) { 198 this[n++] = this[i] 199 } 200 } 201 this.length -= 1 202} 203 204//æ°ç»æ¥æ¾å ç´ 205/** 206 *åæ° _value:æ°ç»ç´¢å¼ 207 */ 208Array.prototype.find = function (_value) { 209 for (var i = 0, len = this.length; i < len; i++) { 210 if (this[i] == _value) { 211 return i; 212 break; 213 } 214 } 215 return -1; 216} 217 218//jsçæ¬ urldecode 219function UrlDecode(zipStr) { 220 var uzipStr = ""; 221 for (var i = 0; i < zipStr.length; i++) { 222 var chr = zipStr.charAt(i); 223 if (chr == "+") { 224 uzipStr += " "; 225 } else if (chr == "%") { 226 var asc = zipStr.substring(i + 1, i + 3); 227 if (parseInt("0x" + asc) > 0x7f) { 228 uzipStr += decodeURI("%" + asc.toString() + zipStr.substring(i + 3, i + 9).toString()); 229 i += 8; 230 } else { 231 uzipStr += AsciiToString(parseInt("0x" + asc)); 232 i += 2; 233 } 234 } else { 235 uzipStr += chr; 236 } 237 } 238 239 return uzipStr; 240} 241 242function AsciiToString(asccode) { 243 return String.fromCharCode(asccode); 244} 245 246/** 247 * 忢è¯è¨ 248 * @param lang 249 * @param api_url 250 * @param jump_url 251 */ 252function changeLang(lang, api_url, jump_url) { 253 // å ¼å®¹IE 254 if(!lang) lang = ''; 255 if(!api_url) api_url = ''; 256 if(!jump_url) jump_url = ''; 257 258 $.ajax({ 259 url: api_url, 260 type: 'GET', 261 data: {lang:lang}, 262 dataType: 'json', 263 success: function (res) { 264 // console.log(res); 265 layer.msg(res.msg, {anim: 2, time: 1500}, function () { 266 if (res.code === 200) { 267 if (jump_url) { 268 window.location.href = jump_url; 269 return false; 270 } 271 window.location.reload(); 272 } 273 }); 274 275 } 276 }) 277} 278 279/** 280 * å å ¥è´ç©è½¦ 281 * @param int product_id ååID 282 * @param int product_num ä¸åååæ°é 283 * @param string api_url æ¥å£å°å 284 * @param string jump_url 跳转å°å 285 * @param int attr_num 屿§æ°é 286 * @param string attr_str 屿§å¼å符串 287 */ 288function addCart(product_id, product_num, api_url, jump_url, attr_num, attr_str) { 289 // å ¼å®¹IE 290 if(!product_id) product_id = 0; 291 if(!product_num) product_num = 0; 292 if(!api_url) api_url = ''; 293 if(!jump_url) jump_url = ''; 294 if(!attr_num) attr_num = 0; 295 if(!attr_str) attr_str = ''; 296 297 //屿§ 298 if(attr_num > 0){ 299 var select_attr_num = 0;//已鿩ç屿§æ°é 300 //è·åéæ©ç屿§ 301 $(".Colour .claxx .clem.on").each(function(i,e){ 302 attr_str += $(this).attr('data-id')+','; 303 select_attr_num ++; 304 }); 305 attr_str = (attr_str.substring(attr_str.length-1)==',')?attr_str.substring(0,attr_str.length-1):attr_str;//å»é¤å符串å³è¾¹éå· 306 // console.log(attr_str); 307 // console.log(select_attr_num); 308 if(attr_num != select_attr_num){ 309 layer.msg(lang_obj.select.product_attr, {anim: 2, time: 1500}); 310 return false;
311 } 312 } 313 314 var product_number = $('#product_number').val();//åååºå 315 if(parseInt(product_num) > parseInt(product_number)){ 316 //layer.msg(lang_obj.global.no_product_number, {anim: 2, time: 3000}); 317 //return false; 318 } 319 320 $.ajax({ 321 url: api_url, 322 type: 'POST', 323 data: {product_id:product_id, product_num:product_num, product_attr_value_id:attr_str}, 324 dataType: 'Json', 325 success: function(res){ 326 if (res.code === 200) { 327 layer.msg(res.msg, { 328 time: 5000, 329 anim: 1, 330 closeBtn: 0, 331 shade: [0.8, '#393D49'], 332 btn: [lang_obj.global.cart, lang_obj.global.look], 333 yes: function(){ 334 if (jump_url) { 335 window.location.href = jump_url; 336 return; 337 } 338 window.location.reload() 339 } 340 }); 341 } else { 342 layer.msg(res.msg, {anim: 2, time: 1500}) 343 } 344 } 345 }) 346} 347 348/** 349 * ç«å³è´ä¹° 350 * @param int product_id ååID 351 * @param string jump_url 跳转å°å 352 * @param int attr_num 屿§æ°é 353 * @param string attr_str 屿§å¼å符串 354 */ 355function buyNow(product_id, jump_url, attr_num, attr_str) { 356 // å ¼å®¹IE 357 if(!product_id) product_id = 0; 358 if(!jump_url) jump_url = ''; 359 if(!attr_num) attr_num = 0; 360 if(!attr_str) attr_str = ''; 361 362 //屿§ 363 if(attr_num > 0){ 364 var select_attr_num = 0;//已鿩ç屿§æ°é 365 //è·åéæ©ç屿§ 366 $(".Colour .claxx .clem.on").each(function(i,e){ 367 attr_str += $(this).attr('data-id')+','; 368 select_attr_num ++; 369 }); 370 attr_str = (attr_str.substring(attr_str.length-1)==',')?attr_str.substring(0,attr_str.length-1):attr_str;//å»é¤å符串å³è¾¹éå· 371 if(attr_num != select_attr_num){ 372 layer.msg(lang_obj.select.product_attr, {anim: 2, time: 1500}); 373 return false; 374 } 375 } 376 377 window.location.href = jump_url + '?product_id='+product_id+'&product_num=1&buy_type=2&product_attr_value_id='+attr_str; 378 return; 379} 380 381 382/** 383 * å å ¥æ¶è 384 */ 385function addFavorite(product_id, api_url){ 386 // å ¼å®¹IE 387 if(!product_id) product_id = 0; 388 if(!api_url) api_url = ''; 389 390 if (product_id == 0) { 391 layer.msg(lang_obj.select.product, {anim: 2, time: 1500}); 392 return false; 393 } 394 395 $.ajax({ 396 url: api_url, 397 type: 'POST', 398 data: {object_id:product_id}, 399 dataType: 'Json', 400 success: function(res){ 401 if (res.code === 200) { 402 layer.msg(lang_obj.success.collection, {anim: 2, time: 1500}) 403 } 404 } 405 }) 406} 407 408/** 409 * 忢æ±ç 410 */ 411function exchangeRate(that, api_url){ 412 // å ¼å®¹IE 413 if(!api_url) api_url = ''; 414 415 var _value = $(that).val(); 416 $.ajax({ 417 url: api_url, 418 type: 'POST', 419 data: {id:_value}, 420 dataType: 'Json', 421 success: function(res){ 422 if (res.code === 200) { 423 window.location.reload(); 424 } 425 } 426 }) 427} 428 429/** 430 * åæ¶è®¢å 431 */ 432/*function orderCancel(id, api_url = ''){ 433 layer.msg(lang_obj.global.is_cancel, { 434 time: 5000, 435 btn: [lang_obj.global.confirm,lang_obj.global.cancel], 436 closeBtn: 0, 437 anim: 1, 438 yes: () => { 439 $.ajax({ 440 url: api_url, 441 type: 'POST', 442 data: {id:id}, 443 dataType: 'Json', 444 success: (res) => { 445 layer.closeAll(); 446 if (res.code === 200) { 447 window.location.reload(); 448 } 449 } 450 }) 451 } 452 }); 453}*/ 454 455/** 456 * åæ¶è®¢åã确认æ¶è´§ãå é¤è®¢å 457 * id 订åID 458 * api_url APIå°å 459 * msg_name æç¤ºæå 460 */ 461function orderAction(id, api_url, msg_name){ 462 // å ¼å®¹IE 463 if(!api_url) api_url = ''; 464 if(!msg_name) msg_name = 'confirm'; 465 466 layer.msg(lang_obj.global[msg_name], { 467 time: 5000, 468 btn: [lang_obj.global.confirm,lang_obj.global.cancel], 469 closeBtn: 0, 470 anim: 1, 471 yes: function(){ 472 $.ajax({ 473 url: api_url, 474 type: 'POST', 475 data: {id:id}, 476 dataType: 'Json', 477 success: function(res){ 478 layer.closeAll(); 479 if (res.code === 200) { 480 window.location.reload(); 481 } 482 } 483 }) 484 } 485 }); 486} 487 488//éªè¯é®ç®±æ ¼å¼ 489function checkEmail(email){ 490 if(email.length == 0){ 491 layer.msg(lang_obj.global.enter_email); 492 return false;
493 } 494 var email_reg = /^([A-Za-z0-9\-\_\.])+@[A-Za-z0-9\-\_\.]+\.([a-zA-Z]{2,4})$/; 495 if (!email_reg.test(email)) { 496 layer.msg(lang_obj.format.email); 497 return false; 498 } 499 return true; 500} 501 502/** 503 * è·åé®ç®±éªè¯ç 504 * @param send_type åé®ç®±ç±»å 1 ç¨æ·æ³¨å/ä¿®æ¹é®ç®± 2æ¾åå¯ç 3ç»å®ç¬¬ä¸æ¹è´¦å· 505 * @param sendButton 506 * @param webUrl 请æ±è®¿é®å°å 507 * @returns {boolean} 508 */ 509function getEmailCode(send_type,sendButton,webUrl){ 510 var email = $("#email").val(); 511 if(!checkEmail(email)){ 512 return false; 513 } 514 var captcha = ''; 515 if(send_type==2 || send_type==3){ 516 //夿éªè¯ç 517 captcha = $("#captcha").val(); 518 if(email.captcha == 0){ 519 layer.msg(lang_obj.global.enter_code); 520 return false; 521 } 522 } 523 $.ajax({ 524 url: webUrl, 525 type: 'POST', 526 data: {send_type:send_type,email:email,captcha:captcha}, 527 dataType: 'json', 528 success: function (res) { 529 if(res.code == 200){ 530 countDown(sendButton); 531 }else{ 532 if(send_type==2 || send_type==3) { 533 $('#captcha').val('').focus(); 534 changCaptcha(); 535 } 536 } 537 layer.msg(res.msg,{time:1500},function() { 538 if (res.code === 200) { 539 540 // window.location.href = '/home/user/security'; 541 } 542 }); 543 } 544 }) 545 return false; 546} 547 548//å çä¿¡/é®ç®± åè®¡æ¶ 549var wait = 60; 550function countDown(obj,msg){ 551 obj = $(obj); 552 if(wait == 0){ 553 obj.removeAttr("disabled"); 554 obj.removeClass("gray"); 555 obj.val(lang_obj.global.get_code); 556 wait = 60; 557 }else{ 558 if(msg == undefined || msg == null){ 559 msg = obj.val(); 560 } 561 obj.attr("disabled","disabled"); 562 obj.addClass("gray"); 563 obj.val(wait + ' ' + lang_obj.global.second); 564 wait--; 565 setTimeout(function(){ 566 countDown(obj,msg) 567 },1000) 568 } 569} 570 571//éªè¯é®ç®±æ ¼å¼20220329 572function verifyEmail(email){ 573 var email_reg =/^([A-Za-z0-9\-\_\.])+@[A-Za-z0-9\-\_\.]+\.([a-zA-Z]{2,4})$/; 574 if (!email_reg.test(email)) { 575 return false; 576 } 577 return true; 578} 579 580
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.