myFamily.vue 4.7 KB

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