PageSourceSearch

https://haiermedical-usa.com/public/home/1000000/js/public.js?v=1791120485

js haiermedical-usa.com collected 2026-10-04 13:28:19 UTC 16,409 bytes, 580 lines download raw bytes

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.