zx.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="">
  3. <top></top>
  4. <view class="content1">
  5. <view class="nav-title">
  6. 首页>行业资讯
  7. </view>
  8. <view class="content-view">
  9. <view @click='toDetail(item.id)' class="item" v-for="item in tableData">
  10. <view class="left-text">
  11. <image :src="item.cover" style="width: 230px;height: 158px;"></image>
  12. </view>
  13. <view class="right-content">
  14. <view class="title">
  15. {{item.title}}
  16. </view>
  17. <view class="row2">
  18. {{item.content}}
  19. </view>
  20. <view class="row3">
  21. <view class="ly">
  22. 来源:{{item.issuingAgency}} </view>
  23. <view class="date">{{item.issuingDate}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="uni-pagination-box">
  29. <uni-pagination show-icon :page-size="pageSize" :current="currentPage" :total="total"
  30. @change="change" />
  31. </view>
  32. </view>
  33. <bottom></bottom>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. mapState
  39. } from 'vuex';
  40. import top from '@/components/top.vue'
  41. import bottom from '@/components/bottom.vue'
  42. export default {
  43. components: {
  44. top,
  45. bottom
  46. },
  47. data() {
  48. return {
  49. type: '',
  50. navTitle: '',
  51. searchVal: '',
  52. tableData: [],
  53. // 每页数据量
  54. pageSize: 10,
  55. // 当前页
  56. currentPage: 1,
  57. // 数据总量
  58. total: 200,
  59. loading: false,
  60. user: {}
  61. }
  62. },
  63. onLoad(options) {
  64. this.user = uni.getStorageSync('userInfo');
  65. if (this.user) {
  66. this.$store.commit('login', this.user)
  67. this.init()
  68. }
  69. },
  70. methods: {
  71. // 获取富文本的纯文字内容
  72. convertIdeogramToNormalCharacter(val) {
  73. const arrEntities = {
  74. 'lt': '<',
  75. 'gt': '>',
  76. 'nbsp': ' ',
  77. 'amp': '&',
  78. 'quot': '"'
  79. };
  80. return val.replace(/&(lt|gt|nbsp|amp|quot);/ig, function(all, t) {
  81. return arrEntities[t];
  82. });
  83. },
  84. getPlainText(richCont) {
  85. debugger
  86. const str = richCont;
  87. let value = richCont;
  88. if (richCont) {
  89. // 方法一:
  90. value = value.replace(/\s*/g, ""); //去掉空格
  91. value = value.replace(/<[^>]+>/g, ""); //去掉所有的html标记
  92. value = value.replace(/↵/g, ""); //去掉所有的↵符号
  93. value = value.replace(/[\r\n]/g, "") //去掉回车换行
  94. value = value.replace(/&nbsp;/g, "") //去掉空格
  95. value = this.convertIdeogramToNormalCharacter(value);
  96. return value;
  97. } else {
  98. return null;
  99. }
  100. },
  101. init() {
  102. this.$request.baseRequest('get', '/hyPublicConsultation/selectHyPublicConsultation', {
  103. currentPage: this.currentPage,
  104. pageSize: this.pageSize,
  105. searchKeyWord: '',
  106. searchType: '资讯'
  107. }).then(res => {
  108. console.log("res", res)
  109. if (res.code == 200) {
  110. debugger
  111. this.tableData = res.data.records
  112. this.total = res.data.total
  113. for (let i = 0; i < this.tableData.length; i++) {
  114. this.tableData[i].content = this.getPlainText(this.tableData[i].releaseContent)
  115. }
  116. uni.hideLoading()
  117. } else {
  118. uni.hideLoading()
  119. uni.showToast({
  120. title: res.message,
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. }
  125. })
  126. .catch(res => {
  127. uni.showToast({
  128. title: res.message,
  129. icon: 'none',
  130. duration: 2000
  131. })
  132. });
  133. },
  134. toDetail(id) {
  135. uni.navigateTo({
  136. url: "/pages/index/zxDetail?id=" + id
  137. })
  138. },
  139. change(val) {
  140. console.log(val)
  141. this.currentPage = val.current
  142. this.init()
  143. },
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .content1 {
  149. width: 80%;
  150. background: white;
  151. margin: 40rpx auto;
  152. padding: 40rpx;
  153. box-sizing: border-box;
  154. .nav-title {
  155. font-size: 28rpx;
  156. color: #66686C;
  157. margin-bottom: 30rpx;
  158. }
  159. .content-view {
  160. .item {
  161. display: flex;
  162. // justify-content: space-between;
  163. border-bottom: 1px solid #F5F5F5;
  164. padding-right: 80rpx;
  165. padding-bottom: 68rpx;
  166. margin-top: 68rpx;
  167. .left-text {
  168. font-size: 36rpx;
  169. color: #333333;
  170. line-height: 64rpx;
  171. display: flex;
  172. align-items: center;
  173. }
  174. .right-content {
  175. margin-left: 40rpx;
  176. .title {
  177. font-size: 48rpx;
  178. font-weight: 600;
  179. color: #333333;
  180. line-height: 66rpx;
  181. }
  182. .row2 {
  183. margin-top: 20rpx;
  184. font-size: 36rpx;
  185. color: #969CA1;
  186. line-height: 64rpx;
  187. overflow: hidden;
  188. text-overflow: ellipsis;
  189. display: -webkit-box;
  190. -webkit-box-orient: vertical;
  191. -webkit-line-clamp: 3;
  192. }
  193. .row3 {
  194. display: flex;
  195. justify-content: space-between;
  196. margin-top: 40rpx;
  197. color: #969CA1;
  198. }
  199. }
  200. }
  201. // .item:nth-last-of-type(1) {
  202. // border-bottom: 0;
  203. // }
  204. }
  205. }
  206. .uni-pagination-box {
  207. margin-top: 40rpx;
  208. }
  209. </style>