//logs.js const util = require('../../utils/util.js') var app = getApp(); Page({ data: { logs: [], bannerList: [], indicatorDots: true, autoplay: true, interval: 2000, duration: 1000, cardList: [], hasNext: true, page: 0, hiddenThis: true, appid: 0 }, onLoad: function () { this.initBanner(); this.initCardList(); app.login(this); }, onShow () { wx.stopPullDownRefresh() }, onHide () { wx.stopPullDownRefresh() this.setData({hiddenThis: true}) }, initConcact (event) { var that = this; var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = event.currentTarget.dataset.id; if (user_id != '0' || tel != '0') { // 绑定了手机号 this.setData({hiddenThis: false, appid: id}) }else{ // 未绑定手机号 wx.navigateTo({ url: "/pages/getPhone/getPhone?from=card&preid=" + id }) } }, initCardList: function () { var data = {}, list = [], that = this, hasNext = true; that.setData({hidden: false}); if (that.data.page === 0) { list = [] }else{ list = that.data.cardList; } wx.request({ url: app.globalData.HOST + '/user/CreditCard/list', method: "POST", data: Object.assign({}, app.globalData.common, {pageId: ++this.data.page}), success: function (res) { if (res.data.errno == '0') { // data = res.data.rst.list; list = list.concat(res.data.rst.list) hasNext = res.data.rst.pageInfo.hasNext } that.setData({ cardList: list, hasNext: hasNext}); }, complete: function () { that.setData({ hidden:true});//加载成功 wx.stopPullDownRefresh() //停止下拉刷新 } }); }, initBanner () { var data = [], that = this; wx.request({ url: app.globalData.HOST + '/user/CreditCard/bannerlist', method: "POST", data: app.globalData.common, success: function (res) { if (res.data.errno == '0') { data = res.data.rst.data; } that.setData({ bannerList: data}); }, complete: function () { // that.setData({ hidden:true});//加载成功 wx.stopPullDownRefresh() //停止下拉刷新 } }); }, onPullDownRefresh: function () { //下拉 this.data.page = 0; this.initCardList() }, onReachBottom: function () { //上拉 if (this.data.hasNext) { this.initCardList() } }, onShareAppMessage: function () { return { title: app.globalData.title, imageUrl: app.globalData.img, path: '/pages/index/index', success: function(res) { app.noticeModal('分享成功') }, fail: function(res) { app.noticeModal('您取消了分享') } } } })