myMessage.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div class="detail">
  3. <mt-header class="detail_head" fixed title="我的消息">
  4. <router-link to="" slot="left">
  5. <mt-button icon="back" v-on:click="jumpBack()"></mt-button>
  6. </router-link>
  7. </mt-header>
  8. <div class="detail_body">
  9. <div class="noList" v-if="list.length==0">
  10. <img src="../../assets/image/noList.png">
  11. </div>
  12. <ul v-else class="recordBox" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10">
  13. <li v-for="item in list" class="one_recordBox detailBox">
  14. <div class="record_head">
  15. <div>{{item.content}}</div>
  16. </div>
  17. <div class="record_body">
  18. <div>时间:{{item.indate}}</div>
  19. </div>
  20. </li>
  21. <div class="order" v-if="haveMore">
  22. <span class="line"></span>
  23. <span class="txt">没有更多了</span>
  24. <span class="line"></span>
  25. </div>
  26. </ul>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. user: JSON.parse(sessionStorage.getItem("user")),
  35. list: [],
  36. pageNum: 1,
  37. pages: 1,
  38. haveMore: false,
  39. }
  40. },
  41. methods: {
  42. // 消息列表
  43. getList() {
  44. this.$indicator.open();
  45. this.http.post(this.port.my.newList, {
  46. 'uid': this.user.id,
  47. 'pageNum': 1
  48. } ,
  49. res => {
  50. this.$indicator.close();
  51. if (res.code == "ok") {
  52. this.list = res.data.list;
  53. this.pages = res.data.pages==0?1:res.data.pages;
  54. } else {
  55. this.$toast({
  56. message: res.msg,
  57. duration: 2000
  58. });
  59. }
  60. }, error => {
  61. this.$indicator.close();
  62. this.$toast({
  63. message: error,
  64. duration: 2000
  65. });
  66. })
  67. },
  68. loadMore() {
  69. if(this.pageNum == this.pages) {
  70. this.haveMore = true;
  71. } else if(this.pageNum < this.pages) {
  72. this.$indicator.open();
  73. this.http.post(this.port.my.newList, {
  74. 'id': this.id,
  75. 'pageNum': ++this.pageNum
  76. } ,
  77. res => {
  78. this.$indicator.close();
  79. if (res.code == "ok") {
  80. this.pages = res.data.pages==0?1:res.data.pages;
  81. if(res.data.list.length != 0) {
  82. for(var i in res.data.list) {
  83. this.list.push(res.data.list[i]);
  84. }
  85. }
  86. } else {
  87. this.$toast({
  88. message: res.msg,
  89. duration: 2000
  90. });
  91. }
  92. }, error => {
  93. this.$indicator.close();
  94. this.$toast({
  95. message: error,
  96. duration: 2000
  97. });
  98. })
  99. }
  100. },
  101. jumpBack() {
  102. this.http.post(this.port.my.noReadNum, {
  103. 'uid': this.user.id,
  104. } ,
  105. res => {
  106. if (res.code == "ok") {
  107. sessionStorage.setItem('noRead', res.data==null?0:res.data);
  108. this.$router.go(-1);
  109. } else {
  110. this.$toast({
  111. message: res.msg,
  112. duration: 2000
  113. });
  114. }
  115. }, error => {
  116. this.$toast({
  117. message: error,
  118. duration: 2000
  119. });
  120. })
  121. }
  122. },
  123. created() {
  124. this.getList();
  125. },
  126. mounted() {
  127. }
  128. }
  129. </script>
  130. <style scoped>
  131. body {
  132. background: #EFEFEF;
  133. }
  134. .detail_head {
  135. background: #fff;
  136. color: #333;
  137. height: 0.4rem;
  138. }
  139. .detail_body {
  140. margin-top: 0.4rem;
  141. padding-bottom: 0.15rem;
  142. }
  143. .tab_head {
  144. position: fixed;
  145. width: 100%;
  146. top: 0.4rem;
  147. z-index: 110;
  148. }
  149. .detail {
  150. background: #EFEFEF;
  151. }
  152. .detailBox {
  153. background: #fff;
  154. margin-bottom: 0.11rem;
  155. }
  156. .recordBox {
  157. margin: 0.12rem 0 0 0;
  158. }
  159. .one_recordBox {
  160. padding: 0.12rem 0.2rem;
  161. }
  162. .record_head {
  163. color: #5FA1F0;
  164. padding: 0 0 0.1rem 0;
  165. border-bottom: 1px solid #ccc;
  166. }
  167. .record_head > div {
  168. width: 100%;
  169. display: inline-block;
  170. vertical-align: middle;
  171. }
  172. .record_head span {
  173. color: #939393;
  174. float: right;
  175. vertical-align: middle;
  176. }
  177. .record_body {
  178. color: #777;
  179. font-size: 0.12rem;
  180. line-height: 0.23rem;
  181. margin-top: 0.12rem;
  182. }
  183. .noList {
  184. text-align: center;
  185. padding: 1.5rem 0;
  186. }
  187. .noList img {
  188. width: 1.2rem;
  189. height: 1.2rem;
  190. }
  191. .order {
  192. height: 0.6rem;
  193. line-height: 0.6rem;
  194. text-align: center;
  195. }
  196. .order .line {
  197. display: inline-block;
  198. width: 1.2rem;
  199. border-top: 1px solid #ccc ;
  200. vertical-align: middle;
  201. }
  202. .order .txt {
  203. color: #ccc;
  204. font-size: 0.13rem;
  205. vertical-align: middle;
  206. }
  207. </style>