inbox.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view>
  3. <uni-fab
  4. horizontal="right"
  5. vertical="bottom"
  6. @fabClick="toAdd"
  7. ></uni-fab>
  8. <u-search :show-action="false" v-model="searchForm.mailDTO.title" @change="inputWord" margin="20rpx 50rpx"></u-search>
  9. <view>
  10. <u-swipe-action>
  11. <view
  12. v-for="(obj, index) in dataList"
  13. :key="index">
  14. <u-swipe-action-item @click="del(obj.id)" :key="obj.id" :threshold="60" duration="500"
  15. :options="options">
  16. <u-cell-group>
  17. <u-cell @click="toDetail(obj)">
  18. <u-avatar slot="icon" size="32" :src="obj.sender.photo"></u-avatar>
  19. <view slot="title" class="content">
  20. <view class="text-bold text-grey">
  21. <view class="ellipsis-description">
  22. 标题:{{obj.mailDTO && obj.mailDTO.title}}
  23. </view>
  24. </view>
  25. <view class="text-grey text-sm">
  26. <view class="ellipsis-description">
  27. 发件人:{{obj.sender.name}}, {{obj.sendTime}}
  28. </view>
  29. </view>
  30. <view class="text-sm">
  31. <view class="ellipsis-description" v-html="`内容:${obj.mailDTO && obj.mailDTO.content || ''}`"></view>
  32. </view>
  33. </view>
  34. <view slot="right-icon" class="action">
  35. <u-tag v-if="obj.readStatus === '1'" text="已读" plain shape="circle" type="success"></u-tag>
  36. <u-tag v-else text="未读" plain shape="circle" type="error"></u-tag>
  37. </view>
  38. </u-cell>
  39. </u-cell-group>
  40. </u-swipe-action-item>
  41. </view>
  42. </u-swipe-action>
  43. </view>
  44. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  45. <u-gap height="20" bgColor="#fff"></u-gap>
  46. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  47. </view>
  48. </template>
  49. <script>
  50. import mailBoxService from "@/api/mail/mailBoxService";
  51. export default {
  52. data() {
  53. return {
  54. status: 'loadmore',
  55. searchForm: {
  56. mailDTO: {
  57. title: "",
  58. }
  59. },
  60. dataList: [],
  61. tablePage: {
  62. pages: 0,
  63. currentPage: 0,
  64. pageSize: 10,
  65. orders: [{ column: "a.create_time", asc: false }],
  66. },
  67. loading: false,
  68. options: [ {
  69. text: '删除',
  70. style: {
  71. backgroundColor: '#f56c6c'
  72. }
  73. }]
  74. }
  75. },
  76. onLoad() {
  77. this.loadmore()
  78. },
  79. methods: {
  80. // 跳转到详细页面
  81. toDetail (mail) {
  82. uni.navigateTo({
  83. url: '/pages/apps/mail/receivedMailDetail?id='+mail.id
  84. })
  85. },
  86. toAdd (){
  87. uni.navigateTo({
  88. url: '/pages/apps/mail/sendEmailForm'
  89. })
  90. },
  91. // 输入监听
  92. inputWord(e){
  93. this.searchTimer && clearTimeout(this.searchTimer)
  94. this.searchTimer = setTimeout(()=>{
  95. this.doSearch()
  96. },300)
  97. },
  98. // 搜索
  99. doSearch(){
  100. this.dataList = [];
  101. this.tablePage.currentPage = 0;
  102. this.tablePage.pageSize = 10;
  103. this.tablePage.pages = 0;
  104. this.loadmore()
  105. },
  106. onReachBottom() {
  107. this.loadmore()
  108. },
  109. loadmore() {
  110. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  111. this.status = 'nomore';
  112. return;
  113. }
  114. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  115. //联网加载数据
  116. this.status = 'loading';
  117. mailBoxService.list({
  118. current: this.tablePage.currentPage,
  119. size: this.tablePage.pageSize,
  120. orders: this.tablePage.orders,
  121. ...this.searchForm
  122. }).then((data)=>{
  123. //追加新数据
  124. this.dataList=this.dataList.concat(data.records);
  125. this.tablePage.pages = data.pages;
  126. if(this.tablePage.pages <= this.tablePage.currentPage){
  127. this.status = 'nomore'
  128. } else {
  129. this.status = 'loadmore'
  130. }
  131. })
  132. },
  133. del (id) {
  134. mailBoxService.delete(id).then((data)=>{
  135. this.doSearch()
  136. uni.showToast({
  137. title: data,
  138. icon:"success"
  139. })
  140. })
  141. },
  142. }
  143. }
  144. </script>