Browse Source

Merge branch 'master' into 8.1.1

Karsa 2 years ago
parent
commit
557dc619b6
4 changed files with 138 additions and 35 deletions
  1. 1 0
      src/main.js
  2. 64 13
      src/views/hzyb/report/ChapterDetail.vue
  3. 64 13
      src/views/hzyb/report/Detail.vue
  4. 9 9
      vite.config.js

+ 1 - 0
src/main.js

@@ -5,5 +5,6 @@ import store from './store'
 import 'normalize.css'
 import './style/common.scss'
 import '@vant/touch-emulator';//vant 
+import 'vant/lib/index.css';
 
 createApp(App).use(router).use(store).mount('#app')

+ 64 - 13
src/views/hzyb/report/ChapterDetail.vue

@@ -1,5 +1,5 @@
 <template>
-<van-pull-refresh v-model="loading" @refresh="onRefresh" style="min-height:100vh">
+<van-pull-refresh v-model="loading" disabled style="min-height:100vh">
   <div class="chapter-detail-page" v-if="info" :style="{paddingBottom:$store.state.hzyb.audioData.url&&'80px'}">
     <div :class="['main-box',!info.auth_ok&&'main-box-noauth']">
       <div class="title">【第{{info.report_chapter_item.stage}}期 | {{info.report_chapter_item.classify_name_first}}  | {{info.report_chapter_item.type_name}}】{{info.report_chapter_item.title}}</div>
@@ -14,7 +14,12 @@
         <span style="color: #e3b377; margin-left: 20px" @click="showDisclaimers = true">免责声明</span>
       </div>
       <div class="rich-content">
-        <div v-html="info.report_chapter_item.content" v-if="info.auth_ok"></div>
+        <!-- <div v-html="info.report_chapter_item.content" v-if="info.auth_ok"></div> -->
+        <div v-if="info.auth_ok">
+          <ul>
+              <li v-for="item in realContent" :key="item" v-html="item"></li>
+          </ul>
+        </div>
         <div v-html="info.report_chapter_item.content_sub" v-else ></div>
       </div>
       <!-- 指标数据模块 -->
@@ -115,6 +120,7 @@ import {apiApplyPermission} from '@/api/hzyb/user'
 import {Popup,Image as VanImage,PullRefresh,Col, Row} from 'vant'
 import AudioBox from './components/AudioBox.vue'
 import SharePoster from '../components/SharePoster.vue'
+import _ from 'lodash';
 export default {
   components:{
     [Popup.name]:Popup,
@@ -158,7 +164,13 @@ export default {
 
       loading:false,
 
-      showToTop:false
+      showToTop:false,
+
+      totalContent:[],
+      realContent:[],
+      page_no: 0,
+      pageSize: 20,//默认初始加载20个p标签
+      total_page: 0,
 
     };
   },
@@ -185,20 +197,20 @@ export default {
                 wx.previewImage({current:curImageSrc,urls:imgArray});
             }
         })
-    window.addEventListener('scroll',this.handelPageScroll)
+    window.addEventListener('scroll',this.loadMoreHandle)
   },
   destroyed () {
-    window.removeEventListener('scroll',this.handelPageScroll)
+    window.removeEventListener('scroll',this.loadMoreHandle)
   },
   methods: {
-    handelPageScroll(){
-      const top=document.documentElement.scrollTop||document.body.scrollTop
-      if(top>window.outerHeight){
-        this.showToTop=true
-      }else{
-        this.showToTop=false
-      }
-    },
+    // handelPageScroll(){
+    //   const top=document.documentElement.scrollTop||document.body.scrollTop
+    //   if(top>window.outerHeight){
+    //     this.showToTop=true
+    //   }else{
+    //     this.showToTop=false
+    //   }
+    // },
 
     async getDetail(){
       const res=await apiChapterDetail({report_chapter_id:Number(this.chapterId)})
@@ -216,6 +228,8 @@ export default {
           this.getTickerValue()
         }
 
+        this.splitContentHandle(this.info.report_chapter_item.content)
+
         if(!res.data.auth_ok){
           // 获取详情如果为联系销售根据判断条件是否主动申请一次
           if(this.info.permission_check.type=='contact'&&!this.info.permission_check.customer_info.has_apply){
@@ -244,6 +258,43 @@ export default {
       }
     },
 
+    /*内容分割*/
+    splitContentHandle(content) {
+        const arr = content.split('</p>');
+        this.totalContent = arr.map(_ => _+'</p>');
+        this.realContent = this.totalContent.slice(0,this.pageSize)
+        this.total_page =  parseInt(this.totalContent.length / this.pageSize) + 1;
+        console.log( this.totalContent,this.realContent,this.total_page)
+    },
+
+    /* 加载下一页内容 */
+    loadContent() {
+        this.realContent = this.realContent.concat(this.totalContent.slice(this.page_no*this.pageSize, (this.page_no + 1)*this.pageSize))
+    },
+
+    loadMoreHandle: _.throttle(function() {
+
+        const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
+
+        if(scrollTop>window.outerHeight){
+            this.showToTop=true
+        }else{
+            this.showToTop=false
+        }
+
+        if(this.page_no >= this.total_page) return
+
+        const clientHeight = document.documentElement.clientHeight || document.body.clientHeight; // 可视高度
+        const scrollHeight = document.body.scrollHeight; // 总高度
+        const bufferHeight = 400;
+
+        if((scrollHeight - scrollTop - clientHeight) < bufferHeight+100) {
+        console.log('触底')
+        this.page_no = this.page_no+1;
+        this.loadContent();
+        }
+    },300),
+
     //获取晨报中指标数据
     async getTickerValue(){
       const res=await apiChapterTickerValue({report_chapter_id:Number(this.chapterId)})

+ 64 - 13
src/views/hzyb/report/Detail.vue

@@ -1,5 +1,5 @@
 <template>
-<van-pull-refresh v-model="loading" @refresh="onRefresh" style="min-height:100vh">
+<van-pull-refresh v-model="loading" disabled style="min-height:100vh">
     <div class="report-detail-page" v-if="info" :style="{paddingBottom:$store.state.hzyb.audioData.url&&'80px'}">
         <!-- 晨报、周报章节 -->
         <div class="chapter-list-wrap" v-if="['晨报','周报'].includes(info.report_info.classify_name_first)">
@@ -60,7 +60,12 @@
             </div>
 
             <div class="rich-content">
-                <div v-html="info.report_info.content" v-if="info.auth_ok"></div>
+                <!-- <div v-html="info.report_info.content" v-if="info.auth_ok"></div> -->
+                <div v-if="info.auth_ok">
+                    <ul>
+                        <li v-for="item in realContent" :key="item" v-html="item"></li>
+                    </ul>
+                </div>
                 <div v-html="info.report_info.content_sub" v-else></div>
             </div>
 
@@ -133,6 +138,7 @@ import {apiApplyPermission} from '@/api/hzyb/user'
 import {Popup,Image as VanImage,PullRefresh} from 'vant'
 import AudioBox from './components/AudioBox.vue'
 import SharePoster from '../components/SharePoster.vue'
+import _ from 'lodash';
 export default {
     components:{
         [Popup.name]:Popup,
@@ -167,7 +173,13 @@ export default {
 				content:'',//弹窗html字符串
 			},
             loading:false,
-            showToTop:false
+            showToTop:false,
+
+            totalContent:[],
+            realContent:[],
+            page_no: 0,
+            pageSize: 20,//默认初始加载20个p标签
+            total_page: 0,
         }
     },
     beforeCreate(){
@@ -192,21 +204,21 @@ export default {
                 wx.previewImage({current:curImageSrc,urls:imgArray});
             }
         })
-        window.addEventListener('scroll',this.handelPageScroll)
+        window.addEventListener('scroll',this.loadMoreHandle)
     },
     destroyed () {
-        window.removeEventListener('scroll',this.handelPageScroll)
+        window.removeEventListener('scroll',this.loadMoreHandle)
     },
     methods: {
         // 页面滚动
-        handelPageScroll(){
-            const top=document.documentElement.scrollTop||document.body.scrollTop
-            if(top>window.outerHeight){
-                this.showToTop=true
-            }else{
-                this.showToTop=false
-            }
-        },
+        // handelPageScroll(){
+        //     const top=document.documentElement.scrollTop||document.body.scrollTop
+        //     if(top>window.outerHeight){
+        //         this.showToTop=true
+        //     }else{
+        //         this.showToTop=false
+        //     }
+        // },
         
         //获取报告详情
         async getDetail(){
@@ -222,6 +234,9 @@ export default {
                 }
                 this.chapterList=res.data.report_chapter_list
                 document.title = res.data.report_info.classify_name_first
+
+                this.splitContentHandle(this.info.report_info.content);
+
                 if(!res.data.auth_ok){
                     // 获取详情如果为联系销售根据判断条件是否主动申请一次
                     if(this.info.permission_check.type=='contact'&&!this.info.permission_check.customer_info.has_apply){
@@ -239,6 +254,7 @@ export default {
                         }
                     }
                 }
+
                 //向小程序发送分享数据
                 wx.miniProgram.postMessage({ 
                     data: {
@@ -249,6 +265,41 @@ export default {
                 
             }
         },
+
+        /*内容分割*/
+        splitContentHandle(content) {
+            const arr = content.split('</p>');
+            this.totalContent = arr.map(_ => _+'</p>');
+            this.realContent = this.totalContent.slice(0,this.pageSize)
+            this.total_page =  parseInt(this.totalContent.length / this.pageSize) + 1;
+        },
+
+        /* 加载下一页内容 */
+        loadContent() {
+            this.realContent = this.realContent.concat(this.totalContent.slice(this.page_no*this.pageSize, (this.page_no + 1)*this.pageSize))
+        },
+
+        loadMoreHandle: _.throttle(function() {
+
+            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; // 滚动的高度
+            if(scrollTop>window.outerHeight){
+                this.showToTop=true
+            }else{
+                this.showToTop=false
+            }
+
+            if(this.page_no >= this.total_page) return
+
+            const clientHeight = document.documentElement.clientHeight || document.body.clientHeight; // 可视高度
+            const scrollHeight = document.body.scrollHeight; // 总高度
+            const bufferHeight = 400;
+
+            if((scrollHeight - scrollTop - clientHeight) < bufferHeight+100) {
+            console.log('触底')
+            this.page_no = this.page_no+1;
+            this.loadContent();
+            }
+        },300),
         
         //返回顶部
         handleBackTop(){

+ 9 - 9
vite.config.js

@@ -7,15 +7,15 @@ export default ({mode})=>defineConfig({
   base:loadEnv(mode, process.cwd()).VITE_APP_BASE_URL,
   plugins: [
     vue(),
-    styleImport({
-      libs: [
-        {
-          libraryName: 'vant',
-          esModule: true,
-          resolveStyle: (name) => `vant/es/${name}/style/index`,
-        },
-      ],
-    }),
+    // styleImport({
+    //   libs: [
+    //     {
+    //       libraryName: 'vant',
+    //       esModule: true,
+    //       resolveStyle: (name) => `vant/es/${name}/style/index`,
+    //     },
+    //   ],
+    // }),
   ],
   resolve: {
     alias: {