select.js 2.8 KB

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