index.vue 5.6 KB

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