帮你贷的小程序

find.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // pages/find/find.js
  2. var utils = require('../../utils/util.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. tabArr: {
  7. curHdIndex: 0,
  8. curBdIndex: 0
  9. },
  10. jobArr: [],
  11. moneyArr: [],
  12. timeArr: [],
  13. obj:{ amount: 0, is_hot: 0, is_new: 0, search: 1, term: 0, user_title: "不限" },
  14. hasNext: false,
  15. page: 1,
  16. tab0:'职业身份',
  17. tab1:'贷款金额',
  18. tab2:'贷款期限'
  19. },
  20. tab: function(e){
  21. //获取触发事件组件的dataset属性
  22. var that = this, _datasetId = e.target.dataset.id, _rank = e.target.dataset.rank;
  23. // console.log("----" + _datasetId + "----");
  24. var _obj = {}, obj_app = this.data.obj;
  25. _obj.curHdIndex = _datasetId;
  26. _obj.curBdIndex = _datasetId;
  27. obj_app['ranking_list'] = _rank;
  28. that.data.page = 1;
  29. that.setData({
  30. tabArr: _obj,
  31. obj: obj_app
  32. });
  33. utils.initList(that, that.data.obj);
  34. },
  35. ajaxFilter: function (event) {
  36. var that = this;
  37. wx.request({
  38. url: app.globalData.HOST + '/user/wx/filter',
  39. method: "POST",
  40. data: app.globalData.common,
  41. success: function (res) {
  42. var data = res.data.rst;
  43. if (res.data.errno == '0') {
  44. that.setData({
  45. jobArr: data.userlist,
  46. moneyArr: data.list,
  47. timeArr: data.month
  48. })
  49. }
  50. },
  51. complete: function () {
  52. that.setData({ hidden:true});//加载成功
  53. wx.stopPullDownRefresh() //停止下拉刷新
  54. }
  55. });
  56. },
  57. showSheet: function(event){
  58. var tab = '';
  59. var that = this, currentTarget = event.currentTarget, arr = [], index = 0, arrData = [];
  60. var obj = {};
  61. that.data.page = 1;
  62. if(currentTarget.id == '0'){
  63. arr = that.data.jobArr.map((item) => item.v);
  64. arrData = that.data.jobArr.map((item) => item.k);
  65. }else if(currentTarget.id == '1'){
  66. arr = that.data.moneyArr.map((item) => item.v);
  67. arrData = that.data.moneyArr.map((item) => item.k);
  68. }else{
  69. arr = that.data.timeArr.map((item) => item.v);
  70. arrData = that.data.timeArr.map((item) => item.k);
  71. }
  72. wx.showActionSheet({
  73. itemList: arr,
  74. success: function (res) {
  75. index = res.tapIndex;
  76. tab = arrData[index];
  77. if(currentTarget.id == '0'){
  78. that.data.obj['user_title'] = tab;
  79. that.setData({tab0: that.data.jobArr[index].v})
  80. }else if(currentTarget.id == '1'){
  81. that.data.obj['amount'] = tab;
  82. that.setData({tab1: that.data.moneyArr[index].v})
  83. }else{
  84. that.data.obj['term'] = tab;
  85. that.setData({tab2: that.data.timeArr[index].v})
  86. }
  87. utils.initList(that, that.data.obj, that.data.page);
  88. },
  89. fail: function (res) {
  90. console.log(res.errMsg)
  91. }
  92. })
  93. },
  94. onLoad: function (options) {
  95. var that = this;
  96. utils.initList(that, that.data.obj);
  97. that.ajaxFilter();
  98. },
  99. onShow () {
  100. wx.stopPullDownRefresh()
  101. },
  102. onPullDownRefresh: function () {
  103. //下拉
  104. var that = this;
  105. that.data.page = 1;
  106. setTimeout(() => {
  107. utils.initList(that, that.data.obj, that.data.page);
  108. }, 500)
  109. },
  110. onReachBottom: function () {
  111. //上拉
  112. var that = this;
  113. if (that.data.hasNext) {
  114. utils.initList(that, that.data.obj, ++that.data.page);
  115. }
  116. },
  117. onReady: function () {
  118. },
  119. onHide: function () {
  120. },
  121. onUnload: function () {
  122. },
  123. onShareAppMessage: function () {
  124. return {
  125. title: app.globalData.title,
  126. imageUrl: app.globalData.img,
  127. path: '/pages/index/index',
  128. success: function(res) {
  129. app.noticeModal('分享成功')
  130. },
  131. fail: function(res) {
  132. app.noticeModal('您取消了分享')
  133. }
  134. }
  135. },
  136. //FormId
  137. formSubmit(e) {
  138. var formId = e.detail.formId;
  139. var id = e.target.dataset.id;
  140. this.getFromid(formId, id);
  141. console.log(formId + "formID发现")
  142. },
  143. getFromid(formId, ids) {
  144. wx.request({
  145. url: app.globalData.HOST + '/user/wx/getFromid',
  146. method: "POST",
  147. data: Object.assign({}, app.globalData.common, { from_id: formId }),
  148. success: function (res) {
  149. wx.navigateTo({
  150. url: '/pages/details/details?id=' + ids
  151. })
  152. },
  153. complete: function () {
  154. }
  155. });
  156. }
  157. })