top-box.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. <view class="detail-box">
  9. <text class="detail">{{childreninfo.className}}</text>
  10. <!-- 选择学期 -->
  11. <view class="select-box">
  12. <u-picker :show="select" :columns="semester" ref="uPicker" @confirm="selectemester" @change="changeHandler"></u-picker>
  13. <!-- <u-button class="select-btn" @click="select = true" size="small" shape="circle">学期</u-button> -->
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- 切换孩子 -->
  19. <view class="list-box" v-show="show">
  20. <view class="children-item" v-for="(item,index) in parentdetail.childrenList" :key="index" @click="switchChildren(item)">
  21. <view class="item-box">
  22. <image class="item-avatar" :src="item.avatar"></image>
  23. <text class="item-text">{{item.name}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. mapState,
  32. mapMutations
  33. } from 'vuex'
  34. export default {
  35. name: "top-box",
  36. data() {
  37. return {
  38. show: false,
  39. select: false,
  40. semester:[
  41. ['19学年','20学年','21学年','22学年']
  42. ],
  43. };
  44. },
  45. computed: {
  46. ...mapState('m_children', ['childreninfo']),
  47. ...mapState('m_parent',['parentdetail'])
  48. },
  49. methods: {
  50. ...mapMutations('m_children',['updateChildrenInfo']),
  51. //学期选择
  52. selectemester(e){
  53. console.log('selectemester',e)
  54. uni.$showMsg('切换完成')
  55. this.select = false
  56. },
  57. //头部孩子选择
  58. showChildrenList(e){
  59. console.log('chooseChildren' + e)
  60. this.show = !this.show
  61. },
  62. switchChildren(item){
  63. console.log(item);
  64. this.updateChildrenInfo(item)
  65. this.show = false
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss">
  71. .home-topinfo {
  72. height: 400rpx;
  73. background: linear-gradient(#0080ff, #f1f3f5);
  74. display: flex;
  75. justify-content: flex-start;
  76. align-items: center;
  77. .children-avatar {
  78. margin-top: 22rpx;
  79. margin-left: 40rpx;
  80. width: 96rpx;
  81. height: 96rpx;
  82. border-radius: 50rpx;
  83. border: 4rpx solid #FFFFFF;
  84. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, 0.2);
  85. }
  86. .children-name {
  87. margin-top: 24rpx;
  88. margin-left: 20rpx;
  89. display: flex;
  90. flex-direction: column;
  91. .name {
  92. color: #3B4144;
  93. font-size: 32rpx;
  94. margin: 4rpx 0 0 10rpx;
  95. font-weight: bold;
  96. }
  97. .detail {
  98. color: #6b778d;
  99. font-weight: bold;
  100. font-size: 28rpx;
  101. margin: 10rpx 0rpx 0 10rpx;
  102. }
  103. }
  104. }
  105. .list-box{
  106. margin: -120rpx 40rpx 120rpx 30rpx;
  107. display: flex;
  108. flex-wrap: wrap;
  109. .children-item{
  110. margin: 0 10rpx 0 10rpx;
  111. .item-box{
  112. display: flex;
  113. flex-direction: column;
  114. justify-content: center;
  115. align-items: center;
  116. .item-avatar{
  117. width: 90rpx;
  118. height: 90rpx;
  119. border-radius: 50rpx;
  120. border: 4rpx solid #FFFFFF;
  121. }
  122. .item-text{
  123. font-size: 24rpx;
  124. font-weight: bold;
  125. color: #6b778d;
  126. }
  127. }
  128. }
  129. }
  130. </style>