zx.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. const str = richCont;
  86. let value = richCont;
  87. if (richCont) {
  88. // 方法一:
  89. value = value.replace(/\s*/g, ""); //去掉空格
  90. value = value.replace(/<[^>]+>/g, ""); //去掉所有的html标记
  91. value = value.replace(/↵/g, ""); //去掉所有的↵符号
  92. value = value.replace(/[\r\n]/g, "") //去掉回车换行
  93. value = value.replace(/&nbsp;/g, "") //去掉空格
  94. value = this.convertIdeogramToNormalCharacter(value);
  95. return value;
  96. } else {
  97. return null;
  98. }
  99. },
  100. init() {
  101. this.$request.baseRequest('get', '/hyPublicConsultation/selectHyPublicConsultation', {
  102. currentPage: this.currentPage,
  103. pageSize: this.pageSize,
  104. searchKeyWord: '',
  105. searchType: '资讯'
  106. }).then(res => {
  107. console.log("res", res)
  108. if (res.code == 200) {
  109. this.tableData = res.data.records
  110. this.total = res.data.total
  111. for (let i = 0; i < this.tableData.length; i++) {
  112. this.tableData[i].content = this.getPlainText(this.tableData[i].releaseContent)
  113. }
  114. uni.hideLoading()
  115. } else {
  116. uni.hideLoading()
  117. uni.showToast({
  118. title: res.message,
  119. icon: 'none',
  120. duration: 2000
  121. })
  122. }
  123. })
  124. .catch(res => {
  125. uni.showToast({
  126. title: res.message,
  127. icon: 'none',
  128. duration: 2000
  129. })
  130. });
  131. },
  132. toDetail(id) {
  133. uni.navigateTo({
  134. url: "/pages/index/zxDetail?id=" + id
  135. })
  136. },
  137. change(val) {
  138. console.log(val)
  139. this.currentPage = val.current
  140. this.init()
  141. },
  142. }
  143. }
  144. </script>
  145. <style scoped lang="scss">
  146. .content1 {
  147. width: 80%;
  148. background: white;
  149. margin: 40rpx auto;
  150. padding: 40rpx;
  151. box-sizing: border-box;
  152. .nav-title {
  153. font-size: 28rpx;
  154. color: #66686C;
  155. margin-bottom: 30rpx;
  156. }
  157. .content-view {
  158. .item {
  159. display: flex;
  160. // justify-content: space-between;
  161. border-bottom: 1px solid #F5F5F5;
  162. padding-right: 80rpx;
  163. padding-bottom: 68rpx;
  164. margin-top: 68rpx;
  165. .left-text {
  166. font-size: 36rpx;
  167. color: #333333;
  168. line-height: 64rpx;
  169. display: flex;
  170. align-items: center;
  171. }
  172. .right-content {
  173. margin-left: 40rpx;
  174. .title {
  175. font-size: 48rpx;
  176. font-weight: 600;
  177. color: #333333;
  178. line-height: 66rpx;
  179. }
  180. .row2 {
  181. margin-top: 20rpx;
  182. font-size: 36rpx;
  183. color: #969CA1;
  184. line-height: 64rpx;
  185. }
  186. .row3 {
  187. display: flex;
  188. justify-content: space-between;
  189. margin-top: 40rpx;
  190. color: #969CA1;
  191. }
  192. }
  193. }
  194. // .item:nth-last-of-type(1) {
  195. // border-bottom: 0;
  196. // }
  197. }
  198. }
  199. .uni-pagination-box {
  200. margin-top: 40rpx;
  201. }
  202. </style>