帮你贷的小程序

index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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') || null;
  21. if (userInfo) {
  22. app.globalData.userInfo = userInfo;
  23. }else{
  24. wx.redirectTo({url: '/pages/login/login'})
  25. }
  26. if (options.source) {
  27. that.setData({source: options.source})
  28. }
  29. const dataParam = Object.assign({}, app.globalData.common, {version: 2, platform: app.globalData.platform});
  30. wx.request({
  31. url: app.globalData.HOST + '/user/product/homeact',
  32. method: 'POST',
  33. data: dataParam,
  34. success: function (res) {
  35. if (res.data.errno == '0'){
  36. that.setData({ imgUrls: res.data.rst.homeact});
  37. }
  38. }
  39. });
  40. utils.initList(that);
  41. },
  42. onShow () {
  43. wx.stopPullDownRefresh();
  44. wx.hideNavigationBarLoading();
  45. },
  46. onHide () {
  47. wx.stopPullDownRefresh()
  48. wx.hideNavigationBarLoading();
  49. },
  50. onPullDownRefresh: function () {
  51. //下拉
  52. var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" };
  53. that.data.page = 1;
  54. setTimeout(()=>{
  55. utils.initList(that, obj, that.data.page);
  56. }, 800)
  57. },
  58. onReachBottom: function () {
  59. //上拉
  60. var that = this, obj = { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" };
  61. if (that.data.hasNext) {
  62. utils.initList(that, obj, ++that.data.page);
  63. }
  64. },
  65. onShareAppMessage: function () {
  66. return {
  67. title: app.globalData.title,
  68. imageUrl: app.globalData.img,
  69. path: '/pages/index/index',
  70. success: function(res) {
  71. app.noticeModal('分享成功')
  72. },
  73. fail: function(res) {
  74. app.noticeModal('您取消了分享')
  75. }
  76. }
  77. },
  78. //FormId
  79. formSubmit(e) {
  80. const formId = e.detail.formId, id = e.target.dataset.id;
  81. const userInfo = app.globalData.userInfo;
  82. this.getFromid(formId,id);
  83. wx.navigateTo({
  84. url: '/pages/details/details?id='+id
  85. })
  86. // console.log(formId + "formID首页")
  87. },
  88. getFromid(formId,ids) {
  89. wx.request({
  90. url: app.globalData.HOST + '/user/wx/getFromid',
  91. method: "POST",
  92. data: Object.assign({}, app.globalData.common, { from_id: formId }),
  93. success: function (res) {
  94. },
  95. complete: function () {
  96. }
  97. });
  98. }
  99. })