index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Page({
  2. onShareAppMessage() {
  3. return {
  4. title: '小程序云开发展示',
  5. path: 'page/cloud/index'
  6. }
  7. },
  8. data: {
  9. list: [
  10. {
  11. id: 'user',
  12. name: '用户鉴权',
  13. open: false,
  14. pages: [
  15. {
  16. zh: '获取 OpenID',
  17. url: 'user-authentication/user-authentication'
  18. }
  19. ]
  20. }, {
  21. id: 'database',
  22. name: '数据库',
  23. open: false,
  24. pages: [
  25. {
  26. zh: '基本操作',
  27. url: 'crud/crud'
  28. }, {
  29. zh: '权限管理',
  30. url: 'db-permission/db-permission'
  31. }, {
  32. zh: '服务端时间',
  33. url: 'server-date/server-date'
  34. }
  35. ]
  36. }, {
  37. id: 'storage',
  38. name: '存储',
  39. open: false,
  40. pages: [
  41. {
  42. zh: '上传文件',
  43. url: 'upload-file/upload-file'
  44. }, {
  45. zh: '下载文件',
  46. url: 'download-file/download-file'
  47. }, {
  48. zh: '删除文件',
  49. url: 'delete-file/delete-file'
  50. }, {
  51. zh: '换取临时链接',
  52. url: 'get-temp-file-url/get-temp-file-url'
  53. }, {
  54. zh: '组件支持',
  55. url: 'cloud-file-component/cloud-file-component'
  56. }
  57. ]
  58. }, {
  59. id: 'scf',
  60. name: '云函数',
  61. open: false,
  62. pages: [
  63. {
  64. zh: 'WXContext',
  65. url: 'get-wx-context/get-wx-context'
  66. }, {
  67. zh: '数据库',
  68. url: 'scf-database/scf-database'
  69. }, {
  70. zh: '存储',
  71. url: 'scf-storage/scf-storage'
  72. }, {
  73. zh: '云调用',
  74. url: 'scf-openapi/scf-openapi'
  75. }
  76. ]
  77. }
  78. ],
  79. theme: 'light'
  80. },
  81. onLoad() {
  82. this.setData({
  83. theme: wx.getSystemInfoSync().theme || 'light'
  84. })
  85. if (wx.onThemeChange) {
  86. wx.onThemeChange(({theme}) => {
  87. this.setData({theme})
  88. })
  89. }
  90. },
  91. kindToggle(e) {
  92. const id = e.currentTarget.id
  93. const list = this.data.list
  94. console.log(id, list)
  95. for (let i = 0, len = list.length; i < len; ++i) {
  96. if (list[i].id === id) {
  97. if (list[i].url) {
  98. console.log(list[i].url)
  99. wx.navigateTo({
  100. url: `../../packageCloud/pages/${list[i].url}`
  101. })
  102. return
  103. }
  104. list[i].open = !list[i].open
  105. } else {
  106. list[i].open = false
  107. }
  108. }
  109. this.setData({
  110. list
  111. })
  112. },
  113. })