Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

dummyproduct.js 17KB

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