家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. const $ = global;
  2. const colors = [
  3. 'blue',
  4. 'green',
  5. 'pink',
  6. 'orange',
  7. 'purple'
  8. ];
  9. new $.Page({
  10. data: {
  11. list: []
  12. },
  13. onShow() {
  14. const meta = $.router.getMeta();
  15. const type = meta && meta.params && meta.params.type || '';
  16. $.request('classifies', 'GET', {}).then((res) => {
  17. const data = res.data;
  18. const list = [];
  19. if (data.length > 0) {
  20. data.forEach(d => {
  21. if (!d.pid) {
  22. if (type) {
  23. if (d.name.includes(type)) {
  24. d.array = [];
  25. list.push(d);
  26. }
  27. } else {
  28. d.array = [];
  29. list.push(d);
  30. }
  31. }
  32. });
  33. data.forEach(d => {
  34. if (d.pid) {
  35. list.forEach((l, index) => {
  36. l.color = colors[index];
  37. if (d.name.includes('咨询')) {
  38. d.isConsult = true;
  39. }
  40. if (l.id === d.pid) {
  41. l['array'].push(d);
  42. }
  43. });
  44. }
  45. });
  46. this.setData({
  47. list
  48. });
  49. $.router.clearCurMeta();
  50. }
  51. });
  52. },
  53. toIntroduce(e) {
  54. const {
  55. id,
  56. name
  57. } = e.currentTarget.dataset;
  58. if (id) {
  59. if (name.includes('母婴')) {
  60. $.router.goto({
  61. path: `/pages/goodsList/index`
  62. });
  63. } else if (name.includes('咨询')) {
  64. // $.router.goto({
  65. // path: `/pages/service/index`
  66. // });
  67. } else {
  68. $.router.goto({
  69. path: `/pages/introduce/index`,
  70. query: {
  71. id,
  72. name
  73. }
  74. });
  75. }
  76. }
  77. }
  78. });