instruct.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="container uni-container uni-container-bg">
  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. <u-list @scrolltolower="scrolltolower" class="card" v-if="tableData.length>0 && isLoaded">
  13. <view>
  14. <view class="clear-yidu">
  15. <image :src="clear_notice" class="yidu"></image>
  16. <u-button :plain="true" text="全部已读" @click="cleanUnread"
  17. style="width:180rpx;height:60rpx;border-radius: 2px;background-color: #E4E4E4;">
  18. </u-button>
  19. </view>
  20. </view>
  21. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onNoticeClick(item)" link>
  22. <!-- <u-button type="primary" text="详情" plain size="small" style="width: 20%;float: right;"></u-button> -->
  23. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  24. <uni-col :span="24" class="text-1cut">
  25. <!-- <rich-text :nodes="item.comTitle"></rich-text> -->
  26. <u-badge v-if="item.comBroadDOList[0].isRead==0" :isDot="true" type="warning"></u-badge>
  27. <text class="uni-body font-14 text-bold">标题:{{item.comTitle}}</text>
  28. </uni-col>
  29. </uni-row>
  30. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  31. <uni-col :span="24" class="text-2cut">
  32. <rich-text :nodes="item.comContent?item.comContent:''" class="font-12"></rich-text>
  33. <!-- <text class="uni-body">{{item.comContent}}</text> -->
  34. </uni-col>
  35. </uni-row>
  36. <uni-row>
  37. <uni-col class="an-niu">
  38. <text @click="onNoticeClick(item)" class="detail">查看详情</text>
  39. </uni-col>
  40. </uni-row>
  41. </u-list-item>
  42. </u-list>
  43. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  44. <view class="text-gray" style="padding-top: 20px;">
  45. <img :src="tan90" alt="暂无数据" />
  46. </view>
  47. </view>
  48. <tarBar :totarBer='tar'></tarBar>
  49. <!-- 加载中 -->
  50. <isLodingModel></isLodingModel>
  51. </view>
  52. </template>
  53. <script>
  54. import tarBar from '@/components/tabBar/index' //先把tabBar.vue组件导入
  55. import {
  56. getNoticeLists,
  57. getNoticeAllRead,
  58. getNoticeOlnyRead
  59. } from "@/api/notice"; // 指令列表
  60. let that = null;
  61. import config from '@/config'
  62. const baseUrlImg = config.baseUrlImg
  63. export default {
  64. components: {
  65. tarBar
  66. },
  67. data() {
  68. return {
  69. isLoaded: false,
  70. tar: {
  71. color: '#07A7E3',
  72. id: 1
  73. }, //向子组件发送的值
  74. // 数据
  75. tableData: [],
  76. clear_notice: `${baseUrlImg}/working/clear_notice.png`, //清除未读的图标
  77. tan90: `${baseUrlImg}/tan90.png`,
  78. // 每页数据量
  79. pageSize: 20,
  80. // 当前页
  81. pageNo: 1,
  82. // 数据总量
  83. total: 0,
  84. // tableData数据加载中
  85. loading: false,
  86. // 初始化时搜索框的值
  87. keyword: '',
  88. ids: '0',
  89. current: '', //指令
  90. }
  91. },
  92. // 在 vue页面,向起始页通过事件传递数据
  93. onLoad: function(option) {
  94. this.ids = option.id
  95. },
  96. onShow() {
  97. this.tableData = []
  98. this.getData(this.pageNo)
  99. },
  100. watch: {
  101. loading: {
  102. handler(newLength, oldLength) {
  103. this.$modal.isLoadingModel(this.loading)
  104. },
  105. immediate: true
  106. }
  107. },
  108. methods: {
  109. handleQuery() { //搜索
  110. this.tableData = []
  111. this.isLoaded = false
  112. this.loading = true
  113. this.getData(1)
  114. },
  115. // //查看详情
  116. // addClickDetail(val) {
  117. // this.isLoaded = false
  118. // uni.navigateTo({
  119. // url: `/pagesA/fire/notice/notcice_details/notcice_details?id=${val.comBroadDOList[0].id}&&current=${this.current}`,
  120. // success: function(res) {
  121. // res.eventChannel.emit('acceptDataFromOpenerPage', val);
  122. // }
  123. // })
  124. // },
  125. // 获取数据
  126. getData(pageNo, value = '') {
  127. this.loading = true
  128. this.pageNo = pageNo
  129. getNoticeLists({
  130. pageNo: this.pageNo,
  131. pageSize: this.pageSize,
  132. userId: this.$store.state.user.id,
  133. comTitle: this.keyword
  134. }).then(response => {
  135. this.isLoaded = true
  136. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  137. this.current = response.data.current
  138. this.tableData = [...this.tableData, ...response.data.records]
  139. // this.tableData = response.data.list;
  140. this.total = response.data.total;
  141. this.loading = false;
  142. console.log(response, 'response');
  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. cleanUnread() {
  158. getNoticeAllRead({
  159. userId: this.$store.state.user.id
  160. }).then(response => {
  161. if (response.data == true) {
  162. this.isLoaded = false
  163. this.loading = true
  164. this.tableData = []
  165. this.getData();
  166. }
  167. });
  168. },
  169. // 单个公告详情点击事件
  170. onNoticeClick(val) {
  171. console.log(val, 'sd');
  172. getNoticeOlnyRead({
  173. id: val.comBroadDOList[0].id
  174. }).then(response => {
  175. if (response.data == true) {
  176. this.isLoaded = false
  177. uni.navigateTo({
  178. url: `/pagesA/fire/notice/notcice_details/notcice_details?id=${val.comBroadDOList[0].id}&&current=${this.current}`,
  179. success: function(res) {
  180. // 通过eventChannel向被打开页面传送数据
  181. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  182. }
  183. });
  184. }
  185. });
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. page {
  192. background-color: #F5F7F9;
  193. }
  194. /deep/.u-button__text {
  195. margin-left: 20rpx;
  196. }
  197. .clear-yidu {
  198. margin: 0 20rpx 20rpx 0;
  199. position: relative;
  200. width: 180rpx;
  201. height: 60rpx;
  202. float: right;
  203. .yidu {
  204. width: 30rpx;
  205. height: 30rpx;
  206. position: absolute;
  207. top: 16rpx;
  208. left: 6px;
  209. z-index: 999;
  210. }
  211. }
  212. .wei-circle {
  213. background-color: red;
  214. width: 24rpx;
  215. height: 24rpx;
  216. border-radius: 50%;
  217. }
  218. .text-1cut {
  219. display: flex;
  220. align-items: center;
  221. }
  222. .an-niu {
  223. // float: right;
  224. font-size: 10px;
  225. text-align: center;
  226. display: flex;
  227. align-items: end;
  228. justify-content: flex-end;
  229. color: #fff;
  230. .detail {
  231. width: 72px;
  232. height: 60rpx;
  233. border-radius: 30px;
  234. background-color: #F7C41E;
  235. margin-right: 20rpx;
  236. text-align: center;
  237. line-height: 60rpx;
  238. }
  239. }
  240. .no-notice {
  241. font-size: 48rpx;
  242. color: rgb(175, 176, 178);
  243. text-align: center;
  244. line-height: 200px;
  245. }
  246. </style>