index.vue 9.9 KB

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