123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- const request = require('../../utils/request.js');
- // pages/home/index.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 组件所需的参数
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标,消息中心 1表示显示 0表示不显示
- showBack: 0, //返回
- title: '我的主页', //导航栏 中间的标题
- // 此页面 页面内容距最顶部的距离
- height: app.globalData.height * 2 + 20,
- },
- // 此页面 页面内容距最顶部的距离
- active: 0,
- icon: {
- normal: '/pages/images/home.png',
- active: '/pages/images/home_fill.png',
- bankNormal:'/pages/images/duijie.png',
- bankActive:'/pages/images/duijie_fill.png',
- marketNormal:'/pages/images/recharge.png',
- marketActive:'/pages/images/recharge_fill.png',
- policyNormal:'/pages/images/news_hot.png',
- policyActive:'/pages/images/news_hot_fill.png',
- myNormal:'/pages/images/people.png',
- myActive:'/pages/images/people_fill.png'
- },
- // 热门产品
- productList: [
- // {
- // "pic": '/pages/images/cooperation01.png',
- // title: '热门产品'
- // },
- // {
- // "pic": '/pages/images/cooperation01.png',
- // title: '热门产品'
- // }
- ],
- // 政策解读
- policyList: [],
- // 轮播
- background: [{
- "pic": "/pages/images/test1.png",
- },
- {
- "pic": "/pages/images/test.jpg",
- }
- ],
- indicatorDots: true,
- vertical: false,
- autoplay: true,
- interval: 2000,
- duration: 500
- },
- // 政策解读页面列表跳转
- policyListTap: function () {
- wx.navigateTo({
- url: '/pages/policy/index'
- })
- },
- // 政策解读页面详情跳转
- // 判断id
- policyListDetailTap: function (e) {
- console.log(e)
- wx.navigateTo({
- url: '/pages/policyDetail/index?id=' + e.currentTarget.dataset.pid // 希望跳转过去的页面
- })
- },
- /*// 无id,模拟数据跳转
- policyListDetailTap: function () {
- wx.navigateTo({
- url: '/pages/policyDetail/index'
- })
- },*/
- // 热门产品跳转
- productListDetail: function (e) {
- console.log('productListDetail',e.currentTarget.id)
- wx.navigateTo({
- url: '/pages/productListDetail/index?id=' + e.currentTarget.id // 希望跳转过去的页面
- })
- },
- // 无id,模拟数据跳转
- // productListDetail: function () {
- // wx.navigateTo({
- // // url: '/pages/policyDetail/index'
- // })
- // },
- // 切换菜单
- onChange(event) {
- this.setData({
- active: event.detail
- });
- if (event.detail == 0) {
- wx.navigateTo({
- url: '/pages/home/index'
- })
- } else if (event.detail == 1) {
- wx.navigateTo({
- url: '/pages/bank/index'
- })
- } else if (event.detail == 2) {
- wx.navigateTo({
- url: '/pages/market/index'
- })
- } else if (event.detail == 3) {
- wx.navigateTo({
- url: '/pages/policy/index'
- })
- } else if (event.detail == 4) {
- wx.navigateTo({
- url: '/pages/my/index'
- })
- }
- },
- topNews: function () {
- wx.request({
- 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({
- productList:arr
- })
- }
- }
- })
- },
- 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.topNews();
- this.loadPolicyList();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- console.log(JSON.stringify(wx.getStorageSync('user')))
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|