index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. import lifecycle from '/util/lifecycle';
  2. import animModal from '/util/items';
  3. Page({
  4. ...lifecycle,
  5. ...animModal.animOp,
  6. data: {
  7. pageName: 'API/index',
  8. hidden: true,
  9. curIndex: 0,
  10. ...animModal.data,
  11. arr: {
  12. onItemTap: 'onGridItemTap',
  13. onChildItemTap: 'onChildItemTap',
  14. list: [{
  15. icon: '/image/api_open.png',
  16. title: '开放接口',
  17. entitle: 'Open API',
  18. subs: [{
  19. title: '获取授权码',
  20. entitle: 'getAuthCode',
  21. page: '../get-auth-code/get-auth-code'
  22. }, {
  23. title: '获取用户信息',
  24. entitle: 'getUserInfo',
  25. page: '../get-user-info/get-user-info'
  26. }, {
  27. title: '发起支付',
  28. entitle: 'tradePay',
  29. page: '../request-payment/request-payment'
  30. }],
  31. }, {
  32. icon: '/image/api_view.png',
  33. title: '界面',
  34. entitle: 'Interface',
  35. subs: [{
  36. title: '警告框',
  37. entitle: 'alert',
  38. page: '../alert/alert'
  39. }, {
  40. title: '确认框',
  41. entitle: 'confirm',
  42. page: '../confirm/confirm'
  43. }, {
  44. title: '弱提示',
  45. entitle: 'toast',
  46. page: '../toast/toast'
  47. }, {
  48. title: '加载提示',
  49. entitle: 'loading',
  50. page: '../loading/loading'
  51. }, {
  52. title: '操作菜单',
  53. entitle: 'showActionSheet',
  54. page: '../action-sheet/action-sheet'
  55. }, {
  56. title: '设置界面导航栏',
  57. entitle: 'setNavigationBar',
  58. page: '../set-navigation-bar/set-navigation-bar'
  59. }, {
  60. title: '标题栏加载动画',
  61. entitle: 'navigationBarLoading',
  62. page: '../navigation-bar-loading/navigation-bar-loading'
  63. }, {
  64. title: '页面跳转',
  65. entitle: 'navigateTo, navigateBack, redirectTo, switchTab',
  66. page: '../navigator/navigator'
  67. }, {
  68. title: '下拉刷新',
  69. entitle: 'pullDownRefresh',
  70. page: '../pull-down-refresh/pull-down-refresh'
  71. }, {
  72. title: '创建动画',
  73. entitle: 'createAnimation',
  74. page: '../animation/animation'
  75. }, {
  76. title: '创建绘画',
  77. entitle: 'createCanvasContext',
  78. page: '../canvas/canvas'
  79. }, {
  80. title: '联系人',
  81. entitle: 'choosePhoneContact, chooseAlipayContact',
  82. page: '../contact/contact'
  83. }, {
  84. title: '选择城市',
  85. entitle: 'chooseCity',
  86. page: '../choose-city/choose-city'
  87. }, {
  88. title: '选择日期',
  89. entitle: 'datePicker',
  90. page: '../date-picker/date-picker'
  91. }, {
  92. title: '滚动页面',
  93. entitle: 'pageScrollTo',
  94. page: '../page-scroll-to/page-scroll-to'
  95. }, {
  96. title: '隐藏键盘',
  97. entitle: 'hideKeyboard',
  98. page: '../keyboard/keyboard'
  99. }]
  100. }, {
  101. icon: '/image/api_device.png',
  102. title: '设备',
  103. entitle: 'Device',
  104. subs: [
  105. {
  106. title: '获取手机网络状态',
  107. entitle: 'getNetworkType',
  108. page: '../get-network-type/get-network-type'
  109. },
  110. {
  111. title: '获取手机系统信息',
  112. entitle: 'getSystemInfo',
  113. page: '../get-system-info/get-system-info'
  114. },
  115. {
  116. title:'获取服务器时间',
  117. entitle:'getServerTime',
  118. page:'../get-server-time/get-server-time'
  119. },
  120. {
  121. title: '摇一摇',
  122. entitle: 'watchShake',
  123. page: '../watch-shake/watch-shake'
  124. },
  125. {
  126. title: '震动',
  127. entitle: 'vibrate',
  128. page: '../vibrate/vibrate'
  129. },
  130. {
  131. title: '打电话',
  132. entitle: 'makePhoneCall',
  133. page: '../make-phone-call/make-phone-call'
  134. },
  135. {
  136. title: '剪贴板',
  137. entitle: 'clipboard',
  138. page: '../clipboard/clipboard'
  139. }
  140. ]
  141. }, {
  142. icon: '/image/api_network.png',
  143. title: '网络',
  144. entitle: 'Network',
  145. subs: [{
  146. title: '发起一个请求',
  147. entitle: 'request',
  148. page: '../request/request'
  149. }
  150. // , {
  151. // title: 'WebSocket',
  152. // entitle: 'WebSocket',
  153. // page: '../web-socket/web-socket'
  154. // }
  155. , {
  156. title: '上传文件',
  157. entitle: 'Upload File',
  158. page: '../upload-file/upload-file'
  159. },
  160. {
  161. title: '下载文件',
  162. entitle: 'Download File',
  163. page: '../download-file/download-file'
  164. }]
  165. }, {
  166. icon: '/image/api_websocket.png',
  167. title: 'Websocket',
  168. entitle: 'Websocket',
  169. page: '../websocket/websocket'
  170. }, {
  171. icon: '/image/api_media.png',
  172. title: '媒体',
  173. entitle: 'Media',
  174. subs: [{
  175. title: '图片',
  176. entitle: 'chooseImage/previewImage/saveImage',
  177. page: '../image/image'
  178. }
  179. ]
  180. }, {
  181. icon: '/image/api_map.png',
  182. title: '位置',
  183. entitle: 'Location',
  184. subs: [{
  185. title: '获取当前位置',
  186. entitle: 'getLocation',
  187. page: '../get-location/get-location'
  188. }, {
  189. title: '使用原生地图查看位置',
  190. entitle: 'openLocation',
  191. page: '../open-location/open-location'
  192. }]
  193. }, {
  194. icon: '/image/api_data.png',
  195. title: '数据',
  196. entitle: 'Storage',
  197. page: '../storage/storage'
  198. }, {
  199. icon: '/image/api_scan.png',
  200. title: '扫码 Scan',
  201. entitle: '',
  202. page: '../scan-code/scan-code'
  203. }, {
  204. icon: '/image/api_share.png',
  205. title: '自定义分享',
  206. entitle: 'Share',
  207. page: '../share/share'
  208. }, {
  209. icon: '/image/api_rsa.png',
  210. title: '非对称加密',
  211. entitle: 'RSA',
  212. page: '../rsa/rsa',
  213. },
  214. {
  215. icon: '/image/api_bluetooth.png',
  216. title: '蓝牙',
  217. entitle: 'Bluetooth',
  218. page: '../bluetooth/bluetooth'
  219. },
  220. ]
  221. }
  222. },
  223. onGridItemTap(e) {
  224. const curIndex = e.target.dataset.index;
  225. const childList = this.data.arr.list[curIndex];
  226. if (childList.subs) {
  227. this.setData({
  228. hidden: !this.data.hidden,
  229. curIndex,
  230. });
  231. this.createMaskShowAnim();
  232. this.createContentShowAnim();
  233. } else {
  234. const e = {
  235. target: {
  236. dataset: { page: childList.page }
  237. }
  238. };
  239. this.onChildItemTap(e);
  240. }
  241. },
  242. onChildItemTap(e) {
  243. const { page } = e.target.dataset;
  244. my.navigateTo({ url: page });
  245. },
  246. onModalCloseTap() {
  247. this.createMaskHideAnim();
  248. this.createContentHideAnim();
  249. setTimeout(() => {
  250. this.setData({
  251. hidden: true,
  252. });
  253. }, 210);
  254. },
  255. })