蓝色 贷款产品助手

card.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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: true,
  10. interval: 2000,
  11. duration: 1000,
  12. cardList: [],
  13. hasNext: true,
  14. page: 0,
  15. hiddenThis: true,
  16. appid: 0
  17. },
  18. onLoad: function () {
  19. this.initBanner();
  20. this.initCardList();
  21. app.login(this);
  22. },
  23. onShow () {
  24. wx.stopPullDownRefresh()
  25. },
  26. onHide () {
  27. wx.stopPullDownRefresh()
  28. this.setData({hiddenThis: true})
  29. },
  30. initConcact (event) {
  31. var that = this;
  32. var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = event.currentTarget.dataset.id;
  33. if (user_id != '0' || tel != '0') {
  34. // 绑定了手机号
  35. this.setData({hiddenThis: false, appid: id})
  36. }else{
  37. // 未绑定手机号
  38. wx.navigateTo({
  39. url: "/pages/getPhone/getPhone?from=card&preid=" + id
  40. })
  41. }
  42. },
  43. initCardList: function () {
  44. var data = {}, list = [], that = this, hasNext = true;
  45. that.setData({hidden: false});
  46. if (that.data.page === 0) {
  47. list = []
  48. }else{
  49. list = that.data.cardList;
  50. }
  51. wx.request({
  52. url: app.globalData.HOST + '/user/CreditCard/list',
  53. method: "POST",
  54. data: Object.assign({}, app.globalData.common, {pageId: ++this.data.page}),
  55. success: function (res) {
  56. if (res.data.errno == '0') {
  57. // data = res.data.rst.list;
  58. list = list.concat(res.data.rst.list)
  59. hasNext = res.data.rst.pageInfo.hasNext
  60. }
  61. that.setData({ cardList: list, hasNext: hasNext});
  62. },
  63. complete: function () {
  64. that.setData({ hidden:true});//加载成功
  65. wx.stopPullDownRefresh() //停止下拉刷新
  66. }
  67. });
  68. },
  69. initBanner () {
  70. var data = [], that = this;
  71. wx.request({
  72. url: app.globalData.HOST + '/user/CreditCard/bannerlist',
  73. method: "POST",
  74. data: app.globalData.common,
  75. success: function (res) {
  76. if (res.data.errno == '0') {
  77. data = res.data.rst.data;
  78. }
  79. that.setData({ bannerList: data});
  80. },
  81. complete: function () {
  82. // that.setData({ hidden:true});//加载成功
  83. wx.stopPullDownRefresh() //停止下拉刷新
  84. }
  85. });
  86. },
  87. onPullDownRefresh: function () {
  88. //下拉
  89. this.data.page = 0;
  90. this.initCardList()
  91. },
  92. onReachBottom: function () {
  93. //上拉
  94. if (this.data.hasNext) {
  95. this.initCardList()
  96. }
  97. },
  98. onShareAppMessage: function () {
  99. return {
  100. title: app.globalData.title,
  101. imageUrl: app.globalData.img,
  102. path: '/pages/index/index',
  103. success: function(res) {
  104. app.noticeModal('分享成功')
  105. },
  106. fail: function(res) {
  107. app.noticeModal('您取消了分享')
  108. }
  109. }
  110. },
  111. //FormId
  112. formSubmit(e) {
  113. var formId = e.detail.formId;
  114. this.getFromid(formId);
  115. },
  116. getFromid(formId) {
  117. wx.request({
  118. url: app.globalData.HOST + '/user/wx/getFromid',
  119. method: "POST",
  120. data: Object.assign({}, app.globalData.common, { from_id: formId }),
  121. success: function (res) {
  122. },
  123. complete: function () {
  124. }
  125. });
  126. }
  127. })