xiaoxi.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="xiaoxi-pages">
  3. <view class="xiaoxi-header">
  4. <u-navbar :fixed="false" bgColor='rgba(0,0,0,0)' placeholder :safeAreaInsetTop="true">
  5. <view slot="left" class="xiaoxi-tabs u-flex u-row-between" style="margin-left: -11rpx;">
  6. <view class="tabs-item u-flex-col u-col-center u-flex-1" :class="{'tabs-item1':current == 1}"
  7. @click="change(1)">
  8. <text>消息</text>
  9. <text></text>
  10. </view>
  11. <view class="tabs-item u-flex-col u-col-center u-flex-1" :class="{'tabs-item1':current == 2}"
  12. @click="change(2)">
  13. <text>通知</text>
  14. <text></text>
  15. </view>
  16. </view>
  17. </u-navbar>
  18. <view v-if="current == 1" class="tabs-header u-flex">
  19. <view class="u-flex tabs-header-item" :class="{'tabs-header-active' : tabs1 == 0}"
  20. @click="changetabs1(0)">
  21. <text>全部</text>
  22. </view>
  23. <view class="u-flex tabs-header-item" :class="{'tabs-header-active' : tabs1 == 1}"
  24. @click="changetabs1(1)">
  25. <u-badge :is-dot="true" type="error" v-if="read"></u-badge>
  26. <text>未读</text>
  27. </view>
  28. </view>
  29. <view v-if="current == 2" class="tabs-header u-flex">
  30. <view class="u-flex tabs-header-item" :class="{'tabs-header-active' : tabs2 == index}"
  31. v-for="(item,index) in tabs2list" :key="index" @click="changetabs2(index)" v-if="index != 1">
  32. <text>{{item}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="xiaoxi-list" v-if="current == 1">
  37. <view class="xiaoxi-item u-flex u-row-between" v-for="(item,index) in list" :key="index"
  38. @click="tochat(index)">
  39. <view class="item-head">
  40. <u-badge type="error" :count="item.unReadCount" :offset="[0,0]"></u-badge>
  41. <image :src="item.user.avatar" mode=""></image>
  42. </view>
  43. <view class="xiaoxi-right u-flex-1">
  44. <view class="right-top u-flex u-row-between">
  45. <text>{{item.user.username}}</text>
  46. <text class="u-line-1">{{item.user.company_name || '' }}·{{item.user.type || ''}}</text>
  47. <text>{{ renderTime(item.lastMessage.time)}}</text>
  48. </view>
  49. <view class="right-down u-line-1" v-if="item.lastMessage && item.lastMessage.type == 'txt'">
  50. {{ item.lastMessage.msg }}
  51. </view>
  52. <view class="right-down u-line-1" v-if="item.lastMessage && item.lastMessage.type == 'img'">
  53. [图片]
  54. </view>
  55. <view class="right-down u-line-1" v-if="item.lastMessage && item.lastMessage.type == 'audio'">
  56. [语音]
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="tongzhi-list" v-if="current == 2">
  62. <view class="tongzhi-item" v-for="(item,index) in list" :key="index" @click="info2(item)">
  63. <view v-if="tabs2 == 0">
  64. <view class="tongzhi-header u-flex u-row-between">
  65. <view class="tongzhi-title u-flex">
  66. <text>{{item.title}}</text>
  67. <text v-if="item.is_view == 0"></text>
  68. </view>
  69. <view class="tongzhi-time">
  70. {{item.createtime}}
  71. </view>
  72. </view>
  73. <view class="tongzhi-tips">
  74. {{item.content}}
  75. </view>
  76. <view class="tongzhi-body">
  77. <view class="body-title u-flex">
  78. <text></text>
  79. <text>{{item.info.job.job_name}}</text>
  80. </view>
  81. <view class="body-name u-flex">
  82. <text></text>
  83. <text class="name-text">{{item.info.company.name || ''}}</text>
  84. <text class="name-text"
  85. style="margin-left: 5rpx;">{{item.info.company.category_name || ''}}</text>
  86. </view>
  87. <view class="body-address u-flex">
  88. <text class="text1">{{item.info.job.work_province}}·{{item.info.job.work_city}}</text>
  89. <text class="text2"></text>
  90. <text class="text1">{{item.info.job.experience_name}}</text>
  91. <text class="text2"></text>
  92. <text class="text1">{{item.info.job.education_name}}</text>
  93. </view>
  94. </view>
  95. </view>
  96. <view v-if="tabs2 == 1">
  97. <view class="tongzhi-header u-flex u-row-between">
  98. <view class="tongzhi-title u-flex">
  99. <text>{{item.title}}</text>
  100. <text v-if="item.is_view == 0"></text>
  101. </view>
  102. <view class="tongzhi-time">
  103. {{item.createtime}}
  104. </view>
  105. </view>
  106. <view class="tongzhi-tips">
  107. {{item.content}}
  108. </view>
  109. <view class="xitong-box" v-if="item.info.job_name">
  110. <view class="xitong-title u-flex">{{item.info.job_name}}</view>
  111. <view class="xitong-address u-flex">
  112. <text class="text1">{{item.info.work_city}}</text>
  113. <text class="text2"></text>
  114. <text class="text1">{{item.info.experience_name}}</text>
  115. <text class="text2"></text>
  116. <text class="text1">{{item.info.education_name}}</text>
  117. </view>
  118. </view>
  119. </view>
  120. <view v-if="tabs2 == 2">
  121. <view class="zixun-box">
  122. <view class="zixun-title">
  123. {{item.title}} {{item.createtime}}
  124. </view>
  125. <image :src="item.info.image" class="zixun-img" mode="aspectFill"></image>
  126. <view class="zixun-tips">
  127. {{item.content}}
  128. </view>
  129. </view>
  130. </view>
  131. <view class="tongzhi-down u-flex u-row-between">
  132. <text class="text">查看详情</text>
  133. <u-icon name="arrow-right" color="#0C66C2"></u-icon>
  134. </view>
  135. </view>
  136. </view>
  137. <view class="" style="border: 40rpx;"></view>
  138. <view style="height: 70vh;" v-if="list.length == 0">
  139. <u-empty text="暂无数据" mode="list"></u-empty>
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. import {
  145. conn
  146. } from '@/utils/WebIM';
  147. import {
  148. renderTime
  149. } from '@/utils/index'
  150. import {
  151. get_list,
  152. notification,
  153. getEmchatUsersData
  154. } from "@/units/inquire.js"
  155. export default {
  156. data() {
  157. return {
  158. current: 1,
  159. tabs1: 0,
  160. tabs1list: ['全部', '未读'],
  161. tabs2: 0,
  162. tabs2list: ['订单通知', '系统通知', '资讯通知'],
  163. page: 1,
  164. total: 0,
  165. list: [],
  166. read: false,
  167. renderTime,
  168. }
  169. },
  170. onLoad() {},
  171. onShow() {
  172. this.getlist()
  173. },
  174. onReachBottom() {
  175. if (this.total != this.list.length) {
  176. this.page++
  177. this.getlist()
  178. }
  179. },
  180. methods: {
  181. change(index) {
  182. this.current = index
  183. this.tabs2 = 0,
  184. this.tabs1 = 0
  185. this.getlist()
  186. },
  187. tochat(index) {
  188. uni.navigateTo({
  189. url: "/pagesC/chat?user_no=" + this.list[index].user.user_no
  190. })
  191. },
  192. info2(item) {
  193. notification({
  194. id: item.id
  195. }).then(res => {
  196. item.is_view = 1
  197. })
  198. if (this.tabs2 == 0) {
  199. uni.navigateTo({
  200. url: "/pagesD/order-info?id=" + item.info.id
  201. })
  202. }
  203. if (this.tabs2 == 1) {
  204. if (item.source_type == 'job') {
  205. uni.navigateTo({
  206. url: "/pagesB/zhiwei-info2?id=" + item.info.id
  207. })
  208. }
  209. }
  210. if (this.tabs2 == 2) {
  211. uni.navigateTo({
  212. url: "/pagesD/zixun-info?id=" + item.info.id
  213. })
  214. }
  215. },
  216. handlecurrent(index) {
  217. this.current = index
  218. this.page = 1
  219. this.total = 0
  220. this.list = []
  221. this.getlist()
  222. },
  223. changetabs1(index) {
  224. this.tabs1 = index
  225. this.page = 1
  226. this.total = 0
  227. this.list = []
  228. this.getlist()
  229. },
  230. changetabs2(index) {
  231. this.tabs2 = index
  232. this.page = 1
  233. this.total = 0
  234. this.list = []
  235. this.getlist()
  236. },
  237. getlist() {
  238. let that = this
  239. if (this.current == 1) {
  240. const options = {
  241. pageSize: 50,
  242. cursor: '',
  243. }
  244. conn.getServerConversations(options).then((res) => {
  245. that.list = res.data.conversations
  246. console.log(that.list);
  247. let list = []
  248. if (that.tabs1 == 1) {
  249. for (var i = 0; i < that.list.length; i++) {
  250. if (that.list[i].unReadCount > 0) {
  251. list.push(that.list[i])
  252. }
  253. }
  254. that.list = list
  255. }
  256. let ids = ''
  257. if (that.list.length > 0) {
  258. for (var i = 0; i < that.list.length; i++) {
  259. ids += that.list[i].conversationId + ','
  260. }
  261. that.getData(ids)
  262. }
  263. }).catch((error) => {
  264. console.log('失败', error);
  265. })
  266. }
  267. if (this.current == 2) {
  268. get_list({
  269. page: this.page,
  270. type: {
  271. 0: 'order',
  272. 1: 'system',
  273. 2: 'info'
  274. } [this.tabs2]
  275. }).then(res => {
  276. this.total = res.data.total
  277. this.list = this.list.concat(res.data.data)
  278. })
  279. }
  280. },
  281. getData(ids) {
  282. let that = this
  283. ids = ids.slice(0, -1)
  284. getEmchatUsersData({
  285. user_no: ids,
  286. }).then((res) => {
  287. if (res.code == 1) {
  288. for (var i = 0; i < that.list.length; i++) {
  289. that.$set(that.list[i], 'user', res.data[i])
  290. }
  291. } else {
  292. that.$u.toast(res.msg)
  293. }
  294. })
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss">
  300. .xiaoxi-pages {
  301. .tongzhi-list {
  302. padding: 1rpx 0;
  303. .tongzhi-item {
  304. margin: 20rpx auto;
  305. width: 702rpx;
  306. background: #FFFFFF;
  307. border-radius: 20rpx;
  308. padding: 0 24rpx;
  309. .xitong-box {
  310. width: 100%;
  311. background: rgba(243, 243, 243, 0.5);
  312. border-radius: 12rpx;
  313. padding: 24rpx;
  314. .xitong-address {
  315. .text1 {
  316. font-size: 26rpx;
  317. font-family: PingFangSC-Regular, PingFang SC;
  318. font-weight: 400;
  319. color: #666666;
  320. }
  321. .text2 {
  322. height: 20rpx;
  323. border: 2rpx solid #E5E5E5;
  324. margin: 0 16rpx;
  325. }
  326. }
  327. .xitong-title {
  328. font-size: 32rpx;
  329. font-family: PingFangSC-Regular, PingFang SC;
  330. font-weight: 400;
  331. color: #222222;
  332. margin-bottom: 20rpx;
  333. }
  334. }
  335. .zixun-box {
  336. .zixun-tips {
  337. font-size: 30rpx;
  338. font-family: PingFangSC-Regular, PingFang SC;
  339. font-weight: 400;
  340. color: #333333;
  341. padding: 24rpx 0;
  342. }
  343. .zixun-img {
  344. width: 100%;
  345. height: 284rpx;
  346. }
  347. .zixun-title {
  348. padding: 24rpx 0 20rpx 0;
  349. font-size: 24rpx;
  350. font-family: PingFangSC-Regular, PingFang SC;
  351. font-weight: 400;
  352. color: #888888;
  353. }
  354. }
  355. .tongzhi-down {
  356. height: 86rpx;
  357. border-top: 2rpx solid #F0F0F0;
  358. .text {
  359. font-size: 26rpx;
  360. font-family: PingFangSC-Regular, PingFang SC;
  361. font-weight: 400;
  362. color: #0C66C2;
  363. }
  364. }
  365. .tongzhi-body {
  366. background: rgba(243, 243, 243, 0.5);
  367. border-radius: 12rpx;
  368. padding: 20rpx;
  369. margin-bottom: 24rpx;
  370. .body-address {
  371. padding: 0 32rpx;
  372. .text2 {
  373. height: 20rpx;
  374. border: 2rpx solid #E5E5E5;
  375. margin: 0 14rpx;
  376. }
  377. .text1 {
  378. font-size: 26rpx;
  379. font-family: PingFangSC-Regular, PingFang SC;
  380. font-weight: 400;
  381. color: #666666;
  382. }
  383. }
  384. .body-name {
  385. margin-bottom: 20rpx;
  386. text:first-child {
  387. width: 12rpx;
  388. height: 12rpx;
  389. background: #0C66C2;
  390. border-radius: 100rpx;
  391. margin-right: 20rpx;
  392. }
  393. text :nth-child(2) {
  394. width: 220rpx;
  395. overflow: hidden;
  396. white-space: nowrap;
  397. text-overflow: ellipsis;
  398. font-size: 24rpx;
  399. font-family: PingFangSC, PingFang SC;
  400. font-weight: 400;
  401. color: #555555;
  402. }
  403. text:last-child {
  404. font-size: 24rpx;
  405. font-family: PingFangSC, PingFang SC;
  406. font-weight: 400;
  407. color: #555555;
  408. }
  409. }
  410. .body-title {
  411. margin-bottom: 28rpx;
  412. text:first-child {
  413. width: 12rpx;
  414. height: 12rpx;
  415. background: #131415;
  416. margin-right: 20rpx;
  417. border-radius: 100rpx;
  418. }
  419. text:last-child {
  420. font-size: 32rpx;
  421. font-family: PingFangSC-Regular, PingFang SC;
  422. font-weight: 400;
  423. color: #222222;
  424. }
  425. }
  426. }
  427. .tongzhi-tips {
  428. font-size: 28rpx;
  429. font-family: PingFangSC-Regular, PingFang SC;
  430. font-weight: 400;
  431. color: #666666;
  432. margin-bottom: 24rpx;
  433. }
  434. .tongzhi-header {
  435. height: 96rpx;
  436. .tongzhi-time {
  437. font-size: 24rpx;
  438. font-family: SFPro-Regular, SFPro;
  439. font-weight: 400;
  440. color: #666666;
  441. }
  442. .tongzhi-title {
  443. text:first-child {
  444. font-size: 32rpx;
  445. font-family: PingFangSC-Medium, PingFang SC;
  446. font-weight: 500;
  447. color: #222222;
  448. margin-right: 16rpx;
  449. }
  450. text:nth-child(2) {
  451. width: 12rpx;
  452. height: 12rpx;
  453. background: #F2413A;
  454. border-radius: 100rpx;
  455. }
  456. }
  457. }
  458. }
  459. }
  460. .xiaoxi-list {
  461. width: 702rpx;
  462. background: #FFFFFF;
  463. border-radius: 20rpx;
  464. margin: 20rpx auto;
  465. .xiaoxi-item {
  466. padding: 24rpx 20rpx;
  467. .xiaoxi-right {
  468. min-width: 1rpx;
  469. .right-down {
  470. font-size: 26rpx;
  471. font-family: PingFangSC-Regular, PingFang SC;
  472. font-weight: 400;
  473. color: #444444;
  474. }
  475. .right-top {
  476. margin-bottom: 18rpx;
  477. text:first-child {
  478. font-size: 30rpx;
  479. }
  480. text:nth-child(2) {
  481. font-size: 22rpx;
  482. font-family: PingFangSC-Regular, PingFang SC;
  483. font-weight: 400;
  484. color: #888888;
  485. margin: 0 8rpx;
  486. }
  487. text:last-child {
  488. font-size: 24rpx;
  489. font-family: SFPro-Regular, SFPro;
  490. font-weight: 400;
  491. color: #999999;
  492. }
  493. }
  494. }
  495. .item-head {
  496. width: 96rpx;
  497. height: 96rpx;
  498. border-radius: 100rpx;
  499. margin-right: 20rpx;
  500. position: relative;
  501. image {
  502. width: 96rpx;
  503. height: 96rpx;
  504. border-radius: 100rpx;
  505. }
  506. }
  507. }
  508. }
  509. .xiaoxi-header {
  510. position: sticky;
  511. top: 0;
  512. left: 0;
  513. width: 750rpx;
  514. z-index: 99;
  515. background: linear-gradient(180deg, #EDF6FF 0%, #F8FAFD 100%);
  516. .tabs-header {
  517. height: 88rpx;
  518. padding: 0 8rpx;
  519. .tabs-header-item {
  520. margin: 0 24rpx;
  521. text {
  522. font-size: 26rpx;
  523. font-family: PingFangSC-Regular, PingFang SC;
  524. font-weight: 400;
  525. color: #777777;
  526. }
  527. }
  528. .tabs-header-active {
  529. text {
  530. color: #0C66C2;
  531. }
  532. }
  533. }
  534. .xiaoxi-tabs {
  535. width: 250rpx;
  536. .tabs-item {
  537. text:first-child {
  538. font-size: 32rpx;
  539. font-family: PingFangSC-Medium, PingFang SC;
  540. font-weight: 500;
  541. color: #777777;
  542. position: relative;
  543. z-index: 1;
  544. }
  545. text:last-child {
  546. width: 76rpx;
  547. height: 12rpx;
  548. border-radius: 100rpx;
  549. margin-top: -14rpx;
  550. }
  551. }
  552. .tabs-item1 {
  553. text:first-child {
  554. font-size: 36rpx;
  555. font-family: PingFangSC-Medium, PingFang SC;
  556. font-weight: 500;
  557. color: #222222;
  558. }
  559. text:last-child {
  560. background: linear-gradient(270deg, #208EFF 0%, rgba(28, 159, 227, 0) 100%);
  561. }
  562. }
  563. }
  564. }
  565. }
  566. page {
  567. background-color: #F3F3F3;
  568. }
  569. </style>