index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div>
  3. <van-nav-bar title="消息记录" left-text="返回" @click-left="back" fixed left-arrow/>
  4. <div class="login_form">
  5. <van-list v-model="loading" :finished="finished" finished-text="没有更多了" :error.sync="error" error-text="请求失败,点击重新加载" @load="getMessage">
  6. <van-cell @click="readMsg(index)" v-for="(item,index) in list" :key="index"
  7. :title="item.msg==null?msgType[item.type]:item.msg" :label="item.time.replace('T', ' ')" >
  8. <div >
  9. <span v-if="item.checked == 1" style="color:green">已读</span>
  10. <span v-if="item.checked == 0" style="color:red">未读</span>
  11. </div>
  12. </van-cell>
  13. </van-list>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. msgType:["日报审核未通过","有新任务"],
  22. user: JSON.parse(localStorage.userInfo),
  23. total: 0,
  24. page: 1,
  25. size: 20,
  26. list: [],
  27. loading: false,
  28. finished: false,
  29. error: false,
  30. refreshing: false,
  31. show: false,
  32. title: "标题",
  33. };
  34. },
  35. created() {
  36. },
  37. methods: {
  38. // 返回
  39. back() {
  40. history.back();
  41. },
  42. readMsg(index) {
  43. var item = this.list[index];
  44. if (item.type == 0) {
  45. //日报
  46. var date = item.content;
  47. this.$axios.post("/information/check", {id:item.id
  48. })
  49. .then(res => {
  50. if(res.code == "ok") {
  51. //跳转到对应的日报上进行修改
  52. this.getMessage();
  53. this.$router.push('/edit?date='+date);
  54. }
  55. }).catch(err=> {this.$toast.clear();});
  56. } else {
  57. var date = item.content;
  58. this.$axios.post("/information/check", {id:item.id
  59. })
  60. .then(res => {
  61. if(res.code == "ok") {
  62. this.getMessage()
  63. }
  64. }).catch(err=> {this.$toast.clear();});
  65. }
  66. },
  67. //获取消息
  68. getMessage() {
  69. if (this.refreshing) {
  70. this.list = [];
  71. this.refreshing = false;
  72. }
  73. if(this.total == this.list.length && this.list.length != 0) {
  74. this.loading = false;
  75. this.finished = true;
  76. return false;
  77. }
  78. this.$axios.post("/information/list", {
  79. })
  80. .then(res => {
  81. if(res.code == "ok") {
  82. this.loading = false;
  83. this.finished = true;
  84. this.list = res.data;
  85. } else {
  86. this.$toast.fail('获取失败');
  87. }
  88. }).catch(err=> {this.$toast.clear();});
  89. },
  90. onRefresh() {
  91. this.finished = false;
  92. this.loading = true;
  93. this.page = 1;
  94. this.getMessage();
  95. },
  96. },
  97. mounted() {
  98. }
  99. };
  100. </script>
  101. <style lang="less" scoped>
  102. .van-cell__title {
  103. min-width: 90%;
  104. }
  105. .login_form {
  106. margin-top: 46px;
  107. }
  108. .one_report {
  109. margin-bottom: 15px;
  110. }
  111. .form_text {
  112. margin: 15px 0 30px;
  113. padding: 0 12px;
  114. }
  115. .form_btn {
  116. text-align: right;
  117. }
  118. .form_btn button {
  119. margin-left: 10px;
  120. }
  121. .one_report_data {
  122. margin-bottom: 20px;
  123. padding: 0 22px;
  124. div {
  125. line-height: 30px;
  126. }
  127. }
  128. .userCheckbox {
  129. padding: 10px;;
  130. }
  131. </style>
  132. <style lang="less">
  133. .van-nav-bar .van-icon , .van-nav-bar__text {
  134. color: #20a0ff;
  135. }
  136. </style>