top-box.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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" @click="select = true">{{semester}}</text>
  10. <!-- 选择学期 -->
  11. <view class="select-box">
  12. <u-picker class="picker" :show="select" :closeOnClickOverlay="true" :columns="semesterList" ref="uPicker" @confirm="selectSemester" @cancel="selectCancel"></u-picker>
  13. <view class="t-icon t-icon-youjiantou" @click="select = true"></view>
  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. semesterList:[
  41. ['19学年上学期','19学年下学期','20学年上学期','20学年下学期']
  42. ],
  43. };
  44. },
  45. computed: {
  46. ...mapState('m_children', ['childreninfo','semester']),
  47. ...mapState('m_parent',['parentdetail'])
  48. },
  49. methods: {
  50. ...mapMutations('m_children',['updateChildrenInfo','updateChildrenSemester']),
  51. //学期选择
  52. selectSemester(e){
  53. console.log('selectSemester',e)
  54. uni.$showMsg('切换完成')
  55. this.updateChildrenSemester(e.value[0])
  56. this.select = false
  57. },
  58. //取消选择
  59. selectCancel(){
  60. uni.$showMsg('取消选择')
  61. this.select = false
  62. },
  63. //头部孩子选择
  64. showChildrenList(e){
  65. console.log('chooseChildren' + e)
  66. this.show = !this.show
  67. },
  68. switchChildren(item){
  69. console.log(item);
  70. this.updateChildrenInfo(item)
  71. this.show = false
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. .home-topinfo {
  78. height: 400rpx;
  79. background: linear-gradient(#0080ff, #f1f3f5);
  80. display: flex;
  81. justify-content: flex-start;
  82. align-items: center;
  83. .children-avatar {
  84. margin-top: 22rpx;
  85. margin-left: 40rpx;
  86. width: 96rpx;
  87. height: 96rpx;
  88. border-radius: 50rpx;
  89. border: 4rpx solid #FFFFFF;
  90. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, 0.2);
  91. }
  92. .children-name {
  93. margin-top: 44rpx;
  94. margin-left: 20rpx;
  95. display: flex;
  96. flex-direction: column;
  97. .name {
  98. color: #3B4144;
  99. font-size: 32rpx;
  100. margin: 4rpx 0 0 10rpx;
  101. font-weight: bold;
  102. }
  103. .detail-box{
  104. display: flex;
  105. .detail {
  106. color: #2197ef;
  107. font-weight: bold;
  108. font-size: 28rpx;
  109. margin: 10rpx 0rpx 0 10rpx;
  110. }
  111. .select-box{
  112. margin: 10rpx;
  113. }
  114. }
  115. }
  116. }
  117. .list-box{
  118. margin: -120rpx 40rpx 120rpx 30rpx;
  119. display: flex;
  120. flex-wrap: wrap;
  121. .children-item{
  122. margin: 0 10rpx 0 10rpx;
  123. .item-box{
  124. display: flex;
  125. flex-direction: column;
  126. justify-content: center;
  127. align-items: center;
  128. .item-avatar{
  129. width: 90rpx;
  130. height: 90rpx;
  131. border-radius: 50rpx;
  132. border: 4rpx solid #FFFFFF;
  133. }
  134. .item-text{
  135. font-size: 24rpx;
  136. font-weight: bold;
  137. color: #6b778d;
  138. }
  139. }
  140. }
  141. }
  142. .t-icon{
  143. width: 40rpx;
  144. height: 40rpx;
  145. }
  146. .picker{
  147. z-index: 99;
  148. }
  149. </style>