index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <view class="message-list" v-if="customerList.length > 0">
  4. <!-- 客服消息 -->
  5. <view
  6. class="message-item"
  7. v-for="(item, index) in customerList"
  8. :key="index"
  9. @click="handleCustomerClick(item)"
  10. >
  11. <view class="message-avatar service-avatar">
  12. <uni-icons
  13. size="30"
  14. color="#ffffff"
  15. customPrefix="iconfont"
  16. type="icon-kefu2"
  17. />
  18. </view>
  19. <view class="message-content">
  20. <view class="message-header">
  21. <text class="message-title">{{ item.imTeamName }}</text>
  22. <!-- <text class="badge" >{{ item.count }}</text> -->
  23. </view>
  24. <!-- <text class="message-desc" v-show="item.newMsg">{{ item.newMsg }}</text> -->
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 数据为空 -->
  29. <view class="not-data-wrapper" v-if="notDataFlag">
  30. <uni-icons type="info" size="70" color="#999999"></uni-icons>
  31. <p>暂无数据</p>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import { ref, reactive, onMounted } from "vue";
  37. import { onPullDownRefresh } from "@dcloudio/uni-app";
  38. import { getCustomerServiceList } from "@/api/customerService";
  39. import { useAppStore } from "@/stores/app";
  40. let customerList = ref([]); //客服列表
  41. let notDataFlag = ref(false); //数据为空
  42. const appStore = useAppStore();
  43. onMounted(() => {
  44. getList();
  45. });
  46. onPullDownRefresh(() => {
  47. getList();
  48. });
  49. // 获取客服列表
  50. function getList() {
  51. try {
  52. getCustomerServiceList()
  53. .then((res) => {
  54. if (res.data && res.data.list && res.data.list.length > 0) {
  55. customerList.value = res.data.list;
  56. } else {
  57. notDataFlag.value = true;
  58. }
  59. })
  60. .catch((err) => {
  61. notDataFlag.value = true;
  62. });
  63. } catch (error) {
  64. notDataFlag.value = true;
  65. }
  66. }
  67. // 点击客服
  68. const handleCustomerClick = (item) => {
  69. // uni.navigateTo({ url: `/pages/message_customer/message_customer?code=${item.imTeamCode}` });
  70. let chatParam = ref({
  71. avatar: "",
  72. where: "teamServes",
  73. });
  74. chatParam.value.to = item.imTeamCode;
  75. chatParam.value.nickName = item.imTeamName || "客服";
  76. appStore.updata_userSelecChat(chatParam);
  77. uni.navigateTo({ url: `/pages/private_chat/index` });
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. .message-list {
  82. .message-item {
  83. display: flex;
  84. align-items: center;
  85. background-color: #fff;
  86. padding: 20rpx 40rpx;
  87. margin-bottom: 8px;
  88. position: relative;
  89. &:active {
  90. background-color: #dedede;
  91. }
  92. .message-avatar {
  93. width: 48px;
  94. height: 48px;
  95. border-radius: 50%;
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. margin-right: 12px;
  100. font-size: 20px;
  101. &.activity-avatar {
  102. background-color: #2196f3;
  103. color: white;
  104. }
  105. &.service-avatar {
  106. background-color: #fc9145;
  107. color: white;
  108. }
  109. }
  110. .message-content {
  111. flex: 1;
  112. .message-header {
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: center;
  116. /* margin-bottom: 4px; */
  117. position: relative;
  118. height: 20px;
  119. .message-title {
  120. font-size: 16px;
  121. /* font-weight: 500; */
  122. color: #333;
  123. }
  124. }
  125. .message-desc {
  126. font-size: 14px;
  127. color: #999;
  128. }
  129. }
  130. .message-right {
  131. display: flex;
  132. flex-direction: column;
  133. justify-content: center;
  134. align-items: flex-end;
  135. }
  136. .message-time {
  137. font-size: 14px;
  138. color: #999;
  139. margin-bottom: 10rpx;
  140. }
  141. .badge {
  142. background-color: #ff4757;
  143. color: white;
  144. border-radius: 50%;
  145. width: 38rpx;
  146. height: 38rpx;
  147. line-height: 38rpx;
  148. text-align: center;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. font-size: 18rpx;
  153. font-weight: 500;
  154. padding: 0 4px;
  155. border: 2px solid #fff;
  156. }
  157. .unread-dot {
  158. position: absolute;
  159. top: 50%;
  160. right: 16px;
  161. transform: translateY(-50%);
  162. width: 8px;
  163. height: 8px;
  164. background-color: #ff4757;
  165. border-radius: 50%;
  166. }
  167. }
  168. }
  169. </style>