SyuanYu hai 6 meses
pai
achega
4e03b2a08c
Modificáronse 1 ficheiros con 102 adicións e 10 borrados
  1. 102 10
      src/components/Chat.vue

+ 102 - 10
src/components/Chat.vue

@@ -361,13 +361,21 @@ async function sendMessage(type = "") {
             if (item.type === "button") {
               info.buttonList.push(item);
               labelContent = "ticket";
-            } else if (item.type === "ticket") {
+            } else {
               info.ticketList.push(item);
-              labelContent = "ticket";
-            } else if (item.type === "brand") {
-              info.ticketList.push(item);
-              labelContent = "brand";
+              labelContent = "card";
             }
+
+            // if (item.type === "button") {
+            //   info.buttonList.push(item);
+            //   labelContent = "ticket";
+            // } else if (item.type === "ticket") {
+            //   info.ticketList.push(item);
+            //   labelContent = "ticket";
+            // } else if (item.type === "brand") {
+            //   info.ticketList.push(item);
+            //   labelContent = "brand";
+            // }
           });
 
           console.log("info", info);
@@ -2556,15 +2564,25 @@ function setInfo(data) {
     if (item.type === "button") {
       info.buttonList.push(item);
       labelContent = "ticket";
-    } else if (item.type === "ticket") {
-      info.ticketList.push(item);
-      labelContent = "ticket";
-    } else if (item.type === "brand") {
+    } else {
       info.ticketList.push(item);
-      labelContent = "brand";
+      labelContent = "card";
     }
+
+    // if (item.type === "button") {
+    //   info.buttonList.push(item);
+    //   labelContent = "ticket";
+    // } else if (item.type === "ticket") {
+    //   info.ticketList.push(item);
+    //   labelContent = "ticket";
+    // } else if (item.type === "brand") {
+    //   info.ticketList.push(item);
+    //   labelContent = "brand";
+    // }
   });
 
+  console.log("info", info);
+
   setTimeout(() => {
     messages.value.push({
       label: labelContent,
@@ -3488,6 +3506,80 @@ onBeforeUnmount(() => {
             </swiper>
           </div>
 
+          <!-- 推播卡片 -->
+          <div v-else-if="message.label === 'card'" class="ticket-item">
+            <!-- 按鈕 -->
+            <swiper
+              v-if="message.body.buttonList?.length"
+              :slidesPerView="'auto'"
+              :spaceBetween="20"
+              :modules="modules"
+              class="btn-swiper"
+              :style="{
+                marginBottom: message.body.ticketList.length ? '35px' : '0px',
+              }"
+            >
+              <swiper-slide v-for="item in message.body.buttonList">
+                <div class="btn-container">
+                  <button @click="setBtnValue(item.info.value)">
+                    {{ item.info.key }}
+                  </button>
+                </div>
+              </swiper-slide>
+            </swiper>
+
+            <!-- 票券 -->
+            <swiper
+              v-if="message.body.ticketList?.length"
+              :slidesPerView="'auto'"
+              :spaceBetween="20"
+              :navigation="true"
+              :modules="modules"
+              class="ticket-slide"
+            >
+              <swiper-slide v-for="(item, index) in message.body.ticketList">
+                <div class="slide-item">
+                  <img
+                    class="cover-img"
+                    :src="item.info.img || item.info.cover_img"
+                    alt=""
+                  />
+                  <section>
+                    <h3 class="title">
+                      {{ item.info.name || item.info.title }}
+                    </h3>
+                    <div class="price-info">
+                      <span>{{ item.info.floor || item.info.price }}</span>
+                      <div class="link-btn">
+                        <!-- <a
+                          :href="item.info.website_url || item.info.url"
+                          target="_blank"
+                        >
+                          {{ t("cta_url") }}
+                        </a> -->
+
+                        <!-- 掃描 QR Code -->
+                        <v-btn
+                          @click="
+                            openQrcodeDialog(
+                              item.info.website_url || item.info.url
+                            )
+                          "
+                          color="primary"
+                        >
+                          <p class="text-white m-0">{{ t("cta_url") }}</p>
+                        </v-btn>
+                      </div>
+                    </div>
+                    <p class="description">
+                      {{ item.info.content || item.info.description }}
+                    </p>
+                  </section>
+                </div>
+              </swiper-slide>
+            </swiper>
+          </div>
+
           <!-- 推薦資訊 -->
           <div v-else-if="message.label === 'ticket'" class="ticket-item">
             <!-- 按鈕 -->