index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import { getAdminOrderList, setOfflinePay } from "../../../api/admin";
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. parameter: {
  9. 'navbar': '1',
  10. 'return': '1',
  11. 'title': '订单列表',
  12. 'color': false
  13. },
  14. loading: false,//是否加载中
  15. loadend: false,//是否加载完毕
  16. loadTitle: '加载更多',//提示语
  17. orderList: [],//订单数组
  18. orderStatus: 0,//订单状态
  19. page: 1,
  20. limit: 10,
  21. isClose: false,
  22. orderInfo: null,
  23. change: false,
  24. navH:''
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. if (options.status) this.setData({ orderStatus: options.status });
  31. this.setData({ orderStatus: options.orderStatus, navH: app.globalData.navHeight});
  32. },
  33. /**
  34. * 登录回调
  35. *
  36. */
  37. onLoadFun: function () {
  38. this.getOrderList();
  39. },
  40. /**
  41. *
  42. * 操作 一键改价 修改备注 打开组件
  43. */
  44. modify: function (e) {
  45. let status = e.currentTarget.dataset.status;
  46. let orderInfo = e.currentTarget.dataset.orderinfo;
  47. this.setData({
  48. change: true,
  49. status: status,
  50. orderInfo: orderInfo
  51. });
  52. },
  53. /**
  54. * 关闭组件
  55. *
  56. */
  57. change: function () {
  58. this.setData({ change: false });
  59. },
  60. /**
  61. * 事件回调
  62. *
  63. */
  64. onChangeFun: function (e) {
  65. let opt = e.detail;
  66. let action = opt.action || null;
  67. let value = opt.value != undefined ? opt.value : null;
  68. (action && this[action]) && this[action](value);
  69. },
  70. /**
  71. * 确认付款
  72. */
  73. offlinePay: function (e) {
  74. let orderinfo = e.currentTarget.dataset.orderinfo;
  75. setOfflinePay({ order_id: orderinfo.order_id }).then(
  76. res => {
  77. app.Tips({ title: res.msg });
  78. this.setData({ loadend: false, page: 1, orderList: [] });
  79. this.getOrderList();
  80. },
  81. error => {
  82. app.Tips({ title: error.msg });
  83. }
  84. );
  85. },
  86. /**
  87. * 切换
  88. */
  89. changeStatus: function (e) {
  90. var status = e.currentTarget.dataset.status;
  91. if (status == this.data.orderStatus) return;
  92. this.setData({ orderStatus: status, loadend: false, page: 1, orderList: [] });
  93. this.getOrderList();
  94. },
  95. /**
  96. * 回调
  97. *
  98. */
  99. getIndex: function () {
  100. this.setData({ loadend: false, page: 1, orderList: [] });
  101. this.getOrderList();
  102. },
  103. /**
  104. * 获取订单列表
  105. */
  106. getOrderList: function () {
  107. if (this.data.loadend) return;
  108. if (this.data.loading) return;
  109. this.setData({ loading: true, loadTitle: "" });
  110. getAdminOrderList({
  111. status: this.data.orderStatus,
  112. page: this.data.page,
  113. limit: this.data.limit,
  114. }).then(res => {
  115. var list = res.data || [];
  116. var loadend = list.length < this.data.limit;
  117. this.data.orderList = app.SplitArray(list, this.data.orderList);
  118. this.setData({
  119. orderList: this.data.orderList,
  120. loadend: loadend,
  121. loading: false,
  122. loadTitle: loadend ? "我也是有底线的" : '加载更多',
  123. page: this.data.page + 1,
  124. });
  125. }).catch(err => {
  126. this.setData({ loading: false, loadTitle: "加载更多" });
  127. })
  128. },
  129. /**
  130. * 去订单详情
  131. */
  132. goOrderDetails: function (e) {
  133. var order_id = e.currentTarget.dataset.order_id;
  134. wx.navigateTo({ url: '/pages/admin/order_details/index?order_id=' + order_id });
  135. },
  136. /**
  137. * 生命周期函数--监听页面显示
  138. */
  139. onShow: function () {
  140. if (app.globalData.isLog && this.data.isClose) {
  141. this.setData({ loadend: false, page: 1, orderList: [] });
  142. this.getOrderList();
  143. }
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide: function () {
  149. this.setData({ isClose: true });
  150. },
  151. /**
  152. * 页面上拉触底事件的处理函数
  153. */
  154. onReachBottom: function () {
  155. this.getOrderList();
  156. },
  157. })