暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dummyproduct.js 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. function ramProductsInit() {
  2. let RAM_ID = "";
  3. async function init() {
  4. let id;
  5. if (
  6. location.search == "" &&
  7. (location.href.includes("laptops") || location.href.includes("allinones"))
  8. ) {
  9. id = await getallproductsFun();
  10. } else {
  11. id = await getProductIdService();
  12. }
  13. getRamData(id);
  14. }
  15. async function getProductsIds(nameArr) {
  16. let resData = await API_SERVICES_ACTIONS.getAPIService(
  17. `apis/v4/bizgaze/integrations/products/getallproducts`,
  18. true
  19. );
  20. if (resData.isError) {
  21. toasterHelper("error", "Something went wrong!");
  22. return;
  23. }
  24. let res = resData.response;
  25. res = JSON.parse(res.result);
  26. let ids = [];
  27. for (let i = 0; i < nameArr.length; i++) {
  28. const currName = nameArr[i];
  29. let id = res.find((item) => {
  30. if (currName === item.productname) {
  31. return item.productid;
  32. }
  33. });
  34. if (id) {
  35. ids.push(id);
  36. }
  37. }
  38. return ids;
  39. }
  40. async function getallproductsFun() {
  41. let laptopStr = ["FYRO Flagship", "Zeno Dualbook", "Zeno Sleekbook"];
  42. let allInOnesStr = ["AIO Zeno", "AIO Fyro"];
  43. let name = window.location.href;
  44. name = name.includes("laptops") ? laptopStr : allInOnesStr;
  45. const ids = await getProductsIds(name);
  46. console.log(ids);
  47. return ids;
  48. }
  49. function getProductIdService() {
  50. return new Promise(async (reslove, reject) => {
  51. let resData = await API_SERVICES_ACTIONS.getAPIService(
  52. `apis/v4/bizgaze/integrations/products/getallproducts`,
  53. true
  54. );
  55. if (resData.isError) {
  56. alert(resData.errorMsg.message);
  57. return;
  58. }
  59. let res = resData.response;
  60. res = JSON.parse(res.result);
  61. // console.log(res);
  62. let searchName = window.location.search.split("?")[1];
  63. let urlPathName = window.location.pathname;
  64. let searchTerm = "";
  65. if (urlPathName.includes("ram")) {
  66. searchTerm = "RAM ORA";
  67. } else if (urlPathName.includes("storage")) {
  68. searchTerm = `SSD ORA`;
  69. } else {
  70. searchTerm = searchName.replaceAll("%20", " ");
  71. }
  72. let resultItem = [];
  73. if (searchTerm.toLowerCase() === "zeno") {
  74. for (let i = 0; i < res.length; i++) {
  75. if (
  76. res[i].productname.includes("Zeno Sleekbook") ||
  77. res[i].productname.includes("Zeno Dualbook")
  78. ) {
  79. resultItem.push(res[i]);
  80. }
  81. }
  82. return reslove(resultItem);
  83. } else if (searchTerm.toLowerCase() === "fyro") {
  84. for (let i = 0; i < res.length; i++) {
  85. if (res[i].productname.includes("FYRO Flagship")) {
  86. resultItem.push(res[i]);
  87. return reslove(resultItem);
  88. }
  89. }
  90. } else {
  91. for (let i = 0; i < res.length; i++) {
  92. if (res[i].productname.includes(searchTerm)) {
  93. resultItem.push(res[i]);
  94. }
  95. }
  96. return reslove(resultItem);
  97. }
  98. });
  99. }
  100. async function getRamData(ids) {
  101. let resData;
  102. let res;
  103. let data = [];
  104. let windowSearch = window.location.href;
  105. for (let i = 0; i < ids.length; i++) {
  106. let id = ids[i].productid;
  107. if (
  108. windowSearch.includes("laptops") ||
  109. windowSearch.includes("allinones")
  110. ) {
  111. resData = await API_SERVICES_ACTIONS.getAPIService(
  112. `apis/v4/Bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`,
  113. true
  114. );
  115. } else {
  116. resData = await API_SERVICES_ACTIONS.getAPIService(
  117. `apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`,
  118. true
  119. );
  120. }
  121. if (resData.isError) {
  122. alert(resData.errorMsg.message);
  123. return;
  124. }
  125. res = resData.response;
  126. res = JSON.parse(res.result);
  127. data = [...data, ...res];
  128. }
  129. console.log(data);
  130. let html = "";
  131. for (let i = 0; i < data.length; i++) {
  132. console.log(data[i].tagids);
  133. let tags_id = data[i].tagids;
  134. let tags_filter = tags_id.includes("106631360000087");
  135. let tags_filter_2 = tags_id.includes("106631360000088");
  136. let tags_filter_3 = tags_id.includes("106631360000089");
  137. if (
  138. tags_filter == false &&
  139. tags_filter_2 == false &&
  140. tags_filter_3 == false
  141. ) {
  142. if (data[i].itemname.includes("AIO Fyro - 32")) continue;
  143. html += getRamCardHTML(data[i]);
  144. } else {
  145. let data_name = tags_id.includes("106631360000087");
  146. let name_id = data[i].tagids.includes("106631360000087");
  147. if (data_name === true && name_id === true) {
  148. for (let j = 0; j < data.length; j++) {
  149. if (j == 0) {
  150. if (data[j].itemname.includes("AIO Fyro - 32")) continue;
  151. html += getRamCardHTML(data[i]);
  152. }
  153. }
  154. }
  155. }
  156. }
  157. $(".product_card_section").html(html);
  158. if (window.location.href.includes("?Zeno")) {
  159. $(".product_card_section div.ram_card:nth-child(1)").addClass("d-none");
  160. $(".product_card_section div.ram_card:nth-child(6)").addClass("d-none");
  161. }
  162. if (window.location.href.includes("?FYRO")) {
  163. $(".product_card_section div.ram_card:nth-child(3)").addClass("d-none");
  164. $(".product_card_section div.ram_card:nth-child(7)").addClass("d-none");
  165. $(".product_card_section div.ram_card:nth-child(8)").addClass("d-none");
  166. }
  167. // $('.ramcard').click(function(e){
  168. // let sku = $(e.target).data('itemid');
  169. // let itemid = $(e.target).data('itemid');
  170. // window.location.href = `/productdetails.html?productId=${RAM_ID}#itemid=${itemid}`
  171. // })
  172. }
  173. function getRamCardHTML({
  174. itemname,
  175. pricelist,
  176. itemid,
  177. sku,
  178. itemimageurl,
  179. productid,
  180. tagnames,
  181. }) {
  182. let img = itemimageurl
  183. ? imgServerNameBuild(itemimageurl)
  184. : "./dist/assets/imgs/nophoto.png";
  185. let tags = itemname.split("-");
  186. let ramTech = tags[tags.length - 2];
  187. let tag_name = tagnames.split("|");
  188. let gb = tags[tags.length - 1];
  189. const [currencySymbol, amount] = getCurrencySymbol(pricelist);
  190. let priceAmt = `${currencySymbol} ${amount}`;
  191. let detailPageName;
  192. let addSearch = "";
  193. if (window.location.href.includes("laptops")) {
  194. detailPageName = "laptopdetails";
  195. let name = itemname.toLowerCase().includes("zeno") ? "Zeno" : "Fyro";
  196. addSearch = `?${name}`;
  197. } else {
  198. detailPageName = "productdetails";
  199. }
  200. let color_name = tag_name[tag_name.length - 1].trim();
  201. let processor_name1 = tagnames.includes("i7");
  202. let processor_name2 = tagnames.includes("i5");
  203. let processor_name3 = tagnames.includes("i3");
  204. let dul_core = itemname.includes("Zeno Dualbook");
  205. let processor;
  206. if (processor_name1 === true) {
  207. if (dul_core === true) {
  208. processor = `i7`;
  209. } else {
  210. processor = `i5 / i7`;
  211. }
  212. } else if (processor_name2 === true) {
  213. if (dul_core === true) {
  214. processor = `i7`;
  215. } else {
  216. processor = `i5 / i7`;
  217. }
  218. } else if (processor_name3 === true) {
  219. processor = `i3`;
  220. } else if (itemname.includes("I7") || itemname.includes("i7")) {
  221. let fyro_data_2 = itemname.includes("RTX 4060");
  222. if (fyro_data_2 === true) {
  223. processor = `i5 / i7 / i9`;
  224. } else {
  225. processor = `i5 / i7`;
  226. }
  227. } else if (itemname.includes("I9") || itemname.includes("i9")) {
  228. let fyro_data_1 = itemname.includes("RTX 4050");
  229. let fyro_data_2 = itemname.includes("RTX 4060");
  230. if (fyro_data_1 === true || fyro_data_2 === true) {
  231. processor = `i5 / i7 / i9`;
  232. } else {
  233. processor = `i9`;
  234. }
  235. } else if (itemname.includes("I5") || itemname.includes("i5")) {
  236. let fyro_data = itemname.includes("RTX 4060");
  237. if (fyro_data === true) {
  238. processor = `i5 / i7 / i9`;
  239. } else {
  240. processor = `i5 / i7 / i9`;
  241. }
  242. }
  243. let item_color_1;
  244. let item_color_2;
  245. let item_color_3;
  246. let item_color_4;
  247. if (color_name == "Eucalyptus Green" || color_name == "Desert Brown") {
  248. item_color_1 = `#5e7975`;
  249. item_color_2 = `#624839`;
  250. item_color_3 = `#253746`;
  251. } else if (color_name == "Deep Sea Blue") {
  252. item_color_1 = `#5e7975`;
  253. item_color_2 = `#624839`;
  254. item_color_3 = `#253746`;
  255. } else {
  256. if (color_name.length <= 14) {
  257. item_color_4 = ``;
  258. } else {
  259. item_color_4 = `#0d0a08`;
  260. }
  261. }
  262. debugger;
  263. return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
  264. <div class="card border bg-white rounded-3 p-1 h-100">
  265. <a href="/${detailPageName}.html${addSearch}#productId=${productid}#itemid=${itemid}" class="">
  266. <img src="${img}" alt="${itemname}" class="p-5" style="width:350px;height:300px"></a>
  267. <div class="card-body">
  268. <a href="/${detailPageName}.html${addSearch}#productId=${productid}#itemid=${itemid}" class="">
  269. <h5 class="card-title satoshi_font mb-0 px-2 text-center font-weight-600">${itemname}</h5>
  270. </a>
  271. </div>
  272. <hr>
  273. <ul class="border-0 mb-0 d-flex h-100 justify-content-between px-md-3 px-4 list-group-flush p-0 text-secondary" style="list-style: none;">
  274. <li class="processor_name"><img src="../dist/assets/imgs/processor.svg" class="w-20p pe-1"/><span class="pt-1">${
  275. processor ? processor : ""
  276. }</span></li>
  277. <li class="d-flex justify-content-between">
  278. <p item_color=${item_color_1} class="colors mb-0 me-1" ${
  279. item_color_1
  280. ? `style="width:18px;height:18px;border-radius:0%;background-color:${item_color_1}"`
  281. : ""
  282. }></p>
  283. <p item_color=${item_color_2} class="mb-0 me-1" ${
  284. item_color_2
  285. ? `style="width:18px;height:18px;border-radius:0%;background-color:${item_color_2}"`
  286. : ""
  287. }></p>
  288. <p item_color=${item_color_3} class="mb-0" ${
  289. item_color_3
  290. ? `style="width:18px;height:18px;border-radius:0%;background-color:${item_color_3}"`
  291. : ""
  292. }></p>
  293. <p item_color=${item_color_4} class="mb-0" ${
  294. item_color_4
  295. ? `style="width:18px;height:18px;border-radius:0%;background-color:${item_color_4}"`
  296. : ""
  297. }></p>
  298. </li>
  299. </ul>
  300. <ul class="border-0 d-flex h-100 justify-content-between px-md-3 px-4 list-group-flush p-0 text-secondary" style="list-style: none;">
  301. <li class="border-0 py-0">
  302. <span class="satoshi_font">
  303. <h6><img src="../dist/assets/imgs/laptop-icon.png" class="w-20p pe-1"/>${gb}</h6>
  304. </span>
  305. </li>
  306. <li class="border-0 py-0">
  307. <span class="satoshi_font"><h6>${
  308. pricelist ? priceAmt : "Coming Soon"
  309. }</h6></span>
  310. </li>
  311. </ul>
  312. <div class="card-body text-center">
  313. <a href="/${detailPageName}.html${addSearch}#productId=${productid}#itemid=${itemid}" class="btn bg-white font-1-2 px-5 w-100">Details
  314. </a>
  315. </div>
  316. </div>
  317. </div>`;
  318. return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
  319. <div class="card border bg-white rounded-3 p-1 h-100">
  320. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class=""><img src="${img}" alt="${itemname}" class="w-100 h-100"></a>
  321. <div class="card-body">
  322. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="">
  323. <h5 class="card-title satoshi_font mb-0 px-2 text-center font-weight-600">${itemname}</h5>
  324. </a>
  325. </div>
  326. <ul class="border-0 d-flex h-100 justify-content-between px-md-3 px-4 list-group-flush p-0 text-secondary" style="list-style: none;">
  327. <li class="border-0 py-0">
  328. <span class="satoshi_font"> <h6>${gb}</h6> <h6>${ramTech}</h6></span>
  329. </li>
  330. <li class="border-0 py-0">
  331. <span class="satoshi_font"><h6>${priceAmt}</h6></span>
  332. </li>
  333. </ul>
  334. <div class="card-body text-center">
  335. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="btn bg-white font-1-2 px-5 w-100">Details
  336. </a>
  337. </div>
  338. </div>
  339. </div>`;
  340. //abhi anna design
  341. return `
  342. <!--desktop--->
  343. <div class="col-sm-4 p-3">
  344. <div class="product_card_3 shadow ram_card">
  345. <div class="card-item-header">
  346. <div class="card-header-sub-3"><a class=" py-md-1" href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}">
  347. <img src="${img}" class="w-100 h-100"></a>
  348. </div>
  349. </div>
  350. <div class="card-item-body">
  351. <h3 cclass="mb-2"> <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="" > ${itemname} </a></h3>
  352. <hr>
  353. <h6>${gb}</h6> <h6>${ramTech}</h6><h6>${priceAmt}</h6>
  354. <div class="py-2 card_product_footer">
  355. <button data-sku="${sku}" data-itemid="${itemid}" class="w-100 border-0 ramcard bg-transparent satoshi_font ram_btn" data_name="ORA 8GB DDR4 3200MHz Desktop RAM " data_version="DDR4" data_device="Desktop" data_gb="8GB" data_price="2900">Details </button>
  356. </div>
  357. </div>
  358. </div>
  359. </div>
  360. `;
  361. return `<div class="col-lg-3 col-md-6 ram_card">
  362. <div class="card shadow border-0 p-1 h-100">
  363. <a href="#">
  364. <img src="../dist/assets/imgs/Navbar/ora_ddr5_laptop.png" class="card-img-top" alt="...">
  365. </a>
  366. <div class="card-body">
  367. <a href="#" class="text-decoration-none text-dark">
  368. <h5 class="card-title satoshi_font mb-0">
  369. ${itemname}
  370. </h5>
  371. </a>
  372. </div>
  373. <ul class="list-group list-group-flush">
  374. <li class="list-group-item border-0 py-0">
  375. <span class="satoshi_font">${gb} ${ramTech}</span>
  376. </li>
  377. <li class="list-group-item border-0 py-0">
  378. <span class="satoshi_font">3200 Mhz</span>
  379. </li>
  380. </ul>
  381. <div class="card-body d-none">
  382. <button class="btn--md btn-primary w-100 card-link">
  383. <span class="cost currency-symbol">₹</span><span class="cost product-price satoshi_font">${pricelist}</span>
  384. </button>
  385. </div>
  386. <div class="card-body text-center">
  387. <div data-sku="${sku}" data-itemid="${itemid}" class="bg-black ramcard btn font-1-2 px-5 text-white w-100 satoshi_font" data_des="Upgrade your laptop with DDR4 Laptop
  388. Memory, oering 3200 MHz speed in 8, 16,
  389. and 32 GB capacities. Experience enhanced
  390. thermal performance, increased longevity,
  391. and superior performance with our
  392. innovative graphene sticker technology." data_name="ORA 8GB DDR4 3200MHz Laptop RAM ">Details
  393. </div>
  394. </div>
  395. </div>
  396. </div>`;
  397. }
  398. init();
  399. }
  400. ramProductsInit();