top-box.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <!-- 头部信息 -->
  4. <view class="home-topinfo">
  5. <image class="children-avatar" :src="childreninfo.avatar" @click="showChildrenList"></image>
  6. <view class="children-name">
  7. <text class="name">{{childreninfo.name}}</text>
  8. <text class="detail">{{childreninfo.className}}</text>
  9. </view>
  10. </view>
  11. <!-- 切换孩子 -->
  12. <view class="list-box" v-show="show">
  13. <view class="children-item" v-for="(item,index) in parentdetail.childrenList" :key="index" @click="switchChildren(item)">
  14. <image class="children-avatar-item" :src="item.avatar"></image>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapState,
  22. mapMutations
  23. } from 'vuex'
  24. export default {
  25. name: "top-box",
  26. data() {
  27. return {
  28. show: false,
  29. };
  30. },
  31. computed: {
  32. ...mapState('m_children', ['childreninfo']),
  33. ...mapState('m_parent',['parentdetail'])
  34. },
  35. methods: {
  36. ...mapMutations('m_children',['updateChildrenInfo']),
  37. showChildrenList(e){
  38. console.log('chooseChildren' + e)
  39. this.show = true
  40. },
  41. switchChildren(item){
  42. console.log(item);
  43. this.updateChildrenInfo(item)
  44. this.show = false
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .home-topinfo {
  51. height: 400rpx;
  52. background: linear-gradient(#0080ff, #f1f3f5);
  53. display: flex;
  54. justify-content: flex-start;
  55. align-items: center;
  56. .children-avatar {
  57. margin-top: 11px;
  58. margin-left: 20px;
  59. width: 48px;
  60. height: 48px;
  61. border-radius: 25px;
  62. border: 2px solid #FFFFFF;
  63. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  64. }
  65. .children-name {
  66. margin-top: 12px;
  67. margin-left: 10px;
  68. display: flex;
  69. flex-direction: column;
  70. .name {
  71. color: #6b778d;
  72. font-size: 15px;
  73. margin: 2px 0px 0px 5px;
  74. font-weight: bold;
  75. }
  76. .detail {
  77. color: #3B4144;
  78. font-weight: bold;
  79. margin: 5px 0px 0px 5px;
  80. }
  81. }
  82. }
  83. .list-box{
  84. margin: -120rpx 20px 60px 15px;
  85. display: flex;
  86. flex-wrap: wrap;
  87. .children-item{
  88. margin: 0px 5px 0 5px;
  89. .children-avatar-item{
  90. width: 48px;
  91. height: 48px;
  92. border-radius: 25px;
  93. border: 2px solid #FFFFFF;
  94. }
  95. }
  96. }
  97. </style>