mymsg.vue 3.9 KB

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