info.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. const str = richCont;
  80. let value = richCont;
  81. if (richCont) {
  82. // 方法一:
  83. value = value.replace(/\s*/g, ""); //去掉空格
  84. value = value.replace(/<[^>]+>/g, ""); //去掉所有的html标记
  85. value = value.replace(/↵/g, ""); //去掉所有的↵符号
  86. value = value.replace(/[\r\n]/g, "") //去掉回车换行
  87. value = value.replace(/&nbsp;/g, "") //去掉空格
  88. value = this.convertIdeogramToNormalCharacter(value);
  89. return value;
  90. } else {
  91. return null;
  92. }
  93. },
  94. init() {
  95. this.$request.baseRequest('get', '/hyPublicConsultation/selectHyPublicConsultation', {
  96. currentPage: this.currentPage,
  97. pageSize: this.pageSize,
  98. searchKeyWord: '',
  99. searchType: this.navTitle
  100. }).then(res => {
  101. console.log("res", res)
  102. if (res.code == 200) {
  103. this.tableData = res.data.records
  104. this.total = res.data.total
  105. for (let i = 0; i < this.tableData.length; i++) {
  106. this.tableData[i].content = this.getPlainText(this.tableData[i].releaseContent)
  107. }
  108. uni.hideLoading()
  109. } else {
  110. uni.hideLoading()
  111. uni.showToast({
  112. title: res.message,
  113. icon: 'none',
  114. duration: 2000
  115. })
  116. }
  117. })
  118. .catch(res => {
  119. uni.showToast({
  120. title: res.message,
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. });
  125. },
  126. toDetail(id, type) {
  127. let _src = ''
  128. if (type == 'zx') {
  129. _src = "/pages/index/zxDetail?id=" + id
  130. } else {
  131. _src = "/pages/index/infoDetail?id=" + id + '&type=' + type
  132. }
  133. uni.navigateTo({
  134. url: _src
  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: 132rpx auto;
  150. padding: 40rpx;
  151. .nav-title {
  152. font-size: 28rpx;
  153. color: #66686C;
  154. line-height: 20px;
  155. }
  156. .content-view {
  157. .item {
  158. display: flex;
  159. justify-content: space-between;
  160. border-bottom: 1px solid #F5F5F5;
  161. padding-right: 80rpx;
  162. line-height: 55px;
  163. height: 55px;
  164. .point {
  165. width: 12rpx;
  166. height: 12rpx;
  167. background: #D8D8D8;
  168. margin: 0 6px;
  169. }
  170. .left-text {
  171. font-size: 36rpx;
  172. color: #333333;
  173. line-height: 64rpx;
  174. display: flex;
  175. align-items: center;
  176. }
  177. .date {
  178. font-size: 36rpx;
  179. color: #90969B;
  180. }
  181. }
  182. // .item:nth-last-of-type(1) {
  183. // border-bottom: 0;
  184. // }
  185. }
  186. }
  187. .uni-pagination-box {
  188. margin-top: 40rpx;
  189. }
  190. </style>