index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Page({
  2. onShow() {
  3. wx.reportAnalytics('enter_home_programmatically', {})
  4. },
  5. onShareAppMessage() {
  6. return {
  7. title: '小程序官方组件展示',
  8. path: 'page/component/index'
  9. }
  10. },
  11. data: {
  12. list: [
  13. {
  14. id: 'view',
  15. name: '视图容器',
  16. open: false,
  17. pages: ['view', 'scroll-view', 'swiper', 'movable-view', 'cover-view']
  18. }, {
  19. id: 'content',
  20. name: '基础内容',
  21. open: false,
  22. pages: ['text', 'icon', 'progress', 'rich-text']
  23. }, {
  24. id: 'form',
  25. name: '表单组件',
  26. open: false,
  27. pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio', 'slider', 'switch', 'textarea', 'editor']
  28. }, {
  29. id: 'nav',
  30. name: '导航',
  31. open: false,
  32. pages: ['navigator']
  33. }, {
  34. id: 'media',
  35. name: '媒体组件',
  36. open: false,
  37. pages: ['image', 'audio', 'video', 'camera']
  38. }, {
  39. id: 'map',
  40. name: '地图',
  41. open: false,
  42. pages: ['map']
  43. }, {
  44. id: 'canvas',
  45. name: '画布',
  46. open: false,
  47. pages: ['canvas']
  48. }, {
  49. id: 'open',
  50. name: '开放能力',
  51. open: false,
  52. pages: ['ad', 'open-data', 'web-view']
  53. }
  54. ]
  55. },
  56. kindToggle(e) {
  57. const id = e.currentTarget.id
  58. const list = this.data.list
  59. for (let i = 0, len = list.length; i < len; ++i) {
  60. if (list[i].id === id) {
  61. list[i].open = !list[i].open
  62. } else {
  63. list[i].open = false
  64. }
  65. }
  66. this.setData({
  67. list
  68. })
  69. wx.reportAnalytics('click_view_programmatically', {})
  70. }
  71. })