index.js 4.9 KB

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