list.vue 7.4 KB

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