PageSourceSearch

http://www.chruotech.com/content/plugins/goodsmanage/utils.js

js chruotech.com collected 2026-09-30 11:35:07 UTC 67,629 bytes, 1,516 lines download raw bytes

1/// <reference path="../../js/lng.js" />
2//var ShopCartCfg = {};
3//var GoodsConfig = {};
4//var ShowShopConfig = {};
5function AddProductToFavorites(pd_id) {
6    Web960.Web.index.AddToFavs("" + pd_id, function (ret) {
7        AjaxReturn(ret, function () {
8            var rc = ret.value;
9
10            if (rc.Status == -2) {
11                ShowLoginDialog({
12                    loginedcallback: function () {
13                        CloseLoginDialog();
14                        AddProductToFavorites(pd_id);
15                    }
16                });
17            }
18            else {
19                alert(rc.ClientMsg);
20            }
21        });
22    });
23}
24function DelProductOfFavorites(fav_id) {
25    Web960.Web.index.DelFavs("" + fav_id, function (ret) {
26        AjaxReturn(ret, function () {
27            var rc = ret.value;
28            if (rc.Status == -2) {
29                ShowLoginDialog({
30                    loginedcallback: function () {
31                        CloseLoginDialog();
32                        DelProductOfFavorites(fav_id);
33                    }
34                });
35            }
36            else {
37                alert(rc.ClientMsg);
38                location.reload();
39            }
40        });
41    });
42}
43function LoadGoodsForProducts()
44{
45    LoadShopCart(false);
46   
47    $("input[name='productitem']").each(function () {
48        var pid = $(this).val();
49        GoLoadGoods(pid, "#goodslist_" + pid);
50    });
51}
52
53///加载购物车显示
54function LoadShopCart(autoLoad)
55{
56   
57        CheckUserLogin(function (logined, url, uname) {
58            if (logined == -1) {
59                if (GoodsGlobalSettings.orderrequiredreg == undefined || GoodsGlobalSettings.orderrequiredreg == "1") {
60
61                    //未登录
62                    if (autoLoad) {
63                        ShowLoginDialog({
64                            loginedcallback: function () {
65                                CloseLoginDialog();
66                                ShowShopCartWithData();
67                            }
68                        });
69                    }
70                    else {
71                        ShowShopCart();
72                    }
73                }
74                else {
75                    ShowShopCartWithData();
76                }
77            }
78            else {
79                ShowShopCartWithData();
80            }
81        });
82
83}
84function ShowShopCartWithData()
85{
86    Web960.Web.index.LoadShopCart( function (ret) {
87        AjaxReturn(ret, function () {
88            var rc = ret.value;
89            if (rc.Status == 1) {
90                ShowShopCart();
91                FillShopCart(rc.ObjResult);
92            } else if(rc.Status==-2) {
93                ShowLoginDialog({
94                    loginedcallback: function () {
95                        CloseLoginDialog();
96                        ShowShopCartWithData();
97                    }
98                });
99            }
100        });
101    });
102}
103function FillShopCart(o)
104{
105    LoadedCart = true;
106    $("#shopcartitemcount").html(o.length);
107    var opt = "";
108
109    if (o.length > 0) {
110        if (ShowShopConfig != undefined && ShowShopConfig.fillshopcart) {
111            opt = ShowShopConfig.fillshopcart(o);
112        }
113        else {
114            opt = '<table class="shopcartitemtable" border="0" cellspacing="0" cellpadding="5"  width="100%">'
115                + '<tr class="shopcartitemtableheader">'
116                + '<td class="itemno">' + rclng.plugin_goodsmanage_itemno + '</td>'
117                + '<td class="price">' + rclng.plugin_goodsmanage_price + '</td>'
118                + '<td class="subtotal">' + rclng.plugin_goodsmanage_subtotal + '</td>'
119                + '<td class="quantity">' + rclng.plugin_goodsmanage_quantity + '</td>'
120                + '<td>&nbsp;</td>'
121                + ' </tr>';
122            for (var i = 0; i < o.length; i++) {
123                var oldprice = o[i].Price;
124                var price = parseFloat(GetRealPriceByPreferent(o[i].Goods, o[i].Inventory.PreferentType, o[i].Inventory.PreferentInfo, o[i].Inventory.MoneyUnit, o[i].Inventory.Price));
125                var itemno = o[i].GoodsNo;
126                //CustomGoods_no
127                if (GoodsConfig != undefined && GoodsConfig.GoodsNoKey != undefined) {
128                    itemno = o[i][GoodsConfig.GoodsNoKey];
129                }
130                opt += '<tr><td class="itemno">' + itemno + '</td>'
131                    + '<td class="price">' + GetSimpMoneyUnit(o[i].MoneyUnit) + '<span id="OitemPrice_' + o[i].CartId + '" style="display:none;">' + o[i].Price + '</span>'
132                    + price.toFixed(2) + ' /<span id="OitemUnit_' + o[i].CartId + '">' + o[i].Unit + '</span></td>'
133                    + ' <td id="OitemSum_' + o[i].CartId + '" class="OitemSum subtotal" moneyunit="' + o[i].MoneyUnit + '">' + (o[i].Amount * price).toFixed(2) + '</td>'
134                    + ' <td class="quantity">'
135                    + ' <div class="cart-quantity-form">'
136                    + ' <a href="javascript:void(0);" class="shopcartchgamounthref" onclick="changeOrderAmount(' + o[i].CartId + ',-1,1);"><img src="' + ShopItemSubImage + '" border="0" /></a>'
137                    + ' <input type="text" maxlength="4" size="4" onBlur="if(this.value==\'\')this.value=1;" onkeyup="value=value.replace(/[^\\d]/g,\'\');RecountPrice(' + o[i].CartId + ',1);" class="shopcartchgamount" onbeforepaste="clipboardData.setData(\'text\',clipboardData.getData(\'text\').replace(/[^\\d]/g,\'\'))"  width="40" id="OitemAmount_' + o[i].CartId + '" value="' + o[i].Amount + '"  /> '
138                    + ' <a href="javascript:void(0);"  class="shopcartchgamounthref"  onclick="changeOrderAmount(' + o[i].CartId + ',1,1);"><img src="' + ShopItemAddImage + '" border="0" /></a>'
139                    + ' </div>'
140                    + ' </td>'
141                    + ' <td><a href="javascript:void(0);" onclick="removeCartItem(this,' + o[i].CartId + ',1)">' + rclng.plugin_goodsmanage_removeitem + '</a></td></tr>';
142            }
143            opt += "</table>";
144        }
145    }
146    $("#shopcartitembox").html(opt);
147    GetTotalPriceOfCart(1);
148    if (ShowShopConfig!=undefined) {
149        if (ShowShopConfig.aftershopcartfill) {
150            ShowShopConfig.aftershopcartfill(o);
151        }
152    }
153}
154function LoadGoods(pd_id, conbox) {
155    if (GoodsGlobalSettings[GoodsOpenOrder] == undefined || GoodsGlobalSettings[GoodsOpenOrder] == "1") {
156        LoadShopCart(false);
157        GoLoadGoods(pd_id, conbox);
158    }
159    else {
160        if (GoodsGlobalSettings[GoodsPriceNeedReg] == undefined || GoodsGlobalSettings[GoodsPriceNeedReg] == "0") {
161            GoLoadGoods(pd_id, conbox);
162        }
163        else {
164            CheckUserLogin(function (logined, url, uname) {
165                if (logined == -1) {
166                    //未登录
167                }
168                else {
169                    GoLoadGoods(pd_id, conbox);
170                }
171            });
172        }
173    }
174}
175function GoLoadGoods(pd_id, conbox) {
176 
177    Web960.Web.index.LoadGoods(pd_id, function (ret) {
178        AjaxReturn(ret, function () {
179            var rc = ret.value;
180            if (rc.Status == 1) {
181                InitGoodsHTML(rc.ObjResult, pd_id, conbox);
182            } else {
183                cb(rc.ClientMsg);
184            }
185        });
186    });
187}
188function InitGoodsHTML(obj, pd_id, conbox) {
189    conbox = (conbox == undefined ? "#GoodsListBox" : conbox);
190    var html = '';
191    if (obj.length > 0) {
192        if (typeof(GoodsConfig)!="undefined"&&GoodsConfig.inventoryitemhtml != undefined)
193        {
194            html = GoodsConfig.inventoryitemhtml(obj, pd_id);
195        }
196        else {
197            html = '<table border="0" width="100%" cellspacing="0" cellpadding="5" class="goodstable">'
198                    + '<tr class="goodstableheader">'
199                        + '<td class="goods_itemno">' + rclng.plugin_goodsmanage_itemno + '</td>'
200                        + GetExtThHeader(obj[0].Goods_info)
201                        + '<td class="goods_store">' + rclng.plugin_goodsmanage_store + '</td>'
202                        +'<td class="goods_qtyavail">' + rclng.plugin_goodsmanage_qtyavail + '</td>'
203                        +'<td class="goods_unit">' + rclng.plugin_goodsmanage_unit + '</td>'
204                        +'<td class="goods_pirce">' + rclng.plugin_goodsmanage_price + '</td>';
205            if (GoodsGlobalSettings[GoodsOpenOrder] == undefined || GoodsGlobalSettings[GoodsOpenOrder] == "1") {
206                 html += '<td class="goods_quantity">' + rclng.plugin_goodsmanage_quantity + '</td>'
207                        +'<td width="90" class="goods_addtocart">' + rclng.plugin_goodsmanage_addtocart + '</td>';
208            }
209            html += '</tr>';
210            
211            for (var i = 0; i < obj.length; i++) {
212
213                html += '<tr><td' + GetGoodsTDRowspan(obj[i].Inventores.length) + ' class="goods_itemno">' + obj[i].Goods_no + '</td>'
214                    + GetExtTdValue(obj[i].Goods_info, obj[i].Inventores.length)
215                html += GetGoodsInventoresItemHtml(obj[i].Inventores, obj[i].Goods_no, pd_id);
216            }
217            html += '</table>';
218        }
219    }
220    if (html == '')
221    {
222        if (typeof (GoodsConfig) != "undefined" && GoodsConfig.whennogoods != undefined) {
223            html= GoodsConfig.whennogoods();
224        }
225        else {
226            html = rclng.plugin_goodsmanage_nogoodsinfo
227        }
228    }
229   
230 
231    $(conbox).html(html);
232    if (typeof (GoodsConfig) != "undefined" && GoodsConfig.callback != undefined) {
233        GoodsConfig.callback();
234    }
235}
236function GetGoodsInventorePrice(PreferentType, PreferentInfo, MoneyUnit)
237{
238    var html = "";
239
240    if (GoodsGlobalSettings.preferentsetting != undefined)
241    {
242        var setting = eval('(' + GoodsGlobalSettings.preferentsetting + ');');
243        var preinfo = eval('('+PreferentInfo+');');
244        if (PreferentType == "1" && setting.suspendpromotion == "0")
245        {
246            //促销
247            
248
249            html = '<br /><span>促销</span> ' + preinfo.val + ' ' + (preinfo.premethod == "1" ? "折" : MoneyUnit);
250        }
251        else if (PreferentType == "2" && setting.SuspendPreferent == "0")
252        {
253            //优惠
254
255            for (var i = 0; i < preinfo.rolessetting.length; i++) {
256                if (preinfo.rolessetting[i].visible == "all") {
257                    html += '<br />' + preinfo.rolessetting[i].rolename + ':' + preinfo.rolessetting[i].zk  + (preinfo.premethod == "1" ? "折" : MoneyUnit);
258                }
259                else if (preinfo.rolessetting[i].visible == "self") {
260                    if (typeof (NowUserInfo) != "undefined") {
261                        if (NowUserInfo.rolename != undefined) {
262                            if (NowUserInfo.rolename == preinfo.rolessetting[i].rolename) {
263                                html += '<br />' + preinfo.rolessetting[i].rolename + ':' + preinfo.rolessetting[i].zk  + (preinfo.premethod == "1" ? "折" : MoneyUnit);
264                            }
265                        }
266                    }
267                }
268            }
269        }
270        else if (PreferentType == "0" && setting.SuspendPreferent == "0" && setting.enable=="1")
271        {
272            
273            //默认优惠设置
274            for (var i = 0; i < setting.rolessetting.length; i++)
275            {
276                if (setting.rolessetting[i].visible == "all"){
277                    html += '<br />' + setting.rolessetting[i].rolename + ':' + setting.rolessetting[i].zk + '折';
278                }
279                else if (setting.rolessetting[i].visible == "self") 
280                {
281                    if (typeof(NowUserInfo) != "undefined") {
282                        if (NowUserInfo.rolename != undefined) {
283                            if (NowUserInfo.rolename == setting.rolessetting[i].rolename) {
284                                html += '<br />' + setting.rolessetting[i].rolename + ':' + setting.rolessetting[i].zk + '折';
285                            }
286                        }
287                    }
288                }
289            }
290        }
291    }
292    return html;
293}
294function GetGoodsInventoresItemHtml(Inventores, Goods_no, pd_id)
295{
296    var html = '<td class="goods_store">&nbsp;</td>'
297            +'<td  class="goods_qtyavail">&nbsp;</td>'
298            +'<td class="goods_unit">&nbsp;</td>'
299            +'<td class="goods_pirce">&nbsp;</td>';
300    if (GoodsGlobalSettings[GoodsOpenOrder] == undefined || GoodsGlobalSettings[GoodsOpenOrder] == "1") {
301    html += '<td class="goods_quantity">&nbsp;</td>'
302    +'<td width="90" class="goods_addtocart">&nbsp;</td>';
303    }
304    html+='</tr>';
305    if (Inventores.length >0)
306    {
307        html = '<td class="goods_store">' + Inventores[0].Placecode.split('|')[1] + '</td>'
308              +'<td  class="goods_qtyavail" id="GoodsInvAmount_' + Inventores[0].Inventory_id + '">' + Inventores[0].Amount + '</td>'
309              +'<td class="goods_unit" id="GoodsInvUnit_' + Inventores[0].Inventory_id + '">' + Inventores[0].Unit + '</td>'
310             + '<td class="goods_pirce">'
311                + '<span  id="GoodsInvPrice_' + Inventores[0].Inventory_id + '">' + Inventores[0].Price + '</span> (<span id="GoodsMoneyUnit_' + Inventores[0].Inventory_id + '">' + Inventores[0].MoneyUnit + '</span>)'
312                + GetGoodsInventorePrice(Inventores[0].PreferentType, Inventores[0].PreferentInfo, Inventores[0].MoneyUnit)
313             + '</td>';
314        if (GoodsGlobalSettings[GoodsOpenOrder] == undefined || GoodsGlobalSettings[GoodsOpenOrder] == "1") {
315            html += '<td class="goods_quantity"><a href="javascript:void(0);" onclick="changeGoodsInvcount(\'GoodsInv_' + Inventores[0].Inventory_id + '\',-1);"  class="shopcartchgamounthref"><img src="'+ShopItemSubImage+'" border="0" /></a>
315<input type="text" width="40" maxlength="4" id="GoodsInv_' + Inventores[0].Inventory_id + '" GoodsNo="' + Goods_no + '" Pdid="' + pd_id + '"  value="1"  /><a href="javascript:void(0);" onclick="changeGoodsInvcount(\'GoodsInv_' + Inventores[0].Inventory_id + '\',1);" class="shopcartchgamounthref"><img src="'+ShopItemAddImage+'" border="0" /></a></td>'
316                + '<td class="goods_addtocart"><input type="button"  class="btn2" onclick="AddToCart(' + Inventores[0].Inventory_id + ');" value="' + rclng.plugin_goodsmanage_addtocart + '" /></td>';
317        }
318        html+='</tr>';
319        for (var j = 1; j < Inventores.length; j++) {
320            html += '<tr><td class="goods_store">' + Inventores[j].Placecode.split('|')[1] + '</td>'
321                +'<td class="goods_qtyavail" id="GoodsInvAmount_' + Inventores[j].Inventory_id + '">' + Inventores[j].Amount + '</td>'
322                +'<td class="goods_unit" id="GoodsInvUnit_' + Inventores[j].Inventory_id + '">' + Inventores[j].Unit + '</td>'
323                + '<td class="goods_pirce"><span  id="GoodsInvPrice_' + Inventores[j].Inventory_id + '">' + Inventores[j].Price + '</span> (<span id="GoodsMoneyUnit_' + Inventores[j].Inventory_id + '">' + Inventores[j].MoneyUnit + '</span>)'
324                 + GetGoodsInventorePrice(Inventores[j].PreferentType, Inventores[j].PreferentInfo, Inventores[j].MoneyUnit)
325               + '</td>';
326            if (GoodsGlobalSettings[GoodsOpenOrder] == undefined || GoodsGlobalSettings[GoodsOpenOrder] == "1") {
327                html += '<td class="goods_quantity"><a href="javascript:void(0);" onclick="changeGoodsInvcount(\'GoodsInv_' + Inventores[j].Inventory_id + '\',-1);" class="shopcartchgamounthref"><img src="' + ShopItemSubImage + '" border="0" /></a><input type="text"  width="40" maxlength="4" id="GoodsInv_' + Inventores[j].Inventory_id + '" GoodsNo="' + Goods_no + '" Pdid="' + pd_id + '"  value="1"  /><a href="javascript:void(0);" onclick="changeGoodsInvcount(\'GoodsInv_' + Inventores[j].Inventory_id + '\',1);"  class="shopcartchgamounthref"><img src="' + ShopItemAddImage + '" border="0" /></a></td>'
328                    + '<td class="goods_addtocart"><input type="button"  class="btn2" onclick="AddToCart(' + Inventores[j].Inventory_id + ');" value="' + rclng.plugin_goodsmanage_addtocart + '" /></td>';
329            }
330            html+='</tr>';
331        }
332    }
333    return html;
334}
335function changeGoodsInvcount(id, t)
336{
337    var v = $("#" + id).val();
338    if (/^\d+$/.test(v))
339    {
340        v = parseInt(v);
341    }
342    else {
343        v = 1;
344    }
345    v = v + t;
346    if (v < 1)
347    {
348        v = 1;
349    }
350    $("#" + id).val(v);
351}
352function GetGoodsTDRowspan(rowspan)
353{
354    var rowh = "";
355    if (rowspan != undefined) {
356        if (rowspan > 1) {
357            rowh = " rowspan=\"" + rowspan + "\"";
358        }
359    }
360    return rowh;
361}
362function GetExtThHeader(val, rowspan)
363{
364    var obj = eval('(' + val + ');');
365    var rowh = GetGoodsTDRowspan(rowspan);
366    
367  var html = "";
368
369    for (var classname in obj) {
370        if (GoodsExtConfig.classes[classname] != undefined)
371        {
372            for (var j = 0; j < GoodsExtConfig.classes[classname].columns.length; j++) {
373                html += '<td' + rowh + ' class="' + classname+'_' + GoodsExtConfig.classes[classname].columns[j].key + '">' + GoodsExtConfig.classes[classname].columns[j].srctitle + '</td>';
374            }
375        }
376    }
377
378    return html;
379}
380function GetExtTdValue(val, rowspan)
381{
382  
383    var obj = eval('('+val+');');
384    var html = "";
385    var rowh = GetGoodsTDRowspan(rowspan);
386
387    for (var classname in obj) {
388        if (GoodsExtConfig.classes[classname] != undefined) {
389            for (var j = 0; j < GoodsExtConfig.classes[classname].columns.length; j++) {
390                html += '<td' + rowh + '  class="' + classname + '_' + GoodsExtConfig.classes[classname].columns[j].key + '">';
391                try {
392                    if (obj[classname][GoodsExtConfig.classes[classname].columns[j].key] != undefined) {
393                        html += obj[classname][GoodsExtConfig.classes[classname].columns[j].key];
394                    }
395                } catch (e)
396                { }
397                html += '</td>';
398            }
399        }
400    }
401
402    return html;
403}
404
405function AddToCart(invid)
406{
407   
408    if (GoodsGlobalSettings.orderrequiredreg == undefined || GoodsGlobalSettings.orderrequiredreg == "1") {
409        CheckUserLogin(function (logined, url, uname) {
410            if (logined == -1) {
411                //未登录
412                CloseShopCart();
413                ShowLoginDialog({
414                    loginedcallback: function () {
415                        CloseLoginDialog();
416                        ShowShopCart();
417                        DoAddToCart(invid);
418                    }
419                });
420            }
421            else {
422                DoAddToCart(invid);
423            }
424        });
425    }
426    else {
427        DoAddToCart(invid);
428    }
429}
430function DoAddToCart(invid)
431{
432    var oldAmount = $("#GoodsInvAmount_" + invid).html();
433    var price = $("#GoodsInvPrice_" + invid).html();
434    var unit = $("#GoodsInvUnit_" + invid).html();
435    var moneyunit = $("#GoodsMoneyUnit_" + invid).html();
436    var oj=$("#GoodsInv_" + invid);
437    var orderAmount = oj.val();
438    var GoodsNo = oj.attr("GoodsNo");
439    var Pdid = oj.attr("Pdid");
440
441    Web960.Web.index.AddToCart(Pdid, orderAmount, ''+invid+'', unit, price, GoodsNo,moneyunit, function (ret) {
442        AjaxReturn(ret, function () {
443            var rc = ret.value;
444          
445            if (rc.Status == 1) {
446                if (ShowShopConfig != undefined) {
447                    if (ShowShopConfig.afteraddtocart != undefined)
448                    {
449                        ShowShopConfig.afteraddtocart();
450                    }
451                    else
452                    {
453                        alert(rc.ClientMsg);
454                    }
455                }
456                else {
457                    alert(rc.ClientMsg);
458                }
459               
460                ShowShopCartWithData();
461            } else if (rc.Status == -2) {
462                AddToCart(invid);
463            }
464            else if (rc.Status == -1)
465            {
466                alert(rc.ClientMsg);
467            }
468           
469        });
470    });
471}
472var LoadedCart = false;
473var CartHTMLStyle = '<style type="text/css">.shopcartchgamounthref{padding:3px 5px 3px 5px;}'
474    + '.ShopCartBox{position:fixed;bottom:0;right:10px;padding:3px;width:450px;background-color:#cf4202;border:1px solid #b01010}'
475    + '* html,* html body{background-image:url(about:blank);background-attachment:fixed}* html .ShopCartBox{position:absolute;'
476    + 'bottom:auto;top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight'
477    + '-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)))}.shopcartitembox{display:none;'
478    + 'height:200px;overflow:auto;border:1px solid #b01010;background-color:#ffffff;padding:2px;background-image:url("data:image/png;base64,'
479    + 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAMAAAC6sdbXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAlQTFRF7u7u5ubm6urqYPTI0gAAAB9JREFU'
480    + 'eNoUiLERAAAMRLD/0Pk0HGSChSOLP/HqBBgAAfcAItOjOxwAAAAASUVORK5CYII=")}.shopcartctrlbox{padding:5px;font-size:14px;color:#ffffff;'
481    + 'background-repeat:no-repeat;line-height:25px;background-position:10px 10px;padding-left:30px;background-image:'
482    + 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAA'
483    + 'AAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i
48377u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEg'
484    + 'eG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAg'
485    + 'ICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlv'
486    + 'biByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAv'
487    + 'MS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUg'
488    + 'UGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6OEEyQjkwRkEzNTJGMTFFMjkyNzk5MjZDMjYxMzRERUIiIHhtcE1NOkRv'
489    + 'Y3VtZW50SUQ9InhtcC5kaWQ6OEEyQjkwRkIzNTJGMTFFMjkyNzk5MjZDMjYxMzRERUIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1w'
490    + 'LmlpZDo4QTJCOTBGODM1MkYxMUUyOTI3OTkyNkMyNjEzNERFQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo4QTJCOTBGOTM1MkYxMUUyOTI3OTkyNkMyNjEzNE'
491    + 'RFQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PiQvthAAAACISURBVHjanFGJDYAgDCzGjWAVd'
492    + '3GE7uQMjgArOEKFpJhaqTVeckAo1+cIRLTBHWvlDh6akJ4Aj6EtMg/vwSs4W414wgl+wqr41ip5FXMlDs6Xq5LSVRT3qN9o4cL3aHwDcnzRgUjfEEdZPXGLm+YkdlYz'
493    + 'Web04bMxY+7ejCoelcXopHAcTgEGAHOtLt9FRk3CAAAAAElFTkSuQmCC")}.shopcartctrlbox .shopcartjiesau{line-height:20px;float:right;'
494    + 'background-color:#ffffff;color:#b01010;font-weight:bold;padding:5px 10px 5px 10px}.shopcartctrlbox .shopcarttogglebtn{color:#ffffff}'
495    + '.shopcartitemtable td{border-bottom:1px solid #dddddd;background-color:#ffffff;padding:8px}.shopcartitemtableheader td{'
496    + 'background-color:#f8f8f8;font-weight:bold}</style>';
497var ShopItemAddImage = 'data:image/gif;base64,R0lGODlhEgANAJEDAJaTk66uru7u7v///yH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wT'
498    +'XBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4zLWMwMTEgNjYuMTQ1NjYxLC'
499    + 'AyMDEyLzAyLzA2LTE0OjU2OjI3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cm'
500    + 'RmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY'
501    + '29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9i'
502    + 'ZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoxNzlGREVDQjVCNUUxMUU0QTNBM0JBRjJDQTRDRUNCRiIgeG1wTU06RG9jdW'
503    + '1lbnRJRD0ieG1wLmRpZDoxNzlGREVDQzVCNUUxMUU0QTNBM0JBRjJDQTRDRUNCRiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjE3'
504    + 'OUZERUM5NUI1RTExRTRBM0EzQkFGMkNBNENFQ0JGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjE3OUZERUNBNUI1RTExRTRBM0EzQkFGMkNBNENFQ0JGIi8+IDwvcm'
505    + 'RmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva'
506    + '2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh'
507    + '3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFh'
508    + 'UUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAQAAAwAsAAAAABIADQAAAiyMjze7IQ/jC2w4iQVtOe8bAR0FQuJYAqrqlc/ZYrBEdthnR5uVT1UCNFQGBQA7';
509var ShopItemSubImage = 'data:image/gif;base64,R0lGODlhEgANAJEDAJaTk66uru7u7v///yH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0w'
510    + 'TXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4zLWMwMTEgNjYuMTQ'
511    + '1NjYxLCAyMDEyLzAyLzA2LTE0OjU2OjI3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucy'
512    + 'MiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuY'
513    + 'WRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29s'
514    + 'PSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozMDU4QTk5NjVCNUUxMUU0OEY1MkU1MkQ5OERDMUIzRiIgeG1wTU0'
515    + '6RG9jdW1lbnRJRD0ieG1wLmRpZDozMDU4QTk5NzVCNUUxMUU0OEY1MkU1MkQ5OERDMUIzRiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaW'
516    + 'lkOjMwNThBOTk0NUI1RTExRTQ4RjUyRTUyRDk4REMxQjNGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjMwNThBOTk1NUI1RTExRTQ4RjUyRTUyRDk4REMxQjNGIi8+I'
517    + 'DwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397'
518    + 'd3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fH'
519    + 't6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaG'
520    + 'RgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAQAAAwAsAAAAABIADQAAAimcHamrNyGinDEcSLOwT2uLeVQifuEEpOlElmPnStxZcrBr32L+MH5QAAA7';
521
522
523var CartHTML = '<div class="ShopCartBox" id="ShopCartBox"><a href="javascript:void(0)" onclick="ToggleCart()" id="cartclosebtn" style="display:none; position:absolute;right:5px; top:5px; background-color:#ffffff; padding:5px;">' + rclng.plugin_goodsmanage_close + '</a><div class="shopcartitembox" id="shopcartitembox"></div>'
524+ '<div class="shopcartctrlbox"><a href="' + webhttp + 'order/shopcart/" class="shopcartjiesau"><span class="shoptotalmoney"></span>' + rclng.plugin_goodsmanage_checkout + '</a><a href="javascript:void(0);" class="shopcarttogglebtn" onclick="ToggleCart();">' + rclng.plugin_goodsmanage_cart + ' (<span id="shopcartitemcount" class="shopcartitemcount">0</span>)' + rclng.plugin_goodsmanage_item + '</a></div></div>';
525function ShowShopCart()
526{
527    if ($("#ShopCartBox").length == 0) {
528      
529        if (ShowShopConfig != undefined)
530        {
531            if (ShowShopConfig.defaultcss) {
532                $("body").append(CartHTMLStyle + CartHTML);
533            }
534            else {
535                $("body").append(CartHTML);
536            }
537        }
538        else
539        {
540            $("body").append(CartHTMLStyle+CartHTML);
541        }
542        ShowShopCart();
543    }
544    else {
545        $("#ShopCartBox").show();
546       
547    }
548}
549function CloseShopCart()
550{
551    $("#ShopCartBox").hide();
552}
553function ToggleCart()
554{
555    if (!LoadedCart) {
556        LoadShopCart(true)
557    }
558    else {
559        if ($('#shopcartitembox').is(":hidden")) {
560            $('#shopcartitembox').show();
561            $("#cartclosebtn").show();
562        }
563        else {
564            $('#shopcartitembox').hide();
565            $("#cartclosebtn").hide();
566        }
567       
568        
569    }
570}
571function removeCartItem(o, cid)
572{
573    
574    Web960.Web.index.RemoveShopCartItem(cid,function (ret) {
575        AjaxReturn(ret, function () {
576            var rc = ret.value;
577            if (rc.Status == 1) {
578                ShowShopCartWithData();
579            } else if (rc.Status == -2) {
580                ShowLoginDialog({
581                    loginedcallback: function () {
582                        CloseLoginDialog();
583                        removeCartItem(o, cid);
584                    }
585                });
586            }
587        });
588    });
589}
590function GetRealPriceByPreferent(goods,PreferentType, PreferentInfo, MoneyUnit, price)
591{
592    var brandprice = price;
593    if (GoodsGlobalSettings.preferentsetting != undefined ) {
594
595        if (GoodsGlobalSettings.app_preferent_on == "1" ) {
596          
597            var setting = eval('(' + GoodsGlobalSettings.preferentsetting + ');');
598            var preinfo = eval('(' + PreferentInfo + ');');
599            var brand = "";
600            if (goods != undefined) {
601                brand= $.trim(web960.utils.tools.getvalfromjson(goods.Goods_info, "{goodsinfo.brand}"));
602            }
603            var brandset = setting["preferentsettingbybrand"];//品牌设置优惠
604           
605            if (brandset != undefined && brand != "") {
606                for (var x = 0; x < brandset.length; x++) {
607                    var tbrandset = brandset[x];
608                    if (brand == tbrandset.brandname) {
609                        //默认品牌优惠设置
610                        for (var i = 0; i < tbrandset.rolessetting.length; i++) {
611                            if (typeof (NowUserInfo) != "undefined") {
612                                if (NowUserInfo.rolename != undefined && NowUserInfo.rolename != "") {
613                                    if (NowUserInfo.rolename == tbrandset.rolessetting[i].rolename) {
614                                        brandprice = parseFloat(tbrandset.rolessetting[i].zk) * price;
615                                        //    html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
616                                    }
617                                } else {
618                                    if (tbrandset.rolessetting[i].visible == "all") {
619                                        brandprice = parseFloat(tbrandset.rolessetting[i].zk) * price;
620                                        // html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
621                                    }
622                                }
623                            }
624                            else {
625                                if (tbrandset.rolessetting[i].visible == "all") {
626                                    brandprice = parseFloat(tbrandset.rolessetting[i].zk) * price;
627                                    // html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
628                                }
629                            }
630                        }
631                        break;
632                    }
633                }
634            }
635
636            if (PreferentType == "1" && setting.suspendpromotion == "0") {
637                //促销
638                if (preinfo.premethod == "1") {
639
640                    price = price * parseFloat(preinfo.val);
641                }
642                else {
643                    price = parseFloat(preinfo.val);
644                }
645                //html = '<br /><span>促销</span> ' + preinfo.val + ' ' + (preinfo.premethod == "1" ? "折" : MoneyUnit);
646            }
647            else if (PreferentType == "2" && setting.SuspendPreferent == "0") {
648                //优惠
649                if (typeof (NowUserInfo) != "undefined") {
650                    if (NowUserInfo.rolename == "") {
651                        //有可能游客也促销,游客默认为角色名:普通会员
652                        if (typeof (GoodsConfig) != "undefined" && GoodsConfig.GuestPrice != undefined) {
653                            price = GoodsConfig.GuestPrice(setting.rolessetting,2, preinfo, price);
654                        }
655                    }
656                    else {
657                        for (var j = 0; j < preinfo.rolessetting.length; j++) {
658
659                            if (NowUserInfo.rolename != undefined) {
660                                if (NowUserInfo.rolename == preinfo.rolessetting[j].rolename) {
661                                    if (preinfo.premethod == "1") {
662
663                                        price = price * parseFloat(preinfo.rolessetting[j].zk);
664                                    }
665                                    else {
666                                        price = parseFloat(preinfo.rolessetting[j].zk);
667                                    }
668                                }
669                            }
670                        }
671                    }
672                }
673            }
674            else if (PreferentType == "0" && setting.SuspendPreferent == "0" && setting.enable == "1") {
675
676
677                //默认优惠设置
678                if (typeof (NowUserInfo) != "undefined") {
679                    if (NowUserInfo.rolename == "") {
680                        //有可能游客也促销,游客默认为角色名:普通会员
681                        if (typeof (GoodsConfig) != "undefined" && GoodsConfig.GuestPrice != undefined) {
682                            price = GoodsConfig.GuestPrice(setting.rolessetting,0, preinfo, price);
683                        }
684                    }
685                    else {
686                        for (var j = 0; j < setting.rolessetting.length; j++) {
687
688                            if (NowUserInfo.rolename != undefined) {
689                                if (NowUserInfo.rolename == setting.rolessetting[j].rolename) {
690
691                                    if (preinfo.premethod == "2") {
692                                        price = parseFloat(setting.rolessetting[j].zk);
693                                    }
694                                    else {
695                                        price = price * parseFloat(setting.rolessetting[j].zk);
696                                    }
697                                }
698                            }
699                        }
700                    }
701                }
702                else {
703                    //有可能游客也促销,游客默认为角色名:普通会员
704                    if (typeof (GoodsConfig) != "undefined" && GoodsConfig.GuestPrice != undefined) {
705                        price = GoodsConfig.GuestPrice(setting.rolessetting,0, preinfo, price);
706                    }
707
708                }
709            }
710        }
711    }
712    if (brandprice > price) {
713        return price;
714    }
715    else {
716        return brandprice;
717    }
718}
719function GetRealPriceByPre(price, id)
720{
721    var brandprice = price;
722    if (GoodsGlobalSettings.preferentsetting != undefined && typeof (ShopCartCfg) != "undefined") {
723   
724        if (GoodsGlobalSettings.app_preferent_on == "1" && ShopCartCfg.invos != undefined) {
725           
726            if (ShopCartCfg.invos.length > 0) {
727                for (var i = 0; i < ShopCartCfg.invos.length; i++) {
728                    if (ShopCartCfg.invos[i].id == id) {
729                        var PreferentType = ShopCartCfg.invos[i].pretype;
730                      
731                        var setting = eval('(' + GoodsGlobalSettings.preferentsetting + ');');
732                        var preinfo = eval('(' + ShopCartCfg.invos[i].preinfo + ');');
733                        var brand = "";
734                        if (ShopCartCfg.goods) {
735                            var goods = ShopCartCfg.goods["inv" + ShopCartCfg.invos[i].id];
736                            if (goods) {
737                                 brand = $.trim(web960.utils.tools.getvalfromjson(goods.Goods_info, "{goodsinfo.brand}"));
738                            }
739                        }
740                        var brandset = setting["preferentsettingbybrand"];//品牌设置优惠
741                       
742                        if (brandset != undefined && brand != "") {
743                            for (var x = 0; x < brandset.length; x++) {
744                                var tbrandset = brandset[x];
745                                if (brand == tbrandset.brandname) {
746                                    //默认品牌优惠设置
747                                    for (var h = 0; h < tbrandset.rolessetting.length; h++) {
748                                        if (typeof (NowUserInfo) != "undefined") {
749                                            if (NowUserInfo.rolename != undefined && NowUserInfo.rolename != "") {
750                                                if (NowUserInfo.rolename == tbrandset.rolessetting[h].rolename) {
751                                                    brandprice = parseFloat(tbrandset.rolessetting[h].zk) * price;
752                                                    //    html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
753                                                }
754                                            } else {
755                                                if (tbrandset.rolessetting[h].visible == "all") {
756                                                    brandprice = parseFloat(tbrandset.rolessetting[h].zk) * price;
757                                                    // html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
758                                                }
759                                            }
760                                        }
761                                        else {
762                                            if (tbrandset.rolessetting[h].visible == "all") {
763                                                brandprice = parseFloat(tbrandset.rolessetting[h].zk) * price;
764                                                // html += GetSimpMoneyUnit(MoneyUnit) + (parseFloat(tbrandset.rolessetting[i].zk) * Price).toFixed(2);
765                                            }
766                                        }
767                                    }
768                                    break;
769                                }
770                            }
771                        }
772
773                        if (PreferentType == "1" && setting.suspendpromotion == "0") {
774                            //促销
775                            if (preinfo.premethod == "1") {
776
777                                price = price * parseFloat(preinfo.val);
778                            }
779                            else {
780                                price = parseFloat(preinfo.val);
781                            }
782                        }
783                        else if (PreferentType == "2" && setting.SuspendPreferent == "0") {
784                            //优惠
785                            if (typeof (NowUserInfo) != "undefined") {
786                                for (var j = 0; j < preinfo.rolessetting.length; j++) {
787
788                                    if (NowUserInfo.rolename != undefined) {
789                                        if (NowUserInfo.rolename == preinfo.rolessetting[j].rolename) {
790                                            if (preinfo.premethod == "1") {
791
792                                                price = price * parseFloat(preinfo.rolessetting[j].zk);
793                                            }
794                                            else {
795                                                price = parseFloat(preinfo.rolessetting[j].zk);
796                                            }
797                                        }
798                                    }
799                                }
800                            }
801                        }
802                        else if (PreferentType == "0" && setting.SuspendPreferent == "0" && setting.enable == "1") {
803                          
804                            
805                            //默认优惠设置
806                            if (typeof (NowUserInfo) != "undefined") {
807                                if (NowUserInfo.rolename == "") {
808                                    //有可能游客也促销,游客默认为角色名:普通会员
809                                    if (typeof (GoodsConfig) != "undefined" && GoodsConfig.GuestPrice != undefined) {
810                                        price = GoodsConfig.GuestPrice(setting.rolessetting,0, preinfo, price);
811                                    }
812                                }
813                                else {
814                                    for (var j = 0; j < setting.rolessetting.length; j++) {
815
816                                        if (NowUserInfo.rolename != undefined) {
817                                            if (NowUserInfo.rolename == setting.rolessetting[j].rolename) {
818
819                                                if (preinfo.premethod == "2") {
820                                                    price = parseFloat(setting.rolessetting[j].zk);
821                                                }
822                                                else {
823                                                    price = price * parseFloat(setting.rolessetting[j].zk);
824                                                }
825                                            }
826                                        }
827                                    }
828                                }
829                            }
830                            else {
831                                //有可能游客也促销,游客默认为角色名:普通会员
832                                if (typeof (GoodsConfig) != "undefined" && GoodsConfig.GuestPrice != undefined) {
833                                    price = GoodsConfig.GuestPrice(setting.rolessetting,0, preinfo, price);
834                                }
835
836                            }
837                        }
838                    }
839                }
840            }
841        }
842    }
843    if (brandprice > price) {
844        return price;
845    }
846    else {
847        return brandprice;
848    }
849}
850///------------------
851function changeOrderAmount(id, p,typeid)
852{
853  
854    var od = parseInt($("#OitemAmount_" + id).val());
855    var newv = od + p;
856    newv = newv < 1 ? 1 : newv;
857   
858    var price = parseFloat($("#OitemPrice_" + id).html());
859
860    price = GetRealPriceByPre(price, id);
861    var unit = $("#OitemUnit_" + id).html();
862    var moneyunit = $("#OitemMoneyUnit_" + id).html();
863
864    Web960.Web.index.EditShopCart(id, newv.toString(),unit,price.toString(),moneyunit, function (ret) {
865        AjaxReturn(ret, function () {
866            var rc = ret.value;
867            if (rc.Status == 1) {
868                var sid = price * newv;
869                $("#OitemAmount_" + id).val(newv);
870                $("#OitemSum_" + id).html(sid.toFixed(2));
871                GetTotalPriceOfCart(typeid);
872            } else if (rc.Status == -2) {
873                ShowLoginDialog({
874                    loginedcallback: function () {
875                        CloseLoginDialog();
876                        removeCartItem(o, cid);
877                    }
878                });
879            }
880        });
881    });
882
883   
884  
885}
886function RecountPrice(id,typeid)
887{
888    changeOrderAmount(id, 0, typeid);
889}
890function InitExchangeRate(cfg)
891{
892
893    var select = rclng.plugin_goodsmanage_moneyselttment+":<select id=\"ExchangeRateSelect\" onchange=\"ExchangeRateSelectChange();\">";
894    var uints = GoodsGlobalSettings[GoodsMoneyUnits];
895    var nl=0;
896    if (uints != undefined) {
897        var us = eval(uints);
898        nl=us.length;
899        if (us.length > 0) {
900            for (var i = 0; i < us.length; i++) {
901                var sel = "";
902               
903                select += '<option value="' + us[i].key + '"' + sel + '>' + us[i].title + '(' + us[i].key + ')' + '</option>';
904            }
905        }
906        else {
907            select += '<option value="CNY">人民币(CNY)</option>';
908        }
909    }
910    else {
911        select += '<option value="CNY">人民币(CNY)</option>';
912    }
913    select += '</select>';
914    $(cfg.conel).html(select);
915    if (nl > 1) {
916        $(cfg.conel).show();
917    }
918    else {
919        $(cfg.conel).hide();
920    }
921    cfg.callback();
922}
923function ExchangeRateSelectChange()
924{
925    GetTotalPriceOfCart();
926}
927function MoneyExchange(sum, unit, aimunit)
928{
929    if (unit == aimunit) {
930        return sum;
931    }
932    else {
933        var jsonk = unit + '_' + aimunit;
934        if (unit > aimunit) {
935            jsonk = aimunit + '_' + unit;
936        }
937       
938        var rate = eval('(' + GoodsGlobalSettings[GoodsExchangeRate] + ');');
939    
940        sum = sum * parseFloat(rate[jsonk][aimunit]) / parseFloat(rate[jsonk][unit]);
941      
942        return sum;
943    }
944}
945
946
947function GetTotalPriceOfCart(t)
948{
949   
950    if (t==undefined) {
951        var totalsum = 0;
952        if ($(".OitemSum").length == 0) {
953             $("#shopcartNeedInfo,#shopcartRemarkinfo,#shopcartKPinfo,#shopcartCtrlbox,#shopcartpaymethod").hide();
954            $(".cahrhjmoney").html(totalsum.toFixed(2));
955            if (typeof (ShopCartCfg) != "undefined" && ShopCartCfg.oncartempty != undefined) {
956                ShopCartCfg.oncartempty();
957            }
958            else {
959                $("#shopCarttable").html('<div style="padding:20px; text-align:center; font-size:16px; font-weight:bold; color:red;">' + rclng.plugin_goodsmanage_shoppingcartisempty + '</div>');
960            }
961        }
962        else {
963            $("#shopcartNeedInfo,#shopcartRemarkinfo,#shopcartKPinfo,#shopcartCtrlbox,#shopcartpaymethod").show();
964            if ($("#exchageratebox").html() == "") {
965                InitExchangeRate({
966                    conel: "#exchageratebox", fel: ".oitemmoneyunit", callback: function () {
967                        GetTotalPriceOfCart(t);
968                    }
969                });
970            }
971            else {
972                var exchange = $("#ExchangeRateSelect").val();
973                $(".OitemSum", $("input[name='item']:checked").parent().parent()).each(function () {
974                    var sum = parseFloat($(this).html());
975                    var moneyunit = $(this).attr("moneyunit");
976                
977                    sum = MoneyExchange(sum, moneyunit, exchange);
978                    totalsum += sum;
979                });
980                //如果有税率
981                if (GoodsGlobalSettings.app_taxrate_on == "1" && typeof (ShopCartCfg) != "undefined" && ShopCartCfg.taxrate != undefined) {
982                    ShopCartCfg.taxrate(totalsum);
983                }
984
985                var rateel = $(".salestaxmoney");
986                var ratemoney = 0;
987                if (rateel.length != 0) {
988                    if (rateel.html() != "")
989                    {
990                        ratemoney = parseFloat(rateel.html());
991                    }
992                }
993
994                if (GoodsGlobalSettings.app_yunfei_on=="1"&&typeof(ShopCartCfg) != "undefined" && ShopCartCfg.yunfei != undefined) {
995                 
996                    ShopCartCfg.yunfei(totalsum, function (totalyunfei) {
997                       $(".cahrhjmoney").html(totalsum.toFixed(2));
998                       totalsum = parseFloat(totalsum) + parseFloat(totalyunfei) + parseFloat(ratemoney);
999                        $(".ordertotalmoney").html(totalsum.toFixed(2));
1000                    });
1001                }
1002                else
1003                {
1004                    totalsum = totalsum + ratemoney;
1005                    $(".cahrhjmoney").html(totalsum.toFixed(2));
1006                    $(".ordertotalmoney").html(totalsum.toFixed(2));
1007                }
1008                $(".simpmoneyunit").html(GetSimpMoneyUnit(exchange));
1009            }
1010           
1011        }
1012       
1013    }
1014    else {
1015        var totalsum = 0;
1016        if ($(".OitemSum").length == 0) {
1017            $(".shoptotalmoney").html("");
1018        }
1019        else {
1020            
1021            $(".OitemSum").each(function () {
1022                var sum = parseFloat($(this).html());
1023                totalsum += sum;
1024            });
1025            $(".shoptotalmoney").html(rclng.plugin_goodsmanage_total+":"+totalsum.toFixed(2)+" ");
1026        }
1027       
1028    }
1029}
1030function DelCartItem(id)
1031{
1032    if (confirm(rclng.plugin_goodsmanage_suretodel)) {
1033        doDelCartItem(id);
1034    }
1035}
1036function doDelCartItem(id,typeid)
1037{
1038    Web960.Web.index.RemoveShopCartItem(id, function (ret) {
1039        AjaxReturn(ret, function () {
1040            var rc = ret.value;
1041            if (rc.Status == 1) {
1042                if ($("#trosci_" + id).length == 1)
1043                {
1044                    $("#trosci_" + id).remove();
1045                }
1046                else
1047                {
1048                    $("#OitemAmount_" + id).parent().parent().remove();
1049                }
1050                GetTotalPriceOfCart(typeid);
1051            } else if (rc.Status == -2) {
1052                ShowLoginDialog({
1053                    loginedcallback: function () {
1054                        CloseLoginDialog();
1055                        DelCartItem(id);
1056                    }
1057                });
1058            }
1059        });
1060    });
1061}
1062function deleteCartItem(name)
1063{
1064    if (confirm(rclng.plugin_goodsmanage_suretodelselecteditems)) {
1065        var ids = getSelectedArrayVal(name);
1066        for (var i = 0; i < ids.length; i++) {
1067            doDelCartItem(ids[i]);
1068        }
1069    }
1070}
1071
1072function InitShopCartForm()
1073{
1074    InitFormVerify({ el: '.usercenterright' });
1075}
1076function VerifyOrderAccountInfoChoose(callback)
1077{
1078    var re = {};
1079    var r = GetAccountInfoArray();
1080    for (var i = 0; i < r.length; i++) {
1081        if (GoodsGlobalSettings[r[i].savekey] != "") {
1082            if ($("input[name='acntckd" + r[i].savekey + "']:checked").length == 0) {
1083                alert(GetLangTxt(rclng.alertrequired, [{ title: "title", text: r[i].title }]));
1084                return false;
1085            }
1086            else {
1087                var idx = parseInt($("input[name='acntckd" + r[i].savekey + "']:checked").eq(0).attr("idx"));
1088
1089                re[r[i].jsonparm] = JSON2.stringify(r[i].val[idx]);
1090
1091            }
1092        }
1093    }
1094    callback(re);
1095}
1096function saveOrder(callback, o)
1097{
1098    VerifyOrderAccountInfoChoose(function (returndata) {
1099        VerifyFormData({ el: '.goodchatinfobox' }, function (postdata, extdata) {
1100            // alert(JSON.stringify(postdata) + "\n" + JSON.stringify(extdata));
1101            var idstr = getSelectedValue("item");
1102            if (idstr == "") {
1103                callback(false);
1104            }
1105            else {
1106                var totalMoney = $(".cahrhjmoney").html();
1107                var moneyUnit = $("#ExchangeRateSelect").val();
1108                var ordererinfo = returndata.ordererinfo;
1109                var billinfo = returndata.billinfo;
1110                var consigneeinfo = returndata.consigneeinfo;
1111                var invoiceinfo = returndata.invoiceinfo;
1112                var yunfei = $(".yunfeimoney").html();
1113                var tax = $(".salestaxmoney").html();
1114                var paymethod = $("input[name='paymethod']:checked").val();
1115                $(o).attr("disabled", true);
1116                Web960.Web.index.SaveOrder(idstr, totalMoney, moneyUnit, JSON2.stringify(postdata), ordererinfo, billinfo, consigneeinfo, invoiceinfo, yunfei, tax, paymethod, function (res) {
1117                    $(o).attr("disabled", false);
1118                    AjaxReturn(res, function () {
1119                        var rc = res.value;
1120                        if (rc.Status == 1) {
1121                            if (callback != undefined) {
1122                                callback(true, rc, paymethod);
1123                            }
1124                            else {
1125                                $(".usercenterright").hide().after('<div class="cartsubmitsuccessed">' + rclng.plugin_goodsmanage_ordersubmitsuccess + '</div>');
1126                            }
1127                        } else if (rc.Status == -2) {
1128                            ShowLoginDialog({
1129                                loginedcallback: function () {
1130                                    CloseLoginDialog();
1131                                    saveOrder(callback);
1132                                }
1133                            });
1134                        }
1135                    });
1136
1137                });
1138            }
1139        });
1140    });
1141}
1142function InitShopCartOrderAccountInfo()
1143{
1144    var r = GetAccountInfoArray();
1145    for (var i = 0; i < r.length; i++)
1146    {
1147        if (GoodsGlobalSettings[r[i].savekey] != "") {
1148            eval('var cfg=' + r[i].savekey + '_Cfg;');
1149            InitOrderAccountInfoHTML(r[i], cfg);
1150        }
1151    }
1152}
1153function InitOrderAccountInfoHTML(ro, cfg,nodefdeflast) {
1154    var vobj = ro.val;
1155    var savekey = ro.savekey;
1156    var r = "";
1157    if (vobj.length > 0) {
1158        r = '<ul class="shopchataccountinfoli">';
1159        var havedefopt = false;
1160        for (var i = 0; i < vobj.length; i++) {
1161            var defopt = "";
1162            var defckd = "";
1163            var selcls = "";
1164
1165            var deflireplace = "";
1166            var defckreplace = "";
1167            if (nodefdeflast != undefined && nodefdeflast==1)
1168            {
1169                if ((i+1) == vobj.length) {
1170                    defckreplace = "{defckreplace}";
1171                    deflireplace = "{deflireplace}";
1172                }
1173            }
1174            else
1175            {
1176                if (i == 0) {
1177                    defckreplace = "{defckreplace}";
1178                    deflireplace = "{deflireplace}";
1179                }
1180            }
1181          
1182            if (vobj[i].defaultoption != undefined && vobj[i].defaultoption == "1") {
1183                defopt = "<font color=red>[" + rclng.defaultoption + "]</font>";
1184                if (nodefdeflast == undefined || nodefdeflast == 0) {
1185                    havedefopt = true;
1186
1187                    defckd = " checked=\"checked\" ";
1188                    selcls = " class=\"selon\" ";
1189                }
1190            }
1191            r += '<li' + selcls +deflireplace+ '><a href="javascript:void(0);" onclick="EditOrderAccountInfo(' + i + ',\'' + savekey + '\');" style="float:right;" >' + rclng.edit + '</a><label><input type="checkbox"' + defckd + defckreplace+' onclick="OrderAccountInfoSelected(this);" idx="' + i + '"  name="acntckd' + savekey + '" /> ' + (i + 1) + '、' + defopt;
1192            var detl = '';
1193            for (ix in cfg.classes) {
1194              
1195                if (vobj[i][ix] != undefined) {
1196                    for (im in vobj[i][ix]) {
1197                       
1198                        if (vobj[i][ix][im] != undefined && vobj[i][ix][im] != "") {
1199                            detl += vobj[i][ix][im] + ",";
1200                        }
1201                    }
1202                }
1203            }
1204            detl = detl == "" ? "" : detl.substr(detl, detl.length - 1);
1205            r += detl+'</label>';
1206            r += '</li>';
1207           
1208        }
1209        if (havedefopt) {
1210            r = r.replace("{defckreplace}", "");
1211            r = r.replace("{deflireplace}", "");
1212        }
1213        else {
1214            r = r.replace("{defckreplace}", " checked=\"checked\" ");
1215            r = r.replace("{deflireplace}", " class=\"selon\" ");
1216        }
1217        r += '<li style="padding-left:22px;"><a href="javascript:void(0);" onclick="AddNewOrderAccontInfo(\'' + savekey + '\')">' + rclng.addnew + '</a></li>';
1218        r += '</ul>';
1219    }
1220    else {
1221        r = '<div><font color="red">' + GetLangTxt(rclng.plugin_goodsmanage_notfillorderaccountinfo, [{ title: "title", text: ro.title }, { title: "button", text: rclng.addnew }]) + '</font></div>';
1222        r += '<ul><li><a href="javascript:void(0);" onclick="AddNewOrderAccontInfo(\'' + savekey + '\')">' + rclng.addnew + '</a></li></ul>';
1223    }
1224   
1225    $(".InfoHTMLBox[reftype='" + savekey + "']").html(r);
1226}
1227function OrderAccountInfoSelected(o)
1228{
1229    var name = $(o).attr("name");
1230    $("input[name='" + name + "']").attr("checked", false);
1231    $(o).attr("checked", true);
1232    $(".selon", $(o).parent().parent().parent()).removeClass("selon");
1233    $(o).parent().parent().addClass("selon");
1234
1235    if (name == 'acntckdplugin_goodsmanage_consigneeform')
1236    {
1237       
1238        if ((GoodsGlobalSettings.app_yunfei_on == "1" && typeof (ShopCartCfg) != 'undefined' && ShopCartCfg.yunfei != undefined) || (GoodsGlobalSettings.app_taxrate_on == "1" && typeof (ShopCartCfg) != "undefined" && ShopCartCfg.taxrate != undefined)) {
1239            GetTotalPriceOfCart();
1240        }
1241    }
1242
1243}
1244function AddNewOrderAccontInfo(savekey)
1245{
1246    $(".forminfo[reftype='" + savekey + "']").toggle();
1247}
1248function EditOrderAccountInfo(i, savekey) {
1249 
1250    $("input[type='button'][savekey='" + savekey + "']").val(rclng.edit).attr("editkey", i);
1251
1252    eval('var ovl =' + savekey + '_ValCfg;');
1253    var ov = ovl.val;
1254    for (ix in ov[i]) {
1255        var classname = ix;
1256      
1257        for (im in ov[i][ix]) {
1258            $("input[classname='" + classname + "'][relkey='" + im + "'],textarea[classname='" + classname + "'][relkey='" + im + "'],select[classname='" + classname + "'][relkey='" + im + "']", $(".forminfo[reftype='" + savekey + "']")).val(ov[i][ix][im]);
1259
1260            $("span[classname = '" + classname + "'][relkey = '" + im + "'][addresstype]").each(function () {
1261                var v = ov[i][ix][im];
1262                var areacode = "";
1263                var areastr = "";
1264                if (v.indexOf('|') != -1) {
1265                    var pl = v.split('|');
1266                    areacode = pl[0];
1267                    areastr = pl[1];
1268                }
1269                else {
1270                    areastr = v;
1271                }
1272                $(this).attr("areacode", areacode).attr("areatitle", areastr);
1273                $(this).empty();
1274                InitExtAddress();
1275            });
1276
1277            $("span[classname = '" + classname + "'][relkey = '" + im + "'][countrytype]").each(function () {
1278                var v = ov[i][ix][im];
1279                var areacode = "";
1280                var areastr = "";
1281                if (v.indexOf('|') != -1) {
1282                    var pl = v.split('|');
1283                    areacode = pl[0];
1284                    areastr = pl[1];
1285                }
1286                else {
1287                    areastr = v;
1288                }
1289                $(this).attr("countrytitle", areacode).attr("countrycode", areastr);
1290                $(this).empty();
1291                InitExtCountry();
1292            });
1293
1294        }
1295    }
1296    if (ov[i].defaultoption != undefined && ov[i].defaultoption == "1") {
1297        $(".forminfo[reftype='" + savekey + "'] input[data-ref='defaultoption']").attr("checked", true);
1298    }
1299    else {
1300        $(".forminfo[reftype='" + savekey + "'] input[data-ref='defaultoption']").attr("checked", false);
1301
1302    }
1303 
1304    $(".forminfo[reftype='" + savekey + "'] select[onchange]").change();
1305    $(".forminfo[reftype='" + savekey + "']").show();
1306}
1307
1308
1309function InitInventoryDisplay(set, cb, goods) {
1310    var dset = eval('(' + set.PreferentInfo + ');');
1311    var r = set.Amount;
1312    if (goods != undefined) {
1313        var totalr = 0;
1314        for (var m = 0; m < goods.Inventores.length; m++) {
1315            totalr += parseFloat(goods.Inventores[m].Amount);
1316        }
1317        r = totalr;
1318    }
1319    var globalset = {};
1320    if (GoodsGlobalSettings["stockseting"] != undefined) {
1321        globalset = eval('(' + GoodsGlobalSettings["stockseting"] + ');');
1322    }
1323    var useglobal = false;
1324    if (globalset["useglobalset"] != undefined && globalset["useglobalset"] == "1") {
1325        useglobal = true;
1326    }
1327    var globalset = function () {
1328        if (GoodsGlobalSettings["stockseting"] != undefined) {
1329            var glset = eval('(' + GoodsGlobalSettings["stockseting"] + ');');
1330            if (glset["stockdisplay"] == "01") {
1331                r = glset["stockcontent"];
1332            }
1333            else if (glset["stockdisplay"] == "02") {
1334                var items = glset["stockcontent"];
1335                var floatAmount = parseFloat(set.Amount);
1336                for (var i = 0; i < items.length; i++) {
1337                    var floatValue = parseFloat(items[i]["value"]);
1338                    var sque = '(' + floatAmount + ' ' + (items[i].symbol == "=" ? "==" : items[i].symbol) + ' ' + floatValue + ');';
1339                    var able = eval(sque);
1340                    if (able) {
1341                        if (items[i].type == "02") {
1342                            r = items[i].content;
1343                        }
1344                        break;
1345                    }
1346                }
1347            }
1348            else if (glset["stockdisplay"] == "04") {
1349                if (dset["zAmount"] != undefined) {
1350                    if (!isNaN(dset["zAmount"])) {
1351                        r = parseInt(dset["zAmount"]);
1352                        if (eval(r) > 10) {
1353                            r = 10;
1354                        }
1355                    }
1356                }
1357
1358            }
1359        }
1360    };
1361    if (useglobal) {
1362        globalset();
1363    }
1364    else {
1365
1366        if (dset["stockseting"] != undefined) {
1367            var sset;
1368            if (typeof (dset["stockseting"]) == "string") {
1369                sset = eval('(' + dset["stockseting"] + ');');
1370            }
1371            else {
1372                sset = dset["stockseting"];
1373            }
1374            var stockdisplay = sset["stockdisplay"];
1375            if (stockdisplay == "00") {
1376                //使用系统全局设置
1377                globalset();
1378            } else if (stockdisplay == "04") {
1379                if (dset["zAmount"] != undefined) {
1380                    if (!isNaN(dset["zAmount"])) {
1381                        r = parseInt(dset["zAmount"]);
1382                        if (eval(r) > 10) {
1383                            r = 10;
1384                        }
1385                    }
1386                }
1387            }
1388            else {
1389                var items = sset["stockcontent"];
1390                var floatAmount = parseFloat(set.Amount);
1391                for (var i = 0; i < items.length; i++) {
1392                    var floatValue = parseFloat(items[i]["value"]);
1393                    var sque = '(' + floatAmount + ' ' + (items[i].symbol == "=" ? "==" : items[i].symbol) + ' ' + floatValue + ');';
1394                    var able = eval(sque);
1395                    if (able) {
1396                        if (items[i].type == "02") {
1397                            r = items[i].content;
1398                        }
1399                        break;
1400                    }
1401                }
1402            }
1403        }
1404        else {
1405            globalset();
1406        }
1407
1408    }
1409    if (cb != undefined) {
1410        cb(r);
1411    }
1412    r = '<span id="stockinventory_' + set.Inventory_id + '">' + r + '</span>';
1413
1414    return r;
1415}
1416
1417function SaveInfo(o,savekey) {
1418    
1419    VerifyFormData({ el: ".forminfo[reftype='" + savekey + "']" }, function (postdata, extstr, extjson) {
1420        eval('var ovl =' + savekey + '_ValCfg;');
1421        var ov = ovl.val;
1422        extjson = $.extend(postdata, extjson);
1423        if (extjson.defaultoption != undefined && extjson.defaultoption == "1") {
1424            for (var k = 0; k < ov.length; k++) {
1425                ov[k]["defaultoption"] = "0";
1426            }
1427        }
1428        else {
1429            extjson.defaultoption = "0";
1430        }
1431        if ($("input[type='button'][savekey='" + savekey + "']").val() == rclng.edit) {
1432            var idx = $("input[type='button'][savekey='" + savekey + "']").attr("editkey");
1433            if (idx != "-1" && idx != "") {
1434                var i = parseInt(idx);
1435               // ov[i] = extjson;
1436                $.extend(ov[i], extjson);
1437            }
1438        }
1439        else {
1440            ov.push(extjson);
1441        }
1442        var save = function () {
1443            extdata = JSON2.stringify(ov);
1444            var saveplu = $(o).attr("refplu");
1445            Web960.Web.index.UpdateUserComment("", saveplu, savekey, extdata, function (res) {
1446                AjaxReturn(res, function () {
1447                    var rv = res.value;
1448                    if (rv.Status == "1") {
1449                        ClearFormData({ el: ".forminfo[reftype='" + savekey + "']" }, function () {
1450
1451                            eval(savekey + '_ValCfg.val=ov;');
1452                            eval('var tv=' + savekey + '_ValCfg;');
1453                            eval('var cfg=' + savekey + '_Cfg;');
1454                            $("input[type='button'][savekey='" + savekey + "']").val(rclng.addnew).attr("editkey", "");
1455                            InitOrderAccountInfoHTML(tv, cfg, 1);
1456                            $(".forminfo[reftype='" + savekey + "']").hide();
1457                            GetTotalPriceOfCart();
1458                        });
1459                    }
1460                    alert(rv.ClientMsg);
1461
1462                });
1463
1464            });
1465        };
1466        var FGuid = function (i) {
1467            if (i < ov.length) {
1468                if (ov[i].id == undefined) {
1469                    //需要获取一个guid
1470                    Guid(function (guid) {
1471                        ov[i]["id"] = guid;
1472                        FGuid(i + 1);
1473                    });
1474                }
1475                else {
1476                    FGuid(i + 1);
1477                }
1478            }
1479            else {
1480                save();
1481            }
1482
1483        }
1484        FGuid(0);
1485    });
1486}
1487
1488function GetYunFeiProInfo(ov)
1489{
1490    
1491    var v = "";
1492    if (GoodsGlobalSettings.yunfeisetting != undefined) {
1493        var set = eval('(' + GoodsGlobalSettings.yunfeisetting + ');');
1494        if (set.yunfeicity_extkey != undefined)
1495        {
1496            if (set.yunfeicity_extkey != "")
1497            {
1498                var params = set.yunfeicity_extkey.split('.');
1499                var mmx;
1500                for (var i = 0; i < params.length; i++)
1501                {
1502                  
1503                    ov = ov[params[i]];
1504                  
1505                }
1506                if (ov != undefined && ov != null && ov != "")
1507                {
1508                    v = ov;
1509                }
1510                
1511            }
1512        }
1513    }
1514
1515    return v;
1516}

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.