index.js 4.4 KB

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