index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // pages/yichang/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. labelid: 1,
  9. labellist:[{
  10. id:1,name:'需用户确认'
  11. },{
  12. id:0,name:'需人工结算'
  13. },{
  14. id:2,name:'处理完成'
  15. }],
  16. keyword: '',
  17. pageindex: 1,
  18. data: []
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. this.setData({pageindex: 1})
  35. this.getdata()
  36. },
  37. getdata() {
  38. var that = this;
  39. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/abnormal", {
  40. status: that.data.labelid,
  41. key: that.data.keyword,
  42. page: that.data.pageindex
  43. }, "get").then(function (res) {
  44. console.log(res);
  45. if (res.code != 200) {
  46. wx.showLoading({
  47. title: res.message.msg,
  48. })
  49. that.setData({pageindex: that.data.pageindex -= 1})
  50. setTimeout(function () {
  51. wx.hideLoading();
  52. }, 1000);
  53. } else {
  54. wx.hideLoading();
  55. if (that.data.pageindex == 1) {
  56. that.setData({data: []})
  57. }
  58. if (res.message.data.data.length > 0) {
  59. that.setData({data: that.data.data.concat(res.message.data.data)})
  60. } else {
  61. that.setData({pageindex: that.data.pageindex -= 1})
  62. }
  63. }
  64. }).catch(function (err) {
  65. console.log(222);
  66. })
  67. },
  68. changkeyword(e) {
  69. this.setData({
  70. keyword: e.detail.value
  71. })
  72. },
  73. changelabel(e){
  74. let id = e.currentTarget.dataset.id
  75. this.setData({labelid:id,pageindex: 1})
  76. this.getdata()
  77. },
  78. gosearch(){
  79. this.setData({pageindex: 1})
  80. this.getdata()
  81. },
  82. goinfo(e){
  83. let id = e.currentTarget.dataset.id;
  84. let order_id=e.currentTarget.dataset.order_id;
  85. console.log(e.currentTarget.dataset)
  86. if(this.data.labelid==1){
  87. wx.navigateTo({
  88. url:'/pages/error/yichangchuli/index?id='+id+"&order_id="+order_id,
  89. })
  90. }else if(this.data.labelid==0){
  91. wx.navigateTo({
  92. url:'/pages/error/jiesuan/index?id='+id+"&order_id="+order_id,
  93. })
  94. }
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面卸载
  103. */
  104. onUnload: function () {
  105. },
  106. /**
  107. * 页面相关事件处理函数--监听用户下拉动作
  108. */
  109. onPullDownRefresh:function(){
  110. this.setData({pageindex: 1})
  111. this.getdata()
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. this.setData({pageindex:this.data.pageindex+=1})
  118. this.getdata()
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function () {
  124. }
  125. })