index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import lifecycle from '/util/lifecycle';
  2. import animModal from '/util/items';
  3. Page({
  4. ...lifecycle,
  5. ...animModal.animOp,
  6. data: {
  7. ...animModal.data,
  8. pageName: 'component/index',
  9. pageInfo: {
  10. pageId: 0,
  11. },
  12. hidden: true,
  13. curIndex: 0,
  14. arr: {
  15. onItemTap: 'onGridItemTap',
  16. onChildItemTap: 'onChildItemTap',
  17. list: [
  18. {
  19. icon: '/image/view.png',
  20. title: '视图容器',
  21. entitle: 'View',
  22. subs: [
  23. {
  24. title: '基础视图',
  25. entitle: 'View',
  26. page: 'view',
  27. },
  28. {
  29. title: '滚动视图',
  30. entitle: 'ScrollView',
  31. page: 'scroll-view',
  32. },
  33. {
  34. title: '滑动视图',
  35. entitle: 'Swiper',
  36. page: 'swiper',
  37. },
  38. ],
  39. }, {
  40. icon: '/image/basic.png',
  41. title: '基础内容',
  42. entitle: 'Basic Content',
  43. subs: [
  44. {
  45. title: '文字',
  46. entitle: 'Text',
  47. page: 'text',
  48. },
  49. {
  50. title: '图标',
  51. entitle: 'Icon',
  52. page: 'icon',
  53. },
  54. {
  55. title: '进度条',
  56. entitle: 'Progress',
  57. page: 'progress',
  58. },
  59. ],
  60. }, {
  61. icon: '/image/form.png',
  62. title: '表单组件',
  63. entitle: 'Form',
  64. subs: [
  65. {
  66. title: '按钮',
  67. entitle: 'Button',
  68. page: 'button',
  69. },
  70. {
  71. title: '复选框',
  72. entitle: 'Checkbox',
  73. page: 'checkbox',
  74. },
  75. {
  76. title: '表单',
  77. entitle: 'Form',
  78. page: 'form',
  79. },
  80. {
  81. title: '文本输入',
  82. entitle: 'Input',
  83. page: 'input',
  84. },
  85. {
  86. title: '标签',
  87. entitle: 'Label',
  88. page: 'label',
  89. },
  90. {
  91. title: '选择器视图',
  92. entitle: 'PickerView',
  93. page: 'picker-view',
  94. },
  95. {
  96. title: '选择器',
  97. entitle: 'Picker',
  98. page: 'picker',
  99. },
  100. {
  101. title: '单选框',
  102. entitle: 'Radio',
  103. page: 'radio',
  104. },
  105. {
  106. title: '滑动条',
  107. entitle: 'Slider',
  108. page: 'slider',
  109. },
  110. {
  111. title: '开关',
  112. entitle: 'Switch',
  113. page: 'switch',
  114. },
  115. {
  116. title: '多行输入',
  117. entitle: 'Textarea',
  118. page: 'textarea',
  119. },
  120. ],
  121. }, {
  122. icon: '/image/feedback.png',
  123. title: '操作反馈',
  124. entitle: 'Feedback',
  125. subs: [
  126. {
  127. title: '动作面板',
  128. entitle: 'ActionSheet',
  129. page: 'action-sheet',
  130. },
  131. {
  132. title: '对话框',
  133. entitle: 'Modal',
  134. page: 'modal',
  135. },
  136. {
  137. title: '轻提示',
  138. entitle: 'Toast',
  139. page: 'toast',
  140. },
  141. {
  142. title: '加载提示',
  143. entitle: 'Loading',
  144. page: 'loading',
  145. },
  146. ],
  147. }, {
  148. icon: '/image/navigator.png',
  149. title: '导航',
  150. entitle: 'Navigator',
  151. page: 'navigator',
  152. }, {
  153. icon: '/image/media.png',
  154. title: '媒体组件',
  155. entitle: 'Media',page: 'image',
  156. }, {
  157. icon: '/image/map.png',
  158. title: '地图',
  159. entitle: 'Map',
  160. page: 'map',
  161. }, {
  162. icon: '/image/canvas.png',
  163. title: '画布',
  164. entitle: 'Canvas',
  165. page: 'canvas',
  166. },
  167. ],
  168. },
  169. },
  170. onGridItemTap(e) {
  171. const curIndex = e.target.dataset.index;
  172. const childList = this.data.arr.list[curIndex];
  173. if (childList.subs) {
  174. this.setData({
  175. hidden: !this.data.hidden,
  176. curIndex,
  177. });
  178. this.createMaskShowAnim();
  179. this.createContentShowAnim();
  180. } else {
  181. this.onChildItemTap({
  182. target: {
  183. dataset: { page: childList.page },
  184. },
  185. });
  186. }
  187. },
  188. onChildItemTap(e) {
  189. const { page } = e.target.dataset;
  190. my.navigateTo({
  191. url: `component-pages/${page}/${page}`,
  192. });
  193. },
  194. onModalCloseTap() {
  195. this.createMaskHideAnim();
  196. this.createContentHideAnim();
  197. setTimeout(() => {
  198. this.setData({
  199. hidden: true,
  200. });
  201. }, 210);
  202. },
  203. });