index.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. orderId: {
  10. type: String,
  11. value: ''
  12. },
  13. orderStatus: {
  14. type: String,
  15. value: ''
  16. }
  17. },
  18. data: {
  19. list: [],
  20. loading: false,
  21. content: {
  22. nocache: true,
  23. pageNumber: 1,
  24. pageSize: 20,
  25. pageTotal: 1,
  26. total: null
  27. }
  28. },
  29. methods: {
  30. /* 获取付款记录列表 */
  31. getList(id, init) {
  32. let content = this.data.content;
  33. content.sa_custorderid = id || this.data.orderId || this.data.sa_custorderid;
  34. if (init) {
  35. content.pageNumber = 1;
  36. this.setData({ loading: true });
  37. }
  38. // 使用新的付款记录API
  39. _Http.basic({
  40. "id": "2026032016050501",
  41. content: {
  42. sa_custorderid: content.sa_custorderid,
  43. pageNumber: content.pageNumber,
  44. pageSize: content.pageSize
  45. }
  46. }).then(res => {
  47. this.setData({ loading: false });
  48. console.log("付款记录列表", res)
  49. if (res.code != 1) return wx.showToast({
  50. title: res.msg,
  51. icon: "none"
  52. })
  53. if (res.data && res.data.length > 0) {
  54. // 格式化金额数据
  55. const formattedData = res.data.map(item => ({
  56. ...item,
  57. showPayAmount: CNY(item.amount || 0)
  58. }))
  59. this.setData({
  60. list: init ? formattedData : this.data.list.concat(formattedData),
  61. "content.pageNumber": res.pageNumber + 1,
  62. "content.pageSize": res.pageSize,
  63. "content.pageTotal": res.pageTotal,
  64. "content.total": res.total,
  65. "sa_custorderid": content.sa_custorderid
  66. })
  67. }
  68. })
  69. },
  70. /* 跳转到创建收款单页面 */
  71. addPayment() {
  72. // 已退单状态不能添加付款记录
  73. if (this.data.orderStatus === '已退单') {
  74. wx.showToast({
  75. title: '已退单订单不能添加付款记录',
  76. icon: 'none'
  77. });
  78. return;
  79. }
  80. const sa_custorderid = this.data.orderId || this.data.sa_custorderid;
  81. wx.navigateTo({
  82. url: `/CRM/order/modules/paymentCreate/create?sa_custorderid=${sa_custorderid}`
  83. });
  84. }
  85. }
  86. })