帮你贷的小程序

util.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // 请求列表数据
  2. var app = getApp();
  3. var initList = function (that, obj, page) {
  4. that.setData({hidden: false});
  5. var obj = obj || { amount: 0, is_hot: 1, is_new: 0, search: 0, term: 0, user_title: "不限" };
  6. obj['page'] = page || 1;
  7. obj['platform'] = app.globalData.platform
  8. var list = [];
  9. if (obj['page'] == 1){
  10. list = [];
  11. }else{
  12. list = that.data.dataList
  13. }
  14. const dataParam = Object.assign({}, obj, app.globalData.common)
  15. wx.request({
  16. url: app.globalData.HOST + '/user/product/searchSecond',
  17. method: "POST",
  18. data: dataParam,
  19. success: function (res) {
  20. var data = res.data.rst.data;
  21. if (res.data.errno == '0') {
  22. that.data.hasNext = res.data.rst.pageinfo.hasNext
  23. // console.log(that.data.hasNext)
  24. for (var i = 0; i < data.length;i++){
  25. list.push(data[i]);
  26. /*if (orient == 'top'){
  27. list.unshift(data[i]);
  28. }else{
  29. }*/
  30. }
  31. that.setData({ dataList: list});
  32. }
  33. },
  34. complete: function () {
  35. // complete
  36. that.setData({ hidden:true});//加载成功
  37. wx.stopPullDownRefresh() //停止下拉刷新
  38. }
  39. });
  40. }
  41. module.exports = {
  42. initList: initList
  43. }