帮你贷的小程序

index.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //index.js
  2. var app = getApp();
  3. var utils = require('../../utils/util.js');
  4. Page({
  5. data: {
  6. imgUrls: [
  7. ],
  8. indicatorDots: true,
  9. autoplay: true,
  10. interval: 2000,
  11. duration: 1000,
  12. page:1,
  13. dataList: [
  14. ],
  15. hidden: true,
  16. listId:0
  17. },
  18. onLoad: function (options) {
  19. var that = this, source = '';
  20. const userInfo = wx.getStorageSync('userInfo');
  21. let tel= wx.getStorageSync('tel'), user = wx.getStorageSync('user');
  22. if (userInfo) {
  23. app.globalData.userInfo = userInfo;
  24. if (tel == 0 && user.user_id == 0) {
  25. wx.redirectTo({url: '/pages/getPhone/getPhone'})
  26. }
  27. }else{
  28. wx.redirectTo({url: '/pages/login/login'})
  29. }
  30. if (options.source) {
  31. that.setData({source: options.source})
  32. }
  33. const dataParam = Object.assign({}, app.globalData.common, {version: 2, platform: app.globalData.platform});
  34. wx.request({
  35. url: app.globalData.HOST + '/user/product/homeact',
  36. method: 'POST',
  37. data: dataParam,
  38. success: function (res) {
  39. if (res.data.errno == '0'){
  40. that.setData({ imgUrls: res.data.rst.homeact});
  41. }
  42. }
  43. });
  44. utils.initList(that);
  45. },
  46. onShow () {
  47. wx.stopPullDownRefresh();
  48. wx.hideNavigationBarLoading();
  49. },
  50. onHide () {
  51. wx.stopPullDownRefresh()
  52. wx.hideNavigationBarLoading();
  53. },
  54. onPullDownRefresh: function () {
  55. //下拉
  56. var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" };
  57. that.data.page = 1;
  58. setTimeout(()=>{
  59. utils.initList(that, obj, that.data.page);
  60. }, 800)
  61. },
  62. onReachBottom: function () {
  63. //上拉
  64. var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" };
  65. if (that.data.hasNext) {
  66. utils.initList(that, obj, ++that.data.page);
  67. }
  68. },
  69. onShareAppMessage: function () {
  70. return {
  71. title: app.globalData.title,
  72. imageUrl: app.globalData.img,
  73. path: '/pages/index/index',
  74. success: function(res) {
  75. app.noticeModal('分享成功')
  76. },
  77. fail: function(res) {
  78. app.noticeModal('您取消了分享')
  79. }
  80. }
  81. },
  82. //FormId
  83. formSubmit(e) {
  84. const formId = e.detail.formId, id = e.target.dataset.id;
  85. const userInfo = app.globalData.userInfo;
  86. this.getFromid(formId,id);
  87. wx.navigateTo({
  88. url: '/pages/details/details?id='+id
  89. })
  90. // console.log(formId + "formID首页")
  91. },
  92. getFromid(formId,ids) {
  93. wx.request({
  94. url: app.globalData.HOST + '/user/wx/getFromid',
  95. method: "POST",
  96. data: Object.assign({}, app.globalData.common, { from_id: formId }),
  97. success: function (res) {
  98. },
  99. complete: function () {
  100. }
  101. });
  102. },
  103. test (e) {
  104. wx.setStorageSync('flag', 1);
  105. console.log(e);
  106. }
  107. })