person.vue 4.9 KB

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