my.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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.userName || '登录/注册'}}</view>
  8. <view class="organization" v-if="user.organizedName">{{user.organizedName}}</view>
  9. <view class="my-tab">
  10. <view class="tab-box">
  11. <view class="tab-item" @click="$navigateTo('/pages/myHouse/myHouse')">
  12. <view class="tab-number">{{fansCount.roomCount}}</view>
  13. <view class="tab-text">房源</view>
  14. </view>
  15. <view class="tab-item" @click="$navigateTo('/pages/fans/fans')">
  16. <view class="tab-number">{{fansCount.fansCount}}</view>
  17. <view class="tab-text">粉丝</view>
  18. </view>
  19. <view class="tab-item" @click="$navigateTo('/pages/attention/attention')">
  20. <view class="tab-number">{{fansCount.attentionCount}}</view>
  21. <view class="tab-text">关注</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="my-list">
  26. <view class="my-list-box">
  27. <view class="my-item" @click="$navigateTo('/pages/collect/collect')">
  28. <view class="my-icon bg1">
  29. <uni-icons custom-prefix="iconfont" type="icon-wodeshoucangshixin" color="#fff" size="20">
  30. </uni-icons>
  31. </view>
  32. <view class="item-content">
  33. 我的收藏
  34. </view>
  35. <view class="my-forward">
  36. <uni-icons type="forward" size="18" color="#c1c0c8"></uni-icons>
  37. </view>
  38. </view>
  39. <view class="my-item" @click="$navigateTo('/pages/client/client')">
  40. <view class="my-icon bg2">
  41. <uni-icons custom-prefix="iconfont" type="icon-wodekehu" color="#fff" size="20">
  42. </uni-icons>
  43. </view>
  44. <view class="item-content">
  45. 我的客户
  46. </view>
  47. <view class="my-forward">
  48. <uni-icons type="forward" size="18" color="#c1c0c8"></uni-icons>
  49. </view>
  50. </view>
  51. <view class="my-item" @click="$navigateTo('/pages/myReservation/myReservation')">
  52. <view class="my-icon bg5">
  53. <uni-icons custom-prefix="iconfont" type="icon-kefuzhongxin" color="#fff" size="24">
  54. </uni-icons>
  55. </view>
  56. <view class="item-content">
  57. 我的预约
  58. </view>
  59. <view class="my-forward">
  60. <uni-icons type="forward" size="18" color="#c1c0c8"></uni-icons>
  61. </view>
  62. </view>
  63. <view class="my-item" @click="$navigateTo('/pages/organization/organization')">
  64. <view class="my-icon bg3">
  65. <uni-icons custom-prefix="iconfont" type="icon-wodegongsi-gaoliang" color="#fff" size="22">
  66. </uni-icons>
  67. </view>
  68. <view class="item-content">
  69. 我的公司
  70. </view>
  71. <view class="my-forward">
  72. <uni-icons type="forward" size="18" color="#c1c0c8"></uni-icons>
  73. </view>
  74. </view>
  75. <view class="my-item" @click="$navigateTo('/pages/download/download')">
  76. <view class="my-icon bg4">
  77. <uni-icons custom-prefix="iconfont" type="icon-wodexiazaizhongxin" color="#fff" size="18">
  78. </uni-icons>
  79. </view>
  80. <view class="item-content">
  81. 我的下载
  82. </view>
  83. <view class="my-forward">
  84. <uni-icons type="forward" size="18" color="#c1c0c8"></uni-icons>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import {
  94. getMyCount,
  95. getUserInfoById
  96. } from '@/request/api/my.js'
  97. export default {
  98. data() {
  99. return {
  100. fansCount: {
  101. attentionCount: 0,
  102. fansCount: 0,
  103. roomCount: 0
  104. },
  105. user: {}
  106. }
  107. },
  108. onShow() {
  109. if (!uni.getStorageSync('token')) {
  110. this.user = {};
  111. this.fansCount = {
  112. attentionCount: 0,
  113. fansCount: 0,
  114. roomCount: 0
  115. }
  116. } else {
  117. this.user = this.$store.getters.user;
  118. this.user.organizedName = this.$store.getters.organization && this.$store.getters.organization.name;
  119. this.init();
  120. }
  121. },
  122. methods: {
  123. init() {
  124. getMyCount().then(res => {
  125. if (res.code === 200) {
  126. this.fansCount = res.data;
  127. }
  128. })
  129. getUserInfoById(this.user.userId).then(res => {
  130. if (res.code === 200) {
  131. this.user = res.data;
  132. this.user['userName'] = res.data.name;
  133. this.user['userId'] = res.data.id;
  134. this.user.organizedName = res.data.mgrOrganization && res.data.mgrOrganization.name;
  135. this.$store.dispatch('app/changeUser', res.data);
  136. }
  137. })
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. .my-box {
  144. height: 100vh;
  145. background: #fff;
  146. overflow-y: auto;
  147. .my-content {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. padding-bottom: 80rpx;
  152. }
  153. .my-top {
  154. height: 260rpx;
  155. 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');
  156. background-position: center center;
  157. background-size: cover;
  158. background-repeat: no-repeat;
  159. width: 100%;
  160. }
  161. .my-avatar {
  162. width: 200rpx;
  163. height: 200rpx;
  164. border-radius: 50%;
  165. margin-top: -100rpx;
  166. border: 6rpx solid #fff;
  167. background: #eee;
  168. }
  169. .name {
  170. font-size: 20px;
  171. font-weight: 700;
  172. margin: 10rpx 0;
  173. }
  174. .organization {
  175. color: $uni-secondary-color;
  176. font-weight: 300;
  177. }
  178. .my-tab {
  179. width: 100%;
  180. padding: 0 30rpx;
  181. box-sizing: border-box;
  182. margin: 40rpx 0;
  183. .tab-box {
  184. height: 160rpx;
  185. border-radius: 24rpx;
  186. box-shadow: 1px 1px 12px rgba(164, 164, 164, 0.25);
  187. display: flex;
  188. align-items: center;
  189. }
  190. .tab-item {
  191. flex: 1;
  192. text-align: center;
  193. }
  194. .tab-number {
  195. font-size: 40rpx;
  196. font-weight: 600;
  197. }
  198. .tab-text {
  199. font-size: 24rpx;
  200. font-weight: 300;
  201. margin-top: 10rpx;
  202. }
  203. }
  204. .my-list {
  205. width: 100%;
  206. padding: 0 30rpx;
  207. box-sizing: border-box;
  208. .my-list-box {
  209. border-radius: 24rpx;
  210. box-shadow: 1px 1px 12px rgba(164, 164, 164, 0.25);
  211. overflow: hidden;
  212. }
  213. .my-item {
  214. display: flex;
  215. align-items: center;
  216. padding: 20rpx 30rpx;
  217. }
  218. .my-item:active {
  219. background: $uni-background-color;
  220. }
  221. .my-icon {
  222. width: 80rpx;
  223. height: 80rpx;
  224. border-radius: 16rpx;
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. margin-right: 20rpx;
  229. background: #c1c0c8;
  230. &.bg1 {
  231. background: #88d498;
  232. }
  233. &.bg2 {
  234. background: #ffb997;
  235. }
  236. &.bg3 {
  237. background: #7ad9ff;
  238. }
  239. &.bg4 {
  240. background: #9ac0cd;
  241. }
  242. &.bg5 {
  243. background: #40e0d0;
  244. }
  245. }
  246. .my-forward {
  247. height: 40rpx;
  248. }
  249. .item-content {
  250. flex: 1;
  251. width: 0;
  252. overflow: hidden;
  253. font-weight: 700;
  254. }
  255. }
  256. }
  257. </style>