金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
5.9 KiB

  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="true" :showIcon="true" bgColor="#F3F8F8" title="个人主页"></lf-nav>
  4. <view class="user-top" v-if="$isRight(discover_info)">
  5. <view class="lf-row-between lf-w-100">
  6. <view class="lf-flex">
  7. <view class="tag-father">
  8. <image :src="discover_info.avatar" mode="aspectFill" class="head-img"></image>
  9. <view class="head-tag">V</view>
  10. </view>
  11. <view class="lf-flex-column lf-m-l-20">
  12. <text class="lf-font-42 lf-color-black lf-font-bold">{{discover_info.username}}</text>
  13. <text class="lf-font-28 lf-color-black">{{discover_info.my_follow_count}}关注 | {{discover_info.follow_me_count}}粉丝</text>
  14. </view>
  15. </view>
  16. <view>
  17. <button class="head-btn" v-if="discover_info.is_follow == true">已关注</button>
  18. <button class="head-btn" v-if="discover_info.is_follow == false">关注</button>
  19. <view v-if="discover_info.is_follow == -1"></view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="lf-m-32" v-for="(item,index) in discover_info.list.data" :key="index" @click="goDetails(item.id)">
  24. <view class="lf-font-48 lf-color-black lf-font-bold">
  25. {{item.create_time[0]}}
  26. </view>
  27. <view class="lf-color-777 lf-font-24">
  28. {{item.create_time[1]}}
  29. </view>
  30. <view class="lf-flex-wrap lf-m-t-20">
  31. <image v-for="(picture,index2) in item.attachs" :key="index2" class="qzone-img" :src="picture.url" mode="aspectFill"></image>
  32. </view>
  33. <view class="lf-m-t-30 lf-row-between lf-p-l-50 lf-p-r-50">
  34. <view class="lf-row-center">
  35. <text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="item.is_like"></text>
  36. <text class="lf-iconfont icon-xihuan" v-else></text>
  37. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{item.likes_count}}</text>
  38. </view>
  39. <view class="lf-row-center">
  40. <text class="lf-iconfont icon-chakan"></text>
  41. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{item.view_count}}</text>
  42. </view>
  43. <view class="lf-row-center">
  44. <text class="lf-iconfont icon-pinglun-"></text>
  45. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{item.comments_count}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view style="height: 40rpx;"></view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. user_id: 0,
  57. page: 1,
  58. page_size: 15,
  59. discover_info: ''
  60. }
  61. },
  62. onLoad(e) {
  63. this.user_id = e.user_id;
  64. let user_info = this.$cookieStorage.get('user_token');
  65. if(user_info) {
  66. this.loginList();
  67. }else {
  68. this.noLoginList();
  69. }
  70. },
  71. methods: {
  72. goDetails(id) {
  73. this.$url('/pages/discover/discoverdetails?discover_id='+id)
  74. },
  75. //未登录时的发现列表
  76. noLoginList() {
  77. this.$http
  78. .get({
  79. api: 'api/discover/user/',
  80. data: {
  81. page: this.page,
  82. page_size: this.page_size
  83. },
  84. header: {
  85. Authorization: this.$cookieStorage.get('user_token')
  86. },
  87. })
  88. .then(res => {
  89. if (res.data.code == 200) {
  90. if (res.data.status) {
  91. this.discover_info = res.data.data;
  92. console.log('未登录时的发现列表',this.discover_info);
  93. } else {
  94. wx.showModal({
  95. content: res.data.message || '请下拉页面刷新重试',
  96. showCancel: false
  97. });
  98. }
  99. } else {
  100. wx.showModal({
  101. content: res.data.message || '请下拉页面刷新重试',
  102. showCancel: false
  103. });
  104. }
  105. wx.hideLoading();
  106. })
  107. .catch(() => {
  108. wx.hideLoading();
  109. wx.showModal({
  110. content: '请求失败',
  111. showCancel: false
  112. });
  113. });
  114. },
  115. //登录时的发现列表
  116. loginList() {
  117. this.$http
  118. .get({
  119. api: 'api/discover/my/'+this.user_id,
  120. data: {
  121. page: this.page,
  122. page_size: this.page_size
  123. },
  124. header: {
  125. Authorization: this.$cookieStorage.get('user_token')
  126. },
  127. })
  128. .then(res => {
  129. if (res.data.code == 200) {
  130. if (res.data.status) {
  131. this.discover_info = res.data.data;
  132. console.log('登录时的发现列表',this.discover_info);
  133. } else {
  134. wx.showModal({
  135. content: res.data.message || '请下拉页面刷新重试',
  136. showCancel: false
  137. });
  138. }
  139. } else {
  140. wx.showModal({
  141. content: res.data.message || '请下拉页面刷新重试',
  142. showCancel: false
  143. });
  144. }
  145. wx.hideLoading();
  146. })
  147. .catch(() => {
  148. wx.hideLoading();
  149. wx.showModal({
  150. content: '请求失败',
  151. showCancel: false
  152. });
  153. });
  154. },
  155. }
  156. }
  157. </script>
  158. <style>
  159. page {
  160. background-color: white;
  161. }
  162. </style>
  163. <style lang="scss" scoped>
  164. .tag-father {
  165. position: relative;
  166. }
  167. .head-tag {
  168. color: white;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. text-align: center;
  173. font-size: 24rpx;
  174. width: 36rpx;
  175. height: 36rpx;
  176. border-radius: 50%;
  177. background-color: #15716E;
  178. border: 1rpx solid #FFFFFF;
  179. position: absolute;
  180. left: 76rpx;
  181. top: 86rpx;
  182. z-index: 99;
  183. }
  184. .qzone-img {
  185. width: 220rpx;
  186. height: 220rpx;
  187. border-radius: 10rpx;
  188. margin-right: 12rpx;
  189. &:nth-child(3n) {
  190. margin-right: 0;
  191. }
  192. &:nth-child(n + 4) {
  193. margin-top: 12rpx;
  194. }
  195. }
  196. .user-top {
  197. background-color: #F3F8F8;
  198. height: 236rpx;
  199. padding: 60rpx;
  200. display: flex;
  201. align-items: center;
  202. }
  203. .head-img {
  204. width: 120rpx;
  205. height: 120rpx;
  206. border-radius: 50%;
  207. }
  208. .head-btn {
  209. width: 160rpx;
  210. height: 70rpx;
  211. background: #15716E;
  212. display: flex;
  213. align-items: center;
  214. font-size: 28rpx;
  215. color: white;
  216. justify-content: center;
  217. border-radius: 35rpx;
  218. }
  219. </style>