myMessage.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. 'uid': this.user.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. background: #EFEFEF;
  143. }
  144. .tab_head {
  145. position: fixed;
  146. width: 100%;
  147. top: 0.4rem;
  148. z-index: 110;
  149. }
  150. .detail {
  151. background: #EFEFEF;
  152. }
  153. .detailBox {
  154. background: #fff;
  155. margin-bottom: 0.11rem;
  156. }
  157. .recordBox {
  158. margin: 0.12rem 0 0 0;
  159. }
  160. .one_recordBox {
  161. padding: 0.12rem 0.2rem;
  162. }
  163. .record_head {
  164. color: #5FA1F0;
  165. padding: 0 0 0.1rem 0;
  166. border-bottom: 1px solid #ccc;
  167. }
  168. .record_head > div {
  169. width: 100%;
  170. display: inline-block;
  171. vertical-align: middle;
  172. }
  173. .record_head span {
  174. color: #939393;
  175. float: right;
  176. vertical-align: middle;
  177. }
  178. .record_body {
  179. color: #777;
  180. font-size: 0.12rem;
  181. line-height: 0.23rem;
  182. margin-top: 0.12rem;
  183. }
  184. .noList {
  185. text-align: center;
  186. padding: 1.5rem 0;
  187. }
  188. .noList img {
  189. width: 1.2rem;
  190. height: 1.2rem;
  191. }
  192. .order {
  193. height: 0.6rem;
  194. line-height: 0.6rem;
  195. text-align: center;
  196. }
  197. .order .line {
  198. display: inline-block;
  199. width: 1.2rem;
  200. border-top: 1px solid #ccc ;
  201. vertical-align: middle;
  202. }
  203. .order .txt {
  204. color: #ccc;
  205. font-size: 0.13rem;
  206. vertical-align: middle;
  207. }
  208. </style>