list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view>
  3. <!-- <u-navbar
  4. :customBack="customBack"
  5. back-icon-color="#fff"
  6. title="客户列表"
  7. :background="{ backgroundColor: '#2080f0' }"
  8. title-color="#fff"
  9. :border-bottom="false"
  10. ></u-navbar> -->
  11. <!-- 顶部筛选栏 -->
  12. <!-- <HM-filterDropdown :menuTop="menuTop" :filterData="filterData" :defaultSelected="filterDropdownValue" @confirm="confirmFilter"></HM-filterDropdown> -->
  13. <view class="customer-list-wrap">
  14. <view v-if="customerList.length == 0" class="empty-wrap"><u-empty mode="list" text="暂无相关客户"></u-empty></view>
  15. <view v-for="(item, index) in customerList" class="customer-item" :key="index">
  16. <view class="info">
  17. <view class="customer">
  18. <view class="relname">
  19. {{ item.name }}
  20. <u-icon
  21. class="u-m-l-5"
  22. :name="item.sex == 'male' ? 'man' : 'woman'"
  23. size="22"
  24. :color="item.sex == 'male' ? '#2080f0' : '#f85f69'"
  25. ></u-icon>
  26. <u-icon
  27. name="attach"
  28. size="32"
  29. label="快速报备"
  30. label-size="24"
  31. class="u-m-l-20"
  32. @click="pageTo('/pages/agent/recommend/create', { info: item })"
  33. ></u-icon>
  34. </view>
  35. <view class="item">
  36. <u-icon class="u-m-r-5" name="phone" size="22"></u-icon>
  37. {{ item.phone }}
  38. </view>
  39. <view class="item" v-if="item.demand">
  40. {{ item.demand }}
  41. </view>
  42. </view>
  43. <view class="data-wrap">
  44. <u-tag
  45. icon="edit-pen"
  46. :text="'编辑'"
  47. :type="'primary'"
  48. class="u-m-r-10"
  49. @click="pageTo('/pages/cust/create', { info: item })"
  50. >
  51. </u-tag>
  52. <view class="u-m-t-20">
  53. <u-tag
  54. @click="delHandle(item)"
  55. plain
  56. :text="'删除'"
  57. :type="'error'"
  58. class="u-m-r-10"
  59. >
  60. </u-tag>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="float-search2" @click="pageTo('/pages/cust/create')"><u-icon name="plus" size="42" color="#fff"></u-icon></view>
  67. <view class="float-search" @click="searchPopupShow = true"><u-icon name="search" size="42" color="#fff"></u-icon></view>
  68. <u-popup v-model="searchPopupShow" mode="center" width="80%" height="440rpx" border-radius="20">
  69. <view class="bwin-popup">
  70. <view class="popup-header">客户搜索</view>
  71. <view class="popup-body">
  72. <u-input v-model="searchFormData.name" border placeholder="请输入客户姓名(支持模糊搜索)"></u-input>
  73. <u-divider marginTop="10" marginBottom="10">或</u-divider>
  74. <u-input v-model="searchFormData.phone" border placeholder="请输入客户手机号(可仅输入一部分)"></u-input>
  75. </view>
  76. <view class="popup-footer" style="position: absolute;">
  77. <u-button size="medium" @click="searchPopupShow = false">取消</u-button>
  78. <u-button size="medium" type="primary" @click="searchHandle()">搜索</u-button>
  79. </view>
  80. </view>
  81. </u-popup>
  82. <u-loadmore
  83. v-if="customerList.length > 0"
  84. marginTop="32"
  85. :line="true"
  86. :status="loadmore.status"
  87. :loading-text="loadmore.loadingText"
  88. :loadmore-text="loadmore.defaultText"
  89. :nomore-text="loadmore.nomoreText"
  90. />
  91. </view>
  92. </template>
  93. <script>
  94. var that;
  95. export default {
  96. data() {
  97. return {
  98. searchKeyword: null,
  99. searchPopupShow: false,
  100. searchFormData: {
  101. name: '',
  102. phone: ''
  103. }, // 搜索栏数据
  104. customerList: [],
  105. loadmore: {
  106. status: 'loadmore',
  107. loadingText: '努力加载中',
  108. defaultText: '轻轻上拉 查看更多',
  109. nomoreText: '实在没有了',
  110. currnetPage: 1
  111. }
  112. };
  113. },
  114. onLoad(params) {
  115. that = this;
  116. // 默认筛选项
  117. if (params.filterStepStatus !== undefined) {
  118. that.filterStepStatus = parseInt(params.filterStepStatus);
  119. this.filterDropdownValue = [[],[],[],[that.filterStepStatus],[]]
  120. }
  121. this.getDataList()
  122. },
  123. onReachBottom() {
  124. if (that.loadmore.status == 'nomore') return;
  125. that.loadmore.currnetPage++
  126. this.getDataList()
  127. },
  128. onPullDownRefresh() {
  129. // 防止频繁刷新
  130. },
  131. methods: {
  132. delHandle (item) {
  133. uni.$msgConfirm('确定删除吗?', () => {
  134. uni.api.cust.apicustomerdel({
  135. id: item.id
  136. }).then(res => {
  137. uni.$msg('删除成功~')
  138. this.loadmore.currnetPage = 1
  139. this.getDataList()
  140. })
  141. })
  142. },
  143. getDataList (bc) {
  144. const that = this
  145. let params = {
  146. ...this.searchFormData
  147. }
  148. uni.api.cust.apicustomerlist({
  149. page: that.loadmore.currnetPage,
  150. ...params,
  151. }).then(res => {
  152. const list = res.list || []
  153. if (list.length < 10) {
  154. that.loadmore.status = 'nomore';
  155. }
  156. if (res.page = 1) {
  157. if (list.length == 0) {
  158. uni.$msg('无搜索结果', 'none');
  159. }
  160. that.customerList = [...list]
  161. } else {
  162. that.customerList = that.customerList.concat(list)
  163. }
  164. if (bc) bc()
  165. })
  166. },
  167. customBack() {
  168. uni.navigateBack();
  169. },
  170. // 带监听器跳转
  171. pageTo(url, data) {
  172. /// xxxxx
  173. uni.navigateTo({
  174. url: url,
  175. events: {
  176. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  177. update: function(data) {
  178. // 当B页面运行 eventChannel.emit('update', { a:1 }); 时,会运行这里的代码逻辑。
  179. }
  180. },
  181. success: function(res) {
  182. // 通过eventChannel向被打开页面传送数据
  183. res.eventChannel.emit('data', data);
  184. }
  185. });
  186. },
  187. searchHandle() {
  188. that.loadmore.currnetPage = 1
  189. this.getDataList(() => {
  190. this.searchPopupShow = false
  191. })
  192. },
  193. }
  194. };
  195. </script>
  196. <style lang="scss">
  197. .search-wrap {
  198. padding: 20rpx;
  199. }
  200. .filter-wrap {
  201. position: relative;
  202. }
  203. // 列表
  204. .customer-list-wrap {
  205. width: 100%;
  206. .customer-item {
  207. display: flex;
  208. flex-direction: column;
  209. align-items: flex-start;
  210. font-size: $u-p2;
  211. color: $u-content-color;
  212. border-bottom: 1rpx solid $u-border-color;
  213. padding: 24rpx 32rpx;
  214. .info {
  215. display: flex;
  216. align-items: flex-start;
  217. justify-content: space-between;
  218. width: 100%;
  219. margin-bottom: 10rpx;
  220. .customer {
  221. display: flex;
  222. flex-direction: column;
  223. align-items: flex-start;
  224. .relname {
  225. color: $u-main-color;
  226. font-size: $u-p;
  227. font-weight: bold;
  228. margin-bottom: 10rpx;
  229. }
  230. .item {
  231. margin-bottom: 10rpx;
  232. }
  233. }
  234. .data-wrap {
  235. text-align: right;
  236. .date {
  237. font-size: $u-sub;
  238. }
  239. }
  240. }
  241. .tool-wrap {
  242. display: flex;
  243. align-items: center;
  244. justify-content: space-between;
  245. width: 100%;
  246. }
  247. }
  248. }
  249. .float-search {
  250. opacity: 0.9;
  251. position: fixed;
  252. right: 20rpx;
  253. bottom: 40rpx;
  254. padding: 20rpx;
  255. border-radius: 50%;
  256. background-color: $u-theme-color;
  257. }
  258. .float-search2 {
  259. opacity: 0.9;
  260. position: fixed;
  261. right: 20rpx;
  262. bottom: 150rpx;
  263. padding: 20rpx;
  264. border-radius: 50%;
  265. background-color: $u-theme-color;
  266. }
  267. </style>