list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="app-container">
  3. <view class="list-container">
  4. <block v-for="(item, index) in customerList" :key='index'>
  5. <view class="item">
  6. <view class="row">客户姓名:{{item.nickName}}</view>
  7. <view class="row">客户电话:{{item.mobile}}</view>
  8. <view class="row">加入时间:{{item.serviceTime ? (item.serviceTime | dateToYYmmdd) : ''}}</view>
  9. <view class="row">最近访问时间:{{item.lastAccessTime || ''}}</view>
  10. <view class="title">客户标签</view>
  11. <view class="tags" @tap="toChooseTag(item.unionId)">
  12. <view class="left" v-if="item.allTags && item.allTags.length > 0">
  13. <block v-for="(it, idx) in item.allTags" :key='idx'>
  14. <text>{{it.tagName}}</text>
  15. </block>
  16. </view>
  17. <view class="no" v-else>添加标签</view>
  18. <image src="@/static/icon/right.png"></image>
  19. </view>
  20. </view>
  21. </block>
  22. </view>
  23. <no-data v-if="!customerList.length" :showText="'暂无客户'"></no-data>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState
  29. } from 'vuex';
  30. export default {
  31. data() {
  32. return {
  33. customerList: [],
  34. }
  35. },
  36. computed: {
  37. ...mapState(['userInfo', 'isLogin', 'userId'])
  38. },
  39. onLoad() {
  40. this.getCustomerList();
  41. uni.$on('refreshCustomerData', () => {
  42. this.getCustomerList();
  43. })
  44. },
  45. // 下拉刷新
  46. onPullDownRefresh() {
  47. this.getCustomerList();
  48. },
  49. methods: {
  50. // 获取客户列表
  51. getCustomerList() {
  52. this.$axios({
  53. url: '/user/customer',
  54. method: 'get',
  55. params: {
  56. userId: this.userId,
  57. pageNum: 1,
  58. pageSize: -1
  59. },
  60. }).then(res => {
  61. if (res.data && res.data.length > 0) {
  62. res.data.forEach(item => {
  63. item.allTags = item.tags.concat(item.customtags);
  64. })
  65. }
  66. this.customerList = res.data || [];
  67. uni.stopPullDownRefresh();
  68. })
  69. },
  70. // 去选择标签
  71. toChooseTag(unionId) {
  72. uni.navigateTo({
  73. url: '/pages/mine/customer/tag?unionId=' + unionId
  74. })
  75. },
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .app-container {
  81. background: #F4F2F2;
  82. box-sizing: border-box;
  83. }
  84. .list-container {
  85. padding: 20rpx;
  86. .item {
  87. background: #FFFFFF;
  88. margin-bottom: 20rpx;
  89. border-radius: 20rpx;
  90. padding: 20rpx;
  91. font-size: 28rpx;
  92. display: flex;
  93. flex-direction: column;
  94. box-sizing: border-box;
  95. .row {
  96. margin-bottom: 10rpx;
  97. }
  98. .title {
  99. margin-top: 10rpx;
  100. }
  101. .tags {
  102. margin-top: 8rpx;
  103. padding: 16rpx 20rpx 6rpx;
  104. border-radius: 10rpx;
  105. background: #F1F1F1;
  106. display: flex;
  107. align-items: center;
  108. justify-content: space-between;
  109. .left {
  110. text {
  111. display: inline-block;
  112. font-size: 24rpx;
  113. padding: 0 16rpx;
  114. height: 48rpx;
  115. line-height: 48rpx;
  116. border-radius: 10rpx;
  117. background: #FFD6BB;
  118. color: #FE781F;
  119. border: 1px solid rgba($color: #FE781F, $alpha: 0.4);
  120. margin-right: 10rpx;
  121. margin-bottom: 10rpx;
  122. &:last-child {
  123. margin-right: 0;
  124. }
  125. }
  126. }
  127. .no {
  128. color: #666666;
  129. margin-bottom: 10rpx;
  130. }
  131. image {
  132. flex-shrink: 0;
  133. width: 14rpx;
  134. height: 28rpx;
  135. margin-left: 10rpx;
  136. margin-bottom: 10rpx;
  137. }
  138. }
  139. }
  140. }
  141. </style>