const request = require('../../utils/request.js'); import WxCountUp from '../../utils/WxCountUp' 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' }, guidanceUnitList:[], // 成功对接 mainOneInfo: { "registerCompany": 0, "solutionFinancing": 0, "demandCount": 0, "demandMoney": 0, "financialProduct": 0, "financialInstitution": 0, "helpCompany": 0, "finalsummoney":0, }, // 热门产品 productList: [], // 政策解读 policyList: [], // 轮播 backgrounds: [{ "pic": "/pages/images/banner1.jpg", link:'../aboutme/index', }, { "pic": "/pages/images/banner2.jpg", link:'../aboutme/index', }, { "pic": "/pages/images/banner3.jpg", link:'../aboutme/index', }, { "pic": "/pages/images/banner4.jpg", link:'../aboutme/index', }, ], indicatorDots: true, vertical: false, autoplay: true, interval: 5000, duration: 500 }, // 我要融资 tongjiBtn: function () { wx.navigateTo({ url: '/pages/bank/index' }) }, // 政策解读页面列表跳转 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 // 希望跳转过去的页面 }) }, // 热门产品跳转 toshow(e) { let claimid = e.currentTarget.dataset.claimid; let img = e.currentTarget.dataset.img; console.log(e); // console.log(JSON.stringify(e.currentTarget.dataset)) wx.navigateTo({ url: '/pages/marketLoanDetail/index?claimid=' + claimid + '&img=' + img, }) }, // 热门产品更多 clickMore(){ }, // 切换菜单 onChange(event) { this.setData({ active: event.detail }); if (event.detail == 0) { wx.redirectTo({ url: '/pages/home/index' }) } else if (event.detail == 1) { wx.redirectTo({ url: '/pages/bank/index' }) } else if (event.detail == 2) { wx.redirectTo({ url: '/pages/market/index' }) } else if (event.detail == 3) { wx.redirectTo({ url: '/pages/policy/index' }) } else if (event.detail == 4) { wx.redirectTo({ url: '/pages/my/index' }) } }, topNews: function () { wx.request({ method: "POST", url: app.globalData.publicUrl + 'api/financial/financeclaims/top', success: (e) => { if (e.data.errcode == 0) { let arr = []; e.data.data.forEach((item) => { let nikeName = ''; if(item.name.length > 3){ nikeName = item.name.substring(0, 3) + '....' }else{ nikeName = item.name } arr.push({ _id: item._id, pic: app.globalData.imageUrl + item.innew.logo, mongey_min_rate: item.mongey_min_rate, mongey_max_rate: item.mongey_max_rate, claims_min_money: item.claims_min_money, claims_max_money: item.claims_max_money, claims_min_term:item.claims_min_term, claims_max_term: item.claims_max_term, introduction: item.innew.introduction, // title: item.name.substring(0, 5) + '...' title: nikeName }); }); this.setData({ productList: arr }) } } }) }, getDate(val, formatStr) { if (val) { return this.format(new Date(Number(val)), formatStr); } return ''; }, format(date, formatStr) { formatStr = formatStr.replace(/yyyy|YYYY/, date.getFullYear()); formatStr = formatStr.replace(/MM/, (date.getMonth() + 1) > 9 ? (date.getMonth() + 1).toString() : '0' + (date.getMonth() + 1)); formatStr = formatStr.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : '0' + date.getDate()); return formatStr; }, loadPolicyList: function () { request.query({ url: 'api/financial/tPolicyInterpretation', data: { skip: 0, limit: 4 } }).then((res) => { let temp = res.data.data.map((item) => { if (item.image) { item.image = request.imageUrl + item.image } if (item.create_time) { item.create_time = this.getDate(item.create_time, 'yyyy.MM.dd') } return item; }); this.setData({ policyList: temp }); }).catch((err) => { console.log(err); }); }, loadGuidanceUnitList: function () { request.query({ url: 'api/financial/tGuidanceUnit', data: { skip: 0, limit: 3 } }).then((res) => { let temp = res.data.data.map((item) => { if (item.image) { item.image = request.imageUrl + item.image } return item; }); this.setData({ guidanceUnitList: temp }); }).catch((err) => { console.log(err); }); }, loadStatistics: function () { var that = this; request.query({ url: 'api/financial/tGovernmentStatistics/pageSelect', }).then((res) => { this.setData({ mainOneInfo: res.data.data }); that.countUp = new WxCountUp('mainOneInfo.registerCompany', res.data.data.registerCompany, {}, that); that.countUp.start(); that.countUp1 = new WxCountUp('mainOneInfo.financialInstitution', res.data.data.financialInstitution, {}, that); that.countUp1.start(); that.countUp2 = new WxCountUp('mainOneInfo.demandCount', res.data.data.demandCount, {}, that); that.countUp2.start(); that.countUp3 = new WxCountUp('mainOneInfo.finalsummoney', res.data.data.finalsummoney, {}, that); that.countUp3.start(); }).catch((err) => { 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.loadGuidanceUnitList(); this.loadStatistics(); this.getbanner(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { console.log(JSON.stringify(wx.getStorageSync('user'))) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })