luntan.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <view class="luntan-pages">
  3. <view class="luntan-header">
  4. <image class="index-bg" src="../../static/images/index-header.png" mode=""></image>
  5. <!-- <u-navbar :isBack="false" :background="{background:'rgba(0,0,0,0)'}" :border-bottom="false"
  6. :isFixed="false"> -->
  7. <u-navbar :fixed="false" bgColor='rgba(0,0,0,0)' placeholder :safeAreaInsetTop="true">
  8. <view id="height" class="index-header u-flex u-row-between" slot="left" style="position: relative;">
  9. <image @click="touser({uid:userinfo.id})" :src="userinfo.group_info.avatar" style="width: 64rpx ; height: 64rpx; border-radius: 50rpx;"
  10. mode=""></image>
  11. </view>
  12. <view id="height" class="index-header u-flex u-row-between" slot="center" style="position: relative;">
  13. <view class="navbar-right u-flex u-flex-1">
  14. <!-- <view class="right-icon">
  15. <u-icon name="search" size="44"></u-icon>
  16. </view> -->
  17. <view class="luntan-search u-flex">
  18. <u-icon name="search" size="22"></u-icon>
  19. <input style="width: 280rpx;" type="text" placeholderStyle="font-size:30rpx" placeholder="搜索你感兴趣的内容" v-model="keyword1" confirm-type="search"
  20. @confirm="tosearch(1)">
  21. </view>
  22. <view class="right-icon" @click="toxiaoxi">
  23. <u-badge type="error" count="7" :offset="[-8,-8]"></u-badge>
  24. <u-icon name="bell" size="22"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. </u-navbar>
  29. <view class="header-tabs u-flex u-col-bottom">
  30. <view class="u-flex-col u-col-center tabs-item" :class="{'tabs-item1':tabsindex == index}"
  31. v-for="(item,index) in tabs" :key="index" @click="changetabs(index)">
  32. <text>{{item}}</text>
  33. <text></text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="luntan-list" v-if="tabsindex == 0">
  38. <view class="luntan-item" v-for="(item,index) in list" :key="index" @click="toinfo(item)">
  39. <view class="luntan-user u-flex u-row-between">
  40. <image class="user-head" :src="item.userinfo.avatar" @click.stop="touser(item)" mode=""></image>
  41. <view class="user-center u-flex-1 u-flex-col">
  42. <text>{{item.userinfo.name}}</text>
  43. <text>{{item.userinfo.company_name.name}}</text>
  44. </view>
  45. <text class="guanzhu-btn" @click.stop="guanzhu(item)">{{item.is_follow ? '已关注' : '关注'}}</text>
  46. </view>
  47. <zhao-text v-if="item.content" :text="item.content"></zhao-text>
  48. <view v-if="item.images" class="luntan-img u-flex u-flex-wrap u-row-between">
  49. <image :src="a" v-for="(a,b) in item.images.split(',')" :key="b"
  50. @click.stop="openimg(item.images.split(','),b)" mode="aspectFill"></image>
  51. <view style="width: 210rpx;"></view>
  52. </view>
  53. <view class="quanzi-box u-flex" v-if="item.circle" @click.stop="toquanzi(item)">
  54. <image src="../../static/images/quanzi.png" mode=""></image>
  55. <text>{{item.circle.title}}</text>
  56. </view>
  57. <view class="item-down u-flex u-row-between">
  58. <view class="u-flex u-row-center down-item" @click.stop="dianzan(item)">
  59. <image v-if="item.is_like" src="../../static/images/dianzan.png" mode=""></image>
  60. <image v-else src="../../static/images/dianzan.png" mode=""></image>
  61. <text class="text1">{{item.like_count}}</text>
  62. </view>
  63. <view class="u-flex u-row-center down-item">
  64. <image src="../../static/images/pinglun.png" mode=""></image>
  65. <text class="text1">{{item.comment_count}}</text>
  66. </view>
  67. <view class="u-flex u-row-center down-item">
  68. <image src="../../static/images/liulan.png" mode=""></image>
  69. <text class="text1">{{item.read || 0}}</text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="quanzi-list" v-if="tabsindex == 1">
  75. <view class="quanzi-item u-flex u-row-between" v-for="(item,index) in list" :key="index"
  76. @click="toquanzi({circle_id:item.id})">
  77. <image :src="item.image" class="img" mode="aspectFill"></image>
  78. <view class="quanzi-center u-flex-col">
  79. <text>{{item.title}}</text>
  80. <text>{{item.article_count}}条内容|{{item.follow_count}}人关注</text>
  81. </view>
  82. <view class="quanzi-btn" @click.stop="guanzhuquanzi(item)">
  83. {{item.is_follow ? '已关注' : '关注'}}
  84. </view>
  85. </view>
  86. </view>
  87. <view class="quanzi-list" v-if="tabsindex == 2">
  88. <view class="quanzi-item u-flex u-row-between" v-for="(item,index) in list" :key="index"
  89. @click="touser({uid:item.uid})">
  90. <image :src="item.userinfo.avatar" class="img" style="border-radius: 100rpx;" mode="aspectFill"></image>
  91. <view class="quanzi-center u-flex-col">
  92. <text>{{item.userinfo.name}}</text>
  93. <text>{{item.userinfo.company_name.name}}</text>
  94. </view>
  95. <view class="quanzi-btn" @click.stop="quxiaoguanzhu(item)">
  96. 已关注
  97. </view>
  98. </view>
  99. </view>
  100. <view class="luntan-fabu u-flex u-row-center" @click="show = true">
  101. <image src="../../static/images/plus.png" mode=""></image>
  102. </view>
  103. <u-popup v-model="show" border-radius="28" :closeable="true" mode="center">
  104. <view class="fabu-luntan u-flex u-row-between">
  105. <view @click="toadd(1)" class="fabu-item u-flex-col u-col-center">
  106. <view class="fabu-img u-flex u-row-center">
  107. <image src="../../static/images/fabu1.png" mode=""></image>
  108. </view>
  109. <text class="fabu-text">发布帖子</text>
  110. </view>
  111. <view @click="toadd(2)" class="fabu-item u-flex-col u-col-center">
  112. <view class="fabu-img u-flex u-row-center">
  113. <image src="../../static/images/fabu2.png" mode=""></image>
  114. </view>
  115. <text class="fabu-text">创建圈子</text>
  116. </view>
  117. </view>
  118. </u-popup>
  119. </view>
  120. </template>
  121. <script>
  122. import {
  123. articlelist,
  124. grouplist,
  125. followuser,
  126. follow,
  127. articlelike,
  128. index
  129. } from "@/units/inquire.js"
  130. export default {
  131. data() {
  132. return {
  133. tabs: ['推荐', '圈子', '关注'],
  134. tabsindex: 0,
  135. show: false,
  136. page: 1,
  137. list: [],
  138. total: 0,
  139. userinfo: {
  140. group_info: {}
  141. },
  142. keyword1: '',
  143. keyword: '',
  144. isshow: false
  145. }
  146. },
  147. onShow() {
  148. if (this.isshow) {
  149. this.isshow = false
  150. } else {
  151. this.page = 1
  152. this.list = []
  153. this.getlist()
  154. this.getuser()
  155. }
  156. },
  157. onReachBottom() {
  158. if (this.total != this.list.length) {
  159. this.page++
  160. // this.getlist()
  161. }
  162. },
  163. methods: {
  164. quxiaoguanzhu(item) {
  165. uni.showLoading({
  166. mask: true,
  167. title: "请稍后"
  168. })
  169. follow({
  170. type: 1,
  171. id: item.uid
  172. }).then(res => {
  173. this.$u.toast(res.msg)
  174. setTimeout(() => {
  175. this.tosearch()
  176. }, 800)
  177. })
  178. },
  179. guanzhuquanzi(item) {
  180. uni.showLoading({
  181. mask: true,
  182. title: "请稍后"
  183. })
  184. follow({
  185. type: 2,
  186. id: item.id
  187. }).then(res => {
  188. this.$u.toast(res.msg)
  189. if (res.code == 1) {
  190. item.is_follow = item.is_follow ? null : {}
  191. if (item.is_follow) {
  192. item.follow_count++
  193. } else {
  194. item.follow_count--
  195. }
  196. }
  197. })
  198. },
  199. openimg(urls, index) {
  200. this.isshow = true
  201. // this.$openimage(urls, index)
  202. uni.previewImage(urls,index)
  203. },
  204. changetabs(index) {
  205. this.tabsindex = index
  206. this.keyword1 = ''
  207. this.tosearch()
  208. },
  209. tosearch(type) {
  210. this.keyword = this.keyword1
  211. this.page = 1
  212. this.list = []
  213. if (type == 1) {
  214. this.tabsindex = this.tabsindex == 2 ? 0 : this.tabsindex
  215. }
  216. this.getlist()
  217. },
  218. getuser() {
  219. index().then(res => {
  220. this.userinfo = res.data
  221. })
  222. },
  223. guanzhu(item) {
  224. uni.showLoading({
  225. mask: true,
  226. title: "请稍后"
  227. })
  228. follow({
  229. type: 1,
  230. id: item.uid
  231. }).then(res => {
  232. this.$u.toast(res.msg)
  233. if (res.code == 1) {
  234. setTimeout(() => {
  235. this.page = 1
  236. this.list = []
  237. this.getlist()
  238. }, 800)
  239. }
  240. })
  241. },
  242. dianzan(item) {
  243. uni.showLoading({
  244. mask: true,
  245. title: "请稍后"
  246. })
  247. articlelike({
  248. id: item.id,
  249. }).then(res => {
  250. if (res.code == 1) {
  251. item.is_like = item.is_like ? null : {}
  252. if (item.is_like) {
  253. item.like_count++
  254. } else {
  255. item.like_count--
  256. }
  257. } else {
  258. this.$u.toast(res.msg)
  259. }
  260. })
  261. },
  262. getlist() {
  263. if (this.tabsindex == 0) {
  264. articlelist({
  265. page: this.page,
  266. keywords: this.keyword
  267. }).then(res => {
  268. this.total = res.data.total
  269. this.list = this.list.concat(res.data.data)
  270. })
  271. }
  272. if (this.tabsindex == 1) {
  273. grouplist({
  274. page: this.page,
  275. keywords: this.keyword
  276. }).then(res => {
  277. this.total = res.data.total
  278. this.list = this.list.concat(res.data.data)
  279. })
  280. }
  281. if (this.tabsindex == 2) {
  282. followuser({
  283. page: this.page,
  284. keywords: this.keyword
  285. }).then(res => {
  286. this.total = res.data.total
  287. this.list = this.list.concat(res.data.data)
  288. })
  289. }
  290. },
  291. touser(item) {
  292. uni.navigateTo({
  293. url: "/pagesC/my-luntan?id=" + item.uid
  294. })
  295. },
  296. toquanzi(item) {
  297. uni.navigateTo({
  298. url: "/pagesC/quanzi-info?id=" + item.circle_id
  299. })
  300. },
  301. toadd(type) {
  302. if (type == 1) {
  303. uni.navigateTo({
  304. url: "/pagesC/add-luntan"
  305. })
  306. }
  307. if (type == 2) {
  308. uni.navigateTo({
  309. url: "/pagesC/add-quanzi"
  310. })
  311. }
  312. this.show = false
  313. },
  314. toinfo(item) {
  315. uni.navigateTo({
  316. url: "/pagesC/luntan-info?id=" + item.id
  317. })
  318. },
  319. toxiaoxi() {
  320. uni.navigateTo({
  321. url: "/pagesC/xiaoxi-list"
  322. })
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss">
  328. .luntan-pages {
  329. .index-header {
  330. // flex: 1;
  331. padding: 0 32rpx;
  332. height: 50rpx;
  333. }
  334. .quanzi-list {
  335. padding: 0 32rpx;
  336. background-color: #fff;
  337. .quanzi-item {
  338. padding: 28rpx 0;
  339. border-bottom: 2rpx solid #F4F4F4;
  340. .quanzi-btn {
  341. width: 112rpx;
  342. border-radius: 24rpx;
  343. border: 1rpx solid #0C66C2;
  344. text-align: center;
  345. line-height: 48rpx;
  346. font-size: 26rpx;
  347. font-family: PingFangSC-Regular, PingFang SC;
  348. font-weight: 400;
  349. color: #0C66C2;
  350. }
  351. .quanzi-center {
  352. flex: 1;
  353. margin: 0 20rpx;
  354. text:first-child {
  355. font-size: 30rpx;
  356. font-family: PingFangSC-Medium, PingFang SC;
  357. font-weight: 500;
  358. color: #222222;
  359. margin-bottom: 14rpx;
  360. }
  361. text:last-child {
  362. font-size: 22rpx;
  363. font-family: PingFangSC-Regular, PingFang SC;
  364. font-weight: 400;
  365. color: #777777;
  366. }
  367. }
  368. .img {
  369. width: 96rpx;
  370. height: 96rpx;
  371. border-radius: 10rpx;
  372. background-color: rgba(0, 0, 0, 0.1);
  373. }
  374. }
  375. }
  376. .fabu-luntan {
  377. width: 566rpx;
  378. height: 308rpx;
  379. padding: 40rpx 100rpx 0 100rpx;
  380. .fabu-item {
  381. .fabu-img {
  382. width: 112rpx;
  383. height: 112rpx;
  384. background: rgba(12, 102, 194, 0.1);
  385. margin-bottom: 32rpx;
  386. border-radius: 100%;
  387. image {
  388. width: 56rpx;
  389. height: 56rpx;
  390. }
  391. }
  392. .fabu-text {
  393. font-size: 28rpx;
  394. font-family: PingFangSC-Medium, PingFang SC;
  395. font-weight: 500;
  396. color: #333333;
  397. }
  398. }
  399. }
  400. .luntan-fabu {
  401. width: 96rpx;
  402. height: 96rpx;
  403. background: #0C66C2;
  404. box-shadow: 0rpx 12rpx 48rpx -20rpx #0C66C2;
  405. position: fixed;
  406. bottom: 44rpx;
  407. right: 24rpx;
  408. z-index: 10;
  409. border-radius: 100rpx;
  410. image {
  411. width: 45rpx;
  412. height: 45rpx;
  413. }
  414. }
  415. .luntan-list {
  416. padding: 20rpx 20rpx 0 24rpx;
  417. box-sizing: border-box;
  418. .luntan-item {
  419. background: #FFFFFF;
  420. border-radius: 20rpx;
  421. margin: 20rpx auto;
  422. padding: 0 20rpx;
  423. .item-down {
  424. height: 84rpx;
  425. .down-item {
  426. width: 214rpx;
  427. image {
  428. width: 33rpx;
  429. height: 33rpx;
  430. }
  431. .text1 {
  432. font-size: 26rpx;
  433. font-family: ArialMT;
  434. color: #777777;
  435. margin-left: 12rpx;
  436. }
  437. }
  438. }
  439. .luntan-img {
  440. margin-top: 20rpx;
  441. width: 100%;
  442. image {
  443. width: 210rpx;
  444. height: 210rpx;
  445. border-radius: 10rpx;
  446. // margin-right: 10rpx;
  447. margin-bottom: 10rpx;
  448. }
  449. }
  450. .luntan-img::after {
  451. width: 210rpx;
  452. }
  453. .quanzi-box {
  454. padding: 0 20rpx;
  455. height: 50rpx;
  456. background: #F6F6F6;
  457. border-radius: 28rpx;
  458. margin: 20rpx 0 0 0;
  459. display: inline-flex;
  460. image {
  461. width: 28rpx;
  462. height: 28rpx;
  463. }
  464. text {
  465. font-size: 24rpx;
  466. font-family: PingFangSC-Regular, PingFang SC;
  467. font-weight: 400;
  468. color: #555555;
  469. margin-left: 8rpx;
  470. }
  471. }
  472. .luntan-user {
  473. height: 130rpx;
  474. .guanzhu-btn {
  475. width: 112rpx;
  476. line-height: 48rpx;
  477. border-radius: 24rpx;
  478. border: 1rpx solid #0C66C2;
  479. text-align: center;
  480. font-size: 26rpx;
  481. font-family: PingFangSC-Regular, PingFang SC;
  482. font-weight: 400;
  483. color: #0C66C2;
  484. }
  485. .user-center {
  486. margin: 0 16rpx;
  487. min-width: 1rpx;
  488. text:first-child {
  489. font-size: 28rpx;
  490. font-family: PingFangSC-Medium, PingFang SC;
  491. font-weight: 500;
  492. color: #222222;
  493. margin-bottom: 4rpx;
  494. }
  495. text:last-child {
  496. font-size: 20rpx;
  497. font-family: PingFangSC-Regular, PingFang SC;
  498. font-weight: 400;
  499. color: #818389;
  500. }
  501. }
  502. .user-head {
  503. width: 72rpx;
  504. height: 72rpx;
  505. border-radius: 100rpx;
  506. }
  507. }
  508. }
  509. }
  510. .luntan-header {
  511. position: sticky;
  512. top: 0;
  513. left: 0;
  514. z-index: 99;
  515. background: linear-gradient(180deg, #EDF6FF 0%, #FFFFFF 100%);
  516. .index-bg {
  517. position: absolute;
  518. top: 0;
  519. left: 0;
  520. z-index: -1;
  521. width: 750rpx;
  522. height: 260rpx;
  523. }
  524. .header-tabs {
  525. height: 84rpx;
  526. .tabs-item {
  527. padding: 0 42rpx;
  528. text:first-child {
  529. font-size: 32rpx;
  530. font-family: PingFangSC-Medium, PingFang SC;
  531. font-weight: 500;
  532. color: #777777;
  533. margin-bottom: 10rpx;
  534. }
  535. text:last-child {
  536. width: 36rpx;
  537. height: 6rpx;
  538. border-radius: 4rpx;
  539. }
  540. }
  541. .tabs-item1 {
  542. text:first-child {
  543. color: #000000;
  544. }
  545. text:last-child {
  546. background-color: #0C66C2;
  547. }
  548. }
  549. }
  550. .luntan-navbar {
  551. flex: 1;
  552. padding: 0 32rpx;
  553. .navbar-right {
  554. .luntan-search {
  555. height: 68rpx;
  556. background: #F3F3F3;
  557. border-radius: 20rpx;
  558. padding: 0 24rpx;
  559. margin-left: 80rpx;
  560. input {
  561. // flex: 1;
  562. margin-left: 12rpx;
  563. font-size: 26rpx;
  564. }
  565. }
  566. .right-icon {
  567. margin-left: 22rpx;
  568. position: relative;
  569. }
  570. }
  571. }
  572. }
  573. }
  574. page {
  575. background-color: #F6F6F6;
  576. }
  577. </style>