123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- //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 = [];
- 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, {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(() => {
- if (this.data.activeIndex == 0) {
- this.initApplication();
- }else{
- this.initCardList();
- }
- }, 600)
- },
- onReachBottom: function () {
- //上拉
- if (this.data.activeIndex == 0) {
- this.initApplication();
- }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 () {
- }
- });
- }
- })
|