家政小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.js 1.8KB

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