소스 검색

update query

SyuanYu 1 년 전
부모
커밋
4269b8f1c7
3개의 변경된 파일23개의 추가작업 그리고 6개의 파일을 삭제
  1. 7 2
      frontend/src/api.ts
  2. 2 2
      frontend/src/stores/main.ts
  3. 14 2
      frontend/src/views/YTViews.vue

+ 7 - 2
frontend/src/api.ts

@@ -141,8 +141,13 @@ export const api = {
     formData.append("amount", amount.toString());
     return axios.post<string>(`${apiUrl}/api/v1/payment/ecpayTestPay`, formData, authHeaders(token))
   },
-  async YTViewsPayment(user_data: YTViewsUserData) {
-    return axios.post<string>(`${apiUrl}/api/v1/payment/ytviews-ecpay-payment`, user_data);
+  async YTViewsPayment(user_data: YTViewsUserData, lang: string) {
+    const config = {
+      params: {
+        lang: lang
+      }
+    };
+    return axios.post<string>(`${apiUrl}/api/v1/payment/ytviews-ecpay-payment`, user_data, config);
   },
   async YTViewsTestPayment(user_data: YTViewsUserData) {
     return axios.post<string>(`${apiUrl}/api/v1/payment/ytviews-ecpay-test-payment`, user_data);

+ 2 - 2
frontend/src/stores/main.ts

@@ -481,12 +481,12 @@ export const useMainStore = defineStore("MainStoreId", {
         await mainStore.checkApiError(error);
       }
     },
-    async YTViewsPayment(user_data: YTViewsUserData) {
+    async YTViewsPayment(user_data: YTViewsUserData, lang: string) {
       const mainStore = useMainStore();
       try {
         const response = (
           await Promise.all([
-            api.YTViewsPayment(user_data),
+            api.YTViewsPayment(user_data, lang),
             await new Promise<void>((resolve, _) => setTimeout(() => resolve(), 0)),
           ])
         );

+ 14 - 2
frontend/src/views/YTViews.vue

@@ -7,7 +7,8 @@ import Navbar from "@/components/Navbar.vue";
 
 const mainStore = useMainStore();
 const urlRules = [
-  (v:any) => /^(http|https):\/\//.test(v) || '請輸入以 http 或 https 開頭的有效網址',
+  (v: any) =>
+    /^(http|https):\/\//.test(v) || "請輸入以 http 或 https 開頭的有效網址",
 ];
 
 const items = reactive([
@@ -139,6 +140,16 @@ async function ECPaySubmit() {
     userData.theme = theme.value;
   }
 
+  let lang = ref("");
+  let getLang = localStorage.getItem("lang");
+
+  // 綠界顯示語言
+  if (getLang === "zh") {
+    lang.value = "ZH";
+  } else {
+    lang.value = "ENG";
+  }
+
   let data: YTViewsUserData = {
     item: `YT0.4-(${assignView.value})`,
     amount: assignPrice.value,
@@ -153,7 +164,8 @@ async function ECPaySubmit() {
     theme: userData.theme,
     taxID: userData.taxID,
   };
-  const originalHTML = await mainStore.YTViewsTestPayment(data);
+
+  const originalHTML = await mainStore.YTViewsPayment(data, lang.value);
   let formHTML = originalHTML?.replace(
     '<script type="text/javascript">document.getElementById("data_set").submit();</scr',
     ""