serviceShow.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const {fetchGraphql} = require('../../../../utils/util.js');
  2. const {servicebyprops} = require('../../../../config/gql.js');
  3. Component({
  4. properties: {
  5. serverID: {
  6. type: String,
  7. observer(newVal, oldVal, changedPath) {
  8. this.setData({
  9. services: '',
  10. service: ''
  11. });
  12. if (newVal !== '') {
  13. fetchGraphql(servicebyprops,
  14. {server_id: newVal},
  15. 'services',
  16. 'servicebyprops',
  17. this
  18. )
  19. .then(services => {
  20. console.log(services);
  21. wx.hideLoading()
  22. });
  23. }
  24. }
  25. }
  26. },
  27. data: {
  28. services: '',
  29. service: ''
  30. },
  31. methods: {
  32. selectService(e) {
  33. let index = e.target.dataset.index;
  34. if(index === 'add') {
  35. this.setData({
  36. service: {id: 'add', server_id: {id: this.properties.serverID}}
  37. })
  38. } else {
  39. this.setData({
  40. service: this.data.services[index]
  41. })
  42. }
  43. }
  44. }
  45. });