contactsItem.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="contacts-item" @click="handleDetail">
  3. <view class="cell">
  4. <view class="left">
  5. {{ iconText }}
  6. </view>
  7. <view class="center">
  8. <view class="name">
  9. {{ itemData.name || ' ' }}
  10. </view>
  11. <view class="text-info">
  12. 最后跟进时间:{{ itemData.lastTime | formatTime }}
  13. </view>
  14. </view>
  15. <view class="right" @click.stop="ringUp(itemData.mobile)">
  16. <image
  17. :src="$static('images/icon/call.png')"
  18. class="call" />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. import moment from 'moment'
  25. export default {
  26. name: 'ContactsItem',
  27. filters: {
  28. formatTime(val) {
  29. if (!val) return '--'
  30. return moment(val).format('YYYY-MM-DD')
  31. }
  32. },
  33. props: {
  34. itemData: {
  35. type: Object,
  36. required: true
  37. }
  38. },
  39. data() {
  40. return {
  41. auth: 'crm.contacts.read'
  42. }
  43. },
  44. computed: {
  45. iconText() {
  46. const reg = /[\u4e00-\u9fa5]+/
  47. let str = this.itemData.name.slice(0, 1) || ''
  48. if (reg.test(str)) {
  49. return this.itemData.name.slice(0, 1)
  50. }
  51. return this.itemData.name.slice(0, 2)
  52. }
  53. },
  54. methods: {
  55. /**
  56. * 联系人详情跳转
  57. */
  58. handleDetail() {
  59. if (!this.$auth(this.auth)) {
  60. this.$toast('权限不足')
  61. return
  62. }
  63. this.$Router.navigateTo({
  64. url: '/pages_crm/contacts/detail',
  65. query: {
  66. id: this.itemData.contactsId
  67. }
  68. })
  69. },
  70. /**
  71. * 拨打电话
  72. * @param {string} tel
  73. */
  74. ringUp(tel) {
  75. console.log('tel: ', tel)
  76. if (!tel) {
  77. this.$toast('暂无电话')
  78. return
  79. }
  80. uni.makePhoneCall({
  81. phoneNumber: tel
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped lang="scss">
  88. @import "../../style/listItem";
  89. .contacts-item {
  90. border-bottom: 1rpx solid $border-color;
  91. background-color: white;
  92. padding: 20rpx 32rpx;
  93. .cell {
  94. .left {
  95. width: 80rpx;
  96. height: 80rpx;
  97. font-size: 36rpx;
  98. color: white;
  99. text-align: center;
  100. line-height: 80rpx;
  101. border-radius: 50%;
  102. background-color: $theme-color;
  103. margin-right: 25rpx;
  104. }
  105. .center {
  106. flex: 1;
  107. text-align: left;
  108. .name {
  109. font-size: 32rpx;
  110. color: #212121;
  111. @include ellipsis;
  112. }
  113. .text-info {
  114. font-size: 26rpx;
  115. color: $gray;
  116. }
  117. }
  118. .right {
  119. padding: 15rpx 0 15rpx 20rpx;
  120. @include center;
  121. }
  122. }
  123. }
  124. </style>