customer.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="customer-list">
  3. <view class="list-wrap">
  4. <u-sticky bgColor="#fff">
  5. <view class="search-wrap">
  6. <view class="input-wrap">
  7. <u-search
  8. bgColor='#fff'
  9. :showAction='false'
  10. :placeholder="$t('base.common.inputPlaceholder')"
  11. @search="searchList"
  12. @clear='searchList'
  13. v-model="keyword">
  14. </u-search>
  15. <view class="search-btn" @click="searchList">{{$t("customer_meter.search")}}</view>
  16. </view>
  17. <u-icon name="plus" size='22' @click="onClickRight"></u-icon>
  18. </view>
  19. </u-sticky>
  20. <u-sticky bgColor="#fff" offsetTop="54">
  21. <view class="tabs-wrap">
  22. <u-tabs :list="tablist" :current="active" @click="changeTab" lineColor="#4680F9">
  23. </u-tabs>
  24. </view>
  25. </u-sticky>
  26. <template v-if="customerList.length">
  27. <u-list @scrolltolower="scrolltolower">
  28. <u-list-item v-for="(item, index) in customerList" :key="index">
  29. <card :data="item"></card>
  30. </u-list-item>
  31. </u-list>
  32. </template>
  33. <template v-else>
  34. <u-empty
  35. mode="list"
  36. icon="https://cdn.uviewui.com/uview/empty/list.png"
  37. >
  38. </u-empty>
  39. </template>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import card from './card.vue'
  45. import {getCustomerList} from '../../api/customer'
  46. export default {
  47. data(){
  48. return {
  49. keyword:'',
  50. active:0,
  51. value:'',
  52. customerList:[],
  53. tablist:[{
  54. name:this.$t("customer_meter.all"),
  55. }, {
  56. name:this.$t("customer_meter.sale"),
  57. }, {
  58. name:this.$t("customer_meter.purchase")
  59. }],
  60. page: {
  61. pages: 1,
  62. size: 10,
  63. },
  64. total: 0,
  65. hasMore: true,
  66. }
  67. },
  68. components:{
  69. card
  70. },
  71. onLoad() {
  72. this.getCustomerList()
  73. },
  74. methods:{
  75. //加载更多
  76. scrolltolower() {
  77. console.log('1111111111');
  78. if (this.hasMore) {
  79. this.page.pages += 1;
  80. this.getCustomerList();
  81. }
  82. },
  83. //搜索列表
  84. searchList(){
  85. this.page.pages = 1
  86. this.hasMore = false
  87. this.getCustomerList()
  88. },
  89. getCustomerList(){
  90. let data = {
  91. current:this.page.pages,
  92. size:this.page.size,
  93. type:this.active == 0 ? '' : (this.active == 1 ? '102' : '104'),
  94. keywords:this.keyword || '' ,
  95. }
  96. getCustomerList(data).then(res=>{
  97. if(res.statusCode == 200 ){
  98. // this.customerList=res.data.data.records
  99. if (this.hasMore) {
  100. this.customerList = [
  101. ...this.customerList,
  102. ...res.data.data.records,
  103. ];
  104. }
  105. console.log(this.customerList);
  106. this.total = res.data.data.total;
  107. if (this.customerList.length >= this.total) {
  108. this.hasMore = false;
  109. } else {
  110. this.hasMore = true;
  111. }
  112. }
  113. })
  114. },
  115. onClickRight(){
  116. uni.navigateTo({ url: `/subpages/customer/add-edit` })
  117. },
  118. changeTab(item){
  119. if(item.index == this.active){
  120. return
  121. }else{
  122. this.keyword=''
  123. this.active = item.index;
  124. this.page.pages = 1
  125. this.hasMore = false
  126. this.getCustomerList()
  127. }
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="less" scoped>
  133. .customer-list{
  134. background: #fff;
  135. .list-wrap{
  136. // padding-top: 88rpx;
  137. .tabs-wrap{
  138. padding: 0 24rpx;
  139. background-color: #fff;
  140. }
  141. .search-wrap{
  142. padding: 20rpx 32rpx;
  143. background-color: #f2f2f2;
  144. display: flex;
  145. .input-wrap{
  146. flex: 1;
  147. display: flex;
  148. background-color: #fff;
  149. border-radius: 100rpx;
  150. align-items: center;
  151. margin-right: 20rpx;
  152. .search-btn{
  153. align-items: center;
  154. margin-right: 32rpx;
  155. padding-left: 20rpx;
  156. height: 44rpx;
  157. line-height: 44rpx;
  158. color: #4680F9;
  159. border-left: 1px solid #9fc4ff;
  160. }
  161. }
  162. }
  163. }
  164. }
  165. // /deep/ .u-search{
  166. // }
  167. /deep/ .u-empty{
  168. background-color: #fff;
  169. }
  170. </style>