暫無描述
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. swapSectionsVideo();
  12. }
  13. async function getProductsIds(nameArr){
  14. let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getallproducts`,true);
  15. if(resData.isError){
  16. toasterHelper("error","Something went wrong!")
  17. return;
  18. }
  19. let res = resData.response;
  20. res = JSON.parse(res.result);
  21. let ids = [];
  22. for(let i=0;i<nameArr.length;i++){
  23. const currName = nameArr[i];
  24. let id = res.find((item)=>{
  25. if(currName === item.productname){
  26. return item.productid;
  27. }
  28. })
  29. if(id){
  30. ids.push(id);
  31. }
  32. }
  33. return ids;
  34. }
  35. async function getallproductsFun(){
  36. let laptopStr = ['FYRO Flagship','Zeno Dualbook','Zeno Sleekbook'];
  37. let allInOnesStr = ['AIO Zeno','AIO Fyro'];
  38. let name = window.location.href;
  39. name = name.includes('laptops') ?laptopStr : allInOnesStr;
  40. const ids = await getProductsIds(name);
  41. console.log(ids);
  42. return ids;
  43. }
  44. function getProductIdService(){
  45. return new Promise(async (reslove,reject)=>{
  46. let resData =await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getallproducts`,true);
  47. if(resData.isError){
  48. alert(resData.errorMsg.message);
  49. return;
  50. }
  51. let res = resData.response;
  52. res = JSON.parse(res.result);
  53. console.log(res);
  54. let searchName = window.location.search.split('?')[1];
  55. let urlPathName = window.location.pathname;
  56. let searchTerm = '';
  57. if(urlPathName.includes('ram')){
  58. searchTerm = "RAM ORA";
  59. }else if(urlPathName.includes('storage')){
  60. searchTerm = `SSD ORA`;
  61. }else{
  62. searchTerm = searchName.replaceAll('%20',' ');
  63. }
  64. let resultItem = [];
  65. if(searchTerm.toLowerCase() === 'zeno'){
  66. for(let i=0;i<res.length;i++){
  67. if(res[i].productname.includes("Zeno Sleekbook")||res[i].productname.includes("Zeno Dualbook")){
  68. resultItem.push( res[i])
  69. }
  70. }
  71. return reslove(resultItem)
  72. }else if(searchTerm.toLowerCase() === 'fyro'){
  73. for(let i=0;i<res.length;i++){
  74. if(res[i].productname.includes("FYRO Flagship")){
  75. resultItem.push( res[i]);
  76. return reslove(resultItem)
  77. }
  78. }
  79. }else{
  80. for(let i=0;i<res.length;i++){
  81. if(res[i].productname.includes(searchTerm)){
  82. resultItem.push( res[i])
  83. }
  84. }
  85. return reslove(resultItem)
  86. }
  87. });
  88. }
  89. async function getRamData(ids){
  90. let resData;
  91. let res
  92. let data = [];
  93. let windowSearch = window.location.href;
  94. for(let i=0;i<ids.length;i++){
  95. let id = ids[i].productid;
  96. if (windowSearch.includes('laptops')||windowSearch.includes('allinones')) {
  97. resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/Bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`, true);
  98. }
  99. else {
  100. resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`, true);
  101. }
  102. if(resData.isError){
  103. alert(resData.errorMsg.message);
  104. return;
  105. }
  106. res = resData.response;
  107. res = JSON.parse(res.result);
  108. data = [...data,...res];
  109. }
  110. console.log(data);
  111. let html = '';
  112. for(let i=0;i<data.length;i++){
  113. if(data[i].itemname.includes('AIO Fyro - 32')) continue;
  114. html += getRamCardHTML(data[i]);
  115. }
  116. $('.product_card_section').html(html);
  117. // $('.ramcard').click(function(e){
  118. // let sku = $(e.target).data('itemid');
  119. // let itemid = $(e.target).data('itemid');
  120. // window.location.href = `/productdetails.html?productId=${RAM_ID}#itemid=${itemid}`
  121. // })
  122. }
  123. function getRamCardHTML({itemname,pricelist,itemid,sku,itemimageurl,productid}){
  124. let img = itemimageurl ? imgServerNameBuild(itemimageurl) : './dist/assets/imgs/nophoto.png'
  125. let tags = itemname.split('-');
  126. let ramTech = tags[tags.length-2];
  127. let gb = tags[tags.length-1];
  128. const [currencySymbol,amount] = getCurrencySymbol(pricelist);
  129. let priceAmt = `${currencySymbol} ${amount}`;
  130. let detailPageName;
  131. let addSearch = '?';
  132. if (window.location.href.includes('laptops')) {
  133. detailPageName = 'laptopdetails';
  134. let name = itemname.toLowerCase().includes('zeno') ? 'Zeno' : 'Fyro';
  135. addSearch = `?${name}`;
  136. } else {
  137. detailPageName = 'productdetails';
  138. };
  139. debugger;
  140. return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
  141. <div class="card border bg-gray-3 rounded-3 p-1 h-100 notes">
  142. <a href="/${detailPageName}.html${addSearch}productId=${productid}#itemid=${itemid}" class="">
  143. <img src="${img}" alt="${itemname}" class="w-100 h-100 p-5 success-img">
  144. </a>
  145. <div class="card-body">
  146. <a href="/${detailPageName}.html${addSearch}productId=${productid}#itemid=${itemid}" class="">
  147. <h5 class="card-title satoshi_font mb-0 px-2 text-center font-weight-600">${itemname}</h5>
  148. </a>
  149. </div>
  150. <hr>
  151. <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;">
  152. <li class="border-0 py-0">
  153. <span class="satoshi_font"> <h6>${gb}</h6> <h6>${ramTech}</h6></span>
  154. </li>
  155. <li class="border-0 py-0">
  156. <span class="satoshi_font"><h6>${pricelist?priceAmt:'Coming Soon'}</h6></span>
  157. </li>
  158. </ul>
  159. <div class="card-body text-center">
  160. <a href="/${detailPageName}.html?productId=${productid}#itemid=${itemid}" class="btn bg-white font-1-2 px-5 w-100">Details
  161. </a>
  162. </div>
  163. </div>
  164. </div>`
  165. return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
  166. <div class="card border bg-gray-3 rounded-3 p-1 h-100">
  167. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class=""><img src="${img}" alt="${itemname}" class="w-100 h-100"></a>
  168. <div class="card-body">
  169. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="">
  170. <h5 class="card-title satoshi_font mb-0 px-2 text-center font-weight-600">${itemname}</h5>
  171. </a>
  172. </div>
  173. <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;">
  174. <li class="border-0 py-0">
  175. <span class="satoshi_font"> <h6>${gb}</h6> <h6>${ramTech}</h6></span>
  176. </li>
  177. <li class="border-0 py-0">
  178. <span class="satoshi_font"><h6>${priceAmt}</h6></span>
  179. </li>
  180. </ul>
  181. <div class="card-body text-center">
  182. <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="btn bg-white font-1-2 px-5 w-100">Details
  183. </a>
  184. </div>
  185. </div>
  186. </div>`;
  187. //abhi anna design
  188. return `
  189. <!--desktop--->
  190. <div class="col-sm-4 p-3">
  191. <div class="product_card_3 shadow ram_card">
  192. <div class="card-item-header">
  193. <div class="card-header-sub-3"><a class=" py-md-1" href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}">
  194. <img src="${img}" class="w-100 h-100"></a>
  195. </div>
  196. </div>
  197. <div class="card-item-body">
  198. <h3 cclass="mb-2"> <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="" > ${itemname} </a></h3>
  199. <hr>
  200. <h6>${gb}</h6> <h6>${ramTech}</h6><h6>${priceAmt}</h6>
  201. <div class="py-2 card_product_footer">
  202. <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>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. `;
  208. return `<div class="col-lg-3 col-md-6 ram_card">
  209. <div class="card shadow border-0 p-1 h-100">
  210. <a href="#">
  211. <img src="../dist/assets/imgs/Navbar/ora_ddr5_laptop.png" class="card-img-top" alt="...">
  212. </a>
  213. <div class="card-body">
  214. <a href="#" class="text-decoration-none text-dark">
  215. <h5 class="card-title satoshi_font mb-0">
  216. ${itemname}
  217. </h5>
  218. </a>
  219. </div>
  220. <ul class="list-group list-group-flush">
  221. <li class="list-group-item border-0 py-0">
  222. <span class="satoshi_font">${gb} ${ramTech}</span>
  223. </li>
  224. <li class="list-group-item border-0 py-0">
  225. <span class="satoshi_font">3200 Mhz</span>
  226. </li>
  227. </ul>
  228. <div class="card-body d-none">
  229. <button class="btn--md btn-primary w-100 card-link">
  230. <span class="cost currency-symbol">₹</span><span class="cost product-price satoshi_font">${pricelist}</span>
  231. </button>
  232. </div>
  233. <div class="card-body text-center">
  234. <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
  235. Memory, oering 3200 MHz speed in 8, 16,
  236. and 32 GB capacities. Experience enhanced
  237. thermal performance, increased longevity,
  238. and superior performance with our
  239. innovative graphene sticker technology." data_name="ORA 8GB DDR4 3200MHz Laptop RAM ">Details
  240. </div>
  241. </div>
  242. </div>
  243. </div>`
  244. }
  245. init();
  246. }
  247. ramProductsInit();