news.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <!-- 聊天消息 -->
  3. <view class="back">
  4. <view class="input u-flex">
  5. <u-icon name="search" color="rgba(153, 153, 153, 1)" size="40"></u-icon>
  6. <input type="text" placeholder="搜索聊天记录/团长" style="width: 600rpx;margin-left: 16rpx;" />
  7. </view>
  8. <!-- 客服 -->
  9. <view class="" v-for="(item,idx) in list" :key="idx">
  10. <view v-if="user_no !='13523652365' && item.conversationId == '13523652365'" class="kefu u-flex"
  11. @click="tokefu">
  12. <image src="/pageA/static/images/kefu.png" style="width: 88rpx;height: 88rpx;" mode=""></image>
  13. <view class="u-row-between"
  14. style="height: 88rpx;display: flex;flex-direction: column;margin-left: 20rpx;width: 85%;">
  15. <view class="u-flex u-row-between">
  16. <view class="name">官方客服</view>
  17. <view class="time">
  18. {{new Date(item.lastMessage.time).getFullYear()}}-{{new Date(item.lastMessage.time).getMonth() + 1}}-{{new Date(item.lastMessage.time).getDate()}}
  19. {{new Date(item.lastMessage.time).toTimeString().substr(0, 8)}}
  20. </view>
  21. </view>
  22. <view class="u-flex u-row-between">
  23. <text v-if="item.lastMessage.msg" class="news">{{item.lastMessage.msg}}</text>
  24. <text v-if="item.lastMessage.type == 'img'" class="news">图片</text>
  25. <u-badge :type="type" max="99" :value="item.unReadCount"></u-badge>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="box ">
  31. <view style="margin-bottom: 26rpx;" v-for="(item,idx) in list" :key="idx" @click="chat(item)">
  32. <view class="u-flex " v-if="item.conversationId != '13523652365'">
  33. <image :src=" item.lastMessage.ext.user_other.avatar" style="width: 88rpx;height: 88rpx;" mode="">
  34. </image>
  35. <view class="u-row-between"
  36. style="display: flex;flex-direction: column;margin-left: 20rpx;width: 85%;">
  37. <view class="u-flex u-row-between">
  38. <view class="name" v-if="item.lastMessage.from == user_no">
  39. {{ item.lastMessage.ext.user_other.merchant_name ||item.lastMessage.ext.user_other.nickname}}
  40. </view>
  41. <view class="name" v-else>
  42. {{ item.lastMessage.ext.user.nickname}}
  43. </view>
  44. <!-- <view class="name">{{item.lastMessage.ext.user}}</view> -->
  45. <view class="time">
  46. {{new Date(item.lastMessage.time).getFullYear()}}-{{new Date(item.lastMessage.time).getMonth() + 1}}-{{new Date(item.lastMessage.time).getDate()}}
  47. {{new Date(item.lastMessage.time).toTimeString().substr(0, 8)}}
  48. </view>
  49. </view>
  50. <view class="u-flex u-row-between"
  51. style="border-bottom: 2rpx solid #979797;padding-bottom: 26rpx;margin-top: 10rpx;">
  52. <text v-if="item.lastMessage.msg" class="news">{{item.lastMessage.msg}}</text>
  53. <text v-if="item.lastMessage.type == 'img'" class="news">图片</text>
  54. <u-badge :type="type" max="99" :value="item.unReadCount"></u-badge>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import {
  64. conn,
  65. } from '@/utils/WebIM';
  66. export default {
  67. data() {
  68. return {
  69. type: "error",
  70. value: 1,
  71. list: [],
  72. user_no: ''
  73. };
  74. },
  75. onLoad() {
  76. this.user_no = uni.getStorageSync('user_no')
  77. // this.getlist()
  78. },
  79. onShow() {
  80. this.getlist()
  81. },
  82. methods: {
  83. getlist() {
  84. conn.getServerConversations({
  85. pageSize: 50,
  86. cursor: ''
  87. }).then((res) => {
  88. console.log(res);
  89. this.list = res.data.conversations
  90. })
  91. },
  92. tokefu() {
  93. uni.navigateTo({
  94. url: '/pageA/service/service'
  95. })
  96. },
  97. chat(item) {
  98. if (item.lastMessage.from == uni.getStorageSync('user_no')) {
  99. uni.navigateTo({
  100. url: '/pageA/chat/chat?user_other_no=' + item.conversationId + '&user_other=' +
  101. encodeURIComponent(JSON
  102. .stringify(item.lastMessage.ext.user_other))
  103. })
  104. } else if (item.lastMessage.to == uni.getStorageSync('user_no')) {
  105. uni.navigateTo({
  106. url: '/pageA/chat/chat?user_other_no=' + item.conversationId + '&user_other=' +
  107. encodeURIComponent(
  108. JSON.stringify(item.lastMessage.ext.user))
  109. })
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .back {
  117. width: 750rpx;
  118. // height: 1624rpx;
  119. background: #F4F4F4;
  120. padding: 20rpx 24rpx;
  121. box-sizing: border-box;
  122. .input {
  123. width: 702rpx;
  124. height: 72rpx;
  125. background: #FFFFFF;
  126. border-radius: 36rpx;
  127. padding: 0 24rpx;
  128. box-sizing: border-box;
  129. }
  130. .kefu {
  131. width: 702rpx;
  132. height: 156rpx;
  133. background: #FFFFFF;
  134. border-radius: 16rpx;
  135. padding: 36rpx 24rpx 32rpx;
  136. box-sizing: border-box;
  137. margin-top: 24rpx;
  138. }
  139. .name {
  140. font-family: PingFangSC, PingFang SC;
  141. font-weight: 400;
  142. font-size: 32rpx;
  143. color: #222222;
  144. line-height: 44rpx;
  145. text-align: left;
  146. font-style: normal;
  147. }
  148. .time {
  149. font-family: SFPro, SFPro;
  150. font-weight: 400;
  151. font-size: 20rpx;
  152. color: #666666;
  153. line-height: 24rpx;
  154. text-align: left;
  155. font-style: normal;
  156. }
  157. .news {
  158. font-family: PingFangSC, PingFang SC;
  159. font-weight: 400;
  160. font-size: 24rpx;
  161. color: #666666;
  162. line-height: 34rpx;
  163. text-align: left;
  164. font-style: normal;
  165. }
  166. .box {
  167. width: 702rpx;
  168. min-height: 1156rpx;
  169. background: #FFFFFF;
  170. border-radius: 16rpx;
  171. padding: 40rpx 24rpx 20rpx;
  172. box-sizing: border-box;
  173. margin-top: 20rpx;
  174. }
  175. }
  176. </style>