123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <view class="my-box">
- <view class="my-content">
- <view class="my-top"></view>
- <image class="my-avatar" @click="$navigateTo('/pages/myDetail/myDetail')" :src="user.portrait"
- mode="aspectFill"></image>
- <view class="name" @click="$navigateTo('/pages/myDetail/myDetail')">{{user.name}}</view>
- <view class="organization">{{user.organizedName}}</view>
- <view class="btn-box">
- <view class="my-button my-button-cancel" v-if="isFans === 1" @click="fans">取消关注</view>
- <view class="my-button" v-if="isFans === 2" @click="fans">关注</view>
- </view>
- <view class="my-house">
- <view class="my-house-title">房源列表</view>
- <custom-waterfalls-flow :value="list" @wapperClick="clickItem" @imageClick="clickItem">
- <!-- #ifdef MP-WEIXIN -->
- <view class="item" v-for="(item,index) in list" :key="index" slot="slot{{index}}">
- <view class="title">{{item.title}}</view>
- <view class="desc">{{item.desc}}</view>
- </view>
- <!-- #endif -->
- <!-- #ifndef MP-WEIXIN -->
- <template v-slot:default="item">
- <view class="item">
- <view class="title">{{item.title}}</view>
- <view class="desc">{{item.desc}}</view>
- </view>
- </template>
- <!-- #endif -->
- </custom-waterfalls-flow>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getUserInfoById,
- isFans,
- attention,
- cancelAttention
- } from '@/request/api/my.js'
- import {
- getHouseListByPage
- } from '@/request/api/house.js'
- export default {
- data() {
- return {
- user: {},
- list: [],
- isFans: 0,
- userId: 4
- }
- },
- onLoad(body) {
- if (body.userId) this.userId = body.userId;
- this.init();
- },
- methods: {
- init() {
- getUserInfoById(this.userId).then(res => {
- if (res.code === 200) {
- this.user = res.data;
- this.user.organizedName = res.data.mgrOrganization.name;
- }
- })
- getHouseListByPage({
- currPage: 1,
- pageSize: 100,
- chargePersonId: this.userId
- }).then(res => {
- if (res.code === 200) {
- this.list = res.data.dataList.map(node => {
- return {
- houseId: node.id,
- image: this.imageUrl(node.showPicture),
- title: `${node.projectItemName}-${node.projectItemTargetName}-${node.roomNumber}`
- }
- })
- }
- })
- this.initFans();
- },
- initFans() {
- isFans(this.userId).then(res => {
- if (res.code === 200) {
- this.isFans = res.data ? 1 : 2;
- }
- })
- },
- fans() {
- this.isFans === 1 ? cancelAttention(this.userId).then(this.successFans) : attention(this.userId).then(this
- .successFans);
- },
- successFans(res) {
- if (res.code === 200) {
- this.$toast(this.isFans === 1 ? '取消成功' : '关注成功');
- this.initFans();
- }
- },
- clickItem(item) {
- this.$navigateTo('/pages/house/house?houseId=' + item.houseId);
- },
- imageUrl(data) {
- if (!data) return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
- return JSON.parse(data)[0].url;
- }
- }
- }
- </script>
- <style lang="scss">
- .my-box {
- height: 100vh;
- background: #fff;
- overflow-y: auto;
- .my-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding-bottom: 80rpx;
- }
- .my-top {
- height: 260rpx;
- background-image: url('https://images.unsplash.com/photo-1558591710-4b4a1ae0f04d?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwyMDUzMDJ8MHwxfHNlYXJjaHw1fHxhYnN0cmFjdHxlbnwxfHx8fDE2NTI4OTYzNTU&ixlib=rb-1.2.1&q=80&w=1080');
- background-position: center center;
- background-size: cover;
- background-repeat: no-repeat;
- width: 100%;
- }
- .my-avatar {
- width: 200rpx;
- height: 200rpx;
- border-radius: 50%;
- margin-top: -100rpx;
- border: 6rpx solid #fff;
- }
- .name {
- font-size: 20px;
- font-weight: 700;
- margin: 10rpx 0;
- }
- .organization {
- color: $uni-secondary-color;
- font-weight: 300;
- }
- .btn-box {
- box-sizing: border-box;
- padding: 30rpx;
- width: 100%;
- }
- .my-button {
- width: 100%;
- height: 68rpx;
- line-height: 68rpx;
- border-radius: 68rpx;
- border: 1px solid $uni-primary;
- background: $uni-primary;
- text-align: center;
- color: #fff;
- &.my-button-cancel {
- border-color: $uni-secondary-color;
- color: $uni-secondary-color;
- background: #fff;
- }
- }
- .my-house {
- width: 100%;
- padding: 0 30rpx;
- box-sizing: border-box;
- .item {
- position: absolute;
- bottom: 0;
- width: 100%;
- height: 56rpx;
- background-color: rgba(0, 0, 0, 0.6);
- line-height: 56rpx;
- font-size: 24rpx;
- font-weight: 300;
- padding: 0 20rpx;
- overflow: hidden;
- color: #fff;
- }
- .my-house-title {
- font-weight: 500;
- margin-bottom: 20rpx;
- }
- }
- }
- </style>
|