index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // pages/tabber/news/index.js
  2. import Dialog from '../../../miniprogram_npm/@vant/weapp/dialog/dialog';
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. orderList: [],
  10. status: 0,
  11. logisticsStatus: "",
  12. page_load:false,
  13. pageindex: 1
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. //this.alert()
  20. // this.setData({pageindex: 1})
  21. // this.getorderList()
  22. this.setData({
  23. logisticsStatus: app.globalData.logisticsStatus,
  24. page_load:true
  25. })
  26. },
  27. onShow() {
  28. this.setData({pageindex: 1})
  29. this.getorderList()
  30. },
  31. onHide(){
  32. console.log("隐藏")
  33. this.setData({
  34. page_load:false
  35. })
  36. },
  37. /**
  38. * 页面上拉触底事件的处理函数
  39. */
  40. onReachBottom: function () {
  41. this.setData({pageindex:this.data.pageindex+=1})
  42. this.getorderList()
  43. },
  44. alert() {
  45. Dialog.alert({
  46. title: '退费说明',
  47. message: `
  48. 本次服务实际发生费用26.00元(抵扣优
  49. 惠后),订单完成后剩余10.00元会原路
  50. 退回到您的支付账户。实际到账时间请
  51. 以银行及第三方支付机构退款时间为准,
  52. 通常不超过7个工作日。`,
  53. messageAlign: 'left',
  54. confirmButtonText: "我知道了",
  55. }).then(() => {
  56. // on close
  57. });
  58. },
  59. detail(e) {
  60. wx.navigateTo({
  61. url: '/pages/order/detail/detail?order_no='+ e.currentTarget.dataset.no,
  62. })
  63. },
  64. onClick(event) {
  65. // wx.showToast({
  66. // title: `点击标签 ${event.detail.name}`,
  67. // icon: 'none',
  68. // });
  69. this.setData({status:event.detail.name})
  70. this.getorderList(event.detail.name);
  71. },
  72. toDetail(e) {
  73. wx.navigateTo({
  74. url: '/pages/order/detail/detail?order_no=' + e.currentTarget.dataset.no,
  75. })
  76. },
  77. getorderList(se) {
  78. var that = this;
  79. var status = se ? se : this.data.status;
  80. app.api.useApi(app.globalData.baseAppUrl + "api/order/index", {
  81. status: status,
  82. page: that.data.pageindex
  83. }, "get").then(function (res) {
  84. if (res.code != 200) {
  85. console.log(res.message.msg)
  86. wx.showLoading({
  87. title: '订单加载失败',
  88. })
  89. that.setData({pageindex: that.data.pageindex -= 1})
  90. } else {
  91. if (that.data.pageindex == 1) {
  92. that.setData({orderList: []})
  93. }
  94. if (res.message.data.data.length > 0) {
  95. that.setData({orderList: that.data.orderList.concat(res.message.data.data)})
  96. } else {
  97. that.setData({pageindex: that.data.pageindex -= 1})
  98. }
  99. }
  100. wx.hideLoading();
  101. }).catch(function (err) {
  102. console.log(222);
  103. })
  104. },
  105. pay(e){
  106. wx.navigateTo({
  107. url: '/pages/my/cashier/cashier?order_no='+e.currentTarget.dataset.oid,
  108. })
  109. },
  110. closOrder(e) {
  111. console.log(e);
  112. var that = this;
  113. var order = e.currentTarget.dataset.oid
  114. wx.showModal({
  115. title: '取消订单',
  116. content: '确认取消订单吗?',
  117. success: function (res) {
  118. if (res.confirm) {//这里是点击了确定以后
  119. app.api.useApi(app.globalData.baseAppUrl + "api/CancelOrders", {
  120. order_id: order,
  121. }, "post").then(function (res) {
  122. if (res.code != 200) {
  123. console.log(res.message.msg)
  124. wx.showToast({
  125. title: '取消成功',
  126. })
  127. console.log(getCurrentPages().length);
  128. } else {
  129. wx.showLoading({
  130. title: res.message.msg,
  131. })
  132. that.setData({pageindex: 1})
  133. that.getorderList();
  134. }
  135. wx.hideLoading();
  136. }).catch(function (err) {
  137. console.log(err);
  138. })
  139. } else {//这里是点击了取消以后
  140. console.log('用户点击取消')
  141. return false;
  142. }
  143. }
  144. })
  145. },
  146. onTabItemTap(e){
  147. if(!this.data.page_load){
  148. this.getorderList()
  149. }
  150. }
  151. })