mypl.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content">
  3. <empty v-if="list.loaded === true && list.length === 0"></empty>
  4. <view class="">
  5. <view class="pl-wrap" v-for="(item,index) in list" @click="navTo(item)">
  6. <!-- 用户名 -->
  7. <view class="user-info flex">
  8. <view class="user-logo">
  9. <image :src="userInfo.avatar" class="avater-img" mode="" v-if="userInfo.avatar"></image>
  10. <image src="../../static/error/missing-face.png" mode="" v-else class="avater-img"></image>
  11. </view>
  12. <view class="user-num">
  13. <view class="user-name">{{ userInfo.nickname }}</view>
  14. <view class="sub-num">{{ item.create }}</view>
  15. </view>
  16. </view>
  17. <!-- 评价 -->
  18. <view class="pl">{{item.content}}</view>
  19. <!-- 别人的评论 -->
  20. <view class="other-pl" v-if="item.to_id != 0">
  21. 回复
  22. <text class="text">{{item.to.user.nickname}}</text>
  23. <text>{{item.to.content}}</text>
  24. </view>
  25. <!-- 文章简介 -->
  26. <view class="art flex">
  27. <view class="art-img" v-if="item.article.image_input.length > 0"><image :src="item.article.image_input[0]" mode=""></image></view>
  28. <view class="art-jj clamp2">{{item.article.title}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. <uni-load-more :status="loadingType"></uni-load-more>
  33. </view>
  34. </template>
  35. <script>
  36. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  37. import empty from '@/components/empty';
  38. import { my_reply } from '@/api/user.js';
  39. import { getTime } from '@/utils/rocessor.js'
  40. import { mapState, mapMutations } from 'vuex';
  41. export default {
  42. components: {
  43. empty,
  44. uniLoadMore
  45. },
  46. data() {
  47. return {
  48. page: 1,
  49. limit: 10,
  50. loadingType: 'more',
  51. list: []
  52. };
  53. },
  54. onLoad() {
  55. this.loadData();
  56. },
  57. onReachBottom() {
  58. this.loadData();
  59. },
  60. computed: {
  61. ...mapState('user', ['hasLogin', 'userInfo'])
  62. },
  63. methods: {
  64. loadData() {
  65. const obj = this;
  66. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  67. return;
  68. }
  69. obj.loadingType = 'loading';
  70. my_reply({
  71. page: obj.page,
  72. limit: obj.limit
  73. }).then(({ data }) => {
  74. console.log(data);
  75. if(data.list.length != ''){
  76. data.list.forEach(e =>{
  77. e.create = getTime(e.add_time)
  78. console.log(e);
  79. })
  80. obj.list = obj.list.concat(data.list)
  81. }
  82. if(data.list.length === obj.limit) {
  83. obj.page++
  84. obj.loadingType = 'more'
  85. }else{
  86. obj.loadingType = 'noMore'
  87. }
  88. this.$set(obj.list, 'loaded', true);
  89. });
  90. },
  91. navTo(item){
  92. uni.navigateTo({
  93. url:'/pages/user/article?id='+ item.article.id
  94. })
  95. }
  96. }
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. .content {
  101. padding-top: 20rpx;
  102. }
  103. .pl-wrap {
  104. background-color: #fff;
  105. padding: 20rpx 30rpx;
  106. }
  107. .user-info {
  108. .user-logo {
  109. flex-shrink: 0;
  110. height: 100rpx;
  111. width: 100rpx;
  112. border-radius: 50%;
  113. image {
  114. border-radius: 50%;
  115. width: 100%;
  116. height: 100%;
  117. }
  118. }
  119. .user-num {
  120. flex-grow: 1;
  121. padding-left: 10rpx;
  122. font-size: 24rpx;
  123. font-weight: 500;
  124. color: #999999;
  125. .user-name {
  126. font-size: 34rpx;
  127. font-weight: 600;
  128. color: #333333;
  129. padding-right: 20rpx;
  130. padding: 0 20rpx 20rpx 0;
  131. }
  132. }
  133. }
  134. .pl {
  135. font-size: 24rpx;
  136. font-weight: 500;
  137. color: #333333;
  138. padding-top: 30rpx;
  139. }
  140. .other-pl {
  141. width: 690rpx;
  142. margin-top: 10rpx;
  143. padding: 16rpx;
  144. font-size: 24rpx;
  145. background: #f5f5f5;
  146. text {
  147. word-break: break-all;
  148. word-wrap: break-word;
  149. }
  150. .text {
  151. color: #3a41ee;
  152. }
  153. }
  154. .art {
  155. margin-top: 15rpx;
  156. width: 690rpx;
  157. height: 138rpx;
  158. background: #f6f9fc;
  159. padding: 15rpx 18rpx;
  160. .art-img {
  161. flex-shrink: 0;
  162. width: 169rpx;
  163. height: 108rpx;
  164. border-radius: 10rpx;
  165. margin-right: 17rpx;
  166. image {
  167. width: 169rpx;
  168. height: 108rpx;
  169. }
  170. }
  171. .art-jj {
  172. flex-grow: 1;
  173. font-size: 23rpx;
  174. font-weight: 500;
  175. color: #323232;
  176. }
  177. }
  178. </style>