select.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. content: {},
  11. result: [],
  12. resultItem: []
  13. },
  14. onLoad(options) {
  15. this.data.content = {
  16. ...JSON.parse(options.ids),
  17. "pageSize": 20,
  18. "where": {
  19. "condition": ""
  20. }
  21. }
  22. this.getList(true)
  23. },
  24. getList(init = false) {
  25. let content = this.data.content;
  26. if (init.detail != undefined) init = init.detail;
  27. if (init) {
  28. content.pageNumber = 1;
  29. content.pageTotal = 1;
  30. }
  31. if (content.pageNumber > content.pageTotal) return;
  32. _Http.basic({
  33. "id": 20231026150004,
  34. content
  35. }).then(res => {
  36. console.log("订单行列表", res)
  37. this.selectComponent('#ListBox').RefreshToComplete();
  38. this.selectComponent("#ListBox").setHeight(".total", this);
  39. if (res.msg != '成功') return wx.showToast({
  40. title: res.msg,
  41. icon: "none"
  42. })
  43. content.pageNumber = res.pageNumber + 1;
  44. content.pageTotal = res.pageTotal;
  45. let list = res.data.map(v => {
  46. v.showmarketprice = CNY(v.marketprice)
  47. v.showdefaultprice = CNY(v.defaultprice)
  48. v.showdefaultamount = CNY(v.defaultamount)
  49. v.showprice = CNY(v.price)
  50. v.showamount = CNY(v.amount)
  51. return v
  52. })
  53. this.setData({
  54. list: res.pageNumber == 1 ? list : this.data.list.concat(list)
  55. })
  56. })
  57. },
  58. onChange(e) {
  59. const {
  60. item
  61. } = e.currentTarget.dataset;
  62. let index = this.data.result.findIndex(v => v == item.sa_orderitemsid),
  63. result = this.data.result,
  64. resultItem = this.data.resultItem;
  65. if (index == -1) {
  66. result.push(item.sa_orderitemsid)
  67. resultItem.push(item)
  68. } else {
  69. result.splice(index, 1)
  70. resultItem.splice(index, 1)
  71. }
  72. this.setData({
  73. result,
  74. resultItem
  75. })
  76. },
  77. submit() {
  78. getApp().globalData.handleSelect && getApp().globalData.handleSelect(this.data.resultItem)
  79. },
  80. startSearch({
  81. detail
  82. }) {
  83. this.data.content.where.condition = detail;
  84. this.getList(true)
  85. },
  86. onClear() {
  87. this.data.content.where.condition = '';
  88. this.getList(true)
  89. },
  90. onUnload() {
  91. getApp().globalData.handleSelect = null;
  92. }
  93. })