index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <view class="group">
  5. <button v-for="(button, index) in buttons" class="button" @click="onHandleClick(button)">
  6. <uni-icons :type="button.icon" :size="button.size" />
  7. <view>{{button.name}}</view>
  8. </button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {
  15. queryUser
  16. } from "@/services/index";
  17. import {buttons} from './buttonConfig.js'
  18. export default {
  19. data() {
  20. return {
  21. user: {},
  22. buttons: buttons.filter(item=>item.show)
  23. };
  24. },
  25. onShow() {
  26. this.getCurrentUser();
  27. },
  28. computed: {
  29. permission() {
  30. let permission = {};
  31. this.user?.Permissions.forEach((item) => {
  32. permission = {
  33. ...permission,
  34. ...item.Menus,
  35. };
  36. });
  37. return permission;
  38. },
  39. },
  40. methods: {
  41. onHandleClick(button) {
  42. uni.navigateTo({
  43. url: button.url,
  44. })
  45. },
  46. async getCurrentUser() {
  47. let res = {};
  48. res = await queryUser();
  49. this.user = res.data;
  50. },
  51. },
  52. };
  53. </script>
  54. <style lang="less" scoped>
  55. .content {
  56. height: 100vh;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. margin: 0;
  61. background: none;
  62. }
  63. .group {
  64. width: calc(100% - 30px);
  65. height: calc(100% - 30px);
  66. padding: 20px 10px;
  67. border-radius: 5px;
  68. background-color: #ffffff;
  69. overflow-y: scroll;
  70. // 每行两个,三行
  71. display: grid;
  72. grid-template-columns: repeat(2, 45%);
  73. // grid-template-columns: 1fr 1fr;
  74. grid-template-rows: repeat(4, 300rpx);
  75. grid-row-gap: 10px;
  76. grid-column-gap: 10px;
  77. justify-content: space-evenly;
  78. justify-items: center;
  79. align-content: flex-start;
  80. align-items: center;
  81. }
  82. .button {
  83. width: 100%;
  84. margin: 5px;
  85. height: 300rpx;
  86. font-size: 32rpx;
  87. background-color: #edf1f7;
  88. box-shadow: 0px 0px 3px 3px rgba(0, 0, 0, 0.1) ;
  89. }
  90. </style>