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.getorderList(event.detail.name);
  70. },
  71. toDetail(e) {
  72. wx.navigateTo({
  73. url: '/pages/order/detail/detail?order_no=' + e.currentTarget.dataset.no,
  74. })
  75. },
  76. getorderList(se) {
  77. var that = this;
  78. var status = se ? se : this.data.status;
  79. app.api.useApi(app.globalData.baseAppUrl + "api/order/index", {
  80. status: status,
  81. page: that.data.pageindex
  82. }, "get").then(function (res) {
  83. if (res.code != 200) {
  84. console.log(res.message.msg)
  85. wx.showLoading({
  86. title: '订单加载失败',
  87. })
  88. that.setData({pageindex: that.data.pageindex -= 1})
  89. } else {
  90. if (that.data.pageindex == 1) {
  91. that.setData({orderList: []})
  92. }
  93. if (res.message.data.data.length > 0) {
  94. that.setData({orderList: that.data.orderList.concat(res.message.data.data)})
  95. } else {
  96. that.setData({pageindex: that.data.pageindex -= 1})
  97. }
  98. }
  99. wx.hideLoading();
  100. }).catch(function (err) {
  101. console.log(222);
  102. })
  103. },
  104. pay(e){
  105. wx.navigateTo({
  106. url: '/pages/my/cashier/cashier?order_no='+e.currentTarget.dataset.oid,
  107. })
  108. },
  109. closOrder(e) {
  110. console.log(e);
  111. var that = this;
  112. var order = e.currentTarget.dataset.oid
  113. wx.showModal({
  114. title: '取消订单',
  115. content: '确认取消订单吗?',
  116. success: function (res) {
  117. if (res.confirm) {//这里是点击了确定以后
  118. app.api.useApi(app.globalData.baseAppUrl + "api/CancelOrders", {
  119. order_id: order,
  120. }, "post").then(function (res) {
  121. if (res.code != 200) {
  122. console.log(res.message.msg)
  123. wx.showToast({
  124. title: '取消成功',
  125. })
  126. console.log(getCurrentPages().length);
  127. } else {
  128. wx.showLoading({
  129. title: res.message.msg,
  130. })
  131. that.setData({pageindex: 1})
  132. that.getorderList();
  133. }
  134. wx.hideLoading();
  135. }).catch(function (err) {
  136. console.log(err);
  137. })
  138. } else {//这里是点击了取消以后
  139. console.log('用户点击取消')
  140. return false;
  141. }
  142. }
  143. })
  144. },
  145. onTabItemTap(e){
  146. if(!this.data.page_load){
  147. this.getorderList()
  148. }
  149. }
  150. })