帮你贷的小程序

card.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //logs.js
  2. const util = require('../../utils/util.js')
  3. var app = getApp();
  4. Page({
  5. data: {
  6. logs: [],
  7. bannerList: [],
  8. indicatorDots: true,
  9. autoplay: false,
  10. interval: 2000,
  11. duration: 1000,
  12. cardList: [],
  13. hasNext: true,
  14. page: 0,
  15. hasPhone: false
  16. },
  17. onLoad: function () {
  18. this.initBanner();
  19. this.initCardList();
  20. app.login();
  21. this.initConcact(null, true);
  22. },
  23. initConcact (event, flag) {
  24. var that = this, event = event || null, flag = flag || false;
  25. var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = 0;
  26. if (user_id != '0' || tel != '0') {
  27. that.setData({hasPhone: true})
  28. }else{
  29. that.setData({hasPhone: false});
  30. console.log(flag);
  31. if (!flag) {
  32. console.log('test');
  33. id = event.currentTarget.dataset.id
  34. wx.navigateTo({
  35. url: "/pages/getPhone/getPhone?from=card&preid=" + id
  36. })
  37. }
  38. }
  39. },
  40. initCardList: function () {
  41. var data = {}, list = [], that = this, hasNext = true;
  42. if (that.data.page === 0) {
  43. list = []
  44. }else{
  45. list = that.data.cardList;
  46. }
  47. wx.request({
  48. url: app.globalData.HOST + '/user/CreditCard/list',
  49. method: "POST",
  50. data: {pageId: ++this.data.page},
  51. success: function (res) {
  52. if (res.data.errno == '0') {
  53. // data = res.data.rst.list;
  54. list = list.concat(res.data.rst.list)
  55. hasNext = res.data.rst.pageInfo.hasNext
  56. }
  57. that.setData({ cardList: list, hasNext: hasNext});
  58. },
  59. complete: function () {
  60. // that.setData({ hidden:true});//加载成功
  61. wx.stopPullDownRefresh() //停止下拉刷新
  62. }
  63. });
  64. },
  65. initBanner () {
  66. var data = [], that = this;
  67. wx.request({
  68. url: app.globalData.HOST + '/user/CreditCard/bannerlist',
  69. method: "POST",
  70. success: function (res) {
  71. if (res.data.errno == '0') {
  72. data = res.data.rst.data;
  73. }
  74. that.setData({ bannerList: data});
  75. },
  76. complete: function () {
  77. // that.setData({ hidden:true});//加载成功
  78. wx.stopPullDownRefresh() //停止下拉刷新
  79. }
  80. });
  81. },
  82. onPullDownRefresh: function () {
  83. //下拉
  84. this.data.page = 0;
  85. this.initCardList()
  86. },
  87. onReachBottom: function () {
  88. //上拉
  89. if (this.data.hasNext) {
  90. this.initCardList()
  91. }
  92. }
  93. })