index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Page({
  2. onShow() {
  3. wx.reportAnalytics('enter_home_programmatically', {})
  4. // http://tapd.oa.com/miniprogram_experiment/prong/stories/view/1020425689866413543
  5. if (wx.canIUse('getExptInfoSync')) {
  6. console.log('getExptInfoSync expt_args_1', wx.getExptInfoSync(['expt_args_1']))
  7. console.log('getExptInfoSync expt_args_2', wx.getExptInfoSync(['expt_args_2']))
  8. console.log('getExptInfoSync expt_args_3', wx.getExptInfoSync(['expt_args_3']))
  9. }
  10. if (wx.canIUse('reportEvent')) {
  11. wx.reportEvent('expt_event_1', {expt_data: 1})
  12. wx.reportEvent('expt_event_2', {expt_data: 5})
  13. wx.reportEvent('expt_event_3', {expt_data: 9})
  14. wx.reportEvent('expt_event_4', {expt_data: 200})
  15. wx.reportEvent('weexpt_event_key_1', {option_1: 1, option_2: 10, option_str_1: 'abc'})
  16. wx.reportEvent('weexpt_event_key_1', {option_1: 'abc', option_2: '1000', option_str_1: '1'})
  17. }
  18. },
  19. onShareAppMessage() {
  20. return {
  21. title: '小程序官方组件展示',
  22. path: 'page/component/index'
  23. }
  24. },
  25. onShareTimeline() {
  26. '小程序官方组件展示'
  27. },
  28. data: {
  29. list: [
  30. {
  31. id: 'view',
  32. name: '视图容器',
  33. open: false,
  34. pages: ['view', 'scroll-view', 'swiper', 'movable-view', 'cover-view']
  35. }, {
  36. id: 'content',
  37. name: '基础内容',
  38. open: false,
  39. pages: ['text', 'icon', 'progress', 'rich-text']
  40. }, {
  41. id: 'form',
  42. name: '表单组件',
  43. open: false,
  44. pages: ['button', 'checkbox', 'form', 'input', 'label', 'picker', 'picker-view', 'radio', 'slider', 'switch', 'textarea', 'editor']
  45. }, {
  46. id: 'nav',
  47. name: '导航',
  48. open: false,
  49. pages: ['navigator']
  50. }, {
  51. id: 'media',
  52. name: '媒体组件',
  53. open: false,
  54. pages: ['image', 'video', 'camera', 'live-pusher', 'live-player']
  55. }, {
  56. id: 'map',
  57. name: '地图',
  58. open: false,
  59. pages: ['map', { appid: 'wxe3f314db2e921db0', name: '腾讯位置服务示例中心'}]
  60. }, {
  61. id: 'canvas',
  62. name: '画布',
  63. open: false,
  64. pages: ['canvas-2d', 'webgl']
  65. }, {
  66. id: 'open',
  67. name: '开放能力',
  68. open: false,
  69. pages: ['ad', 'open-data', 'web-view']
  70. }, {
  71. id: 'obstacle-free',
  72. name: '无障碍访问',
  73. open: false,
  74. pages: ['aria-component']
  75. }
  76. ],
  77. theme: 'light'
  78. },
  79. onLoad() {
  80. this.setData({
  81. theme: wx.getSystemInfoSync().theme || 'light'
  82. })
  83. if (wx.onThemeChange) {
  84. wx.onThemeChange(({theme}) => {
  85. this.setData({theme})
  86. })
  87. }
  88. },
  89. kindToggle(e) {
  90. const id = e.currentTarget.id
  91. const list = this.data.list
  92. for (let i = 0, len = list.length; i < len; ++i) {
  93. if (list[i].id === id) {
  94. list[i].open = !list[i].open
  95. } else {
  96. list[i].open = false
  97. }
  98. }
  99. this.setData({
  100. list
  101. })
  102. wx.reportAnalytics('click_view_programmatically', {})
  103. }
  104. })