permissionList.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="select-variety-page">
  3. <view class="flex variety-list">
  4. <view class="variety-item" v-for="(item,index) in list" :key="item.name">
  5. <image class="variety-img" :src="item.pic_url" mode="aspectFill"></image>
  6. <view class="variety-name">{{item.name}}</view>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import {apiGetPermissionList} from '@/api/common'
  13. export default {
  14. computed: {
  15. list(){
  16. let hasArr=[]
  17. this.userInfo.permission_list&&this.userInfo.permission_list.forEach(item=>{
  18. item.permission_list.forEach(item2=>{
  19. hasArr.push(item2.name)
  20. })
  21. })
  22. let arr=this.reslist.filter(item=>{
  23. if(hasArr.find((e)=>e===item.permission_name)) return item
  24. })
  25. return arr
  26. }
  27. },
  28. data () {
  29. return {
  30. reslist:[]
  31. }
  32. },
  33. onLoad(options){
  34. this.getList()
  35. },
  36. methods: {
  37. async getList(){
  38. const res=await apiGetPermissionList()
  39. if(res.code===200){
  40. this.reslist=res.data
  41. // let hasArr=[]
  42. // this.$store.state.user.userInfo.permissiom_list&&this.$store.state.user.userInfo.permissiom_list.forEach(item=>{
  43. // console.log(item);
  44. // item.permission_list.forEach(item2=>{
  45. // console.log(item2.name);
  46. // hasArr.push(item2.name)
  47. // })
  48. // })
  49. // console.log(hasArr);
  50. // this.list=res.data.filter(item=>{
  51. // if(hasArr.find((e)=>e===item.name)) return item
  52. // })
  53. }
  54. },
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. .variety-list{
  60. padding: 50rpx 68rpx;
  61. justify-content: space-between;
  62. flex-wrap: wrap;
  63. text-decoration: none;
  64. .variety-item{
  65. margin-bottom: 30rpx;
  66. position: relative;
  67. width: 188rpx;
  68. }
  69. .variety-img{
  70. width: 188rpx;
  71. height: 188rpx;
  72. background-color: $global-bg-color-grey;
  73. border-radius: 8rpx;
  74. }
  75. .variety-name{
  76. text-align: center;
  77. }
  78. // 使用伪类 补充一个元素
  79. &::after{
  80. content: "";
  81. height: 0;
  82. width: 188rpx;
  83. }
  84. }
  85. </style>