mybuy.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { get,post } from "../../common/request.js"
  2. import pathmap from "../../common/pathmap"
  3. import stylemap from "../../common/stylemap"
  4. import share from "../../common/share"
  5. import { retCartData } from "../../data/car"
  6. const app = getApp();
  7. Page(Object.assign({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. limit:10,
  13. pageindex:0,
  14. lock:false,
  15. list:[],
  16. hasloadall:false
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. this.getMyBuy();
  23. this.setData(stylemap);
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面隐藏
  37. */
  38. onHide: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload: function () {
  44. },
  45. /**
  46. * 页面相关事件处理函数--监听用户下拉动作
  47. */
  48. onPullDownRefresh: function () {
  49. },
  50. /**
  51. * 页面上拉触底事件的处理函数
  52. */
  53. onReachBottom: function () {
  54. },
  55. /**
  56. * 用户点击右上角分享
  57. */
  58. onShareAppMessage: function () {
  59. },
  60. getMyBuy:function(){
  61. var _self=this;
  62. if(!this.data.lock){
  63. var para = {
  64. offset : this.data.offset,
  65. limit : this.data.limit
  66. }
  67. this.setData({
  68. lock:true
  69. })
  70. get(pathmap.orderlist, para, function (json) {
  71. var list = retCartData(json.data&&json.data.list);
  72. var obj = {
  73. list:_self.data.list.concat(list),
  74. offset:_self.data.offset+_self.data.limit,
  75. lock:false
  76. }
  77. if(json.data.total<=_self.data.limit){
  78. obj.hasloadall=true;
  79. }else{
  80. obj.hasloadall=false;
  81. }
  82. _self.setData(obj);
  83. })
  84. }
  85. }
  86. },share))