Bladeren bron

修改搜索

jwyu 2 jaren geleden
bovenliggende
commit
397021c357

+ 2 - 2
.env.development

@@ -5,6 +5,6 @@ VITE_APP_BASE_URL="/"
 # 打包输入文件名
 VITE_APP_OUTDIR="dist"
 # 扫码登录appid
-VITE_APP_APPID="wx615472d6874eeb7f"
+VITE_APP_APPID="wx4da95782cfc8c5eb"
 # 扫码登录回跳地址
-VITE_APP_REDIRECT_URI="https://ybpctest.hzinsights.com/report/index"
+VITE_APP_REDIRECT_URI="https://ybpc.hzinsights.com/report/index"

+ 11 - 14
src/components/LoginPop.vue

@@ -3,7 +3,6 @@ import { onMounted,onUnmounted,reactive,ref} from 'vue';
 import { ElMessage } from 'element-plus';
 import {ArrowDown} from '@element-plus/icons-vue'
 import {apiUserLogin,apiGetEmailCode,apiGetSMSCode} from '@/api/common'
-import store from '../store';
 
 let sendCodeInterval=null
 
@@ -109,19 +108,17 @@ const handleLogin=async ()=>{
 
 
 onMounted(()=>{
-    // https://hzreport.hzinsights.com/index     wx615472d6874eeb7f  
-    // https://ybpctest.hzinsights.com           wxb059c872d79b9967
-    // const redirect_uri=encodeURIComponent(import.meta.env.VITE_APP_REDIRECT_URI)
-    // let obj=new WxLogin({
-    //     self_redirect:false,
-    //     id:"wx-qrcode-box", 
-    //     appid: import.meta.env.VITE_APP_APPID, 
-    //     scope: "snsapi_login", 
-    //     redirect_uri: redirect_uri,
-    //     state: "",
-    //     style: "",
-    //     href: "",//可传入base64 编码的 css样式
-    // });
+    const redirect_uri=encodeURIComponent(import.meta.env.VITE_APP_REDIRECT_URI)
+    let obj=new WxLogin({
+        self_redirect:true,
+        id:"wx-qrcode-box", 
+        appid: import.meta.env.VITE_APP_APPID, 
+        scope: "snsapi_login", 
+        redirect_uri: redirect_uri,
+        state: "",
+        style: "",
+        href: "",//可传入base64 编码的 css样式
+    });
 })
 
 </script>

+ 5 - 1
src/components/Search.vue

@@ -1,6 +1,10 @@
 <script setup>
 import { computed, ref } from "vue";
 const props=defineProps({
+  defaultVal:{
+    type:String,
+    default:''
+  },
   placeholder:{
     type:String,
     default:'请输入关键词'
@@ -16,7 +20,7 @@ const props=defineProps({
 })
 
 const emit = defineEmits(["search",'clean','blur'])
-let searchData = ref("");
+let searchData = ref(props.defaultVal||"");
 let isFocus=ref(false)
 let showClean = computed(() => {
   return searchData.value.length > 0 ? true : false;

+ 1 - 1
src/router/index.js

@@ -101,7 +101,7 @@ const routes=[
         component: () => import("@/views/report/Search.vue"),
         meta: {
           title: "研报搜索",
-          keepAlive:false,
+          keepAlive:true,
           isRoot:false,
           hasBack:true
         },

+ 2 - 2
src/views/report/ChapterDetail.vue

@@ -23,7 +23,7 @@ let frompage=ref(route.query.frompage||'')//如果来自报告详情页 则展
 let tickerInfo=ref(null)
 let tickerHead=ref([])
 const getTickerValue=async ()=>{
-    const res=await apiChapterTickerValue({report_chapter_id:Number(this.chapterId)})
+    const res=await apiChapterTickerValue({report_chapter_id:Number(chapterId.value)})
     if(res.code===200){
         if(!res.data||!res.data.list) return
         tickerInfo.value=res.data
@@ -345,7 +345,7 @@ let showDisclaimers=ref(false)//显示免责声明
                         </template>
                     </el-popover>
                 </div>
-                <div class="hot-box" style="margin-top: 60px;">
+                <div class="hot-box" style="margin-top: 60px;" v-if="banner">
                     <div class="label">{{banner.Type}}</div>
                     <div class="img-con" :style="'background-image:url('+banner.ImgUrl+')'" @click="handleAsideBanner(banner)">
                         <span class="stage">第{{banner.Stage}}期</span>

+ 2 - 1
src/views/report/Index.vue

@@ -8,7 +8,7 @@ import {
 import { onActivated, onMounted, reactive, ref } from "vue"
 import Search from "@/components/Search.vue"
 import SelfList from '@/components/SelfList.vue'
-import { useRouter } from "vue-router"
+import { onBeforeRouteLeave, useRouter } from "vue-router"
 import { ElMessageBox } from 'element-plus'
 import moment from 'moment'
 import 'moment/dist/locale/zh-cn'
@@ -242,6 +242,7 @@ onActivated(()=>{
   handleDataToXcx()
 })
 
+
 </script>
 <template>
   <!-- 搜索 -->

+ 1 - 0
src/views/report/List.vue

@@ -161,6 +161,7 @@ onActivated(()=>{
             <div class="flex-col-center reportlist-search-filter-wrap">
                 <Search
                     placeholder="请输入标题/关键词"
+                    :defaultVal="reportState.searchVal"
                     @search="handleSearch"
                     @clean="handleSearch"
                 ></Search>

+ 42 - 1
src/views/report/Search.vue

@@ -4,6 +4,9 @@ import {apiReportSearch} from '@/api/report'
 import moment from 'moment'
 import Search from "@/components/Search.vue"
 import SelfList from '@/components/SelfList.vue'
+import { onBeforeRouteLeave, useRouter } from 'vue-router'
+
+const router=useRouter()
 
 let listState=reactive({
     list:[],
@@ -30,6 +33,10 @@ const getSearchList=async ()=>{
     }
 }
 
+const onLoad=()=>{
+    listState.page++
+    getSearchList()
+}
 
 const handleSearch=(e)=>{
     listState.page=1
@@ -40,10 +47,38 @@ const handleSearch=(e)=>{
     getSearchList()
 }
 
+const goDetail=(item)=>{
+    if(['晨报','周报'].includes(item.classify_name_first)){
+        router.push({
+            path:'/report/chapterdetail',
+            query:{
+                chapterId:item.report_chapter_id
+            }
+        })
+    }else{
+        router.push({
+            path:'/report/detail',
+            query:{
+                reportId:item.report_id
+            }
+        })
+    }
+}
+
 let isMounted = ref(false);
 onMounted(() => {
   isMounted.value = true;
 });
+onBeforeRouteLeave((to,from)=>{
+    // 如果是返回到首页则重置搜索页
+    if(to.name=='ReportIndex'){
+        console.log(to.name);
+        listState.list=[]
+        listState.page=1
+        listState.finished=false
+        listState.keyword=''
+    }
+})
 </script>
 
 <template>
@@ -53,6 +88,7 @@ onMounted(() => {
             <Search
                 style="margin-top: 10px;"
                 placeholder="请输入标题/关键词"
+                :defaultVal="listState.keyword"
                 :autoFocus="true"
                 @search="handleSearch"
                 @clean="handleSearch"
@@ -67,7 +103,12 @@ onMounted(() => {
             @listOnload="onLoad"
         >
         <div class="search-list-wrap">
-            <div class="item" v-for="item in listState.list" :key="item.report_id+item.report_chapter_id">
+            <div 
+                class="item" 
+                v-for="item in listState.list" 
+                :key="item.report_id+item.report_chapter_id"
+                @click="goDetail(item)"
+            >
                 <div class="title" v-html="item.title"></div>
                 <div class="des" v-html="item.content_sub"></div>
                 <div class="tags">