wq 5 年之前
父節點
當前提交
2f092c6a63
共有 3 個文件被更改,包括 34 次插入28 次删除
  1. 5 0
      pages/home/banner.wxs
  2. 26 26
      pages/home/index.js
  3. 3 2
      pages/home/index.wxml

+ 5 - 0
pages/home/banner.wxs

@@ -0,0 +1,5 @@
+var bannerimg = function (val) {
+return ('http://124.235.209.122:88'+val);
+}
+//exports: 通过该属性,对外共享本模块的私有变量与函数。
+module.exports.bannerimg = bannerimg;

+ 26 - 26
pages/home/index.js

@@ -1,5 +1,4 @@
 const request = require('../../utils/request.js');
-// pages/home/index.js
 const app = getApp()
 Page({
 
@@ -30,16 +29,7 @@ Page({
       myActive:'/pages/images/people_fill.png'
     },
     // 热门产品
-    productList: [
-      // {
-      //   "pic": '/pages/images/cooperation01.png',
-      //   title: '热门产品'
-      // },
-      // {
-      //   "pic": '/pages/images/cooperation01.png',
-      //   title: '热门产品'
-      // }
-    ],
+    productList: [],
     // 政策解读
     policyList: [],
     // 轮播
@@ -56,12 +46,14 @@ Page({
     interval: 2000,
     duration: 500
   },
+
   // 政策解读页面列表跳转
   policyListTap: function () {
     wx.navigateTo({
       url: '/pages/policy/index'
     })
   },
+
   // 政策解读页面详情跳转
   // 判断id
   policyListDetailTap: function (e) {
@@ -70,12 +62,7 @@ Page({
       url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
     })
   },
-  /*// 无id,模拟数据跳转
-  policyListDetailTap: function () {
-    wx.navigateTo({
-      url: '/pages/policyDetail/index'
-    })
-  },*/
+ 
   // 热门产品跳转
 
   productListDetail: function (e) {
@@ -84,12 +71,7 @@ Page({
     //     url: '/pages/policyDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面
     // })
   },
-  // 无id,模拟数据跳转
-  // productListDetail: function () {
-  //   wx.navigateTo({
-  //     // url: '/pages/policyDetail/index'
-  //   })
-  // },
+  
 
 
   // 切换菜单
@@ -124,11 +106,9 @@ Page({
           method:"POST",
           url: app.globalData.publicUrl + 'api/financial/financeclaims/top',
           success:(e) => {
-            console.log('success',e);
             if(e.data.errcode == 0){
               let arr = [];
               e.data.data.forEach((item) => {
-                // console.log('success',item.name.substring(0,5));
                 arr.push({_id:item._id,pic: app.globalData.imageUrl+item.innew.logo, title: item.name.substring(0,5)+'...'});
               });
               this.setData({
@@ -160,13 +140,33 @@ Page({
       console.log(err);
     });
   },
+
+  //轮播图
+  getbanner(){
+      wx.request({
+        method: "GET",
+        url: app.globalData.publicUrl + 'api/financial/banner',
+        data: {
+          skip: 0,
+          limit: 3,
+        },
+        success: (res)  =>  {
+          if (res.data.errcode == 0) {
+            this.setData({
+              background: res.data.data
+            })
+          }
+        }
+      })
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
     this.topNews();
     this.loadPolicyList();
-
+    this.getbanner();
   },
 
   /**

+ 3 - 2
pages/home/index.wxml

@@ -1,11 +1,12 @@
-	<nav-bar navbar-data='{{nvabarData}}' id="navbar"></nav-bar>
+	<wxs module="banner" src="../home/banner.wxs"></wxs>
+  <nav-bar navbar-data='{{nvabarData}}' id="navbar"></nav-bar>
 	<view class="home">
 		<view class="top">
 			<!-- <image src="/pages/images/test.jpg"></image> -->
 			<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
 				<block wx:key="unique" wx:for="{{background}}" wx:for-item="item">
 					<swiper-item>
-						<image src="{{item.pic}}"></image>
+						<image src="{{banner.bannerimg(item.url)}}"></image>
 					</swiper-item>
 				</block>
 			</swiper>