index.vue 8.4 KB

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