index.vue 10 KB

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