server.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // pages/display/display.js
  2. const {fetchGraphql} = require('../../utils/util.js');
  3. const {serverbyprops} = require('../../config/gql.js');
  4. Page({
  5. data: {
  6. servers: '',
  7. loading: true,
  8. imgUrls: [
  9. 'https://zos.alipayobjects.com/rmsportal/AiyWuByWklrrUDlFignR.png',
  10. 'https://zos.alipayobjects.com/rmsportal/TekJlZRVCjLFexlOCuWn.png',
  11. 'https://zos.alipayobjects.com/rmsportal/IJOtIlfsYdTyaDTRVrLI.png',
  12. ],
  13. indicatorDots: true,
  14. autoplay: true,
  15. interval: 5000,
  16. duration: 1000
  17. },
  18. useStorge() {
  19. const servers = wx.getStorageSync('servers');
  20. if (servers) {
  21. this.setData({
  22. servers,
  23. loading: false
  24. })
  25. } else {
  26. fetchGraphql(serverbyprops, {}, 'servers', 'serverbyprops', this).then(servers => {
  27. wx.setStorage({
  28. key: 'servers',
  29. data: servers
  30. });
  31. this.setData({
  32. loading: false
  33. })
  34. })
  35. }
  36. },
  37. noUserStorge() {
  38. fetchGraphql(serverbyprops, {}, 'servers', 'serverbyprops', this).then(servers => {
  39. this.setData({
  40. loading: false
  41. })
  42. })
  43. },
  44. onLoad() {
  45. this.noUserStorge();
  46. wx.setNavigationBarTitle({
  47. title: '选择一位技师'
  48. })
  49. },
  50. chooseMe(e) {
  51. wx.navigateTo({
  52. url: `../service/service?id=${e.target.id}`,
  53. })
  54. }
  55. });