person.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="my-box">
  3. <view class="my-content">
  4. <view class="my-top"></view>
  5. <image class="my-avatar" @click="$navigateTo('/pages/myDetail/myDetail')" :src="user.portrait"
  6. mode="aspectFill"></image>
  7. <view class="name" @click="$navigateTo('/pages/myDetail/myDetail')">{{user.name}}</view>
  8. <view class="organization">{{user.organizedName}}</view>
  9. <view class="btn-box">
  10. <view class="my-button my-button-cancel" v-if="isFans === 1" @click="fans">取消关注</view>
  11. <view class="my-button" v-if="isFans === 2" @click="fans">关注</view>
  12. </view>
  13. <view class="my-house">
  14. <view class="my-house-title">房源列表</view>
  15. <custom-waterfalls-flow :value="list" @wapperClick="clickItem" @imageClick="clickItem">
  16. <!-- #ifdef MP-WEIXIN -->
  17. <view class="item" v-for="(item,index) in list" :key="index" slot="slot{{index}}">
  18. <view class="title">{{item.title}}</view>
  19. <view class="desc">{{item.desc}}</view>
  20. </view>
  21. <!-- #endif -->
  22. <!-- #ifndef MP-WEIXIN -->
  23. <template v-slot:default="item">
  24. <view class="item">
  25. <view class="title">{{item.title}}</view>
  26. <view class="desc">{{item.desc}}</view>
  27. </view>
  28. </template>
  29. <!-- #endif -->
  30. </custom-waterfalls-flow>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getUserInfoById,
  38. isFans,
  39. attention,
  40. cancelAttention
  41. } from '@/request/api/my.js'
  42. import {
  43. getHouseListByPage
  44. } from '@/request/api/house.js'
  45. export default {
  46. data() {
  47. return {
  48. user: {},
  49. list: [],
  50. isFans: 0,
  51. userId: 4
  52. }
  53. },
  54. onLoad(body) {
  55. if (body.userId) this.userId = body.userId;
  56. this.init();
  57. },
  58. methods: {
  59. init() {
  60. getUserInfoById(this.userId).then(res => {
  61. if (res.code === 200) {
  62. this.user = res.data;
  63. this.user.organizedName = res.data.mgrOrganization.name;
  64. }
  65. })
  66. getHouseListByPage({
  67. currPage: 1,
  68. pageSize: 100,
  69. chargePersonId: this.userId
  70. }).then(res => {
  71. if (res.code === 200) {
  72. this.list = res.data.dataList.map(node => {
  73. return {
  74. houseId: node.id,
  75. image: this.imageUrl(node.showPicture),
  76. title: `${node.projectItemName}-${node.projectItemTargetName}-${node.roomNumber}`
  77. }
  78. })
  79. }
  80. })
  81. this.initFans();
  82. },
  83. initFans() {
  84. isFans(this.userId).then(res => {
  85. if (res.code === 200) {
  86. this.isFans = res.data ? 1 : 2;
  87. }
  88. })
  89. },
  90. fans() {
  91. this.isFans === 1 ? cancelAttention(this.userId).then(this.successFans) : attention(this.userId).then(this
  92. .successFans);
  93. },
  94. successFans(res) {
  95. if (res.code === 200) {
  96. this.$toast(this.isFans === 1 ? '取消成功' : '关注成功');
  97. this.initFans();
  98. }
  99. },
  100. clickItem(item) {
  101. this.$navigateTo('/pages/house/house?houseId=' + item.houseId);
  102. },
  103. imageUrl(data) {
  104. if (!data) return 'https://assets.api.uizard.io/api/cdn/stream/c05650d2-192b-4a56-ae97-05638f53804c.png';
  105. return JSON.parse(data)[0].url;
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .my-box {
  112. height: 100vh;
  113. background: #fff;
  114. overflow-y: auto;
  115. .my-content {
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. padding-bottom: 80rpx;
  120. }
  121. .my-top {
  122. height: 260rpx;
  123. 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');
  124. background-position: center center;
  125. background-size: cover;
  126. background-repeat: no-repeat;
  127. width: 100%;
  128. }
  129. .my-avatar {
  130. width: 200rpx;
  131. height: 200rpx;
  132. border-radius: 50%;
  133. margin-top: -100rpx;
  134. border: 6rpx solid #fff;
  135. }
  136. .name {
  137. font-size: 20px;
  138. font-weight: 700;
  139. margin: 10rpx 0;
  140. }
  141. .organization {
  142. color: $uni-secondary-color;
  143. font-weight: 300;
  144. }
  145. .btn-box {
  146. box-sizing: border-box;
  147. padding: 30rpx;
  148. width: 100%;
  149. }
  150. .my-button {
  151. width: 100%;
  152. height: 68rpx;
  153. line-height: 68rpx;
  154. border-radius: 68rpx;
  155. border: 1px solid $uni-primary;
  156. background: $uni-primary;
  157. text-align: center;
  158. color: #fff;
  159. &.my-button-cancel {
  160. border-color: $uni-secondary-color;
  161. color: $uni-secondary-color;
  162. background: #fff;
  163. }
  164. }
  165. .my-house {
  166. width: 100%;
  167. padding: 0 30rpx;
  168. box-sizing: border-box;
  169. .item {
  170. position: absolute;
  171. bottom: 0;
  172. width: 100%;
  173. height: 56rpx;
  174. background-color: rgba(0, 0, 0, 0.6);
  175. line-height: 56rpx;
  176. font-size: 24rpx;
  177. font-weight: 300;
  178. padding: 0 20rpx;
  179. overflow: hidden;
  180. color: #fff;
  181. }
  182. .my-house-title {
  183. font-weight: 500;
  184. margin-bottom: 20rpx;
  185. }
  186. }
  187. }
  188. </style>