Namespace.register("U.U.Money"); //获取查看区 U.U.Money.GQY = function () { var _UDOD = $("#U_MYContent")[0]; (_UDOD == null) && (_UDOD = $("div#U_MYContent", U.M.Window_Create([1, "0", "0", "85%", "85%", "U_MY", "购物", "", "", "no", false, true, false, ""]))[0]) && (U.D.Tb.WindowRestore(_UDOD.parentNode.parentNode, null, "云购中心")); return _UDOD; } //---------------------------------------------------------------------------商品购物车--------------------------------------------------------------------------- //购物车实体 U.U.Money.ET = function () { var i, _UDE = ["BuyMoney", "BuyNum", "BuyTime", "BuyUser", "CargoID", "CargoName", "IFExist", "ShopID", "CargoImg"] for (i = 0; i < arguments.length; i++) { this[_UDE[i]] = arguments[i]; } } //获取购物车 U.U.Money.CSCT = function () { var _UDOD = U.U.Money.GQY(), _UDE = US.userInfo.GWC; (_UDE == null) && (_UDE = US.userInfo.GWC = { "ET": null }); _UDE = _UDE["ET"]; if (_UDE) { _UDOD.innerHTML = ""; U.U.Money.PCSCT(_UDOD, _UDE); } //打印购物车 else { U.A.Request("Money.SelectShopCartInfo", ['SelectShopCartInfo', US.userInfo.userid], U.U.Money.AsynCSCT, [""]); U.D.PopupWindow(_UDOD.parentNode.parentNode); } //获取用户购物车 } //购物车异步 U.U.Money.AsynCSCT = function (r) { US.userInfo.GWC["ET"] = r.value[0]; U.U.Money.CSCT(); } //打印购物车 U.U.Money.PCSCT = function (UDOD, UDE) { if (UDE.length != 0) { var i, _UDAD, _UDOD, _UDTD, _UDCD, _UDSD, _UDWD, _UDBD, _UDUD, _UDMD, _UM = 0, _TF = UDE[0]["Inventory"] != null; _UDAD = $$("div", { "className": "U_MY_A" }); _UDOD = $$("div", { "className": "U_MY_AT" }, _UDAD); $$("div", { "className": "U_MY_ATO", "innerHTML": "商品" }, _UDOD); $$("div", { "className": "U_MY_ATT", "innerHTML": "单价(元)" }, _UDOD); $$("div", { "className": "U_MY_ATS", "innerHTML": _TF ? "库存" : "数量" }, _UDOD); $$("div", { "className": "U_MY_ATS", "innerHTML": _TF ? "上架时间" : "统计(元)" }, _UDOD); $$("div", { "className": "U_MY_ATS", "innerHTML": "操作" }, _UDOD); _UDTD = $$("div", { "className": "U_MY_AC" }, _UDAD); for (i = 0; i < UDE.length; i++) { _UDCD = $$("div", { "className": "U_MY_ACA" }, _UDTD); _UDWD = $$("div", { "className": "U_MY_ATO U_MY_ACAO" }, _UDCD); _UDSD = $$("div", { "className": "U_MY_ACI", "title": "查看详情", "onclick": [[U.U.Money.MGC, [UDE[i]["CargoID"] || UDE[i]["CargoId"]]]] }, _UDWD); $$("img", { "onerror": [[U.M.ImgError, ["this", 1]]], "src": UDE[i]["CargoImg"] }, _UDSD); $$("div", { "className": "U_MY_ACW", "innerHTML": (UDE[i]["CargoDescribe"] || UDE[i]["CargoName"]) }, _UDWD); $$("div", { "className": "U_MY_ATT", "innerHTML": UDE[i]["BuyMoney"] || UDE[i]["SingleMoney"], "style": { "marginLeft": "0px"} }, _UDCD); $$("div", { "className": "U_MY_ATS", "innerHTML": UDE[i]["BuyNum"] || UDE[i]["Inventory"] }, _UDCD); $$("div", { "className": "U_MY_ATS", "style": { "color": _TF ? "" : "red" }, "innerHTML": _TF ? UDE[i]["Time"].split("T")[0] : (UDE[i]["BuyMoney"] * UDE[i]["BuyNum"]) }, _UDCD); _UM += UDE[i]["BuyMoney"] * UDE[i]["BuyNum"]; $$("div", { "title": _TF ? "加入购物车" : "移除", "className": "U_MY_ATS", "innerHTML": _TF ? "添加" : "移除", "style": { "color": "#7e7e7e" }, "onclick": _TF ? [[U.U.Money.AddGC, [UDE[i], 1]]] : [[U.U.Money.SCGC, [UDE[i]["ShopID"], _UDCD]]] }, _UDCD); } if (!_TF) { _UDUD = $$("div", { "className": "U_MY_AD" }, _UDAD); _UDMD = $$("div", { "className": "U_MY_ADT" }, _UDUD); $$("div", { "className": "U_MY_ADTL", "innerHTML": "合计(不含运费):" }, _UDMD); $$("div", { "id": "MoneyUM", "className": "U_MY_ADTR", "innerHTML": "¥" + _UM }, _UDMD); $$("div", { "className": "U_MY_ADD UD_Radius", "innerHTML": "提交订单", "onclick": U.M.apply(null, "alert('服务暂不开放');") }, _UDUD); } } else { _UDAD = $$("div", { "className": "U_MY_AO", "innerHTML": "暂无物品在购物车" }); } UDOD.appendChild(_UDAD); } //添加到购物车 U.U.Money.AddGC = function (UDE, UDED) { UDED = UDED.innerHTML || UDED; if (U.MS.Number.test(UDED) && UDED > 0 && UDE["Inventory"] > 0 && UDE["Inventory"] - UDED > 0) { U.A.Request("Money.InsertShopCart", ['InsertShopCart', UDE["CargoId"], US.userInfo.userid, "0", UDED], U.U.Money.AsynAddGC, ["", UDE, UDED]); } //http://money.1473.cn else { U.Alert("库存不足或输入的非法数据"); } } //购物车 U.U.Money.AsynAddGC = function (r) { var context = r.context, _UDE = context[1]; r = r.value; if (r) { if (US.userInfo.GWC) { _UDE = U.U.Money.GetGC(_UDE["CargoId"]) || new U.U.Money.ET(_UDE["SingleMoney"], context[2], U.MT.getYearMonthDay(null, "String"), US.userInfo.userid, _UDE["CargoId"], _UDE["CargoName"], 0, r[0][0]["SID"], _UDE["CargoImg"]); US.userInfo.GWC["ET"].push(_UDE); } U.Alert("已添加到购物车"); } } //删除购物车 U.U.Money.SCGC = function (SID, UDOD) { U.A.Request("Money.DeleteShopCartInfo", ['DeleteShopCartInfo', SID], U.U.Money.AsynSCGC, ["", SID, UDOD]); U.Alert("正在移除商品"); //http://money.1473.cn } //删除购物车 U.U.Money.AsynSCGC = function (r) { var _UTE, context = r.context; r = r.value; if (r) { _UTE = U.U.Money.GetGC(context[1], "D"); U.U.Money.SetMoneyUM(_UTE["BuyNum"] * _UTE["BuyMoney"]); context[2].parentNode.removeChild(context[2]); U.Alert("商品移除成功"); } } //获取购物车的东西 U.U.Money.GetGC = function (CID, TF) { var i, _UTE, _UDE = US.userInfo.GWC["ET"]; for (i = 0; i < _UDE.length; i++) { if (_UDE[i]["ShopID"] == CID) { _UTE = _UDE[i]; (TF == "D") && (_UTE = _UDE.splice(i, 1)[0]); return _UTE; } } } //删除物品总价相对应减少 U.U.Money.SetMoneyUM = function (UNUM) { var _UDMD = $("#MoneyUM")[0], _UM = _UDMD.innerHTML.replace("¥", ""); _UDMD.innerHTML = _UM - UNUM; } //-------------------------------------------------------------------------------------云端商品------------------------------------------------------------------------ U.U.Money.CP = { "ET": null, "P": 0, "MS": {} }; //商品信息提取 U.U.Money.GC = function (TP) { // var _UDOD = U.U.Money.GQY(), // _UDE = U.U.Money.GPGC(TP); // if (_UDE[0]) { // _UDOD.innerHTML = ""; // U.U.Money.PGC(_UDOD, _UDE[0], TP); // } // else { // U.A.Request("Money.SelectCargoInfo", ["SelectCargoInfo", (_UDE[1] * 60, (_UDE[1] + 1) * 60 - 1]), U.U.Money.AsynGC, [_UDOD, TP, _UDE[1]]); // } //http://money.1473.cn // if (_UDE) { // U.D.PopupWindow(_UDOD.parentNode.parentNode); // } } //异步获取云端商品 U.U.Money.AsynGC = function (requset) { var context = requset.context; requset = requset.value; (U.U.Money.CP["ET"] == null) && (U.U.Money.CP["ET"] = []); U.U.Money.CP["ET"][context[2]] = requset[0]; U.U.Money.CP["P"] = requset[1][0]["AC"] U.U.Money.GC(context[1]); } //打印云端商品 U.U.Money.PGC = function (UDOD, UDE, TP) { if (UDE.length > 0) { U.U.Money.PCSCT(UDOD, UDE); U.PG.PPage(UDOD, U.U.Money.CP["P"], TP, 20, { "fun": [[U.U.Money.GC, [TP]]], "page": [0] }); } } //根据页数获取商品 U.U.Money.GPGC = function (TP) { var _UDE = U.U.Money.CP["ET"], _UP = parseInt(TP / 3), _S, _E; TP = TP % 3; _E = TP * 20; _S = _E - 20; if (_UDE && (_UDE = _UDE[_UP])) { _UDE = _UDE.slice(_S, _E); } return [_UDE, _UP]; } //---------------------------------------------------------------------------------商品描述--------------------------------------------------------------------------- //商品描述 U.U.Money.MGC = function (CID) { var _UDOD = U.U.Money.GQY(), _UDE = U.U.Money.CP["MS"][CID]; if (_UDE) { _UDOD.innerHTML = ""; U.U.Money.PMGC(_UDOD, _UDE); } else { U.A.Request("Money.SelectOCargoInfo", ["SelectOCargoInfo", CID], U.U.Money.AsynMGC, [_UDOD, CID]); } //http://money.1473.cn if (_UDE) { U.D.PopupWindow(_UDOD.parentNode.parentNode); } } //异步获取云端商品 U.U.Money.AsynMGC = function (requset) { var context = requset.context; U.U.Money.CP["MS"][context[1]] = requset.value[0][0]; U.U.Money.MGC(context[1]); } //打印商品 U.U.Money.PMGC = function (UDOD, UDE) { var _UDOD, _UDTD, _UDSD, _UDAD, _UDED, _UDGD, _UDPD, _UDJD, _UDYD, _UDRD; _UDOD = $$("div", { "className": "U_MY_S" }, UDOD); _UDTD = $$("div", { "className": "U_MY_SM" }, _UDOD); _UDSD = $$("div", { "className": "U_MY_SML" }, _UDTD); _UDAD = $$("div", { "className": "U_MY_SMLI" }, _UDSD); $$("img", { "src": UDE["CargoImg"] }, _UDAD); _UDED = $$("div", { "className": "U_MY_SMR" }, _UDTD); $$("div", { "className": "U_MY_SMRT", "innerHTML": UDE["CargoName"] }, _UDED); $$("div", { "className": "U_MY_SMRC", "innerHTML": UDE["CargoDescribe"] }, _UDED); _UDGD = $$("div", { "className": "U_MY_SMRB U_MY_R" }, _UDED); $$("div", { "className": "U_MY_SMRBS", "innerHTML": "零售价" }, _UDGD); $$("div", { "className": "U_MY_SMRBL", "innerHTML": "¥" + UDE["SingleMoney"] }, _UDGD); $$("div", {}); _UDPD = $$("div", { "className": "U_MY_SMRS" }, _UDED); $$("div", { "className": "U_MY_SMRSS", "innerHTML": "数量" }, _UDPD); _UDJD = $$("div", { "className": "U_MY_SMRSI", "contentEditable": "true", "innerHTML": 1 }, _UDPD); _UDYD = $$("div", { "className": "U_MY_SMRSZ" }, _UDPD); $$("div", { "className": "U_MY_SMRSZS", "onclick": [[U.U.Money.APSL, [_UDJD, true]]] }, _UDYD); $$("div", { "className": "U_MY_SMRSZX", "onclick": [[U.U.Money.APSL, [_UDJD]]] }, _UDYD); $$("div", { "className": "U_MY_SMRSC", "innerHTML": "库存" + UDE["Inventory"] + "件" }, _UDPD); _UDRD = $$("div", { "className": "U_MY_SMRD" }, _UDED); $$("div", { "className": "U_MY_ADD", "innerHTML": "立刻购买", "onclick": [[U.U.Money.AddGC, [UDE, _UDJD]]] }, _UDRD); $$("div", { "className": "U_MY_ADD U_MY_SMRDR", "innerHTML": "加入购物车", "onclick": [[U.U.Money.AddGC, [UDE, _UDJD]]] }, _UDRD); $$("div", { "className": "U_MY_SW", "innerHTML": "商品描述" }, _UDOD); } //增加降低数量 U.U.Money.APSL = function (UDJD, TF) { var _I = (U.MS.Number.test(UDJD.innerHTML) && UDJD.innerHTML > 0 && UDE["Inventory"] > 0 && UDE["Inventory"] - UDJD.innerHTML > 0) ? UDJD.innerHTML : 0; if (TF) { _I++; } else { _I--; } UDJD.innerHTML = _I; }