金诚优选前端代码
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.

259 lines
6.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" @click="payAttention()">已关注</button>
  18. <button class="head-btn" v-if="discover_info.is_follow == false" @click="payAttention()">关注</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" @click.stop="addLike(item.id)">
  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. this.loginList();
  65. },
  66. methods: {
  67. //关注
  68. payAttention() {
  69. this.$http
  70. .post({
  71. api: 'api/discover/add_follow',
  72. data: {
  73. user_id: this.user_id
  74. },
  75. header: {
  76. Authorization: this.$cookieStorage.get('user_token')
  77. },
  78. })
  79. .then(res => {
  80. if (res.data.code == 200) {
  81. if (res.data.status) {
  82. this.$msg(res.data.data);
  83. this.loginList();
  84. } else {
  85. wx.showModal({
  86. content: res.data.message,
  87. showCancel: false
  88. });
  89. }
  90. } else {
  91. wx.showModal({
  92. content: res.data.message,
  93. showCancel: false
  94. });
  95. }
  96. wx.hideLoading();
  97. })
  98. .catch(() => {
  99. wx.hideLoading();
  100. wx.showModal({
  101. content: '请求失败',
  102. showCancel: false
  103. });
  104. });
  105. },
  106. //点赞发现
  107. addLike(id) {
  108. let user_info = this.$cookieStorage.get('user_token');
  109. if(user_info) {
  110. this.$http
  111. .post({
  112. api: 'api/discover/like',
  113. data: {
  114. discover_id: id
  115. },
  116. header: {
  117. Authorization: this.$cookieStorage.get('user_token')
  118. },
  119. })
  120. .then(res => {
  121. if (res.data.code == 200) {
  122. if (res.data.status) {
  123. this.loginList();
  124. } else {
  125. wx.showModal({
  126. content: res.data.message || '请下拉页面刷新重试',
  127. showCancel: false
  128. });
  129. }
  130. } else {
  131. wx.showModal({
  132. content: res.data.message || '请下拉页面刷新重试',
  133. showCancel: false
  134. });
  135. }
  136. wx.hideLoading();
  137. })
  138. .catch(() => {
  139. wx.hideLoading();
  140. wx.showModal({
  141. content: '请求失败',
  142. showCancel: false
  143. });
  144. });
  145. }else {
  146. this.$msg('你还未登录,请前往登录!');
  147. }
  148. },
  149. goDetails(id) {
  150. this.$url('/pages/discover/discoverdetails?discover_id='+id)
  151. },
  152. //登录时的发现列表
  153. loginList() {
  154. this.$http
  155. .get({
  156. api: 'api/discover/user/'+this.user_id,
  157. data: {
  158. page: this.page,
  159. page_size: this.page_size
  160. },
  161. header: {
  162. Authorization: this.$cookieStorage.get('user_token')
  163. },
  164. })
  165. .then(res => {
  166. if (res.data.code == 200) {
  167. if (res.data.status) {
  168. this.discover_info = res.data.data;
  169. console.log('登录时的发现列表',this.discover_info);
  170. } else {
  171. wx.showModal({
  172. content: res.data.message || '请下拉页面刷新重试',
  173. showCancel: false
  174. });
  175. }
  176. } else {
  177. wx.showModal({
  178. content: res.data.message || '请下拉页面刷新重试',
  179. showCancel: false
  180. });
  181. }
  182. wx.hideLoading();
  183. })
  184. .catch(() => {
  185. wx.hideLoading();
  186. wx.showModal({
  187. content: '请求失败',
  188. showCancel: false
  189. });
  190. });
  191. },
  192. }
  193. }
  194. </script>
  195. <style>
  196. page {
  197. background-color: white;
  198. }
  199. </style>
  200. <style lang="scss" scoped>
  201. .tag-father {
  202. position: relative;
  203. }
  204. .head-tag {
  205. color: white;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. text-align: center;
  210. font-size: 24rpx;
  211. width: 36rpx;
  212. height: 36rpx;
  213. border-radius: 50%;
  214. background-color: #15716E;
  215. border: 1rpx solid #FFFFFF;
  216. position: absolute;
  217. left: 76rpx;
  218. top: 86rpx;
  219. z-index: 99;
  220. }
  221. .qzone-img {
  222. width: 220rpx;
  223. height: 220rpx;
  224. border-radius: 10rpx;
  225. margin-right: 12rpx;
  226. &:nth-child(3n) {
  227. margin-right: 0;
  228. }
  229. &:nth-child(n + 4) {
  230. margin-top: 12rpx;
  231. }
  232. }
  233. .user-top {
  234. background-color: #F3F8F8;
  235. height: 236rpx;
  236. padding: 60rpx;
  237. display: flex;
  238. align-items: center;
  239. }
  240. .head-img {
  241. width: 120rpx;
  242. height: 120rpx;
  243. border-radius: 50%;
  244. }
  245. .head-btn {
  246. width: 160rpx;
  247. height: 70rpx;
  248. background: #15716E;
  249. display: flex;
  250. align-items: center;
  251. font-size: 28rpx;
  252. color: white;
  253. justify-content: center;
  254. border-radius: 35rpx;
  255. }
  256. </style>