remotePicker.js 675 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // components/remotePicker/remotePicker.js
  2. import {
  3. postApi
  4. } from "../../apis/api"
  5. Component({
  6. properties: {
  7. url: {
  8. type: String
  9. },
  10. params: {
  11. type: Object
  12. }
  13. },
  14. data: {
  15. arr: [],
  16. value: '',
  17. label: '',
  18. },
  19. methods: {
  20. async getList() {
  21. let res = await postApi(this.data.url, {
  22. ...this.data.params,
  23. term: this.data.label
  24. })
  25. this.setData({
  26. arr: res.data.result
  27. })
  28. console.log(res)
  29. },
  30. selectItem(e) {
  31. let {
  32. label,
  33. value
  34. } = e.currentTarget.dataset
  35. this.setData({
  36. label,
  37. value,
  38. arr: []
  39. })
  40. }
  41. }
  42. })