messageList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view>
  3. <u-navbar :title="title" title-color="#101010" ></u-navbar>
  4. <view class="main" v-if="type=='aa'">
  5. <view class="item" v-for="(item,i) in list"
  6. @click="gotoUrl('/pages/deductionRecord/billPush?site=1&id='+item.id)"
  7. :key="i">
  8. <view class="item-message">
  9. <view>{{item.name}}</view>
  10. <view class="billAmount">¥{{item.billAmount}}元</view>
  11. </view>
  12. <view class="item-time">
  13. {{item.createTime}} <!-- {{item.tenantName}} -->
  14. </view>
  15. </view>
  16. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容"
  17. border-color="#CFD2D5">已经到底了</u-divider>
  18. </view>
  19. <view class="main" v-else >
  20. <view class="item" v-for="(item,i) in list" :key="i">
  21. <view class="item-message">
  22. <view>{{item.content}}</view>
  23. <view class="billAmount"></view>
  24. </view>
  25. <view class="item-time">
  26. {{item.createTime}} <!-- {{item.tenantName}} -->
  27. </view>
  28. </view>
  29. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容"
  30. border-color="#CFD2D5">已经到底了</u-divider>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import * as API from '@/apis/pagejs/message.js'
  36. export default {
  37. data() {
  38. return {
  39. type:0,
  40. formData:{
  41. pageIndex:1,
  42. pageSize:20,
  43. },
  44. list:[],
  45. recordsTotal:0
  46. }
  47. },
  48. computed:{
  49. title(){
  50. if(this.type=='AA'){
  51. return '账单提醒'
  52. }else if(this.type==5){
  53. return '停电通知'
  54. }else if(this.type==4){
  55. return '故障警报'
  56. }else if(this.type==3){
  57. return '断电通知'
  58. }else{
  59. return '消息提醒'
  60. }
  61. }
  62. },
  63. onLoad(op) {
  64. if(op.type){
  65. this.type=op.type;
  66. this.formData.type=op.type;
  67. }
  68. this.getList()
  69. },
  70. onReachBottom() {
  71. if (this.list.length < this.recordsTotal) {
  72. this.myLoadmore();
  73. }
  74. },
  75. methods: {
  76. getList(){
  77. if(this.type=='AA'){
  78. this.getBillList()
  79. }else{
  80. this.getMessageList()
  81. }
  82. },
  83. myLoadmore() {
  84. this.formData.pageIndex += 1;
  85. this.getList()
  86. },
  87. getMessageList(){
  88. uni.showLoading({
  89. mask:true,title:'加载中...'
  90. })
  91. API.messageList(this.formData).then((res) => {
  92. uni.hideLoading();
  93. if(this.formData.pageIndex==1){
  94. this.list = [
  95. ...res.data.data
  96. ];
  97. }else{
  98. this.list = [
  99. ...this.list,
  100. ...res.data.data
  101. ];
  102. }
  103. this.recordsTotal = res.data.recordsTotal;
  104. //this.list=response.data.data;
  105. }).catch(error => {
  106. uni.hideLoading();
  107. })
  108. },
  109. getBillList(){
  110. uni.showLoading({
  111. mask:true,title:'加载中...'
  112. })
  113. API.billList(this.formData).then((res) => {
  114. uni.hideLoading();
  115. if(this.formData.pageIndex==1){
  116. this.list = [
  117. ...res.data.data
  118. ];
  119. }else{
  120. this.list = [
  121. ...this.list,
  122. ...res.data.data
  123. ];
  124. }
  125. this.recordsTotal = res.data.recordsTotal;
  126. //this.list=response.data.data;
  127. }).catch(error => {
  128. uni.hideLoading();
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .main{
  136. background-color: #fff;
  137. margin-top: 24rpx;
  138. .item{
  139. padding: 32rpx;
  140. border-bottom: 1px solid rgba(244,244,244,1);
  141. .item-message{
  142. line-height: 44rpx;
  143. display: flex;
  144. justify-content: space-between;
  145. color: rgba(51,51,51,1);
  146. .billAmount{
  147. color: #F44336;
  148. }
  149. }
  150. .item-time{
  151. color: rgb(153,153,153);
  152. font-size: 24rpx;
  153. margin-top: 16rpx;
  154. }
  155. }
  156. }
  157. </style>