|
@@ -1,11 +1,16 @@
|
|
|
<template>
|
|
|
<view class="house-detail">
|
|
|
- <swiper class="swiper" circular :indicator-dots="true">
|
|
|
- <swiper-item v-for="item in responsibility" :key="item.id">
|
|
|
- <image class="image" :src="item.url" mode="aspectFill">
|
|
|
- </image>
|
|
|
- </swiper-item>
|
|
|
- </swiper>
|
|
|
+ <view class="house-swiper">
|
|
|
+ <swiper class="swiper" circular :indicator-dots="true">
|
|
|
+ <swiper-item v-for="item in responsibility" :key="item.id">
|
|
|
+ <image class="image" :src="item.url" mode="aspectFill">
|
|
|
+ </image>
|
|
|
+ </swiper-item>
|
|
|
+ </swiper>
|
|
|
+ <uni-icons class="btn" @click="roomCollection" :type="detail.roomCollection ? 'heart-filled' : 'heart'"
|
|
|
+ color="#ff4d4f" size="28">
|
|
|
+ </uni-icons>
|
|
|
+ </view>
|
|
|
<view class="house-title">
|
|
|
<view class="house-name">{{detail.name}}</view>
|
|
|
<view class="tag">
|
|
@@ -86,52 +91,79 @@
|
|
|
</view>
|
|
|
<view class="content-title">
|
|
|
<text>访客记录</text>
|
|
|
- <text class="more">查看更多>></text>
|
|
|
+ <text class="more" @click="$navigateTo('/pages/visitor/visitor?houseId=' + houseId)">查看更多>></text>
|
|
|
</view>
|
|
|
<view class="visitor">
|
|
|
- <view class="visitor-item">
|
|
|
- <image class="visitor-avatar"
|
|
|
- src="https://assets.api.uizard.io/api/cdn/stream/d841c8c9-37cc-4fa1-9720-cff12a84352b.png"
|
|
|
- mode="aspectFill">
|
|
|
+ <view class="visitor-item" v-for="(item,index) in visitorList" :key="index">
|
|
|
+ <image class="visitor-avatar" :src="item.userPortrait" mode="aspectFill">
|
|
|
</image>
|
|
|
- <text class="visitor-label">林夕三访问了您的房源</text>
|
|
|
- <text class="visitor-time">2024-01-01</text>
|
|
|
- </view>
|
|
|
- <view class="visitor-item">
|
|
|
- <image class="visitor-avatar"
|
|
|
- src="https://assets.api.uizard.io/api/cdn/stream/d841c8c9-37cc-4fa1-9720-cff12a84352b.png"
|
|
|
- mode="aspectFill">
|
|
|
- </image>
|
|
|
- <text class="visitor-label">林夕三访问了您的房源</text>
|
|
|
- <text class="visitor-time">2024-01-01</text>
|
|
|
+ <text class="visitor-label">{{item.userName}}访问了房源</text>
|
|
|
+ <uni-dateformat class="visitor-time" :date="item.date" :threshold="[60000,3600000 * 24 * 365]">
|
|
|
+ </uni-dateformat>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <view class="content-title">
|
|
|
+ <text>房源评价</text>
|
|
|
+ </view>
|
|
|
+ <view class="evaluate">
|
|
|
+ <hb-comment ref="hbComment" @add="addEvaluate" @del="del" @like="like" :deleteTip="'确认删除?'"
|
|
|
+ :cmData="commentData" v-if="commentData">
|
|
|
+ </hb-comment>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="hui-button-box">
|
|
|
+ <view class="hui-button" @click="$navigateTo('/pages/reservation/reservation?houseId=' + houseId)">预约看房
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import {
|
|
|
- getHouseDetailById
|
|
|
+ dayjs
|
|
|
+ } from '../../uni_modules/iRainna-dayjs/js_sdk/dayjs.min';
|
|
|
+ import {
|
|
|
+ getHouseDetailById,
|
|
|
+ insertVisitor,
|
|
|
+ getVisitorByQuery,
|
|
|
+ collection,
|
|
|
+ disableCollection,
|
|
|
+ getHouseEvaluateListByPage,
|
|
|
+ insertEvaluate
|
|
|
} from '@/request/api/house.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- detail: {},
|
|
|
+ detail: {
|
|
|
+ area: 0
|
|
|
+ },
|
|
|
houseId: 15,
|
|
|
responsibility: [],
|
|
|
coordinates: [],
|
|
|
latitude: 39.90923,
|
|
|
longitude: 116.397428,
|
|
|
mapContext: {},
|
|
|
+ visitorList: [],
|
|
|
+ startTime: '',
|
|
|
+ commentData: {
|
|
|
+ readNumer: 0,
|
|
|
+ commentSize: 0,
|
|
|
+ comment: []
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
onLoad(body) {
|
|
|
if (body.houseId) this.houseId = body.houseId;
|
|
|
- this.init();
|
|
|
+ this.startTime = new Date().getTime();
|
|
|
},
|
|
|
onReady() {
|
|
|
this.mapContext = uni.createMapContext("map", this);
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ let endTime = new Date().getTime();
|
|
|
+ let time = endTime - this.startTime;
|
|
|
+ if (time > 10000) this.createVisitor();
|
|
|
},
|
|
|
methods: {
|
|
|
init() {
|
|
@@ -145,14 +177,87 @@
|
|
|
this.longitude = this.coordinates[0];
|
|
|
this.addMarkers();
|
|
|
}
|
|
|
+ this.getVisitor();
|
|
|
+ this.getHouseEvaluate();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getHouseEvaluate() {
|
|
|
+ getHouseEvaluateListByPage({
|
|
|
+ currPage: 1,
|
|
|
+ pageSize: 100,
|
|
|
+ projectItemTargetRoomId: this.houseId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.commentData.commentSize = res.data.totalCount;
|
|
|
+ this.commentData.comment = this.getTree(res.data.dataList.map(node => {
|
|
|
+ return {
|
|
|
+ "id": node.id, // 唯一主键
|
|
|
+ "owner": true, // 是否是拥有者,为true则可以删除,管理员全部为true
|
|
|
+ "hasLike": false, // 是否点赞
|
|
|
+ "likeNum": 2, // 点赞数量
|
|
|
+ "avatarUrl": node.userPortrait, // 评论者头像地址
|
|
|
+ "nickName": node.userName, // 评论者昵称,昵称过长请在后端截断
|
|
|
+ "content": node.content, // 评论内容
|
|
|
+ "parentId": node.parentId, // 所属评论的唯一主键
|
|
|
+ "createTime": node.date // 创建时间
|
|
|
+ }
|
|
|
+ }))
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ getTree(data) {
|
|
|
+ let result = [];
|
|
|
+ let map = {};
|
|
|
+ data.forEach(item => {
|
|
|
+ map[item.id] = item;
|
|
|
+ });
|
|
|
+ data.forEach(item => {
|
|
|
+ let parent = map[item.parentId];
|
|
|
+ if (parent) {
|
|
|
+ (parent.children || (parent.children = [])).push(item);
|
|
|
+ } else {
|
|
|
+ result.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ addEvaluate(data) {
|
|
|
+ insertEvaluate({
|
|
|
+ userId: this.$store.getters.user.userId,
|
|
|
+ projectItemTargetRoomId: this.houseId,
|
|
|
+ content: data.content,
|
|
|
+ parentId: data.pId || 0
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$toast('评价成功');
|
|
|
+ this.getHouseEvaluate();
|
|
|
+ this.$refs.hbComment.addComplete();
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ del() {
|
|
|
+
|
|
|
+ },
|
|
|
+ like() {
|
|
|
+
|
|
|
},
|
|
|
tell() {
|
|
|
uni.makePhoneCall({
|
|
|
phoneNumber: '17601274604' //仅为示例
|
|
|
});
|
|
|
},
|
|
|
+ roomCollection() {
|
|
|
+ this.detail.roomCollection ? disableCollection(this.houseId).then(res => this.successCollection(res,
|
|
|
+ '取消收藏')) : collection(this.houseId).then(res => this.successCollection(res, '收藏成功'));
|
|
|
+ },
|
|
|
+ successCollection(res, msg) {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.init();
|
|
|
+ this.$toast(msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
addMarkers() {
|
|
|
const positions = [{
|
|
|
latitude: this.coordinates[1],
|
|
@@ -174,6 +279,23 @@
|
|
|
clear: false,
|
|
|
complete(res) {}
|
|
|
})
|
|
|
+ },
|
|
|
+ getVisitor() {
|
|
|
+ getVisitorByQuery({
|
|
|
+ currPage: 1,
|
|
|
+ pageSize: 2,
|
|
|
+ projectItemTargetRoomId: this.houseId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.visitorList = res.data.dataList;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ createVisitor() {
|
|
|
+ insertVisitor({
|
|
|
+ userId: this.$store.getters.user.userId,
|
|
|
+ projectItemTargetRoomId: this.houseId
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
}
|
|
@@ -182,7 +304,17 @@
|
|
|
<style lang="scss">
|
|
|
.house-detail {
|
|
|
background: #fff;
|
|
|
- padding-bottom: 60rpx;
|
|
|
+ padding-bottom: 160rpx;
|
|
|
+
|
|
|
+ .house-swiper {
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ position: absolute;
|
|
|
+ top: 20rpx;
|
|
|
+ right: 30rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
.swiper {
|
|
|
height: 400rpx;
|
|
@@ -350,6 +482,11 @@
|
|
|
margin: 0 20rpx;
|
|
|
}
|
|
|
|
|
|
+ .visitor-time {
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: $uni-secondary-color;
|
|
|
+ }
|
|
|
+
|
|
|
&:last-child {
|
|
|
margin-bottom: 0;
|
|
|
}
|