top-box.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view>
  3. <!-- 头部信息 -->
  4. <view class="home-topinfo">
  5. <!-- 更新时间戳 -->
  6. <view class="refresh-time" :style="'top:'+ capsuleBottom + 'px;left:'+ capsuleMiddle + 'px;' ">
  7. <text class="time-text">更新于: {{timeStamp}}</text>
  8. </view>
  9. </view>
  10. <view style="display: flex;margin-top: -450rpx;
  11. margin-bottom: 120rpx;">
  12. <image class="children-avatar" :src="childreninfo.avatar" @click="showChildrenList"></image>
  13. <view class="children-name">
  14. <text class="name">{{childreninfo.name}}</text>
  15. <view class="detail-box">
  16. <text class="detail" @click="select = true">{{semester}}</text>
  17. <!-- 选择学期 -->
  18. <view class="select-icon">
  19. <view class="t-icon t-icon-youjiantou" @click="select = true"></view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <u-picker class="picker" :show="select" :closeOnClickOverlay="true" :columns="semesterList" ref="uPicker"
  25. @confirm="selectSemester" @cancel="selectCancel"></u-picker>
  26. <!-- 切换孩子 -->
  27. <view class="list-box" v-show="show">
  28. <view class="children-item" v-for="(item,index) in parentdetail.childrenList" :key="index"
  29. @click="switchChildren(item)">
  30. <view class="item-box">
  31. <image class="item-avatar" :src="item.avatar"></image>
  32. <text class="item-text">{{item.name}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. mapState,
  41. mapMutations
  42. } from 'vuex'
  43. export default {
  44. name: "top-box",
  45. props: {
  46. timeStamp: {
  47. type: String,
  48. default: false
  49. }
  50. },
  51. created() {
  52. this.getCapsuleSite()
  53. },
  54. data() {
  55. return {
  56. show: false,
  57. select: false,
  58. //下边界坐标
  59. capsuleBottom: 0,
  60. capsuleMiddle: 0
  61. };
  62. },
  63. computed: {
  64. ...mapState('m_children', ['childreninfo', 'semester', 'semesterList']),
  65. ...mapState('m_parent', ['parentdetail'])
  66. },
  67. methods: {
  68. ...mapMutations('m_children', ['updateChildrenInfo', 'updateChildrenSemester']),
  69. //学期选择
  70. selectSemester(e) {
  71. console.log('selectSemester', e)
  72. uni.$showMsg('切换完成')
  73. this.updateChildrenSemester(e.value[0])
  74. this.select = false
  75. },
  76. //取消选择
  77. selectCancel() {
  78. uni.$showMsg('取消选择')
  79. this.select = false
  80. },
  81. //头部孩子选择
  82. showChildrenList(e) {
  83. console.log('chooseChildren' + e)
  84. this.show = !this.show
  85. },
  86. switchChildren(item) {
  87. console.log(item);
  88. this.updateChildrenInfo(item)
  89. this.show = false
  90. },
  91. //获取胶囊位置信息
  92. getCapsuleSite(){
  93. let res=uni.getMenuButtonBoundingClientRect()
  94. this.capsuleBottom = res.bottom + 5
  95. this.capsuleMiddle = res.left
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .home-topinfo {
  102. height: 600rpx;
  103. background: linear-gradient(#0080ff, #f1f3f5);
  104. }
  105. .children-avatar {
  106. margin-left: 40rpx;
  107. width: 100rpx;
  108. height: 100rpx;
  109. border-radius: 100%;
  110. border: 4rpx solid #FFFFFF;
  111. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, 0.2);
  112. }
  113. .children-name {
  114. margin-left: 25rpx;
  115. padding-top: 5rpx;
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: center;
  119. .name {
  120. color: #3B4144;
  121. font-size: 36rpx;
  122. font-weight: bold;
  123. }
  124. .detail-box {
  125. display: flex;
  126. .detail {
  127. color: #FFFFFF;
  128. font-weight: bold;
  129. font-size: 30rpx;
  130. }
  131. .select-icon {
  132. margin:2rpx 0 0 10rpx;
  133. width: 30rpx;
  134. height: 30rpx;
  135. }
  136. }
  137. }
  138. .refresh-time {
  139. position: relative;
  140. .time-text {
  141. padding: 10rpx;
  142. font-size: 24rpx;
  143. color: #FFFFFF;
  144. font-weight: bold;
  145. }
  146. }
  147. .list-box {
  148. margin: -130rpx 40rpx 120rpx 33rpx;
  149. display: flex;
  150. flex-wrap: wrap;
  151. .children-item {
  152. margin: 0 10rpx 0 10rpx;
  153. .item-box {
  154. display: flex;
  155. flex-direction: column;
  156. justify-content: center;
  157. align-items: center;
  158. .item-avatar {
  159. width: 90rpx;
  160. height: 90rpx;
  161. border-radius: 50rpx;
  162. border: 4rpx solid #FFFFFF;
  163. }
  164. .item-text {
  165. font-size: 24rpx;
  166. font-weight: bold;
  167. color: #6b778d;
  168. }
  169. }
  170. }
  171. }
  172. .t-icon {
  173. width: 40rpx;
  174. height: 40rpx;
  175. }
  176. .picker {
  177. z-index: 99;
  178. }
  179. </style>