index.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. $(".gototop").hide();
  2. $(window).scroll(function () {
  3. var y = window.scrollY;
  4. if (y > 10) {
  5. $(".gototop").show();
  6. } else {
  7. $(".gototop").hide();
  8. }
  9. });
  10. $("*").each(function (index, element) {
  11. // 此元素被點選後執行
  12. $(this).click(function (e) {
  13. // 取得被點選元素的屬性:data-gt-target
  14. var target = $(this).attr("data-gt-target");
  15. var duration = $(this).attr("data-gt-duration");
  16. var offset = $(this).attr("data-gt-offset");
  17. // JS 語法:判斷式
  18. // if (條件) {程式區塊}
  19. // 當條件成立,會執行程式區塊
  20. // 如果 目標有資料 才會執行 { } 內的程式
  21. // 避免出現 undefine (未定義 - 不存在的資料)
  22. if (target) {
  23. //console.log("目標:" + target);
  24. //console.log("時間:" + duration);
  25. //console.log("位移:" + offset);
  26. // 上方位置 = 目標區塊.位移().上方位置
  27. var top = $(target).offset().top;
  28. //console.log("要前往元素的上方位置:" + top);
  29. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  30. // parseInt() 將文字轉為數字
  31. $("html").stop().animate({
  32. scrollTop: top - offset
  33. }, parseInt(duration));
  34. }
  35. });
  36. });
  37. // 避免動畫與使用者滾輪衝突
  38. // html 在滾動滾輪時 停止 html 所有效果
  39. $("html").on("mousewheel", function () {
  40. $("html").stop();
  41. });
  42. $(".playbutton").click(function () {
  43. var videosrc = $(this).data("info");
  44. $('.youtube-video').attr('src', `https://www.youtube.com/embed//${videosrc}?autoplay=1`);
  45. });
  46. $(".btn-close").click(function () {
  47. $('.youtube-video').attr('src', ``);
  48. });
  49. $('#yt-video').on('hidden.bs.modal', function () {
  50. $('.youtube-video').attr('src', ``);
  51. });
  52. $(".banner-slide").slick({
  53. dots: true,
  54. autoplay: true,
  55. arrows: false,
  56. slidesToShow: 1,
  57. slidesToScroll: 1,
  58. autoplaySpeed: 7000,
  59. initialSlide: 0,
  60. infinite: true,
  61. });
  62. $(".violetbeauty_sec01_slide").slick({
  63. slidesToShow: 4,
  64. slidesToScroll: 3,
  65. infinite: true,
  66. // centerMode: true,
  67. arrows: true,
  68. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>',
  69. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>'
  70. });
  71. $(".violetbeauty_sec02_slide").slick({
  72. slidesToShow: 3,
  73. slidesToScroll: 3,
  74. infinite: true,
  75. // centerMode: true,
  76. arrows: true,
  77. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>',
  78. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>'
  79. });
  80. $(".learn_more").click(function () {
  81. var courseid = $(this).data("info");
  82. // console.log(courseid);
  83. $.ajax({
  84. method: "GET",
  85. url: "coursecontent.json",
  86. dataType: "json",
  87. })
  88. .done(function (msg) {
  89. // console.log(msg)
  90. for (var i = 0; i < msg.length; i++) {
  91. if (msg[i].Courseid == courseid) {
  92. var CourseContent = '';
  93. console.log(msg[i]);
  94. CourseContent = `
  95. <div class="course_detail py-3">
  96. <div class="row">
  97. <div class="col-md-7">
  98. <div class="course_detail_img mt-3">
  99. <img class="img-fluid" src="${msg[i].CourseImg}" alt="">
  100. </div>
  101. </div>
  102. <div class="col-md-5">
  103. <div class="course_detail_text">
  104. <div class="features_title fw-bold text-start">${msg[i].CourseTitle}</div>
  105. <div class="sec_content_right_text">
  106. <p>${msg[i].Coursetext}</p>
  107. </div>
  108. </div>
  109. <div class="text-center">
  110. <button class="violetbeauty_CTA mt-4"><a style="text-decoration: none;"
  111. target="_blank" href="https://line.me/R/ti/p/%2540qlo9716l"><img
  112. class="cta_flower" src="./img/flower.png" alt="">立即體驗</a></button>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. `
  118. }
  119. $('.modal-body').html(CourseContent);
  120. }
  121. });
  122. });
  123. // facial.html
  124. $.ajax({
  125. type: "GET",
  126. url: "facial.json",
  127. dataType: "json",
  128. success: function (res) {
  129. let facialList = [];
  130. let facialModalList = [];
  131. for (let i = 0; i < res.length; i++) {
  132. let facialCardContent = `
  133. <div class="col-12 col-md-6 col-lg-4">
  134. <div class="card h-100">
  135. <div class="img-box">
  136. <img src="./img/violetbeauty/karelys-ruiz-PqyzuzFiQfY-unsplash.png" class="card-img-top" alt="...">
  137. </div>
  138. <div class="card-body">
  139. <div class="d-flex justify-content-between">
  140. <h5 class="badge">臉部課程</h5>
  141. <div class="d-flex align-items-center time-box">
  142. <img src="./img/icon-time.png" alt="">
  143. <p><span>${res[i].time}</span>分鐘</p>
  144. </div>
  145. </div>
  146. <h5 class="card-title fw-bold my-3">${res[i].title}</h5>
  147. <p class="card-text">${res[i].description}</p>
  148. </div>
  149. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#facial_modal_${i + 1}">
  150. 了解課程
  151. </button>
  152. </div>
  153. </div>`;
  154. let facialModalContent = `
  155. <div class="modal fade" id="facial_modal_${i + 1}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  156. <div class="modal-dialog modal-dialog-centered modal-xl">
  157. <div class="modal-content">
  158. <div class="modal-header">
  159. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  160. </div>
  161. <div class="modal-body m-3 m-xl-5 mb-2 mb-lg-5">
  162. <div class="container-fluid">
  163. <div class="row align-items-center">
  164. <div class="col-12 col-lg-7">
  165. <img src="./img/violetbeauty/sec00.jpg" alt="" style="width: 100%;">
  166. </div>
  167. <div class="col-12 col-lg-5 px-3 px-xl-5">
  168. <h5 class="fw-bold my-3">${res[i].title}</h5>
  169. <div class="d-flex justify-content-between my-4">
  170. <div class="d-flex flex-column price-box">
  171. <span>體驗價 $${res[i].price}</span>
  172. <span>原價 $${res[i].originalPrice}</span>
  173. </div>
  174. <div class="d-flex align-items-center time-box">
  175. <img src="./img/icon-time.png" alt="">
  176. <p><span>${res[i].time}</span>分鐘</p>
  177. </div>
  178. </div>
  179. <section class="d-flex flex-column justify-content-between">
  180. <p>${res[i].description}</p>
  181. <div class="recommend-item">
  182. <span class="badge">推薦</span>
  183. ${res[i].recommend}
  184. </div>
  185. </section>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>`;
  193. facialList.push(facialCardContent);
  194. facialModalList.push(facialModalContent);
  195. $('.facial-content-item').html(facialList);
  196. $('.facial-modal').html(facialModalList);
  197. }
  198. },
  199. error: function (err) {
  200. console.log('err', err);
  201. }
  202. });
  203. // massage.html
  204. $.ajax({
  205. type: "GET",
  206. url: "massage.json",
  207. dataType: "json",
  208. success: (res) => {
  209. let massageList = [];
  210. let massageModalList = [];
  211. let contentList = [
  212. `<div class="col-12 col-md-6 col-xl-4">
  213. <div class="card h-100">
  214. <div class="img-box">
  215. <img src="./img/violetbeauty/karelys-ruiz-PqyzuzFiQfY-unsplash.png" class="card-img-top" alt="...">
  216. </div>
  217. <div class="card-body">
  218. <div class="d-flex justify-content-between">
  219. <h5 class="badge">身體課程</h5>
  220. <div class="d-flex align-items-center time-box">
  221. <img src="./img/icon-time.png" alt="">
  222. <p><span>60</span>分鐘/<span>120</span>分鐘</p>
  223. </div>
  224. </div>
  225. <h5 class="card-title fw-bold my-3">波動舒活經絡課程</h5>
  226. <p class="card-text">久坐、久站或長期的姿勢不良,讓妳經常腰酸背痛嗎?手技搭配儀器,不再是單純肌肉放鬆,針對氣血循環,功力深厚的技巧,專業的儀器走向,完全放鬆你的身心靈。</p>
  227. </div>
  228. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_1">
  229. 了解課程
  230. </button>
  231. </div>
  232. </div>`,
  233. `<div class="col-12 col-md-6 col-xl-4">
  234. <div class="card h-100">
  235. <div class="img-box">
  236. <img src="./img/violetbeauty/karelys-ruiz-PqyzuzFiQfY-unsplash.png" class="card-img-top" alt="...">
  237. </div>
  238. <div class="card-body">
  239. <div class="d-flex justify-content-between">
  240. <h5 class="badge">身體課程</h5>
  241. <div class="d-flex align-items-center time-box">
  242. <img src="./img/icon-time.png" alt="">
  243. <p><span>40</span>分鐘/<span>60</span>分鐘/<span>80</span>分鐘</p>
  244. </div>
  245. </div>
  246. <h5 class="card-title fw-bold my-3">五行氣穴課程</h5>
  247. <p class="card-text">藉由中醫理論五行學說,透過美容師手勁與技巧將阻塞處舒展,達到通筋通便活絡氣血效應,達到陰陽流暢,全程手技,使用原始原點精油,刺激身體各部位穴點,與一般經絡按摩較不同!愛按摩的你絕不能錯過。</p>
  248. </div>
  249. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_2">
  250. 了解課程
  251. </button>
  252. </div>
  253. </div>`,
  254. `<div class="col-12 col-md-6 col-xl-4">
  255. <div class="card h-100">
  256. <div class="img-box">
  257. <img src="./img/violetbeauty/karelys-ruiz-PqyzuzFiQfY-unsplash.png" class="card-img-top" alt="...">
  258. </div>
  259. <div class="card-body">
  260. <h5 class="badge">身體課程</h5>
  261. <h5 class="card-title fw-bold my-3">半永久熱蠟除毛</h5>
  262. <p class="card-text">擾人的毛髮交給我們,容易悶熱滋生細菌造成異味,妳的救星!熱蠟是所有技術中最低疼痛感,能讓毛髮生長延緩,達到重生毛髮越來越細軟,甚至無毛。</p>
  263. </div>
  264. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_3">
  265. 了解課程
  266. </button>
  267. </div>
  268. </div>`];
  269. for (let i = 0; i < res.length; i++) {
  270. let massageCardContent = `
  271. <div class="col-12 col-md-6 col-xl-4">
  272. <div class="card h-100">
  273. <div class="img-box">
  274. <img src="./img/violetbeauty/karelys-ruiz-PqyzuzFiQfY-unsplash.png" class="card-img-top" alt="...">
  275. </div>
  276. <div class="card-body">
  277. <div class="d-flex justify-content-between">
  278. <h5 class="badge">身體課程</h5>
  279. <div class="d-flex align-items-center time-box">
  280. <img src="./img/icon-time.png" alt="">
  281. <p><span>${res[i].time}</span>分鐘</p>
  282. </div>
  283. </div>
  284. <h5 class="card-title fw-bold my-3">${res[i].title}</h5>
  285. <p class="card-text">${res[i].description}</p>
  286. </div>
  287. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massage_modal_${i + 1}">
  288. 了解課程
  289. </button>
  290. </div>
  291. </div>`;
  292. let massageModalContent = `
  293. <div class="modal fade" id="massage_modal_${i + 1}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  294. <div class="modal-dialog modal-dialog-centered modal-xl">
  295. <div class="modal-content">
  296. <div class="modal-header">
  297. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  298. </div>
  299. <div class="modal-body m-3 mb-2 mb-lg-5">
  300. <div class="container-fluid">
  301. <div class="row align-items-center">
  302. <div class="col-12 col-lg-7">
  303. <img src="./img/violetbeauty/sec00.jpg" alt="" style="width: 100%;">
  304. </div>
  305. <div class="col-12 col-lg-5 px-3 px-xl-5">
  306. <h5 class="fw-bold my-3">${res[i].title}</h5>
  307. <div class="d-flex justify-content-between my-4">
  308. <div class="d-flex flex-column price-box">
  309. <span>體驗價 $${res[i].price}</span>
  310. <span>原價 $${res[i].originalPrice}</span>
  311. </div>
  312. <div class="d-flex align-items-center time-box">
  313. <img src="./img/icon-time.png" alt="">
  314. <p><span>${res[i].time}</span>分鐘</p>
  315. </div>
  316. </div>
  317. <section class="d-flex flex-column justify-content-between">
  318. <p>${res[i].description}</p>
  319. <div class="recommend-item">
  320. <span class="badge">推薦</span>
  321. ${res[i].recommend}
  322. </div>
  323. </section>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. </div>
  330. </div>`;
  331. massageList.push(massageCardContent);
  332. massageModalList.push(massageModalContent);
  333. // 合併陣列
  334. const massageArray = contentList.concat(massageList);
  335. $('.massage-content-item').html(massageArray);
  336. $('.massage-modal').html(massageModalList);
  337. }
  338. },
  339. error: function (err) {
  340. console.log('err', err);
  341. }
  342. });