Переглянути джерело

首页热门产品+消息中心

guhongwei 5 роки тому
батько
коміт
7bae280048

+ 1 - 1
app.json

@@ -11,8 +11,8 @@
     "pages/login/index",
     "pages/unpassword/index",
     "pages/register/index",
-    "pages/messageInfo/index",
     "pages/test/index",
+    "pages/messageInfo/index",
     "pages/logs/logs"
 
   ],

+ 14 - 0
pages/home/index.js

@@ -91,6 +91,20 @@ Page({
       url: '/pages/policyDetail/index'
     })
   },
+  // 热门产品跳转
+  
+  productListDetail: function (e) {
+    console.log(e.currentTarget.id)
+    wx.navigateTo({
+      // url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面    
+    })
+  },
+  // 无id,模拟数据跳转
+  productListDetail: function () {
+    wx.navigateTo({
+      // url: '/pages/policyDetail/index'
+    })
+  },
   // 切换菜单
   onChange(event) {
     console.log(event.detail)

+ 80 - 12
pages/messageInfo/index.js

@@ -13,13 +13,21 @@ Page({
       // 此页面 页面内容距最顶部的距离
       height: app.globalData.height * 2 + 20,
     },
-  },
+    messageList: [],
+    skip: 0,
+    limit: 10,
+    total: 0,
+    listshow: 1,
+    // 是否到底
+    hasMoreData: true
 
+  },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    var that = this;
+    that.searchInfo('正在加载数据...')
   },
 
   /**
@@ -50,24 +58,84 @@ Page({
 
   },
 
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  },
+  // 列表查询
+  searchInfo: function (message) {
+    wx.showLoading({
+      title: message,
+    })
+    var that = this;
+    wx.request({
+      url: 'http://124.235.209.122:88/api/financial/viewnews/select', //真是接口
+      method: 'post',
+      data: {
+        qyid: '5e903455d72a944fd899c59c',
+        skip: that.data.skip,
+        limit: that.data.limit
+      },
+      header: {
+        'content-type': 'application/json', // 默认值
+      },
+      success(res) {
+        console.log(res)
+        if (res.data.errcode == '0') {
+          if (res.data.res.length !== 0) {
+            if (that.data.messageList.isEmpty) {
+              that.setData({ // 设置页面列表的内容
+                messageList: res.data.res,
+              })
+            } else {
+              that.setData({ // 设置页面列表的内容
+                messageList: that.data.messageList.concat(res.data.res),
+                total: res.data.total
+              })
+            }
+          } else {
+            wx.showToast({
+              title: "没有更多数据了",
+              duration: 1000,
+              icon: 'none',
+              mask: true
+            })
+          }
+        }
+      },
+      complete: function () {
+        wx.hideLoading();
+        // complete
+        wx.hideNavigationBarLoading() //完成停止加载
+        wx.stopPullDownRefresh() //停止下拉刷新
+      }
+    })
+  },
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
-
+    wx.showNavigationBarLoading() //在标题栏中显示加载
+    this.data.skip = 0
+    this.searchInfo('正在刷新数据')
   },
-
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+    const pageNum = this.data.skip;
+    const _pagenum = Math.ceil(this.data.total / this.data.limit);
+    if (pageNum < _pagenum) {
+      this.setData({
+        skip: pageNum + 1 //设置下一页
+      })
+      this.searchInfo('正在刷新数据'); //查询数据
+    } else {
+      wx.showToast({
+        title: '没有更多数据',
+      })
+    }
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  }
 })

+ 3 - 1
pages/messageInfo/index.json

@@ -1,5 +1,7 @@
 {
   "usingComponents": {
     "nav-bar": "/commpents/navbar/navbar"
-  }
+  },
+  "onReachBottomDistance": 50,
+  "enablePullDownRefresh": true
 }

+ 10 - 1
pages/messageInfo/index.wxml

@@ -1,6 +1,15 @@
 <nav-bar navbar-data='{{nvabarData}}'></nav-bar>
 <view class="home">
 	<view class="main">
-		列表
+		<view class="list" wx:key="unique" wx:for="{{messageList}}" wx:for-item="item">
+			<view bindtap="bindtap" id="{{list._id}}">
+				<text class="title">{{item.title}}</text>
+				<text class="news">{{item.news}}</text>
+				<view class="info">
+					<text>({{item.status=='0'?'未读':'已读'}})</text>
+					<text>{{item.meta.createdAt}}</text>
+				</view>
+			</view>
+		</view>
 	</view>
 </view>

+ 56 - 1
pages/messageInfo/index.wxss

@@ -1 +1,56 @@
-/* pages/messageInfo/index.wxss */
+.list {
+  float: left;
+  width: 92%;
+  height: 218rpx;
+  padding: 0 0 20rpx 0;
+  margin: 0 30rpx;
+  border-bottom: 1px solid #ccc;
+}
+
+.list .title {
+  float: left;
+  width: 100%;
+  font-size: 30rpx;
+  font-family: Source Han Sans SC;
+  font-weight: 400;
+  color: rgba(40, 40, 40, 1);
+  margin: 30rpx 0;
+}
+
+.list .news {
+  float: left;
+  width: 100%;
+  font-size: 30rpx;
+  font-family: Source Han Sans SC;
+  font-weight: 400;
+  color: rgba(40, 40, 40, 1);
+  margin: 0 0 20rpx 0;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+}
+
+.list .info {
+  float: left;
+  width: 100%;
+}
+
+.list .info text:first-child {
+  float: left;
+  width: 50%;
+  font-size: 30rpx;
+  font-family: Source Han Sans SC;
+  font-weight: 400;
+  color: rgba(40, 40, 40, 1);
+}
+.list .info text:last-child {
+  float: left;
+  width: 50%;
+  font-size: 30rpx;
+  font-family: Source Han Sans SC;
+  font-weight: 400;
+  color: rgba(40, 40, 40, 1);
+}

+ 12 - 4
project.config.json

@@ -4,19 +4,27 @@
 		"ignore": []
 	},
 	"setting": {
-		"urlCheck": true,
+		"urlCheck": false,
 		"es6": true,
 		"postcss": true,
 		"preloadBackgroundData": false,
 		"minified": true,
 		"newFeature": true,
-		"autoAudits": false,
 		"coverView": true,
+		"autoAudits": false,
 		"showShadowRootInWxmlPanel": true,
-		"scopeDataCheck": false
+		"scopeDataCheck": false,
+		"checkInvalidKey": true,
+		"checkSiteMap": true,
+		"uploadWithSourceMap": true,
+		"babelSetting": {
+			"ignore": [],
+			"disablePlugins": [],
+			"outputPath": ""
+		}
 	},
 	"compileType": "miniprogram",
-	"libVersion": "2.11.0",
+	"libVersion": "2.10.4",
 	"appid": "wx2c50f82dae28a9f5",
 	"projectname": "web-finance",
 	"debugOptions": {