list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <view @click="goDetail(item)" class="card" v-for="(item,index) in dataList" :key="index">
  5. <view class="title">
  6. <view class="text-cut-1">
  7. <text class="text-bold">标题:</text>
  8. <text class="">{{item.title}}</text>
  9. </view>
  10. <view class="time">
  11. <text class="cuIcon-time padding-right-10"></text>
  12. <text>{{new Date(item.createTime).getTime() | date('yyyy-mm-dd') }}</text>
  13. </view>
  14. </view>
  15. <view class="content ">
  16. <text class="text-cut-2">{{item.notice | formatHtml}}</text>
  17. </view>
  18. <view class="bottom">
  19. <view @click.stop="delItem(item)" class="cu-btn line-red round sm">
  20. <u-icon top="-1" name="trash-fill" size="25"></u-icon>
  21. <text class="padding-left-10">删除公告</text>
  22. </view>
  23. </view>
  24. </view>
  25. </mescroll-body>
  26. <view @click="add" style="position: fixed;bottom: 25%;right: 20rpx;">
  27. <view class="cuIcon cu-btn bg-blue" style="width: 80rpx;height: 80rpx;">
  28. <text class="cuIcon-add" style="font-size: 60rpx;"></text>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  35. export default {
  36. mixins:[MescrollMixin],
  37. data() {
  38. return {
  39. agencyId:'',
  40. isFirst:false,
  41. dataList:[],
  42. downOption: {
  43. use: true,
  44. auto: false
  45. },
  46. upOption: {
  47. auto: false,
  48. page: {
  49. page: 0,
  50. size: 10
  51. },
  52. noMoreSize: 3,
  53. empty: {
  54. tip: '暂无相关数据'
  55. }
  56. },
  57. }
  58. },
  59. filters: {
  60. formatHtml (str) {
  61. return str.replace(/<[^>]+>/g, "");
  62. }
  63. },
  64. onShow() {
  65. this.mescroll.resetUpScroll()
  66. },
  67. onLoad() {
  68. },
  69. methods: {
  70. goDetail(item){
  71. getApp().globalData.noticeDetail=item
  72. uni.navigateTo({
  73. url:"/pages/index/notice/detail",
  74. })
  75. },
  76. delItem(item){
  77. let params="?ids="+item.id
  78. this.$showModel('确定要删除该公告吗?').then(res=>{
  79. this.$api.notice.remove(params).then(res=>{
  80. if (res.success) {
  81. this.$showModel('删除成功',false).then(res=>{
  82. this.mescroll.resetUpScroll()
  83. })
  84. }else{
  85. this.$showToast('删除失败','error')
  86. }
  87. })
  88. })
  89. },
  90. add(){
  91. uni.navigateTo({
  92. url:"/pages/index/notice/add"
  93. })
  94. },
  95. /**
  96. * 下拉回调
  97. */
  98. downCallback(){
  99. setTimeout(()=>{
  100. this.mescroll.resetUpScroll()
  101. },1500)
  102. },
  103. /**
  104. * 上拉回调
  105. * @param {Object} mescroll
  106. */
  107. upCallback(mescroll) {
  108. try{
  109. let params={
  110. agencyId:this.$cache.get('agencyId'),
  111. current:mescroll.num,
  112. size:mescroll.size
  113. }
  114. this.$api.notice.page(params).then(res=>{
  115. let data=res.data.records
  116. let length=data.length
  117. let total=res.data.total
  118. mescroll.endBySize(length, total);
  119. if(mescroll.num == 1) this.dataList = [];
  120. this.dataList=this.dataList.concat(data);
  121. })
  122. }catch(e){
  123. mescroll.endErr();
  124. }
  125. },
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. .card{
  131. background-color: #FFFFFF;
  132. border-radius: 20rpx;
  133. margin: 20rpx;
  134. .title{
  135. display: flex;
  136. justify-content: space-between;
  137. padding: 20rpx;
  138. font-size: 30rpx;
  139. border-bottom: 0.5rpx solid #e6e5e8;
  140. .time{
  141. padding-top: 8rpx;
  142. font-size: 28rpx;
  143. color: #8d8d8d;
  144. }
  145. }
  146. .content{
  147. height: 150rpx;
  148. padding:30rpx 20rpx;
  149. border-bottom: 1rpx dashed #e6e5e8;
  150. }
  151. .bottom{
  152. padding: 20rpx;
  153. display: flex;
  154. justify-content: flex-end;
  155. }
  156. }
  157. </style>