You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
3.0KB

  1. // pages/ticketCenter/ticketCenter.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. chooseWhich:1,
  9. dataList:[],//需要展示的数据
  10. newData:[],
  11. pageNum:1,//页码,
  12. count:10,//每页条数
  13. total:0,//总条数
  14. total_page:0,//总页数
  15. scrollHig:0,
  16. type:"",
  17. hotType:2,
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. if (app.globalData.openId){
  24. this.getDataList();
  25. }else{
  26. app.globalData.openidSuccessFuc = this.getDataList;
  27. }
  28. console.log(wx.getSystemInfoSync().windowHeight)
  29. this.setData({
  30. scrollHig: wx.getSystemInfoSync().windowHeight-44-12,
  31. });
  32. },
  33. getDataList:function(type,hotType){
  34. if(type || hotType){
  35. this.data.type = type
  36. this.data.hotType = hotType
  37. }else{
  38. this.data.type = ""
  39. this.data.hotType = 2
  40. }
  41. let params = {
  42. list_type:2,
  43. cur_page:this.data.pageNum,
  44. show_num:this.data.count,
  45. item_type:this.data.type,
  46. item_state:1,
  47. hot_state:this.data.hotType
  48. }
  49. app.wxRequest(app.globalData.httpUrl + 'front/sell/listing', params, e => {
  50. console.log(e)
  51. if (e.code == 200) {
  52. for(var i=0;i<e.data.length;i++){
  53. this.data.newData.push(e.data[i]);
  54. }
  55. this.setData({
  56. dataList:this.data.newData
  57. })
  58. this.data.total_page = e.total_page;
  59. }
  60. }, this)
  61. },
  62. getBot:function(){//scroll触底事件
  63. if(this.data.pageNum<this.data.total_page){
  64. this.data.pageNum++;
  65. this.getDataList();
  66. }else{
  67. wx.showToast({
  68. title: '没有更多数据了',
  69. icon:"none"
  70. })
  71. }
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function () {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function () {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom: function () {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage: function () {
  107. },
  108. chooseFn: function(e){//选择
  109. this.setData({
  110. chooseWhich:e.currentTarget.dataset.index
  111. })
  112. console.log(this.data.chooseWhich)
  113. if(this.data.chooseWhich==1){
  114. this.data.type = "";
  115. this.data.hotType = 2;
  116. }else{
  117. this.data.type = this.data.chooseWhich-1;
  118. this.data.hotType = "";
  119. }
  120. this.data.pageNum = 1;
  121. this.data.dataList = [];
  122. this.data.newData = [];
  123. this.getDataList(this.data.type,this.data.hotType);
  124. },
  125. skipPage:function(e){//跳转到购买页面
  126. var id = e.currentTarget.dataset.id
  127. var type = e.currentTarget.dataset.type
  128. console.log(e)
  129. wx.navigateTo({
  130. url: '../buyTicket/buyTicket?id=' + id+"&type="+type
  131. })
  132. },
  133. })