top-box.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view>
  3. <!-- 头部信息 -->
  4. <view class="home-topinfo">
  5. <!-- 更新时间戳 -->
  6. <view class="refresh-time"
  7. :style="'top:'+ capsuleBottom + 'px;left:'+ capsuleMiddle + 'px;'+'width:'+capsuleWidth+ 'px'">
  8. <!-- 订阅版本 -->
  9. <text class="time-text">更新于: {{timeStamp}}</text>
  10. <button class="estate" :style="{backgroundImage:`url(${backgroundImage})`}">{{myData.subscribeLevel}}</button>
  11. </view>
  12. </view>
  13. <view style="display: flex;margin-top: -450rpx;
  14. margin-bottom: 120rpx;">
  15. <image class="children-avatar" :src="childreninfo.avatar" @click="showChildrenList"></image>
  16. <view class="children-name">
  17. <text class="name">{{childreninfo.name}}</text>
  18. <view class="detail-box">
  19. <text class="detail" @click="setSemesterPicker = true">{{semester}}</text>
  20. <!-- 选择学期 -->
  21. <view class="select-icon">
  22. <u-icon name="arrow-down" color="#FFF" @click="setSemesterPicker = true"></u-icon>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <u-picker class="picker" :show="setSemesterPicker" :closeOnClickOverlay="true" :columns="semesterList"
  28. ref="uPicker" @confirm="pickerConfirm" @cancel="pickerCancel" :immediateChange="true"></u-picker>
  29. <!-- 切换孩子 -->
  30. <view class="list-box" v-show="show">
  31. <view class="children-item" v-for="(item,index) in parentdetail.childrenList" :key="index"
  32. @click="switchChildren(item)">
  33. <view class="item-box">
  34. <image class="item-avatar" :src="item.avatar"></image>
  35. <text class="item-text">{{item.name}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState,
  44. mapMutations
  45. } from 'vuex'
  46. export default {
  47. name: "top-box",
  48. props: {
  49. timeStamp: {
  50. type: String,
  51. default: false
  52. }
  53. },
  54. created() {
  55. this.$getCapsuleSite()
  56. },
  57. data() {
  58. return {
  59. show: false,
  60. setSemesterPicker: false,
  61. //胶囊坐标
  62. capsuleBottom: 0,
  63. capsuleMiddle: 0,
  64. capsuleWidth: 0,
  65. //订阅背景图片
  66. backgroundImage: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.Vg_hgwLC0hRD46zTHmCD8wHaHr?pid=ImgDet&rs=1',
  67. };
  68. },
  69. computed: {
  70. ...mapState('m_children', ['childreninfo', 'semester', 'semesterList']),
  71. ...mapState('m_parent', ['parentdetail', 'myData'])
  72. },
  73. methods: {
  74. ...mapMutations('m_children', ['updateChildrenInfo', 'updateChildrenSemester']),
  75. //学期选择
  76. pickerConfirm(e) {
  77. //拼接图表数据
  78. this.updateChildrenSemester(e.value[0])
  79. uni.$showMsg('切换完成', 1000)
  80. this.setSemesterPicker = false
  81. },
  82. //取消选择
  83. pickerCancel() {
  84. uni.$showMsg('取消选择', 1000)
  85. this.setSemesterPicker = false
  86. },
  87. //头部孩子选择
  88. showChildrenList(e) {
  89. console.log('chooseChildren' + e)
  90. this.show = !this.show
  91. },
  92. switchChildren(item) {
  93. console.log(item);
  94. this.updateChildrenInfo(item)
  95. this.show = false
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .home-topinfo {
  102. height: 600rpx;
  103. background: linear-gradient($color-blue, $page-background-color);
  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: 7rpx 0 0 10rpx;
  133. width: 30rpx;
  134. height: 30rpx;
  135. }
  136. }
  137. }
  138. .refresh-time {
  139. height: auto;
  140. position: relative;
  141. display: flex;
  142. flex-direction: column;
  143. .time-text {
  144. margin: 0 auto;
  145. font-size: 24rpx;
  146. color: #FFFFFF;
  147. font-weight: bold;
  148. }
  149. .estate {
  150. margin: 5rpx auto;
  151. font-size: 22rpx;
  152. line-height: 40rpx;
  153. height: 40rpx;
  154. width: 100%;
  155. color: #FFFFFF;
  156. font-weight: bold;
  157. border-radius: 20rpx;
  158. border: none;
  159. background-size: cover;
  160. background-repeat: no-repeat;
  161. }
  162. }
  163. .list-box {
  164. margin: -100rpx 40rpx 120rpx 33rpx;
  165. display: flex;
  166. flex-wrap: wrap;
  167. .children-item {
  168. margin: 0 10rpx 0 10rpx;
  169. .item-box {
  170. display: flex;
  171. flex-direction: column;
  172. justify-content: center;
  173. align-items: center;
  174. .item-avatar {
  175. width: 90rpx;
  176. height: 90rpx;
  177. border-radius: 50rpx;
  178. border: 4rpx solid #FFFFFF;
  179. }
  180. .item-text {
  181. font-size: 24rpx;
  182. font-weight: bold;
  183. color: #6b778d;
  184. }
  185. }
  186. }
  187. }
  188. .t-icon {
  189. width: 40rpx;
  190. height: 40rpx;
  191. }
  192. </style>