123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <div class="news-form">
- <div class="text-center title">
- <h4>線上諮詢</h4>
- <p>與我們合作,馬上展開全新的創作里程碑</p>
- </div>
- <form>
- <div class="row mb-4">
- <label for="nameValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 聯絡人 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <input type="text" class="form-control" id="nameValue" placeholder="請留下聯絡人姓名" required>
- </div>
- </div>
- <div class="row mb-4">
- <label for="phoneValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 聯絡電話 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-sm-4 col-md-3 col-lg-4 col-xl-3">
- <select id="countryCode" class="form-select">
- <option selected>選擇國碼</option>
- </select>
- </div>
- <div class="col-sm-8 col-md-7 col-lg-5 col-xl-7 mt-3 mt-sm-0">
- <input type="tel" class="form-control" id="phoneCode" placeholder="e.g., 988 888 888" required>
- </div>
- </div>
- <div class="row mb-4">
- <label for="companyValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 公司名稱 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <input type="text" class="form-control" id="companyValue" placeholder="請留下公司名稱" required>
- </div>
- </div>
- <div class="row mb-3">
- <label for="emailValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 電子信箱 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <input type="email" class="form-control" id="emailValue" placeholder="請留下 E-mail" required>
- </div>
- <div class="invalid-feedback">
- Please choose a username.
- </div>
- </div>
- <div class="row mb-3">
- <label for="dateValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 預計活動需求日 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10 d-flex align-items-center">
- <input type="date" id="dateValue" name="dateValue" class="px-2"
- style="border:1px solid #ced4da; border-radius: 3px;" required />
- </div>
- </div>
- <div class="row mb-4">
- <label for="budgetValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 預算限制 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <select class="form-select" id="budgetValue" name="budgetValue">
- <option selected>請選擇</option>
- <option value="一萬以內">一萬以內</option>
- <option value="一萬到五萬">一萬到五萬</option>
- <option value="五萬到十萬">五萬到十萬</option>
- <option value="無預算限制">無預算限制</option>
- </select>
- </div>
- </div>
- <div class="row mb-4">
- <label for="demandValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 需求目的 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <!-- <input type="text" class="form-control" id="demandValue" placeholder="請留下需求目的"> -->
- <fieldset>
- <div>
- <input type="radio" id="aiHost" name="demandValue" value="AI主持人" />
- <label for="aiHost">AI主持人(尾牙、活動)</label>
- <br>
- <input type="radio" id="aiGuide" name="demandValue" value="AI導覽員" />
- <label for="aiGuide">AI導覽員</label>
- <br>
- <input type="radio" id="aiOfficial" name="demandValue" value="AI長官替身" />
- <label for="aiOfficial">AI長官替身</label>
- <br>
- <input type="radio" id="otherOption" name="demandValue" value="其他" />
- <label for="otherOption">其他(可自行填寫)</label>
- <input type="text" id="otherText" class="w-100" style="border:1px solid #ced4da; border-radius: 3px;" />
- </div>
- </fieldset>
- </div>
- </div>
- <div class="row mb-4">
- <label for="captionValue" class="col-md-2 col-lg-3 col-xl-2 col-form-label">
- <div class="d-flex flex-nowrap">
- 需求說明 <span class="text-danger">*</span>
- </div>
- </label>
- <div class="col-md-10 col-lg-9 col-xl-10">
- <textarea class="form-control" id="captionValue" rows="3" placeholder="請簡述說明" required></textarea>
- </div>
- </div>
- <div class="row">
- <div class="col-md-10 col-lg-9 col-xl-10 offset-sm-2">
- <div class="form-check">
- <input class="form-check-input mt-2" type="checkbox" id="agreeValue">
- <label class="form-check-label w-100" for="agreeValue">
- 本人同意集仕多搜集資料
- </label>
- </div>
- </div>
- </div>
- <div style="height: 15px;">
- <span class="errorText text-danger">尚有欄位未填寫</span>
- </div>
- <div class="d-flex justify-content-center mt-5">
- <button type="submit" class="submit-btn" id="submitBtn">
- <span class="spinner-border spinner-border-sm me-2 loading-btn" role="status" aria-hidden="true"></span>
- 提交
- </button>
- </div>
- </form>
- </div>
- <script src="//code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
- crossorigin="anonymous"></script>
- <!-- <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
- <script type="module">
- import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'
- const supabase = createClient('http://172.105.241.163:8000', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q');
- let { data: ai_news, error } = await supabase
- .from('ai_news')
- .select('*')
- console.log('ai_news', ai_news);
- const newData = {
- name: 'New AI News',
- data: "",
- };
- let { data: insertedData, error: insertError } = await supabase
- .from('ai_news')
- .insert([newData]);
- </script> -->
- <script>
- // 電話國碼
- const countryCodes = [
- '+1', // 美國
- '+7', // 俄羅斯
- '+33', // 法國
- '+39', // 義大利
- '+44', // 英國
- '+46', // 瑞典
- '+47', // 挪威
- '+49', // 德國
- '+52', // 墨西哥
- '+60', // 馬來西亞
- '+61', // 澳大利亞
- '+62', // 印尼
- '+64', // 紐西蘭
- '+65', // 新加坡
- '+66', // 泰國
- '+81', // 日本
- '+82', // 南韓
- '+86', // 中國大陸
- '+91', // 印度
- '+353', // 愛爾蘭
- '+852', // 香港
- '+853', // 澳門
- '+886', // 台灣
- ];
- const countryCode = document.getElementById('countryCode');
- countryCodes.forEach(code => {
- const option = document.createElement('option');
- option.value = code;
- option.text = code;
- countryCode.appendChild(option);
- });
- // 串接 Google Sheets 表單:https://docs.google.com/spreadsheets/d/1fvCmsUu-0lAraKMSbApUy8cQre3F85eQzzZyh9qwNzA/edit#gid=0
- $('.errorText').hide();
- $('.loading-btn').hide();
- const scriptURL = 'https://script.google.com/macros/s/AKfycbyAUKo8onoxuEgXP876QsR6q0_8379v4hMCvYVCk3gVaaTEIuK7hPNnOSKNWHlBJ4mVgA/exec';
- function send() {
- console.log('addEventListener');
- let name = document.querySelector('#nameValue').value; // 聯絡人
- let phone; // 聯絡電話
- let company = document.querySelector('#companyValue').value; // 公司名稱
- let email = document.querySelector('#emailValue').value; // 電子信箱
- let demand; // 需求目的
- let caption = document.querySelector('#captionValue').value; // 需求說明
- let budget = document.querySelector('#budgetValue').value; // 預算限制
- // let date = document.querySelector('#dateValue').value; // 預計活動需求日
- let agree; // 搜集資料
- let time; // 填單時間
- // 取得當下時間
- const now = new Date();
- const options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' };
- time = now.toLocaleString('zh-TW', options);
- console.log('time', time);
- if (document.querySelector('input[id="agreeValue"]:checked')) {
- agree = "同意";
- } else {
- agree = "不同意";
- }
- if (document.querySelector('input[name="demandValue"]:checked')) {
- demand = document.querySelector('input[name="demandValue"]:checked').value;
- }
- if (demand === "其他") {
- demand = document.querySelector('#otherText').value;
- }
- let countryCode = document.querySelector('#countryCode').value; // 國碼
- let phoneCode = document.querySelector('#phoneCode').value; // 電話號碼
- phone = `${countryCode} ${phoneCode}`;
- $.ajax({
- url: scriptURL,
- method: "post",
- data: {
- "name": name,
- "phone": phone,
- "company": company,
- "email": email,
- "demand": demand,
- "caption": caption,
- "budget": budget,
- // "date": date,
- "agree": agree,
- "time": time
- },
- success: function (response) {
- if (response == "成功") {
- $('.loading-btn').hide();
- alert("成功提交!");
- }
- },
- });
- // 寄信
- let templateParams = {
- name: name,
- phone: phone,
- company: company,
- email: email,
- demand: demand,
- caption: caption,
- budget: budget,
- date: date,
- agree: agree,
- };
- emailjs.send('service_kyazqjp', 'template_n0sqgwh', templateParams).then(
- (response) => {
- console.log('SUCCESS!', response.status, response.text);
- },
- (error) => {
- console.log('FAILED...', error);
- },
- );
- };
- $('button').on('click', function (e) {
- e.preventDefault();
- let countryCode = document.querySelector('#countryCode').value;
- let budget = document.querySelector('#budgetValue').value; // 預算限制
- let demand = ""; // 需求目的
- if (document.querySelector('input[name="demandValue"]:checked')) {
- demand = document.querySelector('input[name="demandValue"]:checked').value;
- }
- if (demand === "其他") {
- demand = document.querySelector('#otherText').value;
- }
- // 手動觸發表單提交
- let form = $(this).closest('form');
- form[0].reportValidity(); // 顯示瀏覽器內建錯誤提示
- if (countryCode === "選擇國碼" || budget === "請選擇" || demand === "") {
- console.log('表單未通過驗證');
- $('.errorText').show();
- return;
- }
- if (form[0].reportValidity()) {
- $('.loading-btn').show();
- $('.errorText').hide();
- send();
- }
- });
- </script>
|