messageList.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="jz_messageItem uni-flex uni-column align-items">
  3. <view class="uni-flex" v-for="(mess,key) in messages" :key="key" @click="goMessage(mess)">
  4. <view v-if="mess.mode==0" class="list_item uni-flex uni-column align-items">
  5. <view class="item_time uni-flex justify-align-center">{{mess.createDate}}</view>
  6. <view class="item_content uni-flex uni-column">
  7. <view class="content_title uni-flex space-between align-items">
  8. <view>{{mess.title}}</view>
  9. <image class="activeimg" src="../../../static/message/noactive.png" v-if="mess.state==1"></image>
  10. <image class="activeimg" src="../../../static/message/active.png" v-if="mess.state==0" ></image>
  11. </view>
  12. <view class="conten_detail">{{mess.intro}}</view>
  13. </view>
  14. </view>
  15. <view v-if="mess.mode==1" class="list_item uni-flex uni-column align-items">
  16. <view class="item_time uni-flex justify-align-center">{{mess.createDate}}</view>
  17. <view class="item_content uni-flex uni-column">
  18. <view class="content_title uni-flex space-between align-items">
  19. <view>{{mess.title}}</view>
  20. <image class="activeimg" src="../../../static/message/noactive.png" v-if="mess.state==1"></image>
  21. <image class="activeimg" src="../../../static/message/active.png" v-if="mess.state==0" ></image>
  22. </view>
  23. <image :src="mess.pic"></image>
  24. <view class="conten_detail">{{mess.intro}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. mapState,
  34. mapMutations
  35. } from 'vuex'
  36. import loadMore from '@/components/uni-load-more.vue';
  37. var index;
  38. export default {
  39. data() {
  40. return {
  41. loadingType: 0,
  42. contentText: {
  43. contentdown: "上拉显示更多",
  44. contentrefresh: "正在加载...",
  45. contentnomore: "没有更多数据了"
  46. },
  47. user: {},
  48. messages: [],
  49. module: 0
  50. }
  51. },
  52. computed: {
  53. ...mapState(['hasLogin', 'jyyUser'])
  54. },
  55. onLoad(e) {
  56. index = 1;
  57. this.module = e.module;
  58. if (!this.hasLogin) {
  59. uni.navigateTo({
  60. url: '../login/login',
  61. });
  62. } else {
  63. this.user = JSON.parse(this.jyyUser);
  64. this.getData();
  65. }
  66. },
  67. onReachBottom() {
  68. this.getData();
  69. },
  70. components: {
  71. loadMore
  72. },
  73. methods: {
  74. goMessage(e) {
  75. uni.navigateTo({
  76. url: 'messageView?id=' + e.id+ '&userid=' + this.user.id
  77. })
  78. },
  79. getData() {
  80. if (this.loadingType !== 0) {
  81. return;
  82. }
  83. this.loadingType = 1;
  84. uni.request({
  85. url: this.webUrl + 'GetMessageList',
  86. method: 'POST',
  87. data: {
  88. pageIndex: index,
  89. userid: this.user.id,
  90. module: this.module
  91. },
  92. header: {
  93. 'content-type': 'application/x-www-form-urlencoded'
  94. },
  95. success: res => {
  96. if (res.data.result.messages.length > 0) {
  97. this.messages = this.messages.concat(res.data.result.messages);
  98. } else {
  99. this.loadingType = 2;
  100. return;
  101. }
  102. if (index == parseInt(res.data.result.pages)) {
  103. this.loadingType = 2;
  104. return;
  105. } else {
  106. this.loadingType = 0;
  107. }
  108. index++;
  109. },
  110. fail: () => {},
  111. complete: () => {}
  112. });
  113. }
  114. }
  115. }
  116. </script>
  117. <style>
  118. </style>