myFamily.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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" :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. roomShow:false,
  42. roomList:[],
  43. roomName:'',
  44. roomId:'',
  45. scrollLeft:0,
  46. current: 0,
  47. swiperCurrent:0,
  48. tabs: [
  49. {
  50. name: '审核通过',
  51. value:0
  52. },
  53. {
  54. name: '申请记录',
  55. value:1
  56. },
  57. {
  58. name: '住户审核',
  59. value:2
  60. }
  61. ],
  62. }
  63. },
  64. onShow(){
  65. this.canReset && this.refreshMescroll()
  66. this.canReset=true
  67. },
  68. onLoad() {
  69. this.getRoomByMemberId()
  70. },
  71. methods:{
  72. getRoomByMemberId(){
  73. let that=this
  74. let params={
  75. residentialId:uni.getStorageSync('residentialId'),
  76. id:getApp().globalData.member.id
  77. }
  78. // let operation = 'estate/getRoomByMemberId';
  79. that.$http.getRoomByMemberId(params).then(res =>{
  80. if (res.data.success) {
  81. that.roomList=res.data.data
  82. this.roomList.forEach(item=>{
  83. item.fullRoomName=item.residentialName+"-"+item.buildingName+"-"+item.unitName+"-"+item.name
  84. })
  85. this.roomName=this.roomList[0].name
  86. this.roomId=that.roomList[0].id
  87. // that.realRoomList.forEach(item=>{
  88. // item.fullRoomName=item.buildingName+"-"+item.unitName+"-"+item.name
  89. // own_room_list.push(item)
  90. // })
  91. // getApp().globalData.own_room_list = own_room_list;
  92. // that.$u.vuex('vuex_own_room_list',own_room_list)
  93. // that.roomName=that.roomList[0].name
  94. // that.roomId=that.roomList[0].id
  95. // that.$u.vuex('vuex_relationshipType', that.roomList[0].relationshipType)
  96. }
  97. })
  98. },
  99. roomChange(e){
  100. this.roomName=this.realRoomList[e[0]].name
  101. this.roomId=this.realRoomList[e[0]].id
  102. // this.$u.vuex('vuex_relationshipType', this.roomList[e[0]].relationshipType)
  103. this.refreshMescroll()
  104. },
  105. /**
  106. * 刷新列表
  107. */
  108. refreshMescroll(){
  109. let curMescroll = this.getMescroll(this.current)
  110. this.$nextTick(function(){
  111. curMescroll && curMescroll.resetUpScroll()
  112. })
  113. },
  114. /**
  115. * 获取Mescroll对象
  116. * @param {Object} i
  117. */
  118. getMescroll(i){
  119. let mescrollItems = this.$refs.mescrollItem;
  120. if(mescrollItems){
  121. let item = mescrollItems[i]
  122. if(item) return item.mescroll
  123. }
  124. return null
  125. },
  126. tabChange(index) {
  127. this.current = index
  128. // this.scrollLeft = (index - 1) * 60
  129. },
  130. swiperChange(e) {
  131. uni.pageScrollTo({
  132. scrollTop: 0,
  133. duration: 0
  134. });
  135. this.current = e.detail.current
  136. // this.scrollLeft = (this.current - 1) * 60
  137. },
  138. animationfinish({detail: { current }}) {
  139. this.swiperCurrent = current;
  140. this.current = current;
  141. },
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .text-xl{
  147. font-size: 34rpx;
  148. }
  149. .container {
  150. height: calc(100vh - 78rpx);
  151. background-color: #F6F6F6;
  152. padding: 78rpx 0rpx 0rpx;
  153. .tabs {
  154. position: fixed;
  155. top: -10rpx;
  156. left: 0;
  157. display: flex;
  158. align-items: center;
  159. width: 100%;
  160. background-color: #FFFFFF;
  161. box-sizing: border-box;
  162. z-index: 3;
  163. }
  164. }
  165. </style>