index.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. $("#menu-box2").hide();
  39. $("#menu-box").hide();
  40. $("#menu-btn1").click(function () {
  41. $(this).toggleClass("fa-times");
  42. $("#menu-box").fadeToggle(500);
  43. $("#menu-box2").fadeToggle(500);
  44. });
  45. $("#menu-box").click(function () {
  46. // let myDiv = document.getElementById('menu-btn1');
  47. // myDiv.className = "fas fa-bars menu ms-2";
  48. $("#menu-box").fadeToggle(500);
  49. $("#menu-box2").fadeToggle(500);
  50. });
  51. // $(".link").click(function () {
  52. // $("#menu-box").slideUp("slow", function () {
  53. // $("#menu-box2").slideUp("slow");
  54. // // Animation complete.
  55. // });
  56. // });
  57. $(".news-slide").slick({
  58. dots: true,
  59. // autoplay: true,
  60. arrows: true,
  61. slidesToShow: 1,
  62. slidesToScroll: 1,
  63. autoplaySpeed: 7000,
  64. initialSlide: 0,
  65. infinite: true,
  66. prevArrow: "<img class='prev slick-prev' src='./img/arrowprev.png'>",
  67. nextArrow: "<img class='next slick-next' src='./img/arrownext.png'>"
  68. });
  69. // 避免動畫與使用者滾輪衝突
  70. // html 在滾動滾輪時 停止 html 所有效果
  71. $("html").on("mousewheel", function () {
  72. $("html").stop();
  73. });
  74. $(".playbutton").click(function () {
  75. var videosrc = $(this).data("info");
  76. $('.youtube-video').attr('src', `https://www.youtube.com/embed//${videosrc}?autoplay=1`);
  77. });
  78. $(".btn-close").click(function () {
  79. $('.youtube-video').attr('src', ``);
  80. });
  81. $('#yt-video').on('hidden.bs.modal', function () {
  82. $('.youtube-video').attr('src', ``);
  83. });
  84. // $(".banner-slide").slick({
  85. // dots: true,
  86. // autoplay: true,
  87. // arrows: false,
  88. // slidesToShow: 1,
  89. // slidesToScroll: 1,
  90. // autoplaySpeed: 7000,
  91. // initialSlide: 0,
  92. // infinite: true,
  93. // });
  94. $(".violetbeauty_sec01_slide").slick({
  95. slidesToShow: 4,
  96. slidesToScroll: 3,
  97. infinite: true,
  98. // centerMode: true,
  99. arrows: true,
  100. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>',
  101. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>'
  102. });
  103. $(".violetbeauty_sec02_slide").slick({
  104. slidesToShow: 3,
  105. slidesToScroll: 3,
  106. infinite: true,
  107. // centerMode: true,
  108. arrows: true,
  109. prevArrow: '<button type="button" class="slick-prev"><i class="fas fa-chevron-left" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>',
  110. nextArrow: '<button type="button" class="slick-next"><i class="fas fa-chevron-right" style="font-size: 32px;color: #CC7DB7;transform: translateY(-10px);"></i></button>'
  111. });
  112. $(".learn_more").click(function () {
  113. var courseid = $(this).data("info");
  114. // console.log(courseid);
  115. $.ajax({
  116. method: "GET",
  117. url: "coursecontent.json",
  118. dataType: "json",
  119. })
  120. .done(function (msg) {
  121. // console.log(msg)
  122. for (var i = 0; i < msg.length; i++) {
  123. if (msg[i].Courseid == courseid) {
  124. var CourseContent = '';
  125. console.log(msg[i]);
  126. CourseContent = `
  127. <div class="course_detail py-3">
  128. <div class="row">
  129. <div class="col-md-7">
  130. <div class="course_detail_img mt-3">
  131. <img class="img-fluid" src="${msg[i].CourseImg}" alt="">
  132. </div>
  133. </div>
  134. <div class="col-md-5">
  135. <div class="course_detail_text">
  136. <div class="features_title fw-bold text-start">${msg[i].CourseTitle}</div>
  137. <div class="sec_content_right_text">
  138. <p>${msg[i].Coursetext}</p>
  139. </div>
  140. </div>
  141. <div class="text-center">
  142. <button class="violetbeauty_CTA mt-4"><a style="text-decoration: none;" target="_blank" href="https://line.me/R/ti/p/%2540qlo9716l"><img class="cta_flower" src="./img/flower.png" alt="">立即體驗</a></button>
  143. </div>
  144. </div>
  145. </div>
  146. </div>`
  147. }
  148. $('.modal-body').html(CourseContent);
  149. }
  150. });
  151. });
  152. // facial.html
  153. $.ajax({
  154. type: "GET",
  155. url: "facial.json",
  156. dataType: "json",
  157. success: function (res) {
  158. let facialList = [];
  159. let facialModalList = [];
  160. for (let i = 0; i < res.length; i++) {
  161. let facialCardContent = `
  162. <div class="col-12 col-md-6 col-xl-4">
  163. <div class="card h-100">
  164. <div class="img-box">
  165. <img src="${res[i].image}" class="card-img-top" alt="...">
  166. </div>
  167. <div class="card-body">
  168. <div class="d-flex justify-content-between">
  169. <h5 class="badge">臉部課程</h5>
  170. <div class="d-flex align-items-center time-box">
  171. <img src="./img/icon-time.png" alt="">
  172. <p><span>${res[i].time}</span>分鐘</p>
  173. </div>
  174. </div>
  175. <h5 class="card-title fw-bold my-3">${res[i].title}</h5>
  176. <p class="card-text">${res[i].description}</p>
  177. </div>
  178. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#facial_modal_${i + 1}">
  179. 了解課程
  180. </button>
  181. </div>
  182. </div>`;
  183. let facialModalContent = `
  184. <div class="modal fade" id="facial_modal_${i + 1}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  185. <div class="modal-dialog modal-dialog-centered modal-xl">
  186. <div class="modal-content">
  187. <div class="modal-header">
  188. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  189. </div>
  190. <div class="modal-body m-3 m-xl-5 mb-2 mb-lg-5">
  191. <div class="container-fluid">
  192. <div class="row align-items-center">
  193. <div class="col-12 col-lg-7">
  194. <img src="${res[i].image}" alt="" style="width: 100%; box-shadow: 0 0 10px rgb(32 32 32 / 25%);">
  195. </div>
  196. <div class="col-12 col-lg-5 px-3 px-xl-5">
  197. <h5 class="fw-bold my-3">${res[i].title}</h5>
  198. <div class="d-flex justify-content-between my-4">
  199. <div class="d-flex flex-column price-box">
  200. <span>體驗價 $${res[i].price}</span>
  201. <span>原價 $${res[i].originalPrice}</span>
  202. </div>
  203. <div class="d-flex align-items-center time-box">
  204. <img src="./img/icon-time.png" alt="">
  205. <p><span>${res[i].time}</span>分鐘</p>
  206. </div>
  207. </div>
  208. <section class="d-flex flex-column justify-content-between">
  209. <p>${res[i].description}</p>
  210. <div class="recommend-item" style="display: ${res[i].recommend !== "" ? 'flex' : 'none'}">
  211. <span class="badge">推薦</span>
  212. ${res[i].recommend}
  213. </div>
  214. </section>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. </div>
  221. </div>`;
  222. facialList.push(facialCardContent);
  223. facialModalList.push(facialModalContent);
  224. $('.facial-content-item').html(facialList);
  225. $('.facial-modal').html(facialModalList);
  226. }
  227. },
  228. error: function (err) {
  229. console.log('err', err);
  230. }
  231. });
  232. // massage.html
  233. $.ajax({
  234. type: "GET",
  235. url: "massage.json",
  236. dataType: "json",
  237. success: (res) => {
  238. let massageList = [];
  239. let massageModalList = [];
  240. let contentList = [
  241. `<div class="col-12 col-md-6 col-xl-4">
  242. <div class="card h-100">
  243. <div class="img-box">
  244. <img src="./img/維生素育膚課程/4.jpg" class="card-img-top" alt="...">
  245. </div>
  246. <div class="card-body">
  247. <div class="d-flex justify-content-between">
  248. <h5 class="badge">身體課程</h5>
  249. <div class="d-flex align-items-center time-box">
  250. <img src="./img/icon-time.png" alt="">
  251. <p><span>60</span>分鐘/<span>120</span>分鐘</p>
  252. </div>
  253. </div>
  254. <h5 class="card-title fw-bold my-3">波動舒活經絡課程</h5>
  255. <p class="card-text">久坐、久站或長期的姿勢不良,讓妳經常腰酸背痛嗎?手技搭配儀器,不再是單純肌肉放鬆,針對氣血循環,功力深厚的技巧,專業的儀器走向,完全放鬆你的身心靈。</p>
  256. </div>
  257. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_1">
  258. 了解課程
  259. </button>
  260. </div>
  261. </div>`,
  262. `<div class="col-12 col-md-6 col-xl-4">
  263. <div class="card h-100">
  264. <div class="img-box">
  265. <img src="./img/維生素育膚課程/14.jpg" class="card-img-top" alt="...">
  266. </div>
  267. <div class="card-body">
  268. <div class="d-flex justify-content-between">
  269. <h5 class="badge">身體課程</h5>
  270. <div class="d-flex align-items-center time-box">
  271. <img src="./img/icon-time.png" alt="">
  272. <p><span>40</span>分鐘/<span>60</span>分鐘/<span>80</span>分鐘</p>
  273. </div>
  274. </div>
  275. <h5 class="card-title fw-bold my-3">五行氣穴課程</h5>
  276. <p class="card-text">藉由中醫理論五行學說,透過美容師手勁與技巧將阻塞處舒展,達到通筋通便活絡氣血效應,達到陰陽流暢,全程手技,使用原始原點精油,刺激身體各部位穴點,與一般經絡按摩較不同!愛按摩的你絕不能錯過。</p>
  277. </div>
  278. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_2">
  279. 了解課程
  280. </button>
  281. </div>
  282. </div>`,
  283. `<div class="col-12 col-md-6 col-xl-4">
  284. <div class="card h-100">
  285. <div class="img-box">
  286. <img src="./img/維生素育膚課程/11.jpg" class="card-img-top" alt="...">
  287. </div>
  288. <div class="card-body">
  289. <h5 class="badge">身體課程</h5>
  290. <h5 class="card-title fw-bold my-3">半永久熱蠟除毛</h5>
  291. <p class="card-text">擾人的毛髮交給我們,容易悶熱滋生細菌造成異味,妳的救星!熱蠟是所有技術中最低疼痛感,能讓毛髮生長延緩,達到重生毛髮越來越細軟,甚至無毛。</p>
  292. </div>
  293. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massageModal_3">
  294. 了解課程
  295. </button>
  296. </div>
  297. </div>`];
  298. for (let i = 0; i < res.length; i++) {
  299. let massageCardContent = `
  300. <div class="col-12 col-md-6 col-xl-4">
  301. <div class="card h-100">
  302. <div class="img-box">
  303. <img src="${res[i].image}" class="card-img-top" alt="...">
  304. </div>
  305. <div class="card-body">
  306. <div class="d-flex justify-content-between">
  307. <h5 class="badge">身體課程</h5>
  308. <div class="d-flex align-items-center time-box">
  309. <img src="./img/icon-time.png" alt="">
  310. <p><span>${res[i].time}</span>分鐘</p>
  311. </div>
  312. </div>
  313. <h5 class="card-title fw-bold my-3">${res[i].title}</h5>
  314. <p class="card-text">${res[i].description}</p>
  315. </div>
  316. <button type="button" class="btn" data-bs-toggle="modal" data-bs-target="#massage_modal_${i + 1}">
  317. 了解課程
  318. </button>
  319. </div>
  320. </div>`;
  321. let massageModalContent = `
  322. <div class="modal fade" id="massage_modal_${i + 1}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  323. <div class="modal-dialog modal-dialog-centered modal-xl">
  324. <div class="modal-content">
  325. <div class="modal-header">
  326. <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  327. </div>
  328. <div class="modal-body m-3 mb-2 mb-lg-5">
  329. <div class="container-fluid">
  330. <div class="row align-items-center">
  331. <div class="col-12 col-lg-7">
  332. <img src="${res[i].image}" alt="" style="width: 100%; box-shadow: 0 0 10px rgb(32 32 32 / 25%);">
  333. </div>
  334. <div class="col-12 col-lg-5 px-3 px-xl-5">
  335. <h5 class="fw-bold my-3">${res[i].title}</h5>
  336. <div class="d-flex justify-content-between my-4">
  337. <div class="d-flex flex-column price-box">
  338. <span>體驗價 $${res[i].price}</span>
  339. <span>原價 $${res[i].originalPrice}</span>
  340. </div>
  341. <div class="d-flex align-items-center time-box">
  342. <img src="./img/icon-time.png" alt="">
  343. <p><span>${res[i].time}</span>分鐘</p>
  344. </div>
  345. </div>
  346. <section class="d-flex flex-column justify-content-between">
  347. <p>${res[i].description}</p>
  348. <div class="recommend-item">
  349. <span class="badge">推薦</span>
  350. ${res[i].recommend}
  351. </div>
  352. </section>
  353. </div>
  354. </div>
  355. </div>
  356. </div>
  357. </div>
  358. </div>
  359. </div>`;
  360. massageList.push(massageCardContent);
  361. massageModalList.push(massageModalContent);
  362. // 合併陣列
  363. const massageArray = contentList.concat(massageList);
  364. $('.massage-content-item').html(massageArray);
  365. $('.massage-modal').html(massageModalList);
  366. }
  367. },
  368. error: function (err) {
  369. console.log('err', err);
  370. }
  371. });
  372. var date = new Date();
  373. var year = date.getFullYear();
  374. var month = ('0' + (date.getMonth() + 1)).slice(-2);
  375. var day = ('0' + (date.getDate())).slice(-2);
  376. // var day = date.getDay();
  377. // console.log(date)
  378. // console.log(date.getDate());
  379. // console.log(date.getMonth())
  380. var time = year + '-' + month + '-' + day;
  381. // console.log(time);
  382. document.getElementById('datepicker').value = time;
  383. document.getElementById('datepicker').setAttribute('min', time);
  384. // // 手機板表單
  385. // $.fn.serializeObject = function () {
  386. // var o = {};
  387. // var a = this.serializeArray();
  388. // $.each(a, function () {
  389. // if (o[this.name]) {
  390. // if (!o[this.name].push) {
  391. // o[this.name] = [o[this.name]];
  392. // }
  393. // o[this.name].push(this.value || '');
  394. // } else {
  395. // o[this.name] = this.value || '';
  396. // }
  397. // });
  398. // return o;
  399. // };
  400. $(".violetbeauty_contract_form").submit(function (e) {
  401. let data_loc = $("#loc").val();
  402. let data_course_name = $("#course_name").val();
  403. let date_name = $("#name").val();
  404. let data_booktime = $("#time").val();
  405. let data_phone = $("#phone").val();
  406. let data_bookdate = $("#datepicker").val();// ];
  407. let data_loc_str = encodeURI(data_loc);
  408. let data_course_name_str = encodeURI(data_course_name);
  409. let data_name_str = encodeURI(date_name);
  410. // let form_data = 'name='+ date_name +'&phone='+ data_phone +'&loc='+ data_loc +'&course_name='+ data_course_name +'&bookdate='+ data_bookdate +'&booktime='+ data_booktime +''
  411. // let data =data_booktime+data_name+data_phone+data_loc+data_course_name+data_bookdate+data_booktime
  412. // console.log(form_data);
  413. var url = "https://api.ptt.cx:19201/submitform";
  414. var xhr = new XMLHttpRequest();
  415. xhr.open("POST", url);
  416. xhr.setRequestHeader("accept", "application/json");
  417. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  418. xhr.onreadystatechange = function () {
  419. var title = "送出成功";
  420. if (xhr.readyState === 4) {
  421. console.log(xhr.status);
  422. console.log(xhr.responseText);
  423. Swal.fire({
  424. title: title,
  425. icon: 'success',
  426. confirmButtonColor: '#3085d6',
  427. });
  428. }
  429. };
  430. // location.reload();
  431. window.setTimeout(() => {
  432. // window.location.href = 'index.html';
  433. location.reload();
  434. }, 2000);
  435. var data = 'name=' + data_name_str + '&phone=' + data_phone + '&loc=' + data_loc_str + '&course_name=' + data_course_name_str + '&bookdate=' + data_bookdate + '&booktime=' + data_booktime + '';
  436. xhr.send(data);
  437. console.log(data);
  438. return false;
  439. });
  440. $(".timepicker").timepicker({
  441. timeFormat: "h:mm p", // 時間隔式
  442. interval: 30, //時間間隔
  443. minTime: "10:30am", //最小時間
  444. maxTime: "18:30pm", //最大時間
  445. defaultTime: "10:30", //預設起始時間
  446. startTime: "10:00", // 開始時間
  447. dynamic: true, //是否顯示項目,使第一個項目按時間順序緊接在所選時間之後
  448. dropdown: true, //是否顯示時間條目的下拉列表
  449. scrollbar: true, //是否顯示捲軸
  450. });
  451. // let data =data_booktime+data_name+data_phone+data_loc+data_course_name+data_bookdate+data_booktime