myFamily.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. own_room_list.push(item)
  95. })
  96. //业主自己的房子
  97. getApp().globalData.own_room_list = own_room_list;
  98. that.$u.vuex('vuex_own_room_list',own_room_list)
  99. that.roomName=that.roomList[0].name
  100. that.roomId=that.roomList[0].id
  101. that.$u.vuex('vuex_relationshipType', that.roomList[0].relationshipType)
  102. }
  103. })
  104. },
  105. roomChange(e){
  106. this.roomName=this.roomList[e[0]].name
  107. this.roomId=this.roomList[e[0]].id
  108. this.$u.vuex('vuex_relationshipType', this.roomList[e[0]].relationshipType)
  109. this.refreshMescroll()
  110. },
  111. /**
  112. * 刷新列表
  113. */
  114. refreshMescroll(){
  115. let curMescroll = this.getMescroll(this.current)
  116. this.$nextTick(function(){
  117. curMescroll && curMescroll.resetUpScroll()
  118. })
  119. },
  120. /**
  121. * 获取Mescroll对象
  122. * @param {Object} i
  123. */
  124. getMescroll(i){
  125. let mescrollItems = this.$refs.mescrollItem;
  126. if(mescrollItems){
  127. let item = mescrollItems[i]
  128. if(item) return item.mescroll
  129. }
  130. return null
  131. },
  132. tabChange(index) {
  133. this.current = index
  134. // this.scrollLeft = (index - 1) * 60
  135. },
  136. swiperChange(e) {
  137. uni.pageScrollTo({
  138. scrollTop: 0,
  139. duration: 0
  140. });
  141. this.current = e.detail.current
  142. // this.scrollLeft = (this.current - 1) * 60
  143. },
  144. animationfinish({detail: { current }}) {
  145. this.swiperCurrent = current;
  146. this.current = current;
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .text-xl{
  153. font-size: 34rpx;
  154. }
  155. .container {
  156. height: calc(100vh - 78rpx);
  157. background-color: #F6F6F6;
  158. padding: 78rpx 0rpx 0rpx;
  159. .tabs {
  160. position: fixed;
  161. top: -10rpx;
  162. left: 0;
  163. display: flex;
  164. align-items: center;
  165. width: 100%;
  166. background-color: #FFFFFF;
  167. box-sizing: border-box;
  168. z-index: 3;
  169. }
  170. }
  171. </style>