productDetails.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport"
  6. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  7. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  8. <meta name='apple-touch-fullscreen' content='yes'>
  9. <meta name="apple-mobile-web-app-capable" content="yes"/>
  10. <meta content="fullscreen=yes,preventMove=no" name="ML-Config">
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <meta name="renderer" content="webkit">
  13. <meta name="apple-mobile-web-app-capable" content="yes"/>
  14. <meta name="keywords" content="电子烟,关键字"/>
  15. <meta name="Description" content="网站描述"/>
  16. <title>商品详情</title>
  17. <link rel="stylesheet" href="/assets/index/css/common.css?t=4111">
  18. <link rel="stylesheet" href="/assets/index/css/productDetails.css?t=11101">
  19. </head>
  20. <body>
  21. <!-- 头部导航栏 -->
  22. <header class="headerContainer" id="headerContainer">
  23. <!-- 顶部提示 -->
  24. <div class="warnContainer">
  25. <h4 class="warnText">WARNING: This product contains nicotine. Nicotine is an addictive chemical.</h4>
  26. </div>
  27. <!-- pc端头部 -->
  28. <div id="computerEndHeader">
  29. <a href="/index/index/index.html">
  30. <h1 class="computerLogo">
  31. <img src="/assets/index/asstes/icon/logo.png" alt="Free Shipping Vapes" title="Free Shipping Vapes">
  32. </h1>
  33. </a>
  34. <div class="headNavContainer">
  35. <nav class="headNavItem active">
  36. <h2 class="headNavTitle">NEW VAPES</h2>
  37. <p class="back"></p>
  38. </nav>
  39. <!-- <nav class="headNavItem">
  40. <h2 class="headNavTitle">DISPOSABLES</h2>
  41. <p class="back"></p>
  42. </nav>-->
  43. </div>
  44. <div class="headIconContainer">
  45. <a href="/index/cart/shoppingCart.html">
  46. <div class="headIconItem shoppingCartIcon">
  47. <img src="/assets/index/asstes/icon/shoppingCart.png" alt="shoppingCart" tabindex="shoppingCart">
  48. </div>
  49. </a>
  50. <!-- 收藏 -->
  51. <!-- <div class="headIconItem collectIcon">-->
  52. <!-- <img src="/assets/index/asstes/icon/collect.png" alt="collect" tabindex="collect">-->
  53. <!-- </div>-->
  54. <!-- 个人中心 -->
  55. <a href="/index/user/order.html">
  56. <div class="headIconItem userIcon">
  57. <img src="/assets/index/asstes/icon/user.png" alt="user" tabindex="user">
  58. </div>
  59. </a>
  60. </div>
  61. </div>
  62. <!-- 移动端头部 -->
  63. <div id="mobileEndHeader">
  64. <div class="mobileEndHeaderConten">
  65. <a href="/index/index/index.html">
  66. <h1 class="mobileLogo">
  67. <img src="/assets/index/asstes/icon/logo.png" alt="Free Shipping Vapes" title="Free Shipping Vapes">
  68. </h1>
  69. </a>
  70. <div class="mobileUserIconList">
  71. <div class="mobileUserIcon userIcon">
  72. <img src="/assets/index/asstes/icon/user.png" alt="user" tabindex="user">
  73. </div>
  74. </div>
  75. <div class="mobileMenu">
  76. <p id="mobileMenuBot">
  77. <span id="mobileMenuLink"></span>
  78. </p>
  79. </div>
  80. </div>
  81. <!-- 移动端菜单 -->
  82. <section class="mobileMenuFixed">
  83. <div class="mobileMenuItem active">
  84. <a href="/index/index/index.html">
  85. <h2 class="menuItemTitle">NEW VAPES</h2>
  86. </a>
  87. </div>
  88. <!-- <div class="mobileMenuItem">
  89. <a href="#">
  90. <h2 class="menuItemTitle">DISPOSABLES</h2>
  91. </a>
  92. </div>-->
  93. <div class="mobileMenuItem">
  94. <a href="/index/cart/shoppingCart.html">
  95. <h2 class="menuItemTitle shoppingCartIcon">Shopping Cart</h2>
  96. </a>
  97. </div>
  98. <!-- <div class="mobileMenuItem">-->
  99. <!-- <h2 class="menuItemTitle collectIcon">Collect</h2>-->
  100. <!-- </div>-->
  101. <div class="mobileMenuItem">
  102. <a href="/index/user/order.html">
  103. <h2 class="menuItemTitle userIcon">Personal</h2>
  104. </a></div>
  105. </section>
  106. </div>
  107. </header>
  108. <main id="main">
  109. <section class="sectionContainer">
  110. <div class="elementorContainer">
  111. <!-- 产品模块 -->
  112. <section class="productContainer">
  113. <!-- 产品图片 -->
  114. <div class="productImgContainer">
  115. <div class="prViewImgBox">
  116. <img class="prViewImg lazy" src="/assets/index/asstes/icon/transparent.png"
  117. data-original="{$goods.goods_image}" alt="">
  118. </div>
  119. <div class="prImgContainer">
  120. <div class="prImgList">
  121. {foreach $goods.goods_images as $img}
  122. <div class="prImgItem">
  123. <img class="lazy" src="/assets/index/asstes/icon/transparent.png"
  124. data-original="{$img.preview_url}" alt="">
  125. </div>
  126. {/foreach}
  127. </div>
  128. <div class="prevArrow">&lt;</div>
  129. <div class="nextArrow">&gt;</div>
  130. </div>
  131. </div>
  132. <!-- 产品信息 -->
  133. <div class="productInfoContainer">
  134. <div>
  135. <h1 class="productTitle">{$goods.goods_name}</h1>
  136. <div class="productPrice">
  137. <p><span>$</span>{$goods.goods_price_min}</p>
  138. </div>
  139. </div>
  140. <div>
  141. <!-- 数量 -->
  142. <div class="productNContainer">
  143. <div class="productNumberBox">
  144. <div class="numberReduce">-</div>
  145. <input id="numberInput" value="1" type="text"/>
  146. <div class="numberAdd">+</div>
  147. </div>
  148. <div class="addToCart">
  149. <p class="tag">+</p>
  150. <p>Add To Cart</p>
  151. </div>
  152. </div>
  153. <div class="safeContainer">
  154. <p class="safeTag">Guaranteed Safe Checkout</p>
  155. <div class="safeList">
  156. <div class="safeItem">
  157. <img src="https://img2.baidu.com/it/u=810087687,2144202516&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1710003600&t=5d86d51c836405ef2225baf3d4aa9349"
  158. alt="">
  159. </div>
  160. <div class="safeItem">
  161. <img src="https://img2.baidu.com/it/u=810087687,2144202516&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1710003600&t=5d86d51c836405ef2225baf3d4aa9349"
  162. alt="">
  163. </div>
  164. <div class="safeItem">
  165. <img src="https://img2.baidu.com/it/u=810087687,2144202516&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1710003600&t=5d86d51c836405ef2225baf3d4aa9349"
  166. alt="">
  167. </div>
  168. <div class="safeItem">
  169. <img src="https://img2.baidu.com/it/u=810087687,2144202516&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1710003600&t=5d86d51c836405ef2225baf3d4aa9349"
  170. alt="">
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </section>
  177. <!-- 文案模块 -->
  178. <article class="articleContainer">
  179. <div class="articleTabBox">
  180. <div class="articleTabItem active" data-type="description">
  181. <p class="tabTag"></p>
  182. <h2 class="articleTabTitle">Description</h2>
  183. </div>
  184. <div class="articleTabItem" data-type="reviews">
  185. <p class="tabTag"></p>
  186. <h2 class="articleTabTitle">Reviews ({$comment_total})</h2>
  187. </div>
  188. </div>
  189. <!-- 商品详情容器 -->
  190. <div class="articleInfo" id="articleInfo">
  191. <h2 class="articleTitle">Product description</h2>
  192. <div id="richTextContainer"></div>
  193. </div>
  194. <!-- 评价内容容器 -->
  195. <div id="reviewsInfo">
  196. <div id="reviews">
  197. </div>
  198. <div id="loadingIndicator">loading...</div>
  199. <div id="reviewsButtonContainer">
  200. <div id="reviewsButtonBox">
  201. <div id="prevPage">Prev page</div>
  202. <div id="nextPage">Next page</div>
  203. </div>
  204. </div>
  205. </div>
  206. </article>
  207. <!-- 悬浮底部模块 -->
  208. <section class="fixedAddSection">
  209. <div class="fixedAddContainer">
  210. <div class="elementorContainer">
  211. <div class="fixedAddBox">
  212. <div class="fPrInfo">
  213. <img class="img lazy" src="/assets/index/asstes/icon/transparent.png"
  214. data-original="https://www.buranshao.com/Content/Img/iqos3duo.jpg" alt="">
  215. <h3 class="fTitle">NEW VAPES</h3>
  216. </div>
  217. <div class="fPrNumberContainer">
  218. <p class="fPrPrice">${$goods.goods_price_min}</p>
  219. <div class="fPrNumberBox">
  220. <div class="fPrNumberReduce">-</div>
  221. <input id="fPrNumberInput" value="1" type="text"/>
  222. <div class="fPrNumberAdd">+</div>
  223. </div>
  224. <div class="fPrAddToCart">
  225. <p class="tag">+</p>
  226. <p>Add To Cart</p>
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. </div>
  232. </section>
  233. </div>
  234. </section>
  235. </main>
  236. <!-- 底部 -->
  237. <footer class="footerContainer">
  238. <section class="sectionContainer">
  239. <div class="elementorContainer">
  240. <div class="footerConter">
  241. <div class="leftText">
  242. <p class="ltK">NEWALETTER</p>
  243. <p class="ltV">Sign up for the Free Shipping Vapes</p>
  244. </div>
  245. <div class="footerInuptBox">
  246. <img class="mailIcon" src="/assets/index/asstes/icon/mailIcon.png" alt="">
  247. <input class="footerInupt" type="text">
  248. <img class="arrowIcon" src="/assets/index/asstes/icon/arrowIcon.png" alt="">
  249. </div>
  250. <div class="footerIconContainer">
  251. <div class="footerIconList">
  252. <a href="#">
  253. <div class="footerIconItem">
  254. <img src="https://i1.branchcn.com/social_media/Wechat.png" alt="">
  255. </div>
  256. </a>
  257. <a href="#">
  258. <div class="footerIconItem">
  259. <img src="https://i1.branchcn.com/social_media/Wechat.png" alt="">
  260. </div>
  261. </a>
  262. <a href="#">
  263. <div class="footerIconItem">
  264. <img src="https://i1.branchcn.com/social_media/Wechat.png" alt="">
  265. </div>
  266. </a>
  267. </div>
  268. <div class="footerVlsaImg">
  269. <a href="#">
  270. <div class="footerVlsaItem">
  271. <img src="https://img2.baidu.com/it/u=1367821108,121397947&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=500"
  272. alt="">
  273. </div>
  274. </a>
  275. <a href="#">
  276. <div class="footerVlsaItem">
  277. <img src="https://img2.baidu.com/it/u=1367821108,121397947&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=500"
  278. alt="">
  279. </div>
  280. </a>
  281. <a href="#">
  282. <div class="footerVlsaItem">
  283. <img src="https://img2.baidu.com/it/u=1367821108,121397947&fm=253&fmt=auto&app=138&f=JPEG?w=1200&h=500"
  284. alt="">
  285. </div>
  286. </a>
  287. </div>
  288. </div>
  289. </div>
  290. </div>
  291. </section>
  292. <section class="sectionContainer warningContainer">
  293. <div class="elementorContainer">
  294. <div class="warningBox">
  295. <p class="warningText">WARNING: Our products contain nicotine, a poisonous and addictive substance.
  296. Our products are only intended for committed smokers of legal smoking age and not by
  297. non-smokers, children, women who are pregnant or may become pregnant or any person with an
  298. elevated risk of, or preexisting condition of, any medical condition which includes, but is not
  299. limited to, heart disease, diabetes, high blood pressure or asthma. If you experience any side
  300. effects or possible side effects, stop using the product immediately and consult a physician.
  301. Product may be poisonous if orally ingested. Our products are not smoking cessation products and
  302. have not been tested or guaranteed as such. Our products have not been evaluated by the Food and
  303. Drug Administration nor is it intended to treat, prevent or cure any disease or condition. For
  304. their protection, please keep out of reach of children and pets. Read our terms of use page
  305. before purchasing our products.</p>
  306. </div>
  307. </div>
  308. </section>
  309. </footer>
  310. <!-- 年龄提示层 -->
  311. <section class="maskContainer">
  312. <div class="ageReminderBox">
  313. <img class="ageReminderBack" src="/assets/index/asstes/ageReminderBack.jpg" alt="">
  314. <div class="ageReminderInfo">
  315. <h3>ARE YOU OF LEAAL SMOKIND AGE?</h3>
  316. <div class="ageReminderButBox">
  317. <div class="ageRBut ageReminderNo"><span>NO</span></div>
  318. <div class="ageRBut ageReminderYes"><span>Yes, I am 21+</span></div>
  319. </div>
  320. </div>
  321. </div>
  322. </section>
  323. <!-- 吐司提示 -->
  324. <div id="toastContainer"></div>
  325. </body>
  326. <script src="/assets/index/js/jquery-1.12.0.js"></script>
  327. <script src="/assets/index/js/flexible.js"></script>
  328. <script src="/assets/index/js/public.js?t=11"></script>
  329. <script src="/assets/index/js/productDetails.js?t=11"></script>
  330. <script src="/assets/index/js/jquery.lazyload.js"></script>
  331. <script>
  332. $(document).ready(function () {
  333. //触屏事件 || 点击事件
  334. const tap = "ontouchstart" in window ? "touchstart" : "click";
  335. var goodsId = {$goods.goods_id};
  336. var goodsSkuId = {$goods['skuList'][0]['goods_sku_id']};
  337. //富文本处理
  338. function initRichText() {
  339. $("#richTextContainer").html(`{$goods.content | raw}`)
  340. }
  341. /**
  342. * 添加购物车
  343. * @param number 数量
  344. * @returns
  345. */
  346. function addCart(number) {
  347. if (!number || number <= 0) {
  348. showToast("Please enter the quantity of products")
  349. return
  350. }
  351. var dp = {
  352. goodsId: goodsId,
  353. goodsSkuId: goodsSkuId,
  354. goodsNum: number
  355. }
  356. $.ajax({
  357. url: "/index/cart/add",
  358. headers: {platform: 'H5'},
  359. dataType: 'json',
  360. data: JSON.stringify(dp),
  361. type: "POST",
  362. contentType: 'application/json',
  363. success: function (obj) {
  364. //注册成功后进入
  365. if (obj.status === 200 || obj.status === '200') {
  366. showToast("Successful")
  367. window.location.href = '/index/cart/shoppingCart.html';
  368. return
  369. } else if (obj.status === 401 || obj.status === '401') {
  370. window.location.replace('../passport/logIn.html')
  371. } else {
  372. showToast(obj.message)
  373. }
  374. }
  375. })
  376. }
  377. /**
  378. * 吐司提示
  379. * @param message 消息
  380. * @returns
  381. */
  382. function showToast(message) {
  383. var toastElement = $('#toastContainer');
  384. toastElement.text(message);
  385. toastElement.stop(true, true).fadeIn(200).delay(2000).fadeOut(200);
  386. }
  387. //商品数量减少
  388. $('.numberReduce, .fPrNumberReduce').click(function () {
  389. var container = $(this).closest('.productNumberBox, .fPrNumberBox');
  390. var inputElement = container.find('#numberInput, #fPrNumberInput');
  391. var currentValue = parseInt(inputElement.val());
  392. if (currentValue > 1) {
  393. inputElement.val(currentValue - 1);
  394. var totalMoney = {$goods.goods_price_min} * (currentValue - 1)
  395. $('.fPrPrice').html('$' + totalMoney.toFixed(2))
  396. }
  397. });
  398. //商品数量增加
  399. $('.numberAdd, .fPrNumberAdd').click(function () {
  400. var container = $(this).closest('.productNumberBox, .fPrNumberBox');
  401. var inputElement = container.find('#numberInput, #fPrNumberInput');
  402. var currentValue = parseInt(inputElement.val());
  403. inputElement.val(currentValue + 1);
  404. var totalMoney = {$goods.goods_price_min} * (currentValue + 1)
  405. console.log(totalMoney)
  406. $('.fPrPrice').html('$' + totalMoney.toFixed(2))
  407. });
  408. // 输入框禁止为空小于等于0
  409. $('#numberInput, #fPrNumberInput').change(function () {
  410. var inputElement = $(this);
  411. var currentValue = parseInt(inputElement.val());
  412. if (currentValue < 1 || isNaN(currentValue)) {
  413. inputElement.val(1);
  414. }
  415. });
  416. //上面的添加按钮
  417. $(".addToCart").on(tap, function () {
  418. const number = $('#numberInput').val();
  419. addCart(number)
  420. });
  421. //悬浮模块的添加按钮
  422. $(".fPrAddToCart").on(tap, function () {
  423. const number = $('#fPrNumberInput').val();
  424. addCart(number)
  425. });
  426. initRichText()
  427. //页码
  428. let page = 1;
  429. //总页数
  430. let totalPage = {$comment_total}
  431. //页数
  432. let itemsPerPage = 10;
  433. //加载中
  434. let isLoading = false;
  435. //详情 & 评论切换
  436. $(".articleTabItem").on(tap, function () {
  437. const type = $(this).attr("data-type")
  438. $(this).addClass("active").siblings().removeClass("active")
  439. // 评论
  440. if (type === "reviews") {
  441. $("#reviewsInfo").show(0)
  442. $("#articleInfo").hide(0)
  443. getReviews()
  444. page = 1
  445. } else {
  446. // 详情
  447. $("#articleInfo").show(0)
  448. $("#reviewsInfo").hide(0)
  449. }
  450. });
  451. //上一页
  452. $("#prevPage").on(tap, function () {
  453. if (page > 1) {
  454. page--
  455. } else {
  456. page = 1
  457. }
  458. getReviews()
  459. });
  460. //下一页
  461. $("#nextPage").on(tap, function () {
  462. if (page >= totalPage) {
  463. page = totalPage
  464. } else {
  465. page++
  466. }
  467. getReviews()
  468. });
  469. // 获取评价列表
  470. function getReviews() {
  471. if (isLoading) {
  472. return;
  473. }
  474. isLoading = true;
  475. // 显示加载指示器
  476. $('#loadingIndicator').show();
  477. //调试后记得去除这段代码
  478. $.ajax({
  479. url: '/index/comment/listPage?goodsId=' + goodsId,
  480. type: 'GET',
  481. data: {
  482. page: page,
  483. per_page: itemsPerPage
  484. },
  485. success: function (response) {
  486. console.log(response.data)
  487. const data = response.data.list.data
  488. // 在页面中添加数据
  489. const container = $('#reviews');
  490. //var html = container.html();
  491. var html = '';
  492. //container.html("")
  493. $.each(data, function (index, item) {
  494. const rating = item.score / 10;
  495. let starHtml = "";
  496. for (let i = 0; i < 5; i++) {
  497. if (i < rating) {
  498. starHtml += '<img src="/assets/index/asstes/icon/selStar.png" alt="">';
  499. } else {
  500. starHtml += '<img src="/assets/index/asstes/icon/star.png" alt="">';
  501. }
  502. }
  503. html += `
  504. <div class="reviewItem">
  505. <div class="userInfo">
  506. <div class="userImg">
  507. <img src="https://himg.bdimg.com/sys/portrait/item/tb.1.772a23f6.WIunUru1_286k2Q9BG9SJg" alt="">
  508. </div>
  509. <p class="userName">${item.user.nick_name}</p>
  510. </div>
  511. <div class="reInfo">
  512. <div class="starBox">${starHtml}
  513. </div>
  514. <h3 class="reviewValues">${item.content}</h3>
  515. </div>
  516. </div>`;
  517. });
  518. container.html(html);
  519. //数据长度大于0显示上下页按钮
  520. //$('#reviewsButtonContainer').show();
  521. console.log(response.data.list.last_page, page, response.data.list.last_page > page)
  522. if (response.data.list.last_page > page) {
  523. $("#nextPage").show()
  524. } else {
  525. $("#nextPage").hide()
  526. }
  527. if (page > 1) {
  528. $("#prevPage").show()
  529. } else {
  530. $("#prevPage").hide()
  531. }
  532. // 隐藏加载指示器
  533. $('#loadingIndicator').hide();
  534. isLoading = false;
  535. },
  536. error: function () {
  537. // 处理错误情况
  538. console.log('请求数据失败');
  539. // 隐藏加载指示器
  540. $('#loadingIndicator').hide();
  541. isLoading = false;
  542. }
  543. });
  544. }
  545. });
  546. </script>
  547. </html>