customerList.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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>¥{{ Number(item.settleAmount)?Number(item.settleAmount).toFixed(2):'0.00' }}</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. uni.showLoading({
  78. title:'加载中',
  79. mask:true
  80. })
  81. queryCustomerPage(params).then(res => {
  82. if (res.status == 200) {
  83. if (this.pageNo > 1) {
  84. this.listData = this.listData.concat(res.data.list || []);
  85. } else {
  86. this.listData = res.data.list || [];
  87. }
  88. this.totalNum = res.data.count || 0;
  89. if (this.listData.length == res.data.count) {
  90. this.status = 'nomore'
  91. } else {
  92. this.status = 'loadmore'
  93. }
  94. } else {
  95. this.status = 'loadmore'
  96. this.listData = []
  97. this.totalNum = 0
  98. this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  99. }
  100. uni.hideLoading();
  101. this.noDataText = '暂无客户'
  102. this.scrollTop = 0;
  103. });
  104. },
  105. // scroll-view到底部加载更多
  106. onreachBottom() {
  107. if (this.listData.length < this.totalNum) {
  108. this.pageNo += 1;
  109. this.getList();
  110. }else{
  111. this.status = "nomore"
  112. }
  113. },
  114. getDetail(data) {
  115. if(uni.getStorageSync('curTab')){
  116. uni.$emit('customerInfo',data.customer);
  117. uni.navigateBack();
  118. }else{
  119. uni.navigateTo({
  120. url: '/pages/sales/bill?data=' + encodeURIComponent(JSON.stringify(data.customer))
  121. })
  122. }
  123. }
  124. }
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .sales-list-component {
  129. .sales-list-con {
  130. .customer-list {
  131. padding: 20rpx;
  132. border-bottom: 1rpx solid #f8f8f8;
  133. }
  134. .customer-b {
  135. margin-top: 10rpx;
  136. color: #666;
  137. font-size: 26rpx;
  138. .customer-box {
  139. width: 46%;
  140. text {
  141. &:last-child {
  142. color: $uni-color-warning;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. </style>