U.U.Money.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. Namespace.register("U.U.Money");
  2. //获取查看区
  3. U.U.Money.GQY = function () {
  4. var _UDOD = $("#U_MYContent")[0];
  5. (_UDOD == null) && (_UDOD = $("div#U_MYContent",
  6. U.M.Window_Create([1, "0", "0", "85%", "85%", "U_MY", "购物", "", "", "no", false, true, false, ""]))[0]) && (U.D.Tb.WindowRestore(_UDOD.parentNode.parentNode, null, "云购中心"));
  7. return _UDOD;
  8. }
  9. //---------------------------------------------------------------------------商品购物车---------------------------------------------------------------------------
  10. //购物车实体
  11. U.U.Money.ET = function () {
  12. var i, _UDE = ["BuyMoney", "BuyNum", "BuyTime", "BuyUser", "CargoID", "CargoName", "IFExist", "ShopID", "CargoImg"]
  13. for (i = 0; i < arguments.length; i++) {
  14. this[_UDE[i]] = arguments[i];
  15. }
  16. }
  17. //获取购物车
  18. U.U.Money.CSCT = function () {
  19. var _UDOD = U.U.Money.GQY(),
  20. _UDE = US.userInfo.GWC;
  21. (_UDE == null) && (_UDE = US.userInfo.GWC = { "ET": null });
  22. _UDE = _UDE["ET"];
  23. if (_UDE) {
  24. _UDOD.innerHTML = "";
  25. U.U.Money.PCSCT(_UDOD, _UDE);
  26. } //打印购物车
  27. else { U.A.Request("Money.SelectShopCartInfo", ['SelectShopCartInfo', US.userInfo.userid], U.U.Money.AsynCSCT, [""]); U.D.PopupWindow(_UDOD.parentNode.parentNode); } //获取用户购物车
  28. }
  29. //购物车异步
  30. U.U.Money.AsynCSCT = function (r) {
  31. US.userInfo.GWC["ET"] = r.value[0];
  32. U.U.Money.CSCT();
  33. }
  34. //打印购物车
  35. U.U.Money.PCSCT = function (UDOD, UDE) {
  36. if (UDE.length != 0) {
  37. var i, _UDAD, _UDOD, _UDTD, _UDCD, _UDSD, _UDWD, _UDBD, _UDUD, _UDMD,
  38. _UM = 0,
  39. _TF = UDE[0]["Inventory"] != null;
  40. _UDAD = $$("div", { "className": "U_MY_A" });
  41. _UDOD = $$("div", { "className": "U_MY_AT" }, _UDAD);
  42. $$("div", { "className": "U_MY_ATO", "innerHTML": "商品" }, _UDOD);
  43. $$("div", { "className": "U_MY_ATT", "innerHTML": "单价(元)" }, _UDOD);
  44. $$("div", { "className": "U_MY_ATS", "innerHTML": _TF ? "库存" : "数量" }, _UDOD);
  45. $$("div", { "className": "U_MY_ATS", "innerHTML": _TF ? "上架时间" : "统计(元)" }, _UDOD);
  46. $$("div", { "className": "U_MY_ATS", "innerHTML": "操作" }, _UDOD);
  47. _UDTD = $$("div", { "className": "U_MY_AC" }, _UDAD);
  48. for (i = 0; i < UDE.length; i++) {
  49. _UDCD = $$("div", { "className": "U_MY_ACA" }, _UDTD);
  50. _UDWD = $$("div", { "className": "U_MY_ATO U_MY_ACAO" }, _UDCD);
  51. _UDSD = $$("div", { "className": "U_MY_ACI", "title": "查看详情", "onclick": [[U.U.Money.MGC, [UDE[i]["CargoID"] || UDE[i]["CargoId"]]]] }, _UDWD);
  52. $$("img", { "onerror": [[U.M.ImgError, ["this", 1]]], "src": UDE[i]["CargoImg"] }, _UDSD);
  53. $$("div", { "className": "U_MY_ACW", "innerHTML": (UDE[i]["CargoDescribe"] || UDE[i]["CargoName"]) }, _UDWD);
  54. $$("div", { "className": "U_MY_ATT", "innerHTML": UDE[i]["BuyMoney"] || UDE[i]["SingleMoney"], "style": { "marginLeft": "0px"} }, _UDCD);
  55. $$("div", { "className": "U_MY_ATS", "innerHTML": UDE[i]["BuyNum"] || UDE[i]["Inventory"] }, _UDCD);
  56. $$("div", { "className": "U_MY_ATS", "style": { "color": _TF ? "" : "red" }, "innerHTML": _TF ? UDE[i]["Time"].split("T")[0] : (UDE[i]["BuyMoney"] * UDE[i]["BuyNum"]) }, _UDCD);
  57. _UM += UDE[i]["BuyMoney"] * UDE[i]["BuyNum"];
  58. $$("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);
  59. }
  60. if (!_TF) {
  61. _UDUD = $$("div", { "className": "U_MY_AD" }, _UDAD);
  62. _UDMD = $$("div", { "className": "U_MY_ADT" }, _UDUD);
  63. $$("div", { "className": "U_MY_ADTL", "innerHTML": "合计(不含运费):" }, _UDMD);
  64. $$("div", { "id": "MoneyUM", "className": "U_MY_ADTR", "innerHTML": "¥" + _UM }, _UDMD);
  65. $$("div", { "className": "U_MY_ADD UD_Radius", "innerHTML": "提交订单", "onclick": U.M.apply(null, "alert('服务暂不开放');") }, _UDUD);
  66. }
  67. }
  68. else { _UDAD = $$("div", { "className": "U_MY_AO", "innerHTML": "暂无物品在购物车" }); }
  69. UDOD.appendChild(_UDAD);
  70. }
  71. //添加到购物车
  72. U.U.Money.AddGC = function (UDE, UDED) {
  73. UDED = UDED.innerHTML || UDED;
  74. if (U.MS.Number.test(UDED) && UDED > 0 && UDE["Inventory"] > 0 && UDE["Inventory"] - UDED > 0) {
  75. U.A.Request("Money.InsertShopCart", ['InsertShopCart', UDE["CargoId"], US.userInfo.userid, "0", UDED], U.U.Money.AsynAddGC, ["", UDE, UDED]);
  76. } //http://money.1473.cn
  77. else {
  78. U.Alert("库存不足或输入的非法数据");
  79. }
  80. }
  81. //购物车
  82. U.U.Money.AsynAddGC = function (r) {
  83. var context = r.context,
  84. _UDE = context[1];
  85. r = r.value;
  86. if (r) {
  87. if (US.userInfo.GWC) {
  88. _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"]);
  89. US.userInfo.GWC["ET"].push(_UDE);
  90. }
  91. U.Alert("已添加到购物车");
  92. }
  93. }
  94. //删除购物车
  95. U.U.Money.SCGC = function (SID, UDOD) {
  96. U.A.Request("Money.DeleteShopCartInfo", ['DeleteShopCartInfo', SID], U.U.Money.AsynSCGC, ["", SID, UDOD]); U.Alert("正在移除商品"); //http://money.1473.cn
  97. }
  98. //删除购物车
  99. U.U.Money.AsynSCGC = function (r) {
  100. var _UTE, context = r.context;
  101. r = r.value;
  102. 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("商品移除成功"); }
  103. }
  104. //获取购物车的东西
  105. U.U.Money.GetGC = function (CID, TF) {
  106. var i, _UTE, _UDE = US.userInfo.GWC["ET"];
  107. for (i = 0; i < _UDE.length; i++) {
  108. if (_UDE[i]["ShopID"] == CID) {
  109. _UTE = _UDE[i];
  110. (TF == "D") && (_UTE = _UDE.splice(i, 1)[0]);
  111. return _UTE;
  112. }
  113. }
  114. }
  115. //删除物品总价相对应减少
  116. U.U.Money.SetMoneyUM = function (UNUM) {
  117. var _UDMD = $("#MoneyUM")[0],
  118. _UM = _UDMD.innerHTML.replace("¥", "");
  119. _UDMD.innerHTML = _UM - UNUM;
  120. }
  121. //-------------------------------------------------------------------------------------云端商品------------------------------------------------------------------------
  122. U.U.Money.CP = {
  123. "ET": null,
  124. "P": 0,
  125. "MS": {}
  126. };
  127. //商品信息提取
  128. U.U.Money.GC = function (TP) {
  129. // var _UDOD = U.U.Money.GQY(),
  130. // _UDE = U.U.Money.GPGC(TP);
  131. // if (_UDE[0]) {
  132. // _UDOD.innerHTML = "";
  133. // U.U.Money.PGC(_UDOD, _UDE[0], TP);
  134. // }
  135. // else {
  136. // U.A.Request("Money.SelectCargoInfo", ["SelectCargoInfo", (_UDE[1] * 60, (_UDE[1] + 1) * 60 - 1]), U.U.Money.AsynGC, [_UDOD, TP, _UDE[1]]);
  137. // } //http://money.1473.cn
  138. // if (_UDE) {
  139. // U.D.PopupWindow(_UDOD.parentNode.parentNode);
  140. // }
  141. }
  142. //异步获取云端商品
  143. U.U.Money.AsynGC = function (requset) {
  144. var context = requset.context;
  145. requset = requset.value;
  146. (U.U.Money.CP["ET"] == null) && (U.U.Money.CP["ET"] = []);
  147. U.U.Money.CP["ET"][context[2]] = requset[0]; U.U.Money.CP["P"] = requset[1][0]["AC"]
  148. U.U.Money.GC(context[1]);
  149. }
  150. //打印云端商品
  151. U.U.Money.PGC = function (UDOD, UDE, TP) {
  152. if (UDE.length > 0) {
  153. U.U.Money.PCSCT(UDOD, UDE);
  154. U.PG.PPage(UDOD, U.U.Money.CP["P"], TP, 20, { "fun": [[U.U.Money.GC, [TP]]], "page": [0] });
  155. }
  156. }
  157. //根据页数获取商品
  158. U.U.Money.GPGC = function (TP) {
  159. var _UDE = U.U.Money.CP["ET"],
  160. _UP = parseInt(TP / 3), _S, _E;
  161. TP = TP % 3; _E = TP * 20; _S = _E - 20;
  162. if (_UDE && (_UDE = _UDE[_UP])) { _UDE = _UDE.slice(_S, _E); }
  163. return [_UDE, _UP];
  164. }
  165. //---------------------------------------------------------------------------------商品描述---------------------------------------------------------------------------
  166. //商品描述
  167. U.U.Money.MGC = function (CID) {
  168. var _UDOD = U.U.Money.GQY(),
  169. _UDE = U.U.Money.CP["MS"][CID];
  170. if (_UDE) {
  171. _UDOD.innerHTML = ""; U.U.Money.PMGC(_UDOD, _UDE);
  172. }
  173. else {
  174. U.A.Request("Money.SelectOCargoInfo", ["SelectOCargoInfo", CID], U.U.Money.AsynMGC, [_UDOD, CID]);
  175. } //http://money.1473.cn
  176. if (_UDE) {
  177. U.D.PopupWindow(_UDOD.parentNode.parentNode);
  178. }
  179. }
  180. //异步获取云端商品
  181. U.U.Money.AsynMGC = function (requset) {
  182. var context = requset.context;
  183. U.U.Money.CP["MS"][context[1]] = requset.value[0][0];
  184. U.U.Money.MGC(context[1]);
  185. }
  186. //打印商品
  187. U.U.Money.PMGC = function (UDOD, UDE) {
  188. var _UDOD, _UDTD, _UDSD, _UDAD, _UDED, _UDGD, _UDPD, _UDJD, _UDYD, _UDRD;
  189. _UDOD = $$("div", { "className": "U_MY_S" }, UDOD);
  190. _UDTD = $$("div", { "className": "U_MY_SM" }, _UDOD);
  191. _UDSD = $$("div", { "className": "U_MY_SML" }, _UDTD);
  192. _UDAD = $$("div", { "className": "U_MY_SMLI" }, _UDSD);
  193. $$("img", { "src": UDE["CargoImg"] }, _UDAD);
  194. _UDED = $$("div", { "className": "U_MY_SMR" }, _UDTD);
  195. $$("div", { "className": "U_MY_SMRT", "innerHTML": UDE["CargoName"] }, _UDED);
  196. $$("div", { "className": "U_MY_SMRC", "innerHTML": UDE["CargoDescribe"] }, _UDED);
  197. _UDGD = $$("div", { "className": "U_MY_SMRB U_MY_R" }, _UDED);
  198. $$("div", { "className": "U_MY_SMRBS", "innerHTML": "零售价" }, _UDGD);
  199. $$("div", { "className": "U_MY_SMRBL", "innerHTML": "¥" + UDE["SingleMoney"] }, _UDGD);
  200. $$("div", {});
  201. _UDPD = $$("div", { "className": "U_MY_SMRS" }, _UDED);
  202. $$("div", { "className": "U_MY_SMRSS", "innerHTML": "数量" }, _UDPD);
  203. _UDJD = $$("div", { "className": "U_MY_SMRSI", "contentEditable": "true", "innerHTML": 1 }, _UDPD);
  204. _UDYD = $$("div", { "className": "U_MY_SMRSZ" }, _UDPD);
  205. $$("div", { "className": "U_MY_SMRSZS", "onclick": [[U.U.Money.APSL, [_UDJD, true]]] }, _UDYD);
  206. $$("div", { "className": "U_MY_SMRSZX", "onclick": [[U.U.Money.APSL, [_UDJD]]] }, _UDYD);
  207. $$("div", { "className": "U_MY_SMRSC", "innerHTML": "库存" + UDE["Inventory"] + "件" }, _UDPD);
  208. _UDRD = $$("div", { "className": "U_MY_SMRD" }, _UDED);
  209. $$("div", { "className": "U_MY_ADD", "innerHTML": "立刻购买", "onclick": [[U.U.Money.AddGC, [UDE, _UDJD]]] }, _UDRD);
  210. $$("div", { "className": "U_MY_ADD U_MY_SMRDR", "innerHTML": "加入购物车", "onclick": [[U.U.Money.AddGC, [UDE, _UDJD]]] }, _UDRD);
  211. $$("div", { "className": "U_MY_SW", "innerHTML": "商品描述" }, _UDOD);
  212. }
  213. //增加降低数量
  214. U.U.Money.APSL = function (UDJD, TF) {
  215. var _I = (U.MS.Number.test(UDJD.innerHTML) && UDJD.innerHTML > 0 && UDE["Inventory"] > 0 && UDE["Inventory"] - UDJD.innerHTML > 0) ? UDJD.innerHTML : 0;
  216. if (TF) { _I++; }
  217. else { _I--; }
  218. UDJD.innerHTML = _I;
  219. }