top-box.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. <text class="time-text">更新于: {{timeStamp}}</text>
  9. <!-- 订阅版本 -->
  10. <button class="estate" :style="{backgroundImage:`url(${backgroundImage})`}" @click="navSubscribe">{{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. watch:{
  55. setSemesterPicker(newValue){
  56. if(newValue === true){
  57. uni.hideTabBar({})
  58. }
  59. if(newValue === false){
  60. uni.showTabBar({})
  61. }
  62. }
  63. },
  64. created() {
  65. this.$getCapsuleSite()
  66. },
  67. data() {
  68. return {
  69. setSemesterPicker: false,
  70. //胶囊坐标
  71. capsuleBottom: 0,
  72. capsuleMiddle: 0,
  73. capsuleWidth: 0,
  74. //订阅背景图片
  75. backgroundImage: 'https://tse1-mm.cn.bing.net/th/id/OIP-C.Vg_hgwLC0hRD46zTHmCD8wHaHr?pid=ImgDet&rs=1',
  76. };
  77. },
  78. computed: {
  79. ...mapState('m_children', ['childreninfo', 'semester', 'semesterList']),
  80. ...mapState('m_parent', ['parentdetail', 'myData'])
  81. },
  82. methods: {
  83. ...mapMutations('m_children', ['updateChildrenInfo', 'updateChildrenSemester']),
  84. //学期选择
  85. pickerConfirm(e) {
  86. //拼接图表数据
  87. this.updateChildrenSemester(e.value[0])
  88. uni.$showMsg('切换完成', 1000)
  89. this.setSemesterPicker = false
  90. },
  91. //取消选择
  92. pickerCancel() {
  93. uni.$showMsg('取消选择', 1000)
  94. this.setSemesterPicker = false
  95. },
  96. //头部孩子选择
  97. showChildrenList(e) {
  98. this.show = !this.show
  99. },
  100. switchChildren(item) {
  101. this.updateChildrenInfo(item)
  102. this.show = false
  103. },
  104. //订阅页面
  105. navSubscribe(){
  106. uni.navigateTo({
  107. url: '/subpkg/subscribecenter/subscribecenter'
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .home-topinfo {
  115. height: 600rpx;
  116. background: linear-gradient($color-blue, $page-background-color);
  117. }
  118. .children-avatar {
  119. margin-left: 40rpx;
  120. width: 100rpx;
  121. height: 100rpx;
  122. border-radius: 100%;
  123. border: 4rpx solid #FFFFFF;
  124. box-shadow: 0 10rpx 20rpx rgba(0, 0, 0, 0.2);
  125. }
  126. .children-name {
  127. margin-left: 25rpx;
  128. padding-top: 5rpx;
  129. display: flex;
  130. flex-direction: column;
  131. justify-content: center;
  132. .name {
  133. color: #3B4144;
  134. font-size: 36rpx;
  135. font-weight: bold;
  136. }
  137. .detail-box {
  138. display: flex;
  139. .detail {
  140. color: #FFFFFF;
  141. font-weight: bold;
  142. font-size: 30rpx;
  143. }
  144. .select-icon {
  145. margin: 7rpx 0 0 10rpx;
  146. width: 30rpx;
  147. height: 30rpx;
  148. }
  149. }
  150. }
  151. .refresh-time {
  152. height: auto;
  153. position: relative;
  154. display: flex;
  155. flex-direction: column;
  156. .time-text {
  157. margin: 0 auto;
  158. font-size: 24rpx;
  159. color: #FFFFFF;
  160. font-weight: bold;
  161. }
  162. .estate {
  163. margin: 5rpx auto;
  164. font-size: 22rpx;
  165. line-height: 40rpx;
  166. height: 40rpx;
  167. width: 100%;
  168. color: #FFFFFF;
  169. font-weight: bold;
  170. border-radius: 20rpx;
  171. border: none;
  172. background-size: cover;
  173. background-repeat: no-repeat;
  174. }
  175. }
  176. .list-box {
  177. margin: -100rpx 40rpx 120rpx 33rpx;
  178. display: flex;
  179. flex-wrap: wrap;
  180. .children-item {
  181. margin: 0 10rpx 0 10rpx;
  182. .item-box {
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: center;
  186. align-items: center;
  187. .item-avatar {
  188. width: 90rpx;
  189. height: 90rpx;
  190. border-radius: 50rpx;
  191. border: 4rpx solid #FFFFFF;
  192. }
  193. .item-text {
  194. font-size: 24rpx;
  195. font-weight: bold;
  196. color: #6b778d;
  197. }
  198. }
  199. }
  200. }
  201. .t-icon {
  202. width: 40rpx;
  203. height: 40rpx;
  204. }
  205. </style>