index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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.ownerName}}</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. userId:this.$store.state.user.userId,
  111. phonenumber:this.$store.state.user.phonenumber,
  112. }
  113. },
  114. onUnload() {
  115. uni.$off('refHouseList')
  116. },
  117. onLoad: function() {
  118. uni.$on('refHouseList',(res)=>{
  119. this.getDataFn()
  120. })
  121. uni.getSystemInfo({
  122. success: (e) => {
  123. this.nvaHeight = Number(e.statusBarHeight)+44;
  124. }
  125. })
  126. this.getDataFn()
  127. },
  128. // 上拉触底加载更多触发事件
  129. onReachBottom() {
  130. if (this.reachflag) {
  131. this.pageNum++
  132. this.getDataFn()
  133. }
  134. },
  135. onPageScroll(e) {
  136. var scrollTop = Number(e.scrollTop);
  137. if (scrollTop > 0) {
  138. this.backgroundColor = '#CCDDFF'
  139. } else {
  140. this.backgroundColor = 'transparent'
  141. }
  142. },
  143. methods:{
  144. checkPermi, checkRole,
  145. getAddFn(){
  146. this.$tab.navigateTo("/mine/pages/house/addhouse")
  147. },
  148. getListFn(){
  149. this.$tab.navigateTo("/mine/pages/house/people")
  150. },
  151. getEdit(id){
  152. this.$tab.navigateTo("/mine/pages/house/addhouse?id="+id)
  153. },
  154. getBackFn(){
  155. uni.navigateBack({
  156. delta:1
  157. })
  158. },
  159. getDelFn(id){
  160. var that=this;
  161. uni.showModal({
  162. title: '确认删除',
  163. content: "是否确认删除",
  164. cancelText: '取消',
  165. confirmText: '确认',
  166. success: function(res) {
  167. if (res.confirm) {
  168. houseInfoDel(id).then(res=>{
  169. if(res.code==200){
  170. that.$toast('删除成功')
  171. setTimeout(function(){
  172. that.getDataFn()
  173. },1200)
  174. }else{
  175. that.$toast(res.msg)
  176. }
  177. })
  178. } else if (res.cancel) {
  179. }
  180. }
  181. });
  182. },
  183. getDataFn(){
  184. var params={
  185. userId:this.userId,
  186. pageSize:this.pageSize,
  187. pageNum: this.pageNum,
  188. }
  189. houseInfoList(params).then(res=>{
  190. if(res.code==200){
  191. if (res.rows.length < this.pageSize) {
  192. this.reachflag = false
  193. this.wtdt = '到底了~';
  194. } else {
  195. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  196. if (num < res.total) {
  197. this.reachflag = true
  198. this.wtdt = ''
  199. } else {
  200. this.reachflag = false
  201. this.wtdt = '到底了~';
  202. }
  203. }
  204. var newArr=JSON.parse(JSON.stringify(res.rows))
  205. newArr.forEach(ite=>{
  206. ite.right=0;
  207. })
  208. if (this.pageNum == 1) {
  209. this.list = newArr;
  210. } else {
  211. this.list = this.list.concat(newArr)
  212. }
  213. }else{
  214. this.$toast(res.msg)
  215. }
  216. })
  217. },
  218. //开始触摸滑动
  219. drawStart(e) {
  220. console.log("开始触发");
  221. var touch = e.touches[0];
  222. this.startX = touch.clientX;
  223. },
  224. //触摸滑动
  225. drawMove(e) {
  226. // console.log("滑动");
  227. for (var index in this.list) {
  228. // this.csListArrl[index].right=0
  229. this.$set(this.list[index],'right',0);
  230. }
  231. var idx=e.currentTarget.dataset.idx
  232. var touch = e.touches[0];
  233. var item = this.list[idx];
  234. var disX = this.startX - touch.clientX;
  235. if (disX >= 20) {
  236. if (disX > this.delBtnWidth) {
  237. disX = this.delBtnWidth;
  238. }
  239. // this.csListArrl[idx].right=disX
  240. this.$set(this.list[idx],'right',disX);
  241. } else {
  242. // this.csListArrl[idx].right=0
  243. this.$set(this.list[idx],'right',0);
  244. }
  245. },
  246. //触摸滑动结束
  247. drawEnd(e) {
  248. // console.log("滑动结束");
  249. var idx=e.currentTarget.dataset.idx
  250. var item = this.list[idx];
  251. if (item.right >= this.delBtnWidth / 2) {
  252. // this.list[idx].right=this.delBtnWidth
  253. this.$set(this.list[idx],'right',this.delBtnWidth);
  254. } else {
  255. this.list[idx].right=0
  256. }
  257. },
  258. }
  259. }
  260. </script>
  261. <style>
  262. page{background: #F3F3F0;}
  263. </style>
  264. <style lang="scss" scoped>
  265. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4; }
  266. .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;
  267. .houtop{padding: 20rpx 4rpx 0 4rpx;height:520rpx;box-sizing: border-box;margin-bottom: 50rpx;position: relative;
  268. .tit{font-size: 36rpx;font-weight: bold;color: #272727;}
  269. .txt{font-size: 26rpx;color: #272727;}
  270. .tita{min-width: 86rpx;font-weight: 500;margin-left: 26rpx;font-size: 24rpx;color: #0156FE;height: 36rpx;border-radius: 18rpx;border: 2rpx solid #0156FE;}
  271. .houseimg{width: 596rpx;height:204rpx;position: absolute;bottom: 0;right: -58rpx;}
  272. .tbtns{font-weight: 500;font-size: 26rpx;color: #0256FD;
  273. image{width: 20rpx;height: 16rpx;margin-left: 10rpx;}
  274. }
  275. }
  276. .housebox{width: 100%;background: #FFFFFF;border-radius: 20rpx;box-sizing: border-box;margin-bottom: 24rpx;
  277. .delleft{
  278. padding: 36rpx 24rpx 16rpx;
  279. }
  280. .hblist{display: flex;margin-bottom: 20rpx;
  281. .laber{font-weight: 500;font-size: 26rpx;color: #666666;flex: 0 0 auto;
  282. text{min-width: 104rpx;text-align-last: justify;display: inline-block;}
  283. }
  284. .tit{color: #272727;font-weight: 500;font-size: 26rpx;}
  285. .adrs{width: 20rpx;height: 22rpx;margin-left: 16rpx;flex: 0 0 auto;margin-top: 6rpx;}
  286. }
  287. }
  288. .hbtns{font-weight: bold;display: flex;align-items: center;justify-content: center;font-size: 26rpx;height: 88rpx;border-radius: 44rpx;box-sizing: border-box;
  289. &.bga{border: 1px solid #0256FD;color: #0256FD;background: #CADBFF;}
  290. &.bgb{border: 1px solid #45CB99;color: #45CB99;background: #DBF8ED;}
  291. }
  292. }
  293. .edit{font-weight: 500;font-size: 24rpx;color: #06C770;
  294. image{width: 22rpx;height: 22rpx;margin-right: 4rpx;}
  295. }
  296. </style>