rows.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. const CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. privacyFieldC: [],
  10. content: {
  11. pageNumber: 1,
  12. pageTotal: 1,
  13. pageSize: 20,
  14. where: {
  15. condition: "",
  16. begindate: "",
  17. enddate: ""
  18. }
  19. }
  20. },
  21. onLoad(options) {
  22. this.getList()
  23. this.setData({
  24. userrole: wx.getStorageSync('userrole')
  25. })
  26. try {
  27. let privacyFieldC = wx.getStorageSync('auth').worderdetails.forms.list.formcols.map(v => v.title);
  28. this.setData({
  29. privacyFieldC
  30. })
  31. console.log("privacyFieldC", privacyFieldC)
  32. } catch (error) {
  33. console.error(error)
  34. }
  35. },
  36. tabsChange({
  37. detail
  38. }) {
  39. this.data.content.where.status = detail.name || ''
  40. this.getList(true)
  41. },
  42. /* 获取产品 */
  43. getList(init = false) {
  44. if (init.detail != undefined) init = init.detail;
  45. let content = this.data.content;
  46. if (init) content.pageNumber = 1;
  47. if (content.pageNumber > content.pageTotal) return;
  48. this.setListHeight();
  49. _Http.basic({
  50. "id": 2025090316070203,
  51. content
  52. }).then(res => {
  53. console.log("订单列表", res)
  54. if (res.msg != '成功') return wx.showToast({
  55. title: res.msg,
  56. icon: "none"
  57. })
  58. this.selectComponent('#ListBox').RefreshToComplete();
  59. content.pageNumber = res.pageNumber + 1
  60. content.pageTotal = res.pageTotal
  61. let list = [];
  62. res.data.forEach(v => {
  63. let index = list.findIndex(item => item.sonum == v.sonum);
  64. v.amount = CNY(currency(v.price).multiply(v.qty));
  65. v.price = CNY(v.price);
  66. if (index != -1) {
  67. list[index].productList.push(v)
  68. } else {
  69. v.productList = []
  70. list[list.length] = v;
  71. }
  72. })
  73. this.setData({
  74. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  75. content
  76. })
  77. })
  78. },
  79. /* 修改查看日期 */
  80. changeDate(e) {
  81. this.data.content.where[e.currentTarget.dataset.name] = e.detail.value;
  82. this.getList(true)
  83. },
  84. initialize() {
  85. this.data.content.where.enddate = "";
  86. this.data.content.where.begindate = "";
  87. this.getList(true)
  88. },
  89. /* 搜索 */
  90. onSearch({
  91. detail
  92. }) {
  93. this.data.content.where.condition = detail;
  94. this.getList(true)
  95. },
  96. /* 设置页面高度 */
  97. setListHeight() {
  98. this.selectComponent("#ListBox").setHeight(".top", this);
  99. }
  100. })