//index.js var app = getApp(); var utils = require('../../utils/util.js'); Page({ data: { page: 0, dataList: [], cardList: [], // tabs: ["借款申请", "信用卡申请"], // activeIndex: 0, hidden: false, hiddenThis: true, appid: 0 }, onLoad: function () { this.initApplication(); // this.data.page = 0; // this.initCardList(); }, onShow () { wx.stopPullDownRefresh() }, initApplication () { var that = this, token = wx.getStorageSync('user').token, list = []; console.log(token); that.setData({hidden: false}); if (that.data.page) { list = that.data.dataList }else{ list = []; } wx.request({ url: app.globalData.HOST + '/user/wx/myapply', method: "POST", data: Object.assign({}, app.globalData.common, {token: token, pageId: ++that.data.page}), success: function (res) { var data = res.data; // console.log(data); if (data.errno == '0') { list = list.concat(data.rst.list) that.setData({ dataList: list }) }else if(data.errno == '90001'){ console.log('go'); // wx.navigateTo({ // url: '/pages/getPhone/getPhone' // }) } }, complete: function () { that.setData({ hidden:true});//加载成功 wx.stopPullDownRefresh() //停止下拉刷新 } }); }, showPanel (e) { var appid = e.currentTarget.dataset.id this.setData({hiddenThis: false, appid: appid}) }, initCardList() { var that = this, token = wx.getStorageSync('user').token, list = []; that.setData({hidden: false}); if (that.data.page) { list = that.data.cardList }else{ list = []; } // console.log('test'); wx.request({ url: app.globalData.HOST + '/user/wx/xykMyapply', method: "POST", data: Object.assign({}, app.globalData.common, {pageId: ++that.data.page}), success: function (res) { var data = res.data; // console.log(data); if (data.errno == '0') { list = list.concat(data.rst.list) that.setData({ cardList: list }) }else if(data.errno == '90001'){ console.log('go'); // wx.navigateTo({ // url: '/pages/getPhone/getPhone' // }) } }, complete: function () { that.setData({ hidden:true});//加载成功 wx.stopPullDownRefresh() //停止下拉刷新 } }); }, /* tabClick: function (e) { var id = e.currentTarget.id; this.setData({ activeIndex: id, page: 0, hiddenThis: true }); // console.log(this.data.activeIndex); if (id == 0) { this.initApplication(); }else{ this.initCardList(); } },*/ onPullDownRefresh: function () { //下拉 this.data.page = 0; setTimeout(() => { this.initApplication(); // if (this.data.activeIndex == 0) { // }else{ // this.initCardList(); // } }, 600) }, onReachBottom: function () { //上拉 this.initApplication(); // if (this.data.activeIndex == 0) { // }else{ // this.initCardList(); // } }, onHide () { this.setData({hiddenThis: true}) }, //FormId formSubmit(e) { var formId = e.detail.formId; this.getFromid(formId); }, getFromid(formId) { wx.request({ url: app.globalData.HOST + '/user/wx/getFromid', method: "POST", data: Object.assign({}, app.globalData.common, { from_id: formId }), success: function (res) { }, complete: function () { } }); } })