myFamily.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="container ">
  3. <view class="tabs flex flex-direction u-border-bottom" >
  4. <view class="flex">
  5. <scroll-view scroll-x class="bg-white nav" :style="current==0?'width: 90%':''">
  6. <view class="flex text-center">
  7. <view class="cu-item flex-sub" :class="index==current?'text-blue text-xl text-bold':'text-lg'" v-for="(item,index) in tabs" :key="index" @tap="tabChange(index)" >
  8. {{item.name}}
  9. </view>
  10. </view>
  11. </scroll-view>
  12. <view v-if="current==0" @click="roomShow=!roomShow" class="flex justify-center padding-top-10 align-center" >
  13. <u-icon name="home" size="32" top="-4"></u-icon>
  14. <text class="text-blue padding-left-10 text-lg text-bold">{{roomName}}</text>
  15. <text v-if="!roomShow" class="text-blue cuIcon-unfold padding-left-10" ></text>
  16. <text v-else class="text-blue cuIcon-fold padding-left-10" ></text>
  17. </view>
  18. </view>
  19. </view>
  20. <view style="height: 100%;">
  21. <swiper style="height: 100%;" :current="current" @change="swiperChange"
  22. @animationfinish="animationfinish">
  23. <swiper-item v-for="(item, index) in tabs" :key="index">
  24. <scroll-view scroll-y style="height: 100%;">
  25. <item ref="mescrollItem" v-if="!$isEmpty(roomId)" :roomId="roomId" :i="index" :item="item" :current="current"></item>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. </view>
  30. <u-picker mode="selector" v-model="roomShow" :default-selector="defaultSelector" :range="roomList" range-key="fullRoomName" @confirm="roomChange"></u-picker>
  31. </view>
  32. </template>
  33. <script>
  34. import item from "./comps/item.vue"
  35. export default {
  36. components: {
  37. item
  38. },
  39. data() {
  40. return {
  41. defaultSelector:[0],
  42. roomShow:false,
  43. roomList:[],
  44. roomName:'',
  45. roomId:'',
  46. scrollLeft:0,
  47. current: 0,
  48. swiperCurrent:0,
  49. tabs: [
  50. {
  51. name: '审核通过',
  52. value:0
  53. },
  54. {
  55. name: '申请记录',
  56. value:1
  57. },
  58. {
  59. name: '住户审核',
  60. value:2
  61. }
  62. ],
  63. }
  64. },
  65. onShow(){
  66. this.canReset && this.refreshMescroll()
  67. this.canReset=true
  68. },
  69. onLoad() {
  70. this.getRoomByMemberId()
  71. },
  72. methods:{
  73. getRoomByMemberId(){
  74. let memberId=getApp().globalData.member.id
  75. let that=this
  76. let params={
  77. residentialId:uni.getStorageSync('residentialId'),
  78. id:memberId
  79. }
  80. that.$http.getRoomByMemberId(params).then(res =>{
  81. if (res.data.success) {
  82. that.roomList=res.data.data
  83. let own_room_list=[]
  84. this.roomList.forEach(item=>{
  85. item.fullRoomName=item.residentialName+"-"+item.buildingName+"-"+item.unitName+"-"+item.name
  86. })
  87. //选中的房间
  88. this.roomName=this.roomList[0].name
  89. this.roomId=that.roomList[0].id
  90. let room= this.vuex_own_room_list.find(item=>item.roomId==this.roomId)
  91. this.$u.vuex('vuex_relationshipType',room.type)
  92. }
  93. })
  94. },
  95. roomChange(e){
  96. this.defaultSelector=[e[0]]
  97. let room=this.roomList[e[0]]
  98. this.roomName=room.name
  99. this.roomId=room.id
  100. let obj= this.vuex_own_room_list.find(line=>line.roomId==this.roomId)
  101. this.$u.vuex('vuex_relationshipType',obj.type)
  102. this.refreshMescroll()
  103. },
  104. /**
  105. * 刷新列表
  106. */
  107. refreshMescroll(){
  108. let curMescroll = this.getMescroll(this.current)
  109. this.$nextTick(function(){
  110. curMescroll && curMescroll.resetUpScroll()
  111. })
  112. },
  113. /**
  114. * 获取Mescroll对象
  115. * @param {Object} i
  116. */
  117. getMescroll(i){
  118. let mescrollItems = this.$refs.mescrollItem;
  119. if(mescrollItems){
  120. let item = mescrollItems[i]
  121. if(item) return item.mescroll
  122. }
  123. return null
  124. },
  125. tabChange(index) {
  126. this.current = index
  127. // this.scrollLeft = (index - 1) * 60
  128. },
  129. swiperChange(e) {
  130. uni.pageScrollTo({
  131. scrollTop: 0,
  132. duration: 0
  133. });
  134. this.current = e.detail.current
  135. // this.scrollLeft = (this.current - 1) * 60
  136. },
  137. animationfinish({detail: { current }}) {
  138. this.swiperCurrent = current;
  139. this.current = current;
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .text-xl{
  146. font-size: 34rpx;
  147. }
  148. .container {
  149. height: calc(100vh - 78rpx);
  150. background-color: #F6F6F6;
  151. padding: 78rpx 0rpx 0rpx;
  152. .tabs {
  153. position: fixed;
  154. top: -10rpx;
  155. left: 0;
  156. display: flex;
  157. align-items: center;
  158. width: 100%;
  159. background-color: #FFFFFF;
  160. box-sizing: border-box;
  161. z-index: 3;
  162. }
  163. }
  164. </style>