jinx 8 mesi fa
parent
commit
e65a2edd2e
4 ha cambiato i file con 133 aggiunte e 117 eliminazioni
  1. 4 4
      src/views/data/index.vue
  2. 1 1
      src/views/home/index.vue
  3. 89 89
      src/views/map/data.js
  4. 39 23
      src/views/map/index.vue

+ 4 - 4
src/views/data/index.vue

@@ -76,22 +76,22 @@ const procressData = (list) => {
       switch (key) {
         case "地图上分类":
           obj["title"] = item[key];
-          if (item[key] === "自然探索") {
+          if (item[key] === "历史文化") {
             obj["type"] = 1;
           }
-          if (item[key] === "政府驻地") {
+          if (item[key] === "自然探索") {
             obj["type"] = 2;
           }
           if (item[key] === "亲子休闲") {
             obj["type"] = 3;
           }
-          if (item[key] === "历史文化") {
+          if (item[key] === "城市烟火") {
             obj["type"] = 4;
           }
           if (item[key] === "交通住宿") {
             obj["type"] = 5;
           }
-          if (item[key] === "城市烟火") {
+          if (item[key] === "政府驻地") {
             obj["type"] = 6;
           }
 

+ 1 - 1
src/views/home/index.vue

@@ -16,7 +16,7 @@
         <div class="item l" @click="goItem(5)"><img src="@/assets/images/homeText5.png" alt="" /></div>
         <div class="item r" @click="goItem(6)"><img src="@/assets/images/homeText6.png" alt="" /></div>
       </div>
-      <div class="close-btn" @click="close"></div>
+      <!-- <div class="close-btn" @click="close"></div> -->
     </div>
   </div>
 </template>

File diff suppressed because it is too large
+ 89 - 89
src/views/map/data.js


+ 39 - 23
src/views/map/index.vue

@@ -15,17 +15,17 @@
     <div id="amap" />
     <div id="panel"></div>
     <!-- <div style="position: absolute; top: 0; left: 0; z-index: 1000"> -->
-      <!-- <wx-open-launch-weapp appid="wx0bc995dace29b2ba" path="pages/banner/index"> -->
-      <!-- <wx-open-launch-weapp appid="wx4cbb8e9d0a6fface">
+    <!-- <wx-open-launch-weapp appid="wx0bc995dace29b2ba" path="pages/banner/index"> -->
+    <!-- <wx-open-launch-weapp appid="wx4cbb8e9d0a6fface">
         <component :is="'script'" type="text/wxtag-template">
           <button class="btn">打开小程序</button>
         </component>
       </wx-open-launch-weapp>
       <button @click="goLocation()">导航1</button> -->
-      <!-- <button @click="goLocation(2)">导航2</button>
+    <!-- <button @click="goLocation(2)">导航2</button>
       <button @click="goLocation(3)">导航3</button> -->
-      <!-- <button @click="openApp">打开小程序</button> -->
-      <!-- <button @click="switchView(1)">切换视图1</button>
+    <!-- <button @click="openApp">打开小程序</button> -->
+    <!-- <button @click="switchView(1)">切换视图1</button>
       <button @click="switchView(2)">切换视图2</button> -->
     <!-- </div> -->
 
@@ -42,9 +42,10 @@
       </div>
       <div class="chat-content">
         <!-- <div class="answer-list"></div> -->
+
         <div class="chat-msg" ref="scrollRef">
           <div class="default-question">
-            <div class="quest-item" @click="hanlderQuest" v-for="i in 10">你好吗</div>
+            <div class="quest-item" @click="hanlderQuest(i)" v-for="i in questList">{{ i }}</div>
           </div>
           <template v-for="(i, index) in messages">
             <div class="ask" v-if="i.role == 'user'">
@@ -66,7 +67,7 @@
 </template>
 
 <script setup>
-import { nextTick, onMounted, ref } from "vue";
+import { nextTick, onMounted, ref, watch } from "vue";
 import AMapLoader from "@amap/amap-jsapi-loader";
 import jsonp from "jsonp";
 import OpenAI from "openai";
@@ -83,6 +84,12 @@ const scrollRef = ref(null);
 // console.error(mapData);
 
 const messages = ref([]);
+if (sessionStorage.getItem("messages")) {
+  messages.value = JSON.parse(sessionStorage.getItem("messages"));
+  nextTick(() => {
+    autoScroll();
+  });
+}
 const answers = ref([]);
 const chat = ref({ content: "", role: "user" });
 
@@ -97,20 +104,20 @@ let openaiA = new OpenAI({
   apiKey: "sk-a42a4d8dda284771a271caf1171d9971",
   dangerouslyAllowBrowser: true,
 });
-
+const questList = ref(["我安排岳阳一日游行程?", "岳阳好吃的地方在哪?", "岳阳哪里最好玩?", "岳阳适合周末带小朋友亲子休闲推荐?"]);
 let dataAll = {
   model: "deepseek-chat",
   stream: true,
 };
 const isLoading = ref(false);
-const hanlderQuest = () => {
+const hanlderQuest = (text) => {
   if (isLoading.value) {
     return;
   }
-  messages.value.push({ content: "你好吗", role: "user" });
+  messages.value.push({ content: text, role: "user" });
   // answers.value.push(JSON.parse(JSON.stringify(chat.value)));
   autoScroll();
-  handleRequest();
+  handleRequest({ content: text, role: "user" });
 };
 const sendChat = () => {
   if (chat.value.content == "" || isLoading.value) {
@@ -122,12 +129,15 @@ const sendChat = () => {
   handleRequest();
 };
 // 像deepSeek发送请求
-const handleRequest = async () => {
+const handleRequest = async (defaultText) => {
   isLoading.value = true;
   // 这个dataAll.messages里面是所有聊天记录,把之前的记录带过去,ai才能进行上下文联动
   // dataAll.messages = dtate.prompts;
-
-  dataAll.messages = [chat.value];
+  if (defaultText) {
+    dataAll.messages = [defaultText];
+  } else {
+    dataAll.messages = [chat.value];
+  }
   // dataAll.messages = answers.value;
   setTimeout(() => {
     chat.value.content = "";
@@ -148,10 +158,13 @@ const handleRequest = async () => {
     }
     isLoading.value = false;
     console.log("完成");
+    sessionStorage.setItem("messages", JSON.stringify(messages.value));
     autoScroll();
   } catch (error) {
+    isLoading.value = false;
     console.error("加载失败");
     messages.value[index].content = "加载失败,请稍后重试!";
+    sessionStorage.setItem("messages", JSON.stringify(messages.value));
   }
 };
 // handleRequest();
@@ -359,7 +372,7 @@ const initMap = async () => {
     securityJsCode: "2d0885f937e5fa6d093830e1765f593d",
   };
   const _AMap = await AMapLoader.load({
-    key: "655ac083de961ed970f2be4ba23b3c9f",//玉骑账号
+    key: "655ac083de961ed970f2be4ba23b3c9f", //玉骑账号
     // key: "b19c9847b3775cd993c5a8a71c5fa1a0",
     version: "2.0",
     plugins: ["AMap.MoveAnimation", "AMap.ImageLayer", "AMap.TileLayer", "AMap.Geolocation", "AMap.DistrictSearch", "AMap.Driving", "AMap.Walking", "AMap.MarkerCluster"],
@@ -703,8 +716,11 @@ const drawBounds = (name) => {
 
 const autoScroll = () => {
   setTimeout(() => {
+    // console.error(scrollRef.value.scrollHeight)
+    let scrollHeight = scrollRef.value.scrollHeight;
     scrollRef.value.scrollTo({
-      top: 999999,
+      // top: 999999,
+      top: scrollHeight,
       behavior: "smooth",
     });
   }, 0);
@@ -1001,8 +1017,8 @@ onMounted(() => {
 <style lang="scss">
 .custom-content-marker {
   position: relative;
-  width: .3333rem;
-  height: .4533rem;
+  width: 0.3333rem;
+  height: 0.4533rem;
 }
 
 .custom-content-marker img {
@@ -1014,15 +1030,15 @@ onMounted(() => {
   position: absolute;
   top: -0.08rem;
   right: -0.1067rem;
-  width: .2rem;
-  height: .2rem;
-  font-size: .16rem;
+  width: 0.2rem;
+  height: 0.2rem;
+  font-size: 0.16rem;
   background: #ccc;
   border-radius: 50%;
   color: #fff;
   text-align: center;
-  line-height: .2rem;
-  box-shadow: -0.0133rem .0133rem .0133rem rgba(10, 10, 10, 0.2);
+  line-height: 0.2rem;
+  box-shadow: -0.0133rem 0.0133rem 0.0133rem rgba(10, 10, 10, 0.2);
 }
 .amap-icon {
   img {