index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. list: [],
  10. loading: false,
  11. content: {
  12. nocache: true,
  13. pageNumber: 1,
  14. pageSize: 20,
  15. pageTotal: 1,
  16. total: null,
  17. where: {
  18. condition: "",
  19. tablefilter: {
  20. sonum: null,
  21. status: null,
  22. name: null,
  23. phonenumber: null,
  24. address: null,
  25. storename: null
  26. },
  27. tableid: 2484
  28. }
  29. }
  30. },
  31. onLoad() {
  32. this.getList(true);
  33. },
  34. onPullDownRefresh() {
  35. this.getList(true);
  36. wx.stopPullDownRefresh();
  37. },
  38. onReachBottom() {
  39. if (this.data.content.pageNumber <= this.data.content.pageTotal) {
  40. this.getList(false);
  41. }
  42. },
  43. onSearch(e) {
  44. const keyword = e.detail.value || "";
  45. this.setData({
  46. "content.where.condition": keyword,
  47. "content.pageNumber": 1
  48. });
  49. this.getList(true);
  50. },
  51. getList(init) {
  52. if (init.detail != undefined) init = init.detail;
  53. let content = this.data.content;
  54. if (init) {
  55. content.pageNumber = 1;
  56. this.setData({ loading: true });
  57. }
  58. _Http.basic({
  59. "id": "2026031410293201",
  60. content
  61. }).then(res => {
  62. this.setData({ loading: false });
  63. console.log("订单列表", res)
  64. this.selectComponent('#ListBox').RefreshToComplete();
  65. if (res.code != 1) return wx.showToast({
  66. title: res.msg,
  67. icon: "none"
  68. })
  69. // 格式化金额数据
  70. const formattedData = res.data.map(item => ({
  71. ...item,
  72. showAmount: CNY(item.amount || 0),
  73. showPayAmount: CNY(item.payamount || 0),
  74. showUnpaidAmount: CNY((item.amount || 0) - (item.payamount || 0))
  75. }))
  76. this.setData({
  77. list: res.pageNumber == 1 ? formattedData : this.data.list.concat(formattedData),
  78. "content.pageNumber": res.pageNumber + 1,
  79. "content.pageSize": res.pageSize,
  80. "content.pageTotal": res.pageTotal,
  81. "content.total": res.total
  82. })
  83. })
  84. },
  85. // 跳转到开单页面
  86. createOrder() {
  87. wx.navigateTo({
  88. url: `/CRM/customer/modules/orderCreate/create`
  89. });
  90. },
  91. // 跳转到付款明细页面
  92. navigateToPaymentDetail(e) {
  93. const orderId = e.currentTarget.dataset.orderid;
  94. wx.navigateTo({
  95. url: `/CRM/order/modules/paymentDetail/index?orderId=${orderId}`
  96. });
  97. }
  98. });