index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="uni-container-bg uni-container ">
  3. <view class="padding-tb-sm" style="">
  4. <uni-row class="demo-uni-row " :gutter="20" width="100%">
  5. <uni-col :span="24">
  6. <view class="u-page__tag-item">
  7. <u-search v-model="keyword" :show-action="true" @custom="handleQuery"></u-search>
  8. </view>
  9. </uni-col>
  10. </uni-row>
  11. </view>
  12. <view class="" v-if="tableData.length>0 && isLoaded">
  13. <uni-card v-for="(item, index) in tableData" :key="index" @click.native="onNoticeClick(item)">
  14. <view class="titles">{{item.title}}</view>
  15. <view style="float: left;">通知公告说明:</view>
  16. <!-- <text class="conts">{{item.taskContent}}</text> -->
  17. <rich-text :nodes="item.content?item.content:''" class="font-12"></rich-text>
  18. <view class="an-niu">
  19. <text @click.native="onNoticeClick(item)" class="detail">查看详情</text>
  20. </view>
  21. </uni-card>
  22. </view>
  23. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  24. <view class="text-gray" style="padding-top: 20px;">
  25. <img :src="tan90" alt="暂无数据" />
  26. </view>
  27. </view>
  28. <view>
  29. <!-- <image :src="Group" @click="addClick" class="tiantupian"></image> -->
  30. </view>
  31. <!--
  32. <u-list @scrolltolower="scrolltolower" class="card">
  33. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onNoticeClick(item)" link>
  34. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  35. <uni-col :span="24" class="text-1cut">
  36. <rich-text :nodes="item.title" class="font-12"></rich-text>
  37. <text class="uni-body font-14 text-bold ">{{item.title}}</text>
  38. </uni-col>
  39. </uni-row>
  40. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  41. <uni-col :span="24" class="text-2cut">
  42. <rich-text :nodes="item.content" class="font-12"></rich-text>
  43. <text class="uni-body">{{item.comContent}}</text>
  44. </uni-col>
  45. </uni-row>
  46. <uni-row class="demo-uni-row padding-tb-sm text-sm" :gutter="20" width="100%">
  47. <uni-col :span="24" class=" text-grey1 ">
  48. <text class="uni-body flex justify-end ">{{item.createTime}}</text>
  49. <text class="uni-body flex justify-end ">09-26</text>
  50. </uni-col>
  51. </uni-row>
  52. <u-button type="primary" text="详情" plain size="small" style="width: 20%;float: right;"></u-button>
  53. </u-list-item>
  54. </u-list> -->
  55. <tarBar :totarBer='tar'></tarBar>
  56. <!-- 加载中 -->
  57. <isLodingModel></isLodingModel>
  58. </view>
  59. </template>
  60. <script>
  61. import tarBar from '@/components/tabBar/index' //先把tabBar.vue组件导入
  62. import {
  63. getNoticeList, // 通知公告列表
  64. } from "@/api/notice";
  65. let that = null;
  66. export default {
  67. components: {
  68. tarBar
  69. },
  70. data() {
  71. return {
  72. isLoaded: false,
  73. tar: {
  74. color: '#07A7E3',
  75. id: 1
  76. }, //向子组件发送的值
  77. // 数据
  78. tableData: [],
  79. // 每页数据量
  80. pageSize: 20,
  81. // 当前页
  82. pageNo: 1,
  83. // 数据总量
  84. total: 0,
  85. // tableData数据加载中
  86. loading: false,
  87. // 初始化时搜索框的值
  88. keyword: '',
  89. ids: '0',
  90. title: '1'
  91. }
  92. },
  93. // 在 vue页面,向起始页通过事件传递数据
  94. onLoad: function(option) {
  95. this.ids = option.id
  96. },
  97. onShow() {
  98. this.tableData = []
  99. // this.tableD
  100. this.getData(this.pageNo)
  101. },
  102. watch: {
  103. loading: {
  104. handler(newLength, oldLength) {
  105. this.$modal.isLoadingModel(this.loading)
  106. },
  107. immediate: true
  108. }
  109. },
  110. methods: {
  111. handleQuery() { //搜索
  112. this.isLoaded = false
  113. this.loading = true
  114. this.tableData = []
  115. this.getData(1)
  116. },
  117. // 获取数据
  118. getData(pageNo, value = '') {
  119. this.loading = true
  120. this.pageNo = pageNo
  121. getNoticeList({
  122. pageNo: this.pageNo,
  123. pageSize: 10,
  124. title: this.keyword
  125. }).then(response => {
  126. this.isLoaded = true
  127. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  128. this.tableData = [...this.tableData, ...response.data.list]
  129. // this.tableData = response.data.list;
  130. this.total = response.data.total;
  131. this.loading = false;
  132. console.log(response, 'response');
  133. });
  134. },
  135. // 单个公告详情点击事件
  136. onNoticeClick(val) {
  137. this.isLoaded = false
  138. uni.navigateTo({
  139. url: `/pagesA/fire/notice/notcice_details/notcice_details?id=${val.id}`,
  140. success: function(res) {
  141. // 通过eventChannel向被打开页面传送数据
  142. res.eventChannel.emit('acceptDataFromOpenerPage', val)
  143. }
  144. })
  145. },
  146. // scrolltolower() {
  147. // // 判断是否还有下一页数据
  148. // if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  149. // title: `数据加载完毕`
  150. // })
  151. // // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  152. // if (this.loading) return
  153. // this.pageNo += 1
  154. // this.getData(this.pageNo)
  155. // },
  156. },
  157. // 触底的事件
  158. onReachBottom() {
  159. // 判断是否还有下一页数据
  160. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  161. title: `数据加载完毕`
  162. })
  163. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  164. if (this.loading) return
  165. this.pageNo += 1
  166. this.getData(this.pageNo)
  167. },
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. body {
  172. background-color: #F5F7F9;
  173. }
  174. page {
  175. background-color: #F5F7F9;
  176. }
  177. .an-niu {
  178. float: right;
  179. font-size: 10px;
  180. text-align: center;
  181. display: flex;
  182. padding-bottom: 30rpx;
  183. margin-top: 50rpx;
  184. color: #fff;
  185. .detail {
  186. width: 72px;
  187. height: 60rpx;
  188. border-radius: 30px;
  189. background-color: #F7C41E;
  190. margin-right: 20rpx;
  191. text-align: center;
  192. line-height: 60rpx;
  193. }
  194. }
  195. //列表样式
  196. .titles {
  197. font-weight: 600;
  198. margin-bottom: 10rpx;
  199. font-size: 14px;
  200. }
  201. /deep/.uni-card {
  202. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  203. border-radius: 30rpx;
  204. }
  205. rich-text {
  206. display: -webkit-box;
  207. -webkit-box-orient: vertical;
  208. -webkit-line-clamp: 1;
  209. overflow: hidden;
  210. }
  211. </style>