info.vue 4.3 KB

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