index.vue 4.9 KB

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