xiaomei 7 months ago
parent
commit
1d55e0f78c

+ 93 - 57
src/views/bulletin/index.vue

@@ -1,10 +1,10 @@
 <template>
-  <div class="invite">
+  <div class="invite" @scroll="handleScroll">
     <div class="head">
       <img @click="back" src="@/assets/images/back.png" class="arrow_img" />
       <span>{{ $t('lang219') }}</span>
     </div>
-    <van-list v-model="loading" :finished="finished" :finished-text="finishText" @load="onLoad">
+    <div v-if="list.length > 0">
       <div class="notice" v-for="(item, index) in list" :key="index" @click="navigatorTo('bulletinDetail', item.id)">
         <img class="notice_img" :src="item.img_url" alt="" v-if="item.img_url" />
         <div class="right">
@@ -12,7 +12,10 @@
           <span class="time_text">{{ dateFormatFn(item.createtime) }}</span>
         </div>
       </div>
-    </van-list>
+    </div>
+    <div class="bare" v-else>
+      <span>{{ $t('lang60') }}</span>
+    </div>
   </div>
 </template>
   
@@ -23,46 +26,60 @@ export default {
   data() {
     return {
       list: [],
-      page: 0,
+      page: 1,
       loading: false,
       finished: false,
-      total: 1,
+      total: 0,
       finishText: this.$t('lang200'),
     };
   },
   mounted() {
-    this.onLoad();
-    window.addEventListener('scroll', this.scrollBottom);
+    this.getAnnouncement();
+    // window.addEventListener('scroll', this.scrollBottom);
   },
   destroyed() {
-    window.removeEventListener('scroll', this.scrollBottom);
+    // window.removeEventListener('scroll', this.scrollBottom);
   },
   methods: {
     //返回上一页
     back() {
       this.$router.back();
     },
-    scrollBottom() {
-      //加载更多
-      var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //变量windowHeight是可视区的高度
-      var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; //变量scrollHeight是滚动条的总高度
-      var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; //滚动条到底部的条件
-      console.log(scrollTop, 'scrollTop');
-      console.log(windowHeight, 'windowHeight');
-      console.log(scrollHeight, 'scrollHeight');
-      if (scrollTop + windowHeight >= scrollHeight && scrollTop > 0) {
-        //写后台加载数据的函数
-        // console.log('滚动到底部啦');
-        if (this.finished) {
-          this.loading = true; // 关闭加载状态
-          this.finished = false; // 加载开始
-          this.finishText = this.$t('lang200');
-          this.onLoad();
+    handleScroll(event) {
+      const container = event.target;
+      const scrollTop = container.scrollTop; // 滚动距离
+      const scrollHeight = container.scrollHeight; // 内容总高度
+      const clientHeight = container.clientHeight; // 可视区域高度
+      // 判断是否滑动到底部
+      if (scrollTop + clientHeight >= scrollHeight - 10) {
+        console.log('Bottom', this.page);
+        if (this.page != -1) {
+          this.page++; // 页数加 1
+          this.getAnnouncement(); // 触发加载更多
         }
-      } else {
-        // this.loading = false; // 关闭加载状态
       }
     },
+    // scrollBottom() {
+    //   //加载更多
+    //   var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //变量windowHeight是可视区的高度
+    //   var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; //变量scrollHeight是滚动条的总高度
+    //   var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; //滚动条到底部的条件
+    //   console.log(scrollTop, 'scrollTop');
+    //   console.log(windowHeight, 'windowHeight');
+    //   console.log(scrollHeight, 'scrollHeight');
+    //   if (scrollTop + windowHeight >= scrollHeight && scrollTop > 0) {
+    //     //写后台加载数据的函数
+    //     // console.log('滚动到底部啦');
+    //     if (this.finished) {
+    //       this.loading = true; // 关闭加载状态
+    //       this.finished = false; // 加载开始
+    //       this.finishText = this.$t('lang200');
+    //       this.onLoad();
+    //     }
+    //   } else {
+    //     // this.loading = false; // 关闭加载状态
+    //   }
+    // },
     navigatorTo(name, id) {
       this.$router.push({ name, query: { id: id } });
     },
@@ -73,53 +90,65 @@ export default {
       let params = {
         page: this.page,
         query: {},
-        type_id: 1
+        type_id: 1,
       };
       homeApi.getAnnouncement(params).then(res => {
+        // if (res.code == 200) {
+        //   let rows = res.data.rows;
+        //   // 如果返回的数组是空或数组长度是0
+        //   if (rows == null || rows.length === 0) {
+        //     this.loading = false; // 关闭加载状态
+        //     this.finished = true; // 加载结束
+        //     this.finishText = this.$t('lang202');
+        //     if (this.list.length <= 0) {
+        //       this.total = 0;
+        //     }
+        //     return;
+        //   }
+        //   this.loading = false; // 关闭加载状态
+        //   this.finishText = this.$t('lang203');
+        //   this.finished = true;
+        //   this.total = res.data.total; //数据总条数
+        //   this.list = this.list.concat(rows); //合并数组
+        //   console.log(this.list);
+
+        //   // 如果合并之后的数组长度大于返回的数据总条数
+        //   if (this.list.length >= this.total) {
+        //     this.finished = true; // 加载结束
+        //     this.finishText = this.$t('lang202');
+        //   }
+        // } else {
+        //   this.total = 0;
+        //   this.loading = false; // 关闭加载状态
+        //   this.finished = true; // 加载结束
+        //   this.finishText = this.$t('lang202');
+        // }
         if (res.code == 200) {
-          let rows = res.data.rows;
-          // 如果返回的数组是空或数组长度是0
-          if (rows == null || rows.length === 0) {
-            this.loading = false; // 关闭加载状态
-            this.finished = true; // 加载结束
-            this.finishText = this.$t('lang202');
-            if (this.list.length <= 0) {
-              this.total = 0;
+          if (this.list.length >= res.data.total) {
+            this.page = -1; // 重置为 -1,表示没有更多数据
+          } else {
+            this.list = [...this.list, ...res.data.rows];
+            if (this.list.length >= res.data.total) {
+              this.page = -1; // 重置为 -1,表示没有更多数据
             }
-            return;
-          }
-          this.loading = false; // 关闭加载状态
-          this.finishText = this.$t('lang203');
-          this.finished = true;
-          this.total = res.data.total; //数据总条数
-          this.list = this.list.concat(rows); //合并数组
-          console.log(this.list);
-
-          // 如果合并之后的数组长度大于返回的数据总条数
-          if (this.list.length >= this.total) {
-            this.finished = true; // 加载结束
-            this.finishText = this.$t('lang202');
           }
         } else {
-          this.total = 0;
-          this.loading = false; // 关闭加载状态
-          this.finished = true; // 加载结束
-          this.finishText = this.$t('lang202');
         }
       });
     },
-    onLoad() {
-      this.page += 1;
-      this.getAnnouncement();
-    },
+    // onLoad() {
+    //   this.page += 1;
+    //   this.getAnnouncement();
+    // },
   },
 };
 </script>
   
 <style lang="less" scoped>
 .invite {
-  min-height: calc(100vh + 50px);
   padding: 66px 16px;
+  height: 100vh;
+  overflow: auto;
   .head {
     position: fixed;
     top: 0;
@@ -170,5 +199,12 @@ export default {
       }
     }
   }
+
+  .bare {
+    text-align: center;
+    font-size: 14px;
+    padding: 60px 14px;
+    color: #888;
+  }
 }
 </style>

+ 5 - 2
src/views/index/index.vue

@@ -19,9 +19,12 @@
               </van-swipe-item>
             </van-swipe>
           </div>
-          <van-notice-bar class="notice" color="#000" background="#ffffff" :text="indexinfo.notice_list[0]?.title" @click="navigatorToPage('bulletinDetail', indexinfo.notice_list[0].id)">
+          <van-notice-bar class="notice" color="#000" background="#ffffff" :scrollable="false">
             <div slot="left-icon" class="notice-ico">{{ $t('lang3') }}</div>
-            <div slot="right-icon" @click="navigatorTo('bulletin')"><van-icon name="wap-nav" size="20" color="#29b286" /></div>
+            <van-swipe vertical class="notice-swipe" style="height: 24px;" :autoplay="3000" :show-indicators="false">
+              <van-swipe-item v-for="(item, index) in indexinfo.notice_list" :key="index" @click="navigatorToPage('bulletinDetail', indexinfo.notice_list[0].id)">{{ item.title }}</van-swipe-item>
+            </van-swipe>
+            <div slot="right-icon" style="padding-left: 10px" @click="navigatorTo('bulletin')"><van-icon name="wap-nav" size="20" color="#29b286" /></div>
           </van-notice-bar>
         </div>
       </div>

+ 1 - 1
src/views/mine/synthesisDetail.vue

@@ -190,7 +190,7 @@
             </div>
             <div class="table_body flex" v-if="product.material_three.length > 0">
               <span>{{ $t('lang311') }}3</span>
-              <span>{{ product.material_three * number }}</span>
+              <span>{{ product.material_three_num * number }}</span>
             </div>
           </div>
         </div>

+ 2 - 2
src/views/storage/mulDetail.vue

@@ -11,11 +11,11 @@
         <div class="flex">
           <div class="">
             <span class="key">APY:</span>
-            <span class="value_2">{{ Number(product.income_reta) * 100 }}</span>
+            <span class="value_2">{{ Number(product.income_reta) * 100 || 0 }}</span>
           </div>
           <div class="">
             <span class="key">{{ $t('lang332') }}:</span>
-            <span class="value_1">{{ product.day_num }}</span>
+            <span class="value_1">{{ product.day_num || 0 }}</span>
           </div>
         </div>
       </div>

+ 2 - 2
src/views/storage/singleDetail.vue

@@ -11,11 +11,11 @@
         <div class="flex">
           <div class="">
             <span class="key">APY:</span>
-            <span class="value_2">{{ Number(product.income_reta) * 100 }}</span>
+            <span class="value_2">{{ Number(product.income_reta) * 100 || 0 }}</span>
           </div>
           <div class="">
             <span class="key">{{ $t('lang332') }}:</span>
-            <span class="value_1">{{ product.day_num }}</span>
+            <span class="value_1">{{ product.day_num || 0 }}</span>
           </div>
         </div>
       </div>