customer.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="search-box">
  3. <up-search placeholder="搜索关键词" v-model="keyword" height="35" @blur="onSearch" :clearabled="false"
  4. :showAction="false" />
  5. <view v-if="content.where.condition" class="clear" @click.stop="onSearch('')">
  6. <up-icon name="close-circle-fill" size="20" />
  7. </view>
  8. </view>
  9. <view style="height: 20rpx; " />
  10. <My_listbox ref="listBox" :empty="!list.length" @getlist="getList">
  11. <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.sa_customersid"
  12. @click="selected(item)">
  13. <view class="content">
  14. <view class="row">
  15. <text class="label">
  16. 姓名
  17. </text>
  18. {{ item.name || ' --' }}
  19. </view>
  20. <view class="row">
  21. <text class="label">
  22. 电话
  23. </text>
  24. {{ item.phonenumber || ' --' }}
  25. </view>
  26. <view class="row">
  27. <text class="label">
  28. 省市县
  29. </text>
  30. {{ item.province ? item.province + item.city + item.county : ' --' }}
  31. </view>
  32. <view class="row">
  33. <text class="label">
  34. 地址
  35. </text>
  36. {{ item.address || ' --' }}
  37. </view>
  38. <view class="row">
  39. <text class="label">
  40. 创建日期
  41. </text>
  42. {{ item.createdate || ' --' }}
  43. </view>
  44. </view>
  45. </view>
  46. <view style="height: 30px;" />
  47. </My_listbox>
  48. </template>
  49. <script setup>
  50. import { ref, reactive, getCurrentInstance } from 'vue';
  51. const { $Http } = getCurrentInstance().proxy;
  52. import { onLoad } from '@dcloudio/uni-app';
  53. const keyword = ref('');
  54. const listBox = ref(null);
  55. const content = reactive({
  56. loading: false,
  57. "pageNumber": 1,
  58. "pageSize": 20,
  59. "where": {
  60. "condition": ""
  61. }
  62. });
  63. function onSearch(e) {
  64. if (content.where.condition == e) return;
  65. content.where.condition = e;
  66. keyword.value = e;
  67. getList(true);
  68. }
  69. const list = ref([])
  70. onLoad(() => {
  71. getList();
  72. });
  73. function getList(init = false) {
  74. if (content.loading) {
  75. listBox.value.refreshToComplete();
  76. listBox.value.setHeight();
  77. return
  78. };
  79. content.loading = true;
  80. if (init) content.pageNumber = 1;
  81. $Http.basic({
  82. "id": "2025090909115603",
  83. content
  84. }).then(res => {
  85. content.loading = false;
  86. if (res.code != 1) return uni.showToast({
  87. title: res.msg,
  88. icon: 'none'
  89. });
  90. console.log("获取客户档案列表", res)
  91. listBox.value.refreshToComplete();
  92. listBox.value.setHeight();
  93. if (res.code == 1) {
  94. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  95. content.pageTotal = res.pageTotal;
  96. content.pageNumber = res.pageNumber;
  97. } else {
  98. if (res.msg) uni.showToast({
  99. title: res.msg,
  100. icon: 'none'
  101. });
  102. }
  103. })
  104. }
  105. function selected(item) {
  106. $Http.onSelected && $Http.onSelected(item)
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .search-box {
  111. position: relative;
  112. padding: 20rpx;
  113. background: #fff;
  114. .clear {
  115. position: absolute;
  116. display: flex;
  117. align-items: center;
  118. right: 0;
  119. top: 50%;
  120. transform: translateY(-50%);
  121. width: 80rpx;
  122. padding-left: 10rpx;
  123. height: 70rpx;
  124. z-index: 2;
  125. }
  126. }
  127. .item {
  128. position: relative;
  129. display: flex;
  130. width: 95%;
  131. box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
  132. border-radius: 10rpx;
  133. box-sizing: border-box;
  134. padding: 20rpx 30rpx;
  135. overflow: hidden;
  136. margin: 0 auto 20rpx;
  137. background: #fff;
  138. .content {
  139. margin-left: 20rpx;
  140. .row {
  141. display: flex;
  142. line-height: 32rpx;
  143. font-family: Microsoft YaHei, Microsoft YaHei;
  144. font-size: 24rpx;
  145. margin-top: 8rpx;
  146. .label {
  147. color: #666;
  148. flex-shrink: 0;
  149. }
  150. .label::after {
  151. content: ':';
  152. }
  153. }
  154. }
  155. }
  156. </style>