annotationList.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="bg-white" >
  3. <cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="index">
  4. <block slot="backText">返回</block>
  5. <block slot="content">公告消息</block>
  6. </cu-custom>
  7. <view class="container">
  8. <view class="solid-bottom">
  9. <scroll-view scroll-x class="bg-white nav text-center ">
  10. <view class="flex text-center justify-around">
  11. <view class="cu-item" :class="item.value==TabCur?'text-blue cur':''" v-for="(item,index) in tabs" :key="index" @tap="tabSelect" :data-id="item.value">
  12. {{item.title}}
  13. </view>
  14. </view>
  15. </scroll-view>
  16. </view>
  17. <mescroll-uni ref="mescrollRef" @init="mescrollInit" :top="top" @down="downCallback" @up="upCallback">
  18. <!-- 数据列表 -->
  19. <view class="al-list cu-list">
  20. <view class="message_text bg-white cu-item flex justify-around align-center solid-bottom margin-bottom-sm margin-top-sm" style="width: 100vw;" v-for="(item,index) in msgList" :key="index" @tap="goAnnotationDetail(item)" :class="modalName=='move-box-'+ index?'move-cur':''"
  21. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  22. <view v-if="isEmail(item)" class="padding-left">
  23. <view class="cu-avatar radius cuIcon-mail bg-orange" ></view>
  24. </view>
  25. <view v-if="item.msgCategory == '1'&&!isEmail(item)" class="padding-left">
  26. <view class="cu-avatar radius cuIcon-notification bg-orange" ></view>
  27. </view>
  28. <view v-if="item.msgCategory == '2'&&!isEmail(item)" class="padding-left">
  29. <view class="cu-avatar radius cuIcon-notice bg-orange" ></view>
  30. </view>
  31. <view class="titlePad content" style="height: 4em;">
  32. <view class="flex justify-start text-cut text-lg" style="width:26em;color: #333;font-family: '黑体';">
  33. <!-- <view v-if="item.readFlag == '0'" class="cu-tag light bg-blue">未读</view> -->
  34. <view v-if="item.readFlag == '0'">
  35. <text class="cuIcon-title text-red padding-left-sm" style="margin-right: -0.8em;"></text>
  36. </view>
  37. <view class="padding-left">
  38. <text class="text-black" v-if="isEmail(item)&&item.emailTitle">{{titleFilter(item.emailTitle,12)}} </text>
  39. <text class="text-black" v-else>{{titleFilter(item.titile,12)}} </text>
  40. </view>
  41. </view>
  42. <view class="flex justify-between margin-top-xs" style="font-family: '黑体';color: #999;">
  43. <view v-if="isEmail(item)" class="text-content text-cut" style="padding-left: .8rem;width:18em;"
  44. v-html="item.msgContent" @click="goEmailDetailPage(item);">
  45. </view>
  46. <view v-else-if="!isEmail(item)" style="padding-left: .8rem;">
  47. <view class="text-content text-cut" v-if="item.msgAbstract && item.msgAbstract.length > 0" style="width:18em;"
  48. v-html="item.msgAbstract">
  49. </view>
  50. <view v-else>
  51. 无摘要
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="action text-sm" style="color: #aaa;margin-top: -2em;margin-left: -13em;width: 10em;">
  57. <text >{{formatDate(item.sendTime,10)}}</text>
  58. </view>
  59. <view class="move">
  60. <view class="bg-red" style="margin-right: 3em;margin-left: 2px;" @tap.stop="deleteAnnotation(item)">删除</view>
  61. </view>
  62. </view>
  63. </view>
  64. </mescroll-uni>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. const tabs = [{title:'通知公告',value:0}, {title:'系统消息',value:1}];
  70. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  71. export default {
  72. mixins: [MescrollMixin], // 使用mixin
  73. data() {
  74. return {
  75. tabs,
  76. TabCur: 0,
  77. scrollLeft: 0,
  78. NavBarColor:this.NavBarColor,
  79. upOption:{
  80. page: {
  81. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  82. size: 10 // 每页数据的数量
  83. },
  84. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  85. empty:{
  86. tip: '~ 暂无数据 ~', // 提示
  87. },
  88. loading:'',
  89. text:'全部',
  90. isShowNoMore:false,
  91. textNoMore:'我是有底线的 >_<'
  92. },
  93. msgList: [], //列表数据
  94. read: "all",
  95. announcement1:[],
  96. msg1Count:"",
  97. msg1Title:"",
  98. announcement2:[],
  99. msg2Count:"",
  100. msg2Title:"",
  101. url:"/sys/sysAnnouncementSend/getMyAnnouncementSend",
  102. delUrl:'/sys/sysAnnouncementSend/delete',
  103. listTouchStart: 0,
  104. modalName: null,
  105. listTouchDirection: null,
  106. }
  107. },
  108. onShow() {
  109. if(this.mescroll){
  110. this.mescroll.resetUpScroll()
  111. }
  112. },
  113. computed:{
  114. top() {
  115. return this.CustomBar * 2 + 95
  116. },
  117. style() {
  118. var StatusBar= this.StatusBar;
  119. var CustomBar= this.CustomBar;
  120. var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
  121. return style
  122. },
  123. },
  124. methods: {
  125. // unique(arr) {
  126. // var obj = {};
  127. // return arr.filter(function(item, index, arr){
  128. // return obj.hasOwnProperty(typeof item + item) ? false : (obj[typeof item + item] = true)
  129. // })
  130. // },
  131. upCallback(page) {
  132. //联网加载数据
  133. console.log("tabindex",this.TabCur )
  134. let keyword = this.TabCur
  135. if(keyword == 0){
  136. this.$http.get(this.url,{params:{pageNo: page.num, pageSize:page.size,msgCategory: '1'}}).then(res=>{
  137. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  138. this.announcement1 = res.data.result.records
  139. this.mescroll.endSuccess(this.announcement1.length);
  140. //console.log("url", res)
  141. //设置列表数据
  142. if (res.data.success) {
  143. console.log("res",res.data)
  144. this.msg1Count = res.data.result.total
  145. this.msg1Title = "通知(" + res.data.result.total + ")";
  146. for(let annItem of this.announcement1){
  147. this.msgList.push(annItem)
  148. }
  149. }
  150. if(page.num == 1){
  151. this.msgList = []; //如果是第一页需手动制空列表
  152. this.msgList = this.msgList.concat(this.announcement1); //追加新数据
  153. }
  154. }).catch(()=>{
  155. //联网失败, 结束加载
  156. this.mescroll.endErr();
  157. })
  158. }
  159. if(keyword == 1){
  160. this.$http.get(this.url,{params:{pageNo: page.num,pageSize: page.size,msgCategory: '2'}}).then(res=>{
  161. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  162. this.announcement2 = res.data.result.records
  163. this.mescroll.endSuccess(this.announcement2.length,this.msgCount);
  164. //设置列表数据
  165. if (res.data.success) {
  166. console.log("res sys",res.data)
  167. this.msg2Count = res.data.result.total
  168. this.msg2Title = "通知(" + res.data.result.total + ")";
  169. // this.announcement2.filter((item,index) => {
  170. // // console.log("item",item)
  171. // if(item.anntId == this.announcement2[index+1].anntId){
  172. // this.announcement2.splice(item,1)
  173. for(let item of this.announcement2){
  174. this.msgList.push(item)
  175. }
  176. // }
  177. // })
  178. }
  179. if(page.num == 1){
  180. this.msgList = []; //如果是第一页需手动制空列表
  181. this.msgList = this.msgList.concat(this.announcement2); //追加新数据
  182. }
  183. }).catch(()=>{
  184. //联网失败, 结束加载
  185. this.mescroll.endErr();
  186. })
  187. }
  188. },
  189. tabSelect(e) {
  190. this.TabCur = e.currentTarget.dataset.id;
  191. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
  192. this.msgList = []// 先置空列表,显示加载进度
  193. this.mescroll.resetUpScroll() // 再刷新列表数据
  194. },
  195. goAnnotationDetail(item){
  196. //item.readFlag = '1'
  197. this.mescroll.resetUpScroll()
  198. if(item.openType=="component" && item.openPage.indexOf('email')>= 0){
  199. this.goEmailDetailPage(item)
  200. }else{
  201. // console.log("detail",encodeURIComponent(JSON.stringify(item)))
  202. uni.navigateTo({
  203. url: '/pages/annotation/annotationDetail?item='+ encodeURIComponent(JSON.stringify(item))
  204. });
  205. }
  206. },
  207. isEmail(item){
  208. if(item.openType=="component" &&item.openPage.indexOf('email')>=0){
  209. return true;
  210. }else{
  211. return false;
  212. }
  213. },
  214. goEmailDetailPage(item){
  215. console.log("go",item.anntId)
  216. console.log("item",item)
  217. if(item.readFlag == '0'){
  218. //item.readFlag = '1'
  219. this.mescroll.resetUpScroll()
  220. let readUrl = '/sys/sysAnnouncementSend/editByAnntIdAndUserId';
  221. this.$http.put(readUrl,{anntId:item.anntId})
  222. }
  223. // console.log("goe",item.busId)
  224. uni.navigateTo({
  225. url: '/pages/mail/mailDetail?id='+item.busId
  226. });
  227. },
  228. ListTouchStart(e) {
  229. this.listTouchStart = e.touches[0].pageX
  230. },
  231. // ListTouch计算方向
  232. ListTouchMove(e) {
  233. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
  234. },
  235. // ListTouch计算滚动
  236. ListTouchEnd(e) {
  237. if (this.listTouchDirection == 'left') {
  238. this.modalName = e.currentTarget.dataset.target
  239. } else {
  240. this.modalName = null
  241. }
  242. this.listTouchDirection = null
  243. },
  244. deleteAnnotation(item) {
  245. this.$http.delete(this.delUrl+'?id='+item.id).then(res => {
  246. console.log("结果数据9", res)
  247. if (res.data.success) {
  248. this.mescroll.resetUpScroll()
  249. }
  250. }).catch(e => {
  251. console.log("al delUrl请求错误2", e)
  252. this.mescroll.endErr();
  253. })
  254. },
  255. formatDate(text,len){
  256. if(!text || text.length==0){
  257. return ''
  258. }
  259. if(text.length<len){
  260. return text;
  261. }
  262. return text.substr(0,len)
  263. },
  264. titleFilter(text,len){
  265. if(!text || text.length==0){
  266. return ''
  267. }
  268. if(text.length<len){
  269. return text;
  270. }
  271. return text.substr(0,len)+"..."
  272. }
  273. }
  274. }
  275. </script>
  276. <style scoped>
  277. .e-btn{margin-bottom: 1rem;}
  278. .titlePad{margin-top:0.6rem;}
  279. .cu-list>.move-cur{
  280. transform: translateX(-150rpx);
  281. }
  282. .nav .cu-item.cur {
  283. position: flex;
  284. z-index: 9;
  285. border-bottom: 4upx solid;
  286. }
  287. </style>