|
@@ -3,6 +3,7 @@ import { ref } from "vue";
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
import { useMainStore } from "@/stores/store";
|
|
|
import axios from "axios";
|
|
|
+import QrcodeVue from "qrcode.vue";
|
|
|
import Footer from "../components/Footer.vue";
|
|
|
|
|
|
const { t } = useI18n();
|
|
@@ -15,9 +16,6 @@ const shareData = {
|
|
|
text: "AI明信片", // 文字內容
|
|
|
};
|
|
|
|
|
|
-console.log("shareData", shareData);
|
|
|
-console.log("store.assignBgImgTitle", store.assignBgImgTitle);
|
|
|
-
|
|
|
const imageUrl = ref("");
|
|
|
|
|
|
// 儲存圖片
|
|
@@ -59,22 +57,50 @@ async function share() {
|
|
|
alert(err);
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+let dialog = ref(false);
|
|
|
+let randomUrl = ref(""); // 館外店家連結
|
|
|
+let randomStoreName = ref(""); // 館外店家名稱
|
|
|
+
|
|
|
+// 取得隨機館外店家
|
|
|
+async function getBrand() {
|
|
|
+ let url =
|
|
|
+ "https://cmm.ai:9101/find_brand?keyword=%E9%A4%A8%E5%A4%96&language=ch";
|
|
|
+
|
|
|
+ try {
|
|
|
+ let response = await axios.get(url);
|
|
|
+ console.log("getBrand", response);
|
|
|
|
|
|
- // console.log("share");
|
|
|
- // if (navigator.share) {
|
|
|
- // try {
|
|
|
- // await navigator.share({
|
|
|
- // title: "101",
|
|
|
- // text: "AI明信片",
|
|
|
- // url: store.imgPath,
|
|
|
- // });
|
|
|
- // console.log("分享成功");
|
|
|
- // } catch (error) {
|
|
|
- // console.error("分享失敗", error);
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // alert("Web Share API 不支援在此設備上運行");
|
|
|
- // }
|
|
|
+ const randomItem =
|
|
|
+ response.data.data[Math.floor(Math.random() * response.data.data.length)];
|
|
|
+
|
|
|
+ randomUrl.value = randomItem.info.url;
|
|
|
+ randomStoreName.value = randomItem.info.name;
|
|
|
+
|
|
|
+ setPostcardLog();
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+getBrand();
|
|
|
+
|
|
|
+// 儲存 Log
|
|
|
+async function setPostcardLog() {
|
|
|
+ let url = `https://cmm.ai:9101/ai-postcard-log/`;
|
|
|
+
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append("url", randomUrl.value);
|
|
|
+ formData.append("file", store.imgFile);
|
|
|
+ formData.append("store_name", randomStoreName.value);
|
|
|
+
|
|
|
+ try {
|
|
|
+ let response = await axios.post(url, formData);
|
|
|
+ console.log("setPostcardLog", response);
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -100,12 +126,46 @@ async function share() {
|
|
|
|
|
|
<!-- <button @click="share()" class="main-btn mt-15">分享相片</button> -->
|
|
|
|
|
|
- <div class="d-flex flex-column mt-15">
|
|
|
+ <div class="d-flex flex-column mt-10">
|
|
|
<button @click="downloadImage(store.imgPath)" class="main-btn mb-7">
|
|
|
{{ t("save_photo") }}
|
|
|
</button>
|
|
|
|
|
|
- <button class="main-btn">{{ t("get_coupon") }}</button>
|
|
|
+ <!-- <a :href="randomUrl" target="_blank" class="main-btn">
|
|
|
+ {{ t("get_coupon") }}
|
|
|
+ </a> -->
|
|
|
+
|
|
|
+ <button @click="dialog = true" class="main-btn">
|
|
|
+ {{ t("get_coupon") }}
|
|
|
+ </button>
|
|
|
+
|
|
|
+ <v-dialog v-model="dialog" width="auto">
|
|
|
+ <v-card max-width="400">
|
|
|
+ <v-card-title class="pa-6">
|
|
|
+ {{ randomStoreName }} <br />
|
|
|
+ 5G活動優惠
|
|
|
+ </v-card-title>
|
|
|
+
|
|
|
+ <v-card-text class="pt-0">
|
|
|
+ <div class="coupon">
|
|
|
+ <img class="bg-img" src="../assets/img/coupon.png" alt="" />
|
|
|
+
|
|
|
+ <img class="result-img" :src="store.imgPath" alt="" />
|
|
|
+
|
|
|
+ <span class="qrcode">
|
|
|
+ <qrcode-vue :value="randomUrl" size="100" level="H" />
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </v-card-text>
|
|
|
+ <template v-slot:actions>
|
|
|
+ <v-btn
|
|
|
+ class="ms-auto"
|
|
|
+ text="關閉"
|
|
|
+ @click="dialog = false"
|
|
|
+ ></v-btn>
|
|
|
+ </template>
|
|
|
+ </v-card>
|
|
|
+ </v-dialog>
|
|
|
</div>
|
|
|
|
|
|
<v-dialog v-if="store.assignBgImgTitle === '南投日月潭'" max-width="300">
|
|
@@ -161,7 +221,14 @@ async function share() {
|
|
|
|
|
|
.img-item {
|
|
|
img {
|
|
|
- border: 8px solid white;
|
|
|
+ border: 8px solid transparent;
|
|
|
+ border-image: linear-gradient(
|
|
|
+ to right,
|
|
|
+ rgba(138, 160, 172, 0.75),
|
|
|
+ rgba(165, 142, 116, 0.75),
|
|
|
+ rgba(128, 108, 87, 0.75)
|
|
|
+ )
|
|
|
+ 1;
|
|
|
}
|
|
|
|
|
|
p {
|
|
@@ -174,12 +241,34 @@ async function share() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-.v-card-title {
|
|
|
- letter-spacing: 1px;
|
|
|
-}
|
|
|
-
|
|
|
a {
|
|
|
- color: var(--main-color);
|
|
|
+ color: white;
|
|
|
text-decoration: none;
|
|
|
}
|
|
|
+
|
|
|
+.coupon {
|
|
|
+ position: relative;
|
|
|
+ .bg-img {
|
|
|
+ width: 100%;
|
|
|
+ position: relative;
|
|
|
+ z-index: 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ .result-img {
|
|
|
+ width: 100%;
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .qrcode {
|
|
|
+ position: absolute;
|
|
|
+ right: 5vw;
|
|
|
+ bottom: 5vw;
|
|
|
+ z-index: 100;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.v-card-title {
|
|
|
+ letter-spacing: 1px;
|
|
|
+}
|
|
|
</style>
|