index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Component({
  8. properties: {
  9. id: {
  10. type: String,
  11. value: ''
  12. }
  13. },
  14. data: {
  15. list: [],
  16. loading: false,
  17. content: {
  18. nocache: true,
  19. pageNumber: 1,
  20. pageSize: 10,
  21. pageTotal: 1,
  22. total: null
  23. },
  24. loading: false
  25. },
  26. methods: {
  27. /* 获取订单列表 */
  28. getList(id, init) {
  29. if (this.data.loading) return;
  30. let content = this.data.content;
  31. content.sa_customersid = id || this.data.id || this.data.sa_customersid;
  32. if (init) {
  33. content.pageNumber = 1;
  34. this.setData({ loading: true });
  35. }
  36. _Http.basic({
  37. "id": "2026030916334801",
  38. content
  39. }).then(res => {
  40. this.setData({ loading: false });
  41. console.log("客户订单列表", res)
  42. if (res.code != 1) return wx.showToast({
  43. title: res.msg,
  44. icon: "none"
  45. })
  46. // 格式化金额数据
  47. const formattedData = res.data.map(item => ({
  48. ...item,
  49. showAmount: CNY(item.amount || 0),
  50. showUnpaidAmount: CNY((item.amount || 0) - (item.payamount || 0))
  51. }))
  52. this.setData({
  53. list: res.pageNumber == 1 ? formattedData : this.data.list.concat(formattedData),
  54. "content.pageNumber": res.pageNumber + 1,
  55. "content.pageSize": res.pageSize,
  56. "content.pageTotal": res.pageTotal,
  57. "content.total": res.total,
  58. "sa_customersid": content.sa_customersid
  59. })
  60. })
  61. }
  62. }
  63. })