myFamily.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. <!-- <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 "./item.vue"
  36. export default {
  37. components: {
  38. item
  39. },
  40. data() {
  41. return {
  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 that=this
  75. let params={
  76. member_id:getApp().globalData.member.id
  77. }
  78. let operation = 'estate/getRoomByMemberId';
  79. getApp().globalData.postRequest(params,operation,(res)=>{
  80. if (res.data.result_code == 1) {
  81. that.roomList=res.data.list
  82. let own_room_list=[]
  83. that.roomList.forEach(item=>{
  84. if (item.relationshipType==0) {
  85. own_room_list.push(item)
  86. }
  87. item.fullRoomName=item.buildingName+"-"+item.unitName+"-"+item.name
  88. })
  89. //业主自己的房子
  90. getApp().globalData.own_room_list = own_room_list;
  91. that.$u.vuex('vuex_own_room_list',own_room_list)
  92. that.roomName=that.roomList[0].name
  93. that.roomId=that.roomList[0].id
  94. that.$u.vuex('vuex_relationshipType', that.roomList[0].relationshipType)
  95. }
  96. })
  97. },
  98. roomChange(e){
  99. this.roomName=this.roomList[e[0]].name
  100. this.roomId=this.roomList[e[0]].id
  101. this.$u.vuex('vuex_relationshipType', this.roomList[e[0]].relationshipType)
  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>