index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // pages/tabber/news/index.js
  2. const app=getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. inpscreenind: 0,
  9. inpscreenlist: ['水洗码', '封签号', '订单号', '物流单号', '手机号'],
  10. stateind: 0,
  11. statelist: ['全部'],
  12. shopsind: 0,
  13. shopslist: [{
  14. id:0,title:'全部'
  15. }],
  16. date: '',
  17. keyword: '',
  18. selectInfo: {},
  19. data:{},
  20. pageindex: 1
  21. },
  22. onPullDownRefresh:function(){
  23. this.setData({pageindex: 1})
  24. this.getdata()
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. class Select {
  31. in = 1
  32. getSelet(){
  33. console.log(2);
  34. return 10
  35. }
  36. }
  37. var b = new Select();
  38. console.log(b.getSelet());
  39. this.getdata()
  40. this.getshopslist()
  41. },
  42. /**
  43. * 页面上拉触底事件的处理函数
  44. */
  45. onReachBottom: function () {
  46. // this.setData({pageindex:this.data.pageindex+=1})
  47. // this.getdata()
  48. },
  49. /**
  50. * 生命周期函数--监听页面初次渲染完成
  51. */
  52. onReady: function () {
  53. const query = wx.createSelectorQuery()
  54. query.select('#nav').boundingClientRect((res) => {
  55. console.log(res);
  56. this.setData({
  57. selectInfo: res
  58. })
  59. })
  60. query.exec()
  61. },
  62. getshopslist(){
  63. let that = this
  64. wx.showLoading()
  65. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/ReportList", {}, "get").then(function (res) {
  66. wx.hideLoading()
  67. if(res.code==200){
  68. that.setData({
  69. shopslist:that.data.shopslist.concat(res.message.shop)
  70. })
  71. }
  72. }).catch(function (err) {
  73. console.log(222);
  74. })
  75. },
  76. getdata() {
  77. var that = this;
  78. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/ReportList", {
  79. network_id: that.data.shopsind!=0?that.data.shopslist[that.data.shopsind].id:'',
  80. status: that.data.stateind!=0?that.data.stateind:'',
  81. key: that.data.keyword,
  82. created_at: that.data.date,
  83. page: that.data.pageindex
  84. }, "get").then(function (res) {
  85. console.log(res);
  86. if (res.code != 200) {
  87. wx.showLoading({
  88. title: res.message.msg,
  89. })
  90. that.setData({pageindex: that.data.pageindex -= 1})
  91. setTimeout(function () {
  92. wx.hideLoading();
  93. }, 1000);
  94. } else {
  95. wx.hideLoading();
  96. if (that.data.pageindex == 1) {
  97. that.setData({data: []})
  98. }
  99. if (res.message.data.length > 0) {
  100. that.setData({data: that.data.data.concat(res.message.data)})
  101. } else {
  102. that.setData({pageindex: that.data.pageindex -= 1})
  103. }
  104. }
  105. }).catch(function (err) {
  106. console.log(222);
  107. })
  108. },
  109. changkeyword(e){
  110. this.setData({keyword: e.detail.value})
  111. },
  112. closedate(){
  113. this.setData({date: ''})
  114. this.setData({pageindex: 1})
  115. this.getdata()
  116. },
  117. datechange(e){
  118. this.setData({date:e.detail.value})
  119. this.setData({pageindex: 1})
  120. this.getdata()
  121. },
  122. shopschange(e){
  123. this.setData({shopsind: e.detail.value})
  124. this.setData({pageindex: 1})
  125. this.getdata()
  126. },
  127. changeinpscreen() {
  128. let that = this
  129. wx.showActionSheet({
  130. itemList: that.data.inpscreenlist,
  131. success(res) {
  132. that.setData({inpscreenind: res.tapIndex})
  133. }
  134. })
  135. },
  136. changestate() {
  137. let that = this
  138. wx.showActionSheet({
  139. itemList: that.data.statelist,
  140. success(res) {
  141. that.setData({stateind: res.tapIndex})
  142. this.setData({pageindex: 1})
  143. that.getdata()
  144. }
  145. })
  146. },
  147. })