select.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. "content": {
  5. nocache: true,
  6. "pageNumber": 1,
  7. "pageTotal": 1,
  8. "pageSize": 20,
  9. "where": {
  10. "condition": "",
  11. },
  12. },
  13. },
  14. onLoad() {
  15. this.getList(true)
  16. },
  17. /* 获取产品 */
  18. getList(init = false) {
  19. if (init.detail != undefined) init = init.detail;
  20. let content = this.data.content;
  21. if (init) content.pageNumber = 1;
  22. if (content.pageNumber > content.pageTotal) return;
  23. _Http.basic({
  24. "id": 20230105110003,
  25. content
  26. }).then(res => {
  27. console.log("选择序列号", res)
  28. this.selectComponent('#ListBox').RefreshToComplete();
  29. this.selectComponent("#ListBox").setHeight(".tab", this);
  30. this.setData({
  31. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  32. "content.pageNumber": res.pageNumber + 1,
  33. "content.pageTotal": res.pageTotal,
  34. "content.sort": res.sort,
  35. "content.total": res.total,
  36. })
  37. })
  38. },
  39. onClick(e) {
  40. const {
  41. item
  42. } = e.currentTarget.dataset;
  43. let page = getCurrentPages()[getCurrentPages().length - 2]
  44. if (page.__route__ = "packageA/repair/insert") {
  45. page.changeForm(item)
  46. } else {
  47. _Http.skuItem = item;
  48. wx.redirectTo({
  49. url: '/packageA/repair/insert',
  50. })
  51. }
  52. },
  53. onSearch({
  54. detail
  55. }) {
  56. if (this.data.content.where.condition == detail) return;
  57. this.setData({
  58. "content.where.condition": detail
  59. })
  60. this.getList(true)
  61. },
  62. onClear() {
  63. if (this.data.content.where.condition == "") return;
  64. this.setData({
  65. "content.where.condition": ""
  66. })
  67. this.getList(true)
  68. },
  69. })