liming 5 years ago
parent
commit
b67b24b237

+ 165 - 38
pages/policy/index.js

@@ -1,3 +1,4 @@
+const request = require('../../utils/request.js');
 // pages/policyDetail/index.js
 const app = getApp()
 Page({
@@ -14,32 +15,17 @@ Page({
       height: app.globalData.height * 2 + 20,
     },
     currentTab: 0,
-    policyList: [{
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-      {
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-    ],
-    unscrambleList: [{
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-      {
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-    ],
+    policyPageIndex: 0,
+    policyPageSize: 6,
+    policyHasMore: true,
+    policyUrl: 'api/financial/tPolicyInterpretation/select',
+    unscramblePageIndex: 0,
+    unscramblePageSize: 6,
+    unscrambleHasMore: true,
+    unscrambleUrl: 'api/financial/tPolicyDeclaration/select',
+    state: 1,
+    policyList: [],
+    unscrambleList: [],
     active: 3,
     icon: {
       normal: '/pages/images/home.png',
@@ -61,34 +47,31 @@ Page({
       currentTab: e.detail.current
     });
   },
-  // 政策发布页面详情跳转
-  // 判断id
+
   policyListDetail: function (e) {
     console.log(e.currentTarget.id)
     wx.navigateTo({
-      url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面    
+      url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
     })
   },
-  // 无id,模拟数据跳转
+  /*// 无id,模拟数据跳转
   policyListDetail: function () {
     wx.navigateTo({
       url: '/pages/policyDetail/index'
     })
-  },
-  // 政策解读页面详情跳转
+  },*/
 
-  // 判断id
   unscrambleListDetail: function (e) {
     wx.navigateTo({
-      url: '/pages/unscrambleDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面    
+      url: '/pages/unscrambleDetail/index?id=' + e.currentTarget.dataset.unid // 希望跳转过去的页面
     })
   },
-  // 无id,模拟数据跳转
+  /*// 无id,模拟数据跳转
   unscrambleListDetail: function () {
     wx.navigateTo({
       url: '/pages/unscrambleDetail/index'
     })
-  },
+  },*/
   //点击切换
   clickTab: function (e) {
     var that = this;
@@ -127,10 +110,138 @@ Page({
       })
     }
   },
+  loadMore: function () {
+
+    if(this.data.currentTab === 0){
+      if (!this.data.policyHasMore) return;
+      request.query({
+        url: this.data.policyUrl,
+        data: {
+          skip: (++this.data.policyPageIndex - 1) * this.data.policyPageSize,
+          limit: this.data.policyPageSize,
+          publish_state: this.data.state
+        }
+      }).then((res) => {
+        let temp = res.data.data.map((item) => {
+          if (item.image) {
+            item.image = request.baseUrl + item.image
+          }
+          return item;
+        });
+        console.log(res);
+        let newList = this.data.policyList.concat(temp);
+        console.log(newList);
+        console.log(res.data.total);
+        let flag = this.data.policyPageIndex * this.data.policyPageSize < res.data.total;
+        this.setData({
+          policyList: newList,
+          policyHasMore: flag,
+        });
+      }).catch((err) => {
+        console.log(err);
+      });
+    }else {
+      if (!this.data.unscrambleHasMore) return;
+      request.query({
+        url: this.data.unscrambleUrl,
+        data: {
+          skip: (++this.data.unscramblePageIndex - 1) * this.data.unscramblePageSize,
+          limit: this.data.unscramblePageSize,
+          current_state: this.data.state
+        }
+      }).then((res) => {
+        let temp = res.data.data.map((item) => {
+          if (item.image) {
+            item.image = request.baseUrl + item.image
+          }
+          return item;
+        });
+        console.log(res);
+        let newList = this.data.unscrambleList.concat(temp);
+        console.log(newList);
+        console.log(res.data.total);
+        let flag = this.data.unscramblePageIndex * this.data.unscramblePageSize < res.data.total;
+        this.setData({
+          unscrambleList: newList,
+          unscrambleHasMore: flag,
+        });
+      }).catch((err) => {
+        console.log(err);
+      });
+
+    }
+
+  },
+  loadPolicyFirst: function () {
+
+    request.query({
+      url: this.data.policyUrl,
+      data: {
+        skip: (++this.data.policyPageIndex - 1) * this.data.policyPageSize,
+        limit: this.data.policyPageSize,
+        publish_state: this.data.state
+      }
+    }).then((res) => {
+      let temp = res.data.data.map((item) => {
+        if (item.image) {
+          item.image = request.baseUrl + item.image
+        }
+        return item;
+      });
+      console.log(res);
+      let newList = this.data.policyList.concat(temp);
+      console.log(newList);
+      console.log(res.data.total);
+      let flag = this.data.policyPageIndex * this.data.policyPageSize < res.data.total;
+      this.setData({
+        policyList: newList,
+        policyHasMore: flag,
+      });
+    }).catch((err) => {
+      console.log(err);
+    });
+
+  },
+  loadUnscrambleFirst: function () {
+
+      request.query({
+        url: this.data.unscrambleUrl,
+        data: {
+          skip: (++this.data.unscramblePageIndex - 1) * this.data.unscramblePageSize,
+          limit: this.data.unscramblePageSize,
+          current_state: this.data.state
+        }
+      }).then((res) => {
+        let temp = res.data.data.map((item) => {
+          if (item.image) {
+            item.image = request.baseUrl + item.image
+          }
+          return item;
+        });
+        console.log(res);
+        let newList = this.data.unscrambleList.concat(temp);
+        console.log(newList);
+        console.log(res.data.total);
+        let flag = this.data.unscramblePageIndex * this.data.unscramblePageSize < res.data.total;
+        this.setData({
+          unscrambleList: newList,
+          unscrambleHasMore: flag,
+        });
+      }).catch((err) => {
+        console.log(err);
+      });
+
+  },
+  loadMoreFirst: function () {
+    this.loadPolicyFirst();
+    this.loadUnscrambleFirst();
+
+  },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.loadMoreFirst();
 
   },
 
@@ -166,13 +277,29 @@ Page({
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
-
+    console.log("下拉事件");
+    if(this.data.currentTab === 0){
+      this.setData({
+        policyList:[],
+        policyPageIndex:0,
+        policyHasMore:true,
+      });
+    }else {
+      this.setData({
+        unscrambleList:[],
+        unscramblePageIndex:0,
+        unscrambleHasMore:true,
+      });
+    }
+    this.loadMore();
+    wx.stopPullDownRefresh();
   },
 
   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
+    this.loadMore();
 
   },
 
@@ -182,4 +309,4 @@ Page({
   onShareAppMessage: function () {
 
   }
-})
+})

+ 3 - 1
pages/policy/index.json

@@ -1,6 +1,8 @@
 {
+  "onReachBottomDistance":80,
+  "enablePullDownRefresh": true,
   "component": true,
   "usingComponents": {
     "nav-bar": "/commpents/navbar/navbar"
   }
-}
+}

+ 15 - 11
pages/policy/index.wxml

@@ -2,41 +2,45 @@
 <view class="home">
 	<view class="main">
 		<view class="swiper-tab">
-			<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">政策发布</view>
-			<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">政策解读</view>
+			<view class="swiper-tab-item {{currentTab==0?'active':''}}" data-current="0" bindtap="clickTab">政策解读</view>
+			<view class="swiper-tab-item {{currentTab==1?'active':''}}" data-current="1" bindtap="clickTab">政策发布</view>
 		</view>
 		<swiper current="{{currentTab}}" bindchange="swiperTab">
 			<swiper-item>
 				<view class="policyLeft">
 					<view class="list" wx:key="unique" wx:for="{{policyList}}" wx:for-item="item">
-						<view bindtap="policyListDetail" id="{{list._id}}">
-							<image src="{{item.pic}}"></image>
+						<view bindtap="policyListDetail" id="{{list._id}}" data-pid="{{item.id}}">
+							<image src="{{item.image}}"></image>
 							<view class="info">
 								<p>{{item.title}}</p>
 								<p>
-									<span>主题词:{{item.zhuti}}</span>
-									<span>政策等级:{{item.dengji}}</span>
+									<span>主题词:{{item.subject_headings}}</span>
+									<span>政策等级:{{item.subject_classification}}</span>
 								</p>
 							</view>
 						</view>
 					</view>
 				</view>
+				<view class="loadmore loading" wx:if="{{ policyHasMore }}">正在加载...</view>
+				<view class="loadmore" wx:else>已经到底了</view>
 			</swiper-item>
 			<swiper-item>
 				<view class="policyLeft policyRight">
 					<view class="list" wx:key="unique" wx:for="{{unscrambleList}}" wx:for-item="item">
-						<view bindtap="unscrambleListDetail" id="{{list._id}}">
-							<image src="{{item.pic}}"></image>
+						<view bindtap="unscrambleListDetail" id="{{list._id}}" data-unid="{{item.id}}">
+							<image src="{{item.image}}"></image>
 							<view class="info">
 								<p>{{item.title}}</p>
 								<p>
-									<span>主题词:{{item.zhuti}}</span>
-									<span>政策等级:{{item.dengji}}</span>
+									<span>主题词:{{item.subject_headings}}</span>
+									<span>政策等级:{{item.subject_classification}}</span>
 								</p>
 							</view>
 						</view>
 					</view>
 				</view>
+				<view class="loadmore loading" wx:if="{{ unscrambleHasMore }}">正在加载...</view>
+				<view class="loadmore" wx:else>已经到底了</view>
 			</swiper-item>
 		</swiper>
 	</view>
@@ -67,4 +71,4 @@
 				我的</van-tabbar-item>
 		</van-tabbar>
 	</view>
-</view>
+</view>

File diff suppressed because it is too large
+ 31 - 1
pages/policy/index.wxss


File diff suppressed because it is too large
+ 91 - 64
pages/policyDetail/index.js


+ 8 - 7
pages/policyDetail/index.wxml

@@ -2,14 +2,15 @@
 <view class="home">
 	<view class="main">
 		<text class="title">{{policyDetail.title}}</text>
-		<text class="jiguan">发文机关:{{policyDetail.jiguan}}</text>
-		<text class="zihao">发文字号:{{policyDetail.zihao}}</text>
+		<text class="jiguan">发文机关:{{policyDetail.issuing_organ}}</text>
+		<text class="zihao">发文字号:{{policyDetail.issued_number}}</text>
 		<p class="zhuti">
-		<span>主题词:{{policyDetail.zhuti}}</span>
-		<span>政策等级:{{policyDetail.dengji}}</span>
-		<span>{{policyDetail.date}}</span>
+			<span>主题词:{{policyDetail.subject_headings}}</span>
+			<span>政策等级:{{policyDetail.subject_classification}}</span>
+			<span>{{policyDetail.publish_time}}</span>
 		</p>
-		<image src="{{policyDetail.pic}}" class="image"></image>
-		<text class="content">{{policyDetail.content}}</text>
+		<image src="{{policyDetail.image}}" class="image"></image>
+		<!--<text class="content">{{policyDetail.description}}</text>-->
+		<rich-text class="content" nodes="{{policyDetail.description}}"></rich-text>
 	</view>
 </view>

File diff suppressed because it is too large
+ 41 - 11
pages/unscrambleDetail/index.js


+ 10 - 9
pages/unscrambleDetail/index.wxml

@@ -1,15 +1,16 @@
 <nav-bar navbar-data='{{nvabarData}}'></nav-bar>
 <view class="home">
 	<view class="main">
-		<text class="title">{{policyDetail.title}}</text>
-		<text class="jiguan">发文机关:{{policyDetail.jiguan}}</text>
-		<text class="zihao">发文字号:{{policyDetail.zihao}}</text>
+		<text class="title">{{unscrambleDetail.title}}</text>
+		<text class="jiguan">发文机关:{{unscrambleDetail.issuing_organ}}</text>
+		<text class="zihao">发文字号:{{unscrambleDetail.issued_number}}</text>
 		<p class="zhuti">
-		<span>主题词:{{policyDetail.zhuti}}</span>
-		<span>政策等级:{{policyDetail.dengji}}</span>
-		<span>{{policyDetail.date}}</span>
+		<span>主题词:{{unscrambleDetail.subject_headings}}</span>
+		<span>政策等级:{{unscrambleDetail.subject_classification}}</span>
+		<span>{{unscrambleDetail.current_state_time}}</span>
 		</p>
-		<image src="{{policyDetail.pic}}" class="image"></image>
-		<text class="content">{{policyDetail.content}}</text>
+		<image src="{{unscrambleDetail.image}}" class="image"></image>
+		<!--<text class="content">{{unscrambleDetail.content}}</text>-->
+		<rich-text class="content" nodes="{{unscrambleDetail.description}}"></rich-text>
 	</view>
-</view>
+</view>

+ 1 - 1
utils/request.js

@@ -17,7 +17,7 @@ module.exports = {
     fetch({url, id}) {
         return new Promise((resolve, reject) => {
             wx.request({
-                url: `${baseUrl}}/${url}/${id}`,
+                url: `${baseUrl}/${url}/${id}`,
                 method: 'GET',
                 header: {'content-type': 'application/json'},
                 dataType: 'json',