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

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