index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. import config from '@/config'
  67. const baseUrlImg = config.baseUrlImg
  68. export default {
  69. components: {
  70. tarBar
  71. },
  72. data() {
  73. return {
  74. isLoaded: false,
  75. tar: {
  76. color: '#07A7E3',
  77. id: 1
  78. }, //向子组件发送的值
  79. // 数据
  80. tableData: [],
  81. // 每页数据量
  82. pageSize: 20,
  83. // 当前页
  84. pageNo: 1,
  85. // 数据总量
  86. total: 0,
  87. // tableData数据加载中
  88. loading: false,
  89. // 初始化时搜索框的值
  90. keyword: '',
  91. ids: '0',
  92. title: '1',
  93. tan90: `${baseUrlImg}/tan90.png`,
  94. }
  95. },
  96. // 在 vue页面,向起始页通过事件传递数据
  97. onLoad: function(option) {
  98. this.ids = option.id
  99. },
  100. onShow() {
  101. this.tableData = []
  102. // this.tableD
  103. this.getData(this.pageNo)
  104. },
  105. watch: {
  106. loading: {
  107. handler(newLength, oldLength) {
  108. this.$modal.isLoadingModel(this.loading)
  109. },
  110. immediate: true
  111. }
  112. },
  113. methods: {
  114. handleQuery() { //搜索
  115. this.isLoaded = false
  116. this.loading = true
  117. this.tableData = []
  118. this.getData(1)
  119. },
  120. // 获取数据
  121. getData(pageNo, value = '') {
  122. this.loading = true
  123. this.pageNo = pageNo
  124. getNoticeList({
  125. pageNo: this.pageNo,
  126. pageSize: 10,
  127. title: this.keyword
  128. }).then(response => {
  129. this.isLoaded = true
  130. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  131. this.tableData = [...this.tableData, ...response.data.list]
  132. // this.tableData = response.data.list;
  133. this.total = response.data.total;
  134. this.loading = false;
  135. console.log(response, 'response');
  136. });
  137. },
  138. // 单个公告详情点击事件
  139. onNoticeClick(val) {
  140. this.isLoaded = false
  141. uni.navigateTo({
  142. url: `/pagesA/fire/notice/notcice_details/notcice_details?id=${val.id}`,
  143. success: function(res) {
  144. // 通过eventChannel向被打开页面传送数据
  145. res.eventChannel.emit('acceptDataFromOpenerPage', val)
  146. }
  147. })
  148. },
  149. // scrolltolower() {
  150. // // 判断是否还有下一页数据
  151. // if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  152. // title: `数据加载完毕`
  153. // })
  154. // // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  155. // if (this.loading) return
  156. // this.pageNo += 1
  157. // this.getData(this.pageNo)
  158. // },
  159. },
  160. // 触底的事件
  161. onReachBottom() {
  162. // 判断是否还有下一页数据
  163. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  164. title: `数据加载完毕`
  165. })
  166. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  167. if (this.loading) return
  168. this.pageNo += 1
  169. this.getData(this.pageNo)
  170. },
  171. }
  172. </script>
  173. <style lang="scss" scoped>
  174. body {
  175. background-color: #F5F7F9;
  176. }
  177. page {
  178. background-color: #F5F7F9;
  179. }
  180. .an-niu {
  181. float: right;
  182. font-size: 10px;
  183. text-align: center;
  184. display: flex;
  185. padding-bottom: 30rpx;
  186. margin-top: 50rpx;
  187. color: #fff;
  188. .detail {
  189. width: 72px;
  190. height: 60rpx;
  191. border-radius: 30px;
  192. background-color: #F7C41E;
  193. margin-right: 20rpx;
  194. text-align: center;
  195. line-height: 60rpx;
  196. }
  197. }
  198. //列表样式
  199. .titles {
  200. font-weight: 600;
  201. margin-bottom: 10rpx;
  202. font-size: 14px;
  203. }
  204. /deep/.uni-card {
  205. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  206. border-radius: 30rpx;
  207. }
  208. rich-text {
  209. display: -webkit-box;
  210. -webkit-box-orient: vertical;
  211. -webkit-line-clamp: 1;
  212. overflow: hidden;
  213. }
  214. </style>