index.js 4.8 KB

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