Ver Fonte

feature 内容轮播

xiahan há 4 meses atrás
pai
commit
20b95bab76
4 ficheiros alterados com 27 adições e 13 exclusões
  1. 3 1
      app.js
  2. 20 6
      pages/homepage/homepage.js
  3. 2 2
      pages/homepage/homepage.wxml
  4. 2 4
      pages/tongzhiList/tongzhiList.js

+ 3 - 1
app.js

@@ -120,6 +120,8 @@ App({
         yl: '/static_file/yl.png',
         jcsfcjtzd:'/static_file/jcsfcjtzd.jpg'
       }
-    }
+    },
+    // 用户通知公告
+    notices:[]
   }
 })

+ 20 - 6
pages/homepage/homepage.js

@@ -57,6 +57,8 @@ Page({
         url: '/pages/tousujianyi/tousujianyi'
       }
     ],
+    currentIndex:0,
+    noticeList:[],
     // 活动信息
     activity: {
       title: '净水器活动',
@@ -66,7 +68,6 @@ Page({
   },
 
   onLoad() {
-    // debugger;
     let refresh= app.globalData.refresh;
     if(refresh==1){
       wx.showLoading({
@@ -77,7 +78,6 @@ Page({
         return;
       }
       const _this = this;
-      // debugger;
       wx.request({
         url: app.globalData.interfaceUrls.homePageInfo+app.globalData.currentAccountInfo.usernumber,
         method: 'GET',
@@ -90,7 +90,11 @@ Page({
         success (res) {
           wx.hideLoading();
           let apiReturnData=res.data;
-          // debugger;
+          app.globalData.notices= apiReturnData.data.swNotificationAnnouncementDos;
+          let data= apiReturnData.data.swNotificationAnnouncementDos.filter(data=>{
+            return data.homepageslider=='1';
+          });
+      
           _this.setData({
             billInfo:{
               totalAmount:apiReturnData.data.duFees,  // 总计应缴
@@ -102,6 +106,8 @@ Page({
               accountNumber: apiReturnData.data.usernumber,
               address: apiReturnData.data.address
             },
+            noticeList :data,
+            isScrolling: true,
           })
         },
         fail(error) {
@@ -206,17 +212,25 @@ Page({
   },
 
   startNoticeScroll: function() {
-    const content = this.data.noticeList[this.data.currentIndex].content;
-    const title = this.data.noticeList[this.data.currentIndex].title;
+    if(this.data.noticeList.length==0){
+      return;
+    }
+    let data= (this.data.noticeList||[]).filter(data=>{
+       return data.homepageslider=='1';
+     });
+   
+    const content = data[this.data.currentIndex].scrollingcontent;
+    const title = data[this.data.currentIndex].noticetitle;
     const duration = (title.length + content.length) * 0.3;
 
     this.setData({
       scrollDuration: duration,
-      isScrolling: true
+      isScrolling: true,
     });
   },
 
   onScrollComplete: function() {
+    debugger;
     this.setData({
       isScrolling: false
     });

+ 2 - 2
pages/homepage/homepage.wxml

@@ -74,8 +74,8 @@
                 bindanimationend="onScrollComplete"
                 bindtap="goToNoticeDetail"
                 style="animation-duration: {{scrollDuration}}s;">
-            <text class="notice-title">{{noticeList[currentIndex].title}}:</text>
-            <text>{{noticeList[currentIndex].content}}</text>
+            <text class="notice-title">{{noticeList[currentIndex].noticetitle}}:</text>
+            <text>{{noticeList[currentIndex].scrollingcontent}}</text>
           </view>
         </view>
       </view>

+ 2 - 4
pages/tongzhiList/tongzhiList.js

@@ -12,11 +12,9 @@ Page({
 
   onLoad: function (options) {
     debugger
-    app.globalData.waterCompanys[0].notifications.forEach(data=>{
-      data.publishtime=utils.formatDate(new Date(data.publishtime))
-    });
+  
     this.setData({
-      noticeList: app.globalData.waterCompanys[0].notifications
+      noticeList:app.globalData.notices
     });
   },