Ver código fonte

Merge branch 'master' of http://git.cc-lotus.info/financial_platform/web-financial

wq 5 anos atrás
pai
commit
696f275630
4 arquivos alterados com 72 adições e 43 exclusões
  1. 35 35
      pages/home/index.js
  2. 6 6
      pages/home/index.wxml
  3. 2 2
      pages/policyDetail/index.js
  4. 29 0
      utils/request.js

+ 35 - 35
pages/home/index.js

@@ -1,3 +1,4 @@
+const request = require('../../utils/request.js');
 // pages/home/index.js
 const app = getApp()
 Page({
@@ -39,31 +40,7 @@ Page({
       }
     ],
     // 政策解读
-    policyList: [{
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-      {
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-      {
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-      {
-        "pic": "/pages/images/test.jpg",
-        "title": "中国银保监会就《商业银行小微企业金融服务监管评价暂行办法(试行)》",
-        "zhuti": "疫情",
-        "dengji": "吉林省"
-      },
-    ],
+    policyList: [],
     // 轮播
     background: [{
         "pic": "/pages/images/test1.png",
@@ -79,31 +56,31 @@ Page({
     duration: 500
   },
   // 政策解读页面列表跳转
-  policyList: function () {
+  policyListTap: function () {
     wx.navigateTo({
       url: '/pages/policy/index'
     })
   },
   // 政策解读页面详情跳转
   // 判断id
-  policyListDetail: function (e) {
-    console.log(e.currentTarget.id)
+  policyListDetailTap: function (e) {
+    console.log(e)
     wx.navigateTo({
-      url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面    
+      url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
     })
   },
-  // 无id,模拟数据跳转
-  policyListDetail: function () {
+  /*// 无id,模拟数据跳转
+  policyListDetailTap: function () {
     wx.navigateTo({
       url: '/pages/policyDetail/index'
     })
-  },
+  },*/
   // 热门产品跳转
-  
+
   productListDetail: function (e) {
     console.log(e.currentTarget.id)
     wx.navigateTo({
-      // url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面    
+      // url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面
     })
   },
   // 无id,模拟数据跳转
@@ -139,10 +116,33 @@ Page({
       })
     }
   },
+  loadPolicyList: function () {
+    request.query({
+      url: 'api/financial/tPolicyInterpretation/select',
+      data: {
+        skip: 0,
+        limit: 4,
+        publish_state: 1
+      }
+    }).then((res) => {
+      let temp = res.data.data.map((item) => {
+        if (item.image) {
+          item.image = request.baseUrl + item.image
+        }
+        return item;
+      });
+      this.setData({
+        policyList: temp
+      });
+    }).catch((err) => {
+      console.log(err);
+    });
+  },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    this.loadPolicyList();
 
   },
 
@@ -194,4 +194,4 @@ Page({
   onShareAppMessage: function () {
 
   }
-})
+})

+ 6 - 6
pages/home/index.wxml

@@ -31,17 +31,17 @@
 			<view class="mainThree">
 				<view class="mainThreeTop">
 					<span>政策解读</span>
-					<a bindtap="policyList">MORE></a>
+					<a bindtap="policyListTap">MORE></a>
 				</view>
 				<view class="mainThreeList">
 					<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="policyListDetailTap" 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>
@@ -76,4 +76,4 @@
 					我的</van-tabbar-item>
 			</van-tabbar>
 		</view>
-	</view>
+	</view>

+ 2 - 2
pages/policyDetail/index.js

@@ -29,7 +29,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-
+    console.log(options);
   },
 
   /**
@@ -80,4 +80,4 @@ Page({
   onShareAppMessage: function () {
 
   }
-})
+})

+ 29 - 0
utils/request.js

@@ -0,0 +1,29 @@
+const baseUrl = 'http://124.235.209.122:88';
+module.exports = {
+    baseUrl,
+    query({url, data, method = 'GET'}) {
+        return new Promise((resolve, reject) => {
+            wx.request({
+                url: `${baseUrl}/${url}`,
+                data: data,
+                method: method,
+                header: {'content-type': 'application/json'},
+                dataType: 'json',
+                success: resolve,
+                fail: reject,
+            });
+        });
+    },
+    fetch({url, id}) {
+        return new Promise((resolve, reject) => {
+            wx.request({
+                url: `${baseUrl}}/${url}/${id}`,
+                method: 'GET',
+                header: {'content-type': 'application/json'},
+                dataType: 'json',
+                success: resolve,
+                fail: reject,
+            });
+        });
+    },
+}