index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="house" :style="'padding-top:'+nvaHeight+'px;'">
  3. <view class="navbox">
  4. <uni-nav-bar color="#272727" left-icon="left" @clickLeft="getBackFn" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
  5. </uni-nav-bar>
  6. </view>
  7. <view class="houtop">
  8. <!-- 有 -->
  9. <view class="flexc mb10" v-if="list.length">
  10. <view class="tit">嗨,{{nickName}}!</view>
  11. <view class="tita flexcc" v-if="list[0].isHouseholder=='Y'">户主</view>
  12. <view class="flex1"></view>
  13. <view class="tbtns flex0 flexc" @click="getListFn">家庭成员
  14. <image :src="more"></image>
  15. </view>
  16. </view>
  17. <!-- 无 -->
  18. <block v-else>
  19. <view class="flexc mb10">
  20. <view class="tit">我的房屋</view>
  21. </view>
  22. <view class="txt mb10 fw5">您还未添加房屋信息喔~</view>
  23. </block>
  24. <view class="txt">Welcome back home</view>
  25. <image :src="housebg" class="houseimg"></image>
  26. </view>
  27. <block v-if="list.length">
  28. <view class="housebox pr" v-for="(ite,idx) in list" :key="idx" :data-idx="idx"
  29. @touchstart="drawStart" @touchmove="drawMove" @touchend="drawEnd" :style="'right:'+ite.right+'px'"
  30. >
  31. <view class="delleft pr">
  32. <view class="hblist">
  33. <view class="laber"><text>房屋坐落</text>:</view>
  34. <view class="tit">{{ite.location}}</view>
  35. <image :src="adrs" class="adrs"></image>
  36. <view class="flex1"></view>
  37. <view class="edit flexc flex0" @click.stop="getEdit(ite.houseId)">
  38. <image :src="edit"></image>
  39. 编辑
  40. </view>
  41. </view>
  42. <view class="flexc">
  43. <view class="hblist w50">
  44. <view class="laber"><text>小区名称</text>:</view>
  45. <view class="tit">{{ite.communityName}}</view>
  46. </view>
  47. <view class="hblist w50">
  48. <view class="laber"><text>门牌号</text>:</view>
  49. <view class="tit">{{ite.detailedAddress}}</view>
  50. </view>
  51. </view>
  52. <view class="flexc">
  53. <view class="hblist w50">
  54. <view class="laber"><text>房屋所属</text>:</view>
  55. <view class="tit">{{ite.rightType}}</view>
  56. </view>
  57. <view class="hblist w50">
  58. <view class="laber"><text>建筑面积</text>:</view>
  59. <view class="tit">{{ite.area}}m²</view>
  60. </view>
  61. </view>
  62. <!-- <view class="flexc">
  63. <view class="hblist w50">
  64. <view class="laber"><text>房型</text>:</view>
  65. <view class="tit">3室1厅</view>
  66. </view>
  67. <view class="hblist w50">
  68. <view class="laber"><text>居住人口</text>:</view>
  69. <view class="tit">3口人</view>
  70. </view>
  71. </view> -->
  72. <view class="flexc">
  73. <view class="hblist w50">
  74. <view class="laber"><text>有无车位</text>:</view>
  75. <view class="tit">{{ite.hasParkingSpace=='Y'?'有':'无'}}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="spdel" v-if="ite.right>0&&checkPermi(['wuYe:houseInfo:remove'])" @click.stop="getDelFn(ite.houseId)">删除</view>
  80. </view>
  81. </block>
  82. <view style="height: 76rpx;"></view>
  83. <!-- <view class="hbtns bga mb18" v-if="list.length">修改信息</view> -->
  84. <view class="hbtns bgb" :class="list.length?'':'mt110'" @click="getAddFn">添加房屋</view>
  85. <loading></loading>
  86. </view>
  87. </template>
  88. <script>
  89. import config from '@/config'
  90. const baseUrl = config.baseUrl;
  91. import {houseInfoList,houseInfoDel} from "@/api/work/work.js"
  92. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  93. export default{
  94. components:{},
  95. data(){
  96. return{
  97. housebg:require('@/mine/static/house/house.png'),
  98. more:require("@/work/static/visitor/more.png"),
  99. adrs:require('@/mine/static/house/adrs.png'),
  100. edit:require('@/mine/static/house/edit.png'),
  101. backgroundColor: "transparent",
  102. nvaHeight:44,
  103. list:[],
  104. pageSize: 10,
  105. pageNum: 1,
  106. reachflag: true,
  107. wtdt:'',
  108. delBtnWidth:66,//左滑默认宽度
  109. nickName:this.$store.state.user.nickName,
  110. }
  111. },
  112. onUnload() {
  113. uni.$off('refHouseList')
  114. },
  115. onLoad: function() {
  116. uni.$on('refHouseList',(res)=>{
  117. this.getDataFn()
  118. })
  119. uni.getSystemInfo({
  120. success: (e) => {
  121. this.nvaHeight = Number(e.statusBarHeight)+44;
  122. }
  123. })
  124. this.getDataFn()
  125. },
  126. onPageScroll(e) {
  127. var scrollTop = Number(e.scrollTop);
  128. if (scrollTop > 0) {
  129. this.backgroundColor = '#CCDDFF'
  130. } else {
  131. this.backgroundColor = 'transparent'
  132. }
  133. },
  134. methods:{
  135. checkPermi, checkRole,
  136. getAddFn(){
  137. this.$tab.navigateTo("/mine/pages/house/addhouse")
  138. },
  139. getListFn(){
  140. console.log(2)
  141. this.$tab.navigateTo("/mine/pages/house/people")
  142. },
  143. getEdit(id){
  144. this.$tab.navigateTo("/mine/pages/house/addhouse?id="+id)
  145. },
  146. getBackFn(){
  147. uni.navigateBack({
  148. delta:1
  149. })
  150. },
  151. getDelFn(id){
  152. var that=this;
  153. uni.showModal({
  154. title: '确认删除',
  155. content: "是否确认删除",
  156. cancelText: '取消',
  157. confirmText: '确认',
  158. success: function(res) {
  159. if (res.confirm) {
  160. houseInfoDel(id).then(res=>{
  161. if(res.code==200){
  162. that.$toast('删除成功')
  163. setTimeout(function(){
  164. that.getDataFn()
  165. },1200)
  166. }else{
  167. that.$toast(res.msg)
  168. }
  169. })
  170. } else if (res.cancel) {
  171. }
  172. }
  173. });
  174. },
  175. getDataFn(){
  176. var params={}
  177. houseInfoList(params).then(res=>{
  178. if(res.code==200){
  179. var newArr=JSON.parse(JSON.stringify(res.rows))
  180. newArr.forEach(ite=>{
  181. ite.right=0;
  182. })
  183. this.list = JSON.parse(JSON.stringify(newArr));
  184. }else{
  185. this.$toast(res.msg)
  186. }
  187. })
  188. },
  189. //开始触摸滑动
  190. drawStart(e) {
  191. console.log("开始触发");
  192. var touch = e.touches[0];
  193. this.startX = touch.clientX;
  194. },
  195. //触摸滑动
  196. drawMove(e) {
  197. // console.log("滑动");
  198. for (var index in this.list) {
  199. // this.csListArrl[index].right=0
  200. this.$set(this.list[index],'right',0);
  201. }
  202. var idx=e.currentTarget.dataset.idx
  203. var touch = e.touches[0];
  204. var item = this.list[idx];
  205. var disX = this.startX - touch.clientX;
  206. if (disX >= 20) {
  207. if (disX > this.delBtnWidth) {
  208. disX = this.delBtnWidth;
  209. }
  210. // this.csListArrl[idx].right=disX
  211. this.$set(this.list[idx],'right',disX);
  212. } else {
  213. // this.csListArrl[idx].right=0
  214. this.$set(this.list[idx],'right',0);
  215. }
  216. },
  217. //触摸滑动结束
  218. drawEnd(e) {
  219. // console.log("滑动结束");
  220. var idx=e.currentTarget.dataset.idx
  221. var item = this.list[idx];
  222. if (item.right >= this.delBtnWidth / 2) {
  223. // this.list[idx].right=this.delBtnWidth
  224. this.$set(this.list[idx],'right',this.delBtnWidth);
  225. } else {
  226. this.list[idx].right=0
  227. }
  228. },
  229. }
  230. }
  231. </script>
  232. <style>
  233. page{background: #F3F3F0;}
  234. </style>
  235. <style lang="scss" scoped>
  236. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  237. .house{min-height: 100vh;background: linear-gradient(180deg, #CDDDFF 0%, rgba(255,255,255,0) 100%) no-repeat;background-size: 100% 578rpx;padding: 0 54rpx 100rpx;
  238. .houtop{padding: 20rpx 4rpx 0 4rpx;height:520rpx;box-sizing: border-box;margin-bottom: 50rpx;position: relative;
  239. .tit{font-size: 36rpx;font-weight: bold;color: #272727;}
  240. .txt{font-size: 26rpx;color: #272727;}
  241. .tita{min-width: 86rpx;font-weight: 500;margin-left: 26rpx;font-size: 24rpx;color: #0156FE;height: 36rpx;border-radius: 18rpx;border: 2rpx solid #0156FE;}
  242. .houseimg{width: 596rpx;height:204rpx;position: absolute;bottom: 0;right: -58rpx;}
  243. .tbtns{font-weight: 500;font-size: 26rpx;color: #0256FD;
  244. image{width: 20rpx;height: 16rpx;margin-left: 10rpx;}
  245. }
  246. }
  247. .housebox{width: 100%;background: #FFFFFF;border-radius: 20rpx;box-sizing: border-box;margin-bottom: 24rpx;
  248. .delleft{
  249. padding: 36rpx 24rpx 16rpx;
  250. }
  251. .hblist{display: flex;margin-bottom: 20rpx;
  252. .laber{font-weight: 500;font-size: 26rpx;color: #666666;flex: 0 0 auto;
  253. text{min-width: 104rpx;text-align-last: justify;display: inline-block;}
  254. }
  255. .tit{color: #272727;font-weight: 500;font-size: 26rpx;}
  256. .adrs{width: 20rpx;height: 22rpx;margin-left: 16rpx;flex: 0 0 auto;margin-top: 6rpx;}
  257. }
  258. }
  259. .hbtns{font-weight: bold;display: flex;align-items: center;justify-content: center;font-size: 26rpx;height: 88rpx;border-radius: 44rpx;box-sizing: border-box;
  260. &.bga{border: 1px solid #0256FD;color: #0256FD;background: #CADBFF;}
  261. &.bgb{border: 1px solid #45CB99;color: #45CB99;background: #DBF8ED;}
  262. }
  263. }
  264. .edit{font-weight: 500;font-size: 24rpx;color: #06C770;
  265. image{width: 22rpx;height: 22rpx;margin-right: 4rpx;}
  266. }
  267. </style>