帮你贷的小程序

application.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //index.js
  2. var app = getApp();
  3. var utils = require('../../utils/util.js');
  4. Page({
  5. data: {
  6. page: 0,
  7. dataList: [],
  8. cardList: [],
  9. tabs: ["借款申请", "信用卡申请"],
  10. activeIndex: 0,
  11. hidden: false,
  12. hiddenThis: true,
  13. appid: 0
  14. },
  15. onLoad: function () {
  16. this.initApplication();
  17. // this.data.page = 0;
  18. // this.initCardList();
  19. },
  20. onShow () {
  21. wx.stopPullDownRefresh()
  22. },
  23. initApplication () {
  24. var that = this, token = wx.getStorageSync('user').token, list = [];
  25. that.setData({hidden: false});
  26. if (that.data.page) {
  27. list = that.data.dataList
  28. }else{
  29. list = [];
  30. }
  31. wx.request({
  32. url: app.globalData.HOST + '/user/wx/myapply',
  33. method: "POST",
  34. data: Object.assign({}, app.globalData.common, {pageId: ++that.data.page}),
  35. success: function (res) {
  36. var data = res.data;
  37. // console.log(data);
  38. if (data.errno == '0') {
  39. list = list.concat(data.rst.list)
  40. that.setData({
  41. dataList: list
  42. })
  43. }else if(data.errno == '90001'){
  44. console.log('go');
  45. // wx.navigateTo({
  46. // url: '/pages/getPhone/getPhone'
  47. // })
  48. }
  49. },
  50. complete: function () {
  51. that.setData({ hidden:true});//加载成功
  52. wx.stopPullDownRefresh() //停止下拉刷新
  53. }
  54. });
  55. },
  56. showPanel (e) {
  57. var appid = e.currentTarget.dataset.id
  58. this.setData({hiddenThis: false, appid: appid})
  59. },
  60. initCardList() {
  61. var that = this, token = wx.getStorageSync('user').token, list = [];
  62. that.setData({hidden: false});
  63. if (that.data.page) {
  64. list = that.data.cardList
  65. }else{
  66. list = [];
  67. }
  68. // console.log('test');
  69. wx.request({
  70. url: app.globalData.HOST + '/user/wx/xykMyapply',
  71. method: "POST",
  72. data: Object.assign({}, app.globalData.common, {pageId: ++that.data.page}),
  73. success: function (res) {
  74. var data = res.data;
  75. // console.log(data);
  76. if (data.errno == '0') {
  77. list = list.concat(data.rst.list)
  78. that.setData({
  79. cardList: list
  80. })
  81. }else if(data.errno == '90001'){
  82. console.log('go');
  83. // wx.navigateTo({
  84. // url: '/pages/getPhone/getPhone'
  85. // })
  86. }
  87. },
  88. complete: function () {
  89. that.setData({ hidden:true});//加载成功
  90. wx.stopPullDownRefresh() //停止下拉刷新
  91. }
  92. });
  93. },
  94. tabClick: function (e) {
  95. var id = e.currentTarget.id;
  96. this.setData({
  97. activeIndex: id,
  98. page: 0,
  99. hiddenThis: true
  100. });
  101. // console.log(this.data.activeIndex);
  102. if (id == 0) {
  103. this.initApplication();
  104. }else{
  105. this.initCardList();
  106. }
  107. },
  108. onPullDownRefresh: function () {
  109. //下拉
  110. this.data.page = 0;
  111. setTimeout(() => {
  112. if (this.data.activeIndex == 0) {
  113. this.initApplication();
  114. }else{
  115. this.initCardList();
  116. }
  117. }, 600)
  118. },
  119. onReachBottom: function () {
  120. //上拉
  121. if (this.data.activeIndex == 0) {
  122. this.initApplication();
  123. }else{
  124. this.initCardList();
  125. }
  126. },
  127. onHide () {
  128. this.setData({hiddenThis: true})
  129. },
  130. //FormId
  131. formSubmit(e) {
  132. var formId = e.detail.formId;
  133. this.getFromid(formId);
  134. },
  135. getFromid(formId) {
  136. wx.request({
  137. url: app.globalData.HOST + '/user/wx/getFromid',
  138. method: "POST",
  139. data: Object.assign({}, app.globalData.common, { from_id: formId }),
  140. success: function (res) {
  141. },
  142. complete: function () {
  143. }
  144. });
  145. }
  146. })