customerList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="sales-list-component">
  3. <scroll-view class="sales-list-con" :scroll-top="scrollTop" :style="{ height: scrollH + 'px' }" scroll-y @scrolltolower="onreachBottom">
  4. <view class="customer-list" v-for="(item, i) in listData" :key="i" @click="getDetail(item)">
  5. <view class="u-line-1">{{ item.customer.customerName }}</view>
  6. <view class="customer-b u-flex">
  7. <view class="customer-box">
  8. <text>欠款:</text>
  9. <text>¥{{ item.settleAmount || 0 }}</text>
  10. </view>
  11. <view class="customer-box">收款方式:{{ item.customer.settleStyleSnDictValue || '--' }}</view>
  12. </view>
  13. </view>
  14. <view v-if="listData && listData.length == 0"><u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" :text="noDataText" mode="list" :margin-top="100"></u-empty></view>
  15. <view style="padding:20upx 0;"><u-loadmore v-if="totalNum > listData.length || status == 'loading'" :status="status" /></view>
  16. </scroll-view>
  17. </view>
  18. </template>
  19. <script>
  20. import { queryCustomerPage } from '@/api/verify.js';
  21. export default {
  22. props: {
  23. height: {
  24. // 滚动区域高度 upx
  25. type: [String, Number],
  26. default: 300
  27. },
  28. params: {
  29. // 列表查询条件
  30. type: Object,
  31. default: () => {
  32. return {};
  33. }
  34. }
  35. },
  36. data() {
  37. return {
  38. listData: [],
  39. pageNo: 1,
  40. pageSize: 15,
  41. totalNum: 0,
  42. status: 'loadmore',
  43. noDataText: '暂无数据',
  44. dataInfo: null,
  45. scrollH: 300,
  46. scrollTop:0
  47. };
  48. },
  49. watch: {
  50. height(a, b) {
  51. const sys = uni.getSystemInfoSync();
  52. if (sys.platform == 'android') {
  53. this.scrollH = sys.windowHeight - a;
  54. } else {
  55. if (sys.safeArea.top) {
  56. this.scrollH = sys.windowHeight - a + sys.statusBarHeight - 34;
  57. } else {
  58. this.scrollH = sys.windowHeight - a - 14;
  59. }
  60. }
  61. }
  62. },
  63. methods: {
  64. refash() {
  65. this.listData = [];
  66. this.totalNum = 0;
  67. this.getList(1);
  68. },
  69. // 列表
  70. getList(pageNo) {
  71. const _this = this;
  72. if (pageNo) {
  73. this.pageNo = pageNo;
  74. }
  75. let params = Object.assign(this.params, { pageNo: this.pageNo, pageSize: this.pageSize });
  76. this.status = 'loading';
  77. queryCustomerPage(params).then(res => {
  78. if (res.status == 200) {
  79. if (this.pageNo > 1) {
  80. this.listData = this.listData.concat(res.data.list || []);
  81. } else {
  82. this.listData = res.data.list || [];
  83. }
  84. this.totalNum = res.data.count || 0;
  85. if (this.listData.length == res.data.count) {
  86. this.status = 'nomore'
  87. } else {
  88. this.status = 'loadmore'
  89. }
  90. } else {
  91. this.status = 'loadmore'
  92. this.listData = []
  93. this.totalNum = 0
  94. this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  95. }
  96. this.noDataText = '暂无客户'
  97. this.scrollTop = 0;
  98. });
  99. },
  100. // scroll-view到底部加载更多
  101. onreachBottom() {
  102. if (this.listData.length < this.totalNum) {
  103. this.pageNo += 1;
  104. this.getList();
  105. }else{
  106. this.status = "nomore"
  107. }
  108. },
  109. getDetail(data) {
  110. if(uni.getStorageSync('curTab')){
  111. uni.$emit('customerInfo',data.customer);
  112. uni.navigateBack();
  113. }else{
  114. uni.navigateTo({
  115. url: '/pages/sales/bill?data=' + JSON.stringify(data.customer)
  116. })
  117. }
  118. }
  119. }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. .sales-list-component {
  124. .sales-list-con {
  125. .customer-list {
  126. padding: 20rpx;
  127. border-bottom: 1rpx solid #f8f8f8;
  128. }
  129. .customer-b {
  130. margin-top: 10rpx;
  131. color: #666;
  132. font-size: 26rpx;
  133. .customer-box {
  134. width: 46%;
  135. text {
  136. &:last-child {
  137. color: $uni-color-warning;
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. </style>