draft.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" backUrl="/pages/apps/mail/mail" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content"> 草稿箱</block>
  6. </cu-custom>
  7. <view :style="[{top:CustomBar + 'px'}]">
  8. <view class="cu-bar search">
  9. <view class="search-form bg-white round">
  10. <text class="cuIcon-search"></text>
  11. <input type="text" placeholder="搜索" v-model="curWord" confirm-type="search" @input="inputWord"></input>
  12. </view>
  13. </view>
  14. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  15. <view class="cu-list menu-avatar">
  16. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(obj, index) in list" :key="index"
  17. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  18. <view @click="toDetail(obj)" class="cu-avatar round" :style="'background-image:url('+(obj.sender.photo?obj.sender.photo:'/static/user/flat-avatar.png')+');'">
  19. </view>
  20. <view @click="toDetail(obj)" class="content">
  21. <view class="text-bold text-grey">
  22. <view class="ellipsis-description">
  23. {{obj.sender.name}}
  24. </view>
  25. </view>
  26. <view class=" text-sm">
  27. <view class="ellipsis-description">
  28. {{obj.mailDTO.title}}
  29. </view>
  30. </view>
  31. <view class=" text-gray text-sm">
  32. <view class="ellipsis-description">
  33. <p v-html="obj.mailDTO.content"></p>
  34. </view>
  35. </view>
  36. </view>
  37. <view @click="toDetail(obj)" class="action">
  38. <view class="text-grey text-xs" >{{obj.sendTime}}</view>
  39. <view class="cu-tag bg-red round sm">
  40. 草稿
  41. </view>
  42. </view>
  43. <view class="move" >
  44. <view class="bg-red" @click="del(obj.id)">删除</view>
  45. </view>
  46. </view>
  47. </view>
  48. </mescroll-body>
  49. </view>
  50. <uni-fab
  51. :pattern=" {
  52. color: '#7A7E83',
  53. backgroundColor: '#fff',
  54. selectedColor: '#007AFF',
  55. buttonColor: '#007AFF'
  56. }"
  57. horizontal="right"
  58. vertical="bottom"
  59. @fabClick="toAdd"
  60. ></uni-fab>
  61. </view>
  62. </template>
  63. <script>
  64. import uniFab from '@/components/uni-fab/uni-fab.vue';
  65. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  66. import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
  67. import mailComposeService from "@/api/mail/mailComposeService";
  68. export default {
  69. mixins: [MescrollMixin,MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
  70. props:{
  71. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  72. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  73. type: Number,
  74. default(){
  75. return 0
  76. }
  77. },
  78. tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
  79. type: Array,
  80. default(){
  81. return []
  82. }
  83. }
  84. },
  85. components:{
  86. uniFab
  87. },
  88. data() {
  89. return {
  90. upOption: {
  91. noMoreSize: 3, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
  92. empty: {
  93. tip: '~ 搜索无结果 ~' // 提示
  94. }
  95. },
  96. CustomBar: this.CustomBar,
  97. list: [], // 数据列表
  98. modalName: null,
  99. curWord:"" //当前搜索关键词
  100. }
  101. },
  102. methods: {
  103. // 跳转到详细页面
  104. toDetail (mail) {
  105. uni.navigateTo({
  106. url: '/pages/apps/mail/sendEmailDetail?id='+mail.id
  107. })
  108. },
  109. toAdd (){
  110. uni.navigateTo({
  111. url: '/pages/apps/mail/sendEmailForm'
  112. })
  113. },
  114. // 输入监听
  115. inputWord(e){
  116. // this.curWord = e.detail.value // 已使用v-model,无需再次赋值
  117. // 节流,避免输入过快多次请求
  118. this.searchTimer && clearTimeout(this.searchTimer)
  119. this.searchTimer = setTimeout(()=>{
  120. this.doSearch(this.curWord)
  121. },300)
  122. },
  123. // 搜索
  124. doSearch(word){
  125. this.curWord = word
  126. this.list = []; // 先清空列表,显示加载进度
  127. this.mescroll.resetUpScroll();
  128. },
  129. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  130. upCallback(page) {
  131. //联网加载数据
  132. mailComposeService.list({
  133. current: page.num,
  134. size: page.size,
  135. status: '0',
  136. mailDTO: {
  137. title: this.curWord
  138. }
  139. }).then(({data})=>{
  140. let curPageData = data.records
  141. this.mescroll.endBySize(curPageData.length, data.total);
  142. //如果是第一页需手动制空列表
  143. if(page.num == 1)
  144. this.list = [];
  145. //追加新数据
  146. this.list=this.list.concat(curPageData);
  147. }).catch(e=>{
  148. //联网失败, 结束加载
  149. this.mescroll.endErr();
  150. })
  151. },
  152. del (id) {
  153. mailComposeService.delete(id).then(({data})=>{
  154. uni.showToast({
  155. title: data,
  156. icon:"success"
  157. })
  158. this.doSearch()
  159. })
  160. },
  161. // ListTouch触摸开始
  162. ListTouchStart(e) {
  163. this.listTouchStart = e.touches[0].pageX
  164. },
  165. // ListTouch计算方向
  166. ListTouchMove(e) {
  167. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > -60? 'right' : 'left'
  168. },
  169. // ListTouch计算滚动
  170. ListTouchEnd(e) {
  171. if (this.listTouchDirection == 'left') {
  172. this.modalName = e.currentTarget.dataset.target
  173. } else {
  174. this.modalName = null
  175. }
  176. this.listTouchDirection = null
  177. }
  178. }
  179. }
  180. </script>
  181. <style>
  182. .ellipsis-description {
  183. font-size: 12px;
  184. line-height: $line-height-base;
  185. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  186. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  187. overflow: hidden; /*超出的文本隐藏*/
  188. text-overflow: ellipsis; /* 溢出用省略号*/
  189. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  190. }
  191. .cu-bar .search-form{
  192. background-color: white;
  193. }
  194. </style>