myForum.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="index">
  3. <view class="search">
  4. <view class="item">
  5. <text class="icon">&#xe628;</text>
  6. <input type="text" v-model="map.keywords" confirm-type="search" @confirm="search" placeholder="输入您想要找寻的文章" placeholder-class="inupt_p" />
  7. </view>
  8. <text class="icon" @tap="navigateTo('/pages/forum/addForum')">&#xe60e;</text>
  9. </view>
  10. <view class="new" v-for="(v, i) in info.data" :key="i">
  11. <view class="title">
  12. <text @tap="navigateTo('/pages/forum/articleDetails?message_id=' + v.id)">{{ v.title }}</text>
  13. <text class="delete" @tap="del(v.id)">删除</text>
  14. </view>
  15. <view class="user" @tap="navigateTo('/pages/forum/articleDetails?message_id=' + v.id)">
  16. <image :src="v.user.avatar" mode=""></image>
  17. <text class="t1">{{ v.user.nickname }}</text>
  18. <text class="t2">{{ v.createtime | date }}</text>
  19. </view>
  20. <view class="info" v-html="v.content"></view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import helper from '../../common/helper.js';
  26. import api from '../../common/api.js';
  27. export default {
  28. data() {
  29. return {
  30. map: {
  31. keywords: '',
  32. page: 1
  33. },
  34. info: {
  35. data: []
  36. }
  37. };
  38. },
  39. filters: {
  40. date: value => {
  41. let date = new Date(value * 1000);
  42. let y = date.getFullYear();
  43. let m = date.getMonth() + 1;
  44. let d = date.getDate();
  45. return y + '-' + (m > 9 ? m : '0' + m) + '-' + (d > 9 ? d : '0' + d);
  46. }
  47. },
  48. onShow() {
  49. this.getList();
  50. },
  51. methods: {
  52. search() {
  53. this.map.page = 1;
  54. this.getList();
  55. },
  56. async getList() {
  57. let res = await api.getMyMessageList(this.map);
  58. this.info = res.data;
  59. uni.stopPullDownRefresh();
  60. },
  61. async del(id) {
  62. uni.showModal({
  63. title: '操作提示',
  64. content: '确认要删除该话题吗?',
  65. success: async res => {
  66. if (res.confirm) {
  67. let res = await api.deleteMessage(id);
  68. helper.toast(res.msg);
  69. if (res.code == 1) {
  70. this.getList();
  71. }
  72. }
  73. }
  74. });
  75. },
  76. onPullDownRefresh() {
  77. this.map.page = 1;
  78. this.getList();
  79. },
  80. onReachBottom() {
  81. if (this.info.last_page > this.info.current_page) {
  82. this.getList();
  83. }
  84. },
  85. navigateTo(url) {
  86. uni.navigateTo({
  87. url: url
  88. });
  89. }
  90. }
  91. };
  92. </script>
  93. <style lang="scss" scoped>
  94. .icon {
  95. font-size: 32upx;
  96. }
  97. .index {
  98. background-color: #f6f6f6;
  99. }
  100. .search {
  101. width: 100%;
  102. padding: 0 5%;
  103. background-color: #ffffff;
  104. display: flex;
  105. padding: 30upx 0;
  106. align-items: center;
  107. justify-content: center;
  108. .item {
  109. display: flex;
  110. width: 76%;
  111. align-items: center;
  112. background-color: #f7f7f7;
  113. border: 1px solid #e8e8e8;
  114. border-radius: 40upx;
  115. padding: 10upx;
  116. padding-left: 20upx;
  117. .icon {
  118. margin-right: 10upx;
  119. }
  120. .inupt_p {
  121. color: #101010;
  122. font-size: 28upx;
  123. }
  124. }
  125. text {
  126. width: 10%;
  127. text-align: center;
  128. }
  129. }
  130. .new {
  131. padding: 30upx 5%;
  132. background-color: #ffffff;
  133. margin-bottom: 20upx;
  134. .title {
  135. font-size: 32upx;
  136. font-weight: 800;
  137. line-height: 2;
  138. .delete {
  139. float: right;
  140. color: #999999;
  141. font-size: 28upx;
  142. }
  143. }
  144. .user {
  145. display: flex;
  146. padding: 22upx 0;
  147. align-items: center;
  148. image {
  149. width: 60upx;
  150. height: 60upx;
  151. border-radius: 50%;
  152. }
  153. .t1 {
  154. margin-left: 20upx;
  155. font-size: 24upx;
  156. color: #666666;
  157. }
  158. .t2 {
  159. margin-left: 20upx;
  160. font-size: 24upx;
  161. color: #999999;
  162. }
  163. }
  164. .info {
  165. font-size: 28upx;
  166. color: #555555;
  167. line-height: 48upx;
  168. display: -webkit-box;
  169. -webkit-line-clamp: 3;
  170. overflow: hidden;
  171. text-overflow: ellipsis;
  172. -webkit-box-orient: vertical;
  173. }
  174. }
  175. </style>