luntan.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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 :show="show" round="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. console.log("aaa",this.list);
  272. }
  273. if (this.tabsindex == 1) {
  274. grouplist({
  275. page: this.page,
  276. keywords: this.keyword
  277. }).then(res => {
  278. this.total = res.data.total
  279. this.list = this.list.concat(res.data.data)
  280. })
  281. console.log("bbb",this.list);
  282. }
  283. if (this.tabsindex == 2) {
  284. followuser({
  285. page: this.page,
  286. keywords: this.keyword
  287. }).then(res => {
  288. this.total = res.data.total
  289. this.list = this.list.concat(res.data.data)
  290. })
  291. }
  292. },
  293. touser(item) {
  294. uni.navigateTo({
  295. url: "/pagesC/my-luntan?id=" + item.uid
  296. })
  297. },
  298. toquanzi(item) {
  299. uni.navigateTo({
  300. url: "/pagesC/quanzi-info?id=" + item.circle_id
  301. })
  302. },
  303. toadd(type) {
  304. if (type == 1) {
  305. uni.navigateTo({
  306. url: "/pagesC/add-luntan"
  307. })
  308. }
  309. if (type == 2) {
  310. uni.navigateTo({
  311. url: "/pagesC/add-quanzi"
  312. })
  313. }
  314. this.show = false
  315. },
  316. toinfo(item) {
  317. uni.navigateTo({
  318. url: "/pagesC/luntan-info?id=" + item.id
  319. })
  320. },
  321. toxiaoxi() {
  322. uni.navigateTo({
  323. url: "/pagesC/xiaoxi-list"
  324. })
  325. }
  326. }
  327. }
  328. </script>
  329. <style lang="scss">
  330. .luntan-pages {
  331. .index-header {
  332. // flex: 1;
  333. padding: 0 32rpx;
  334. height: 50rpx;
  335. }
  336. .quanzi-list {
  337. padding: 0 32rpx;
  338. background-color: #fff;
  339. .quanzi-item {
  340. padding: 28rpx 0;
  341. border-bottom: 2rpx solid #F4F4F4;
  342. .quanzi-btn {
  343. width: 112rpx;
  344. border-radius: 24rpx;
  345. border: 1rpx solid #0C66C2;
  346. text-align: center;
  347. line-height: 48rpx;
  348. font-size: 26rpx;
  349. font-family: PingFangSC-Regular, PingFang SC;
  350. font-weight: 400;
  351. color: #0C66C2;
  352. }
  353. .quanzi-center {
  354. flex: 1;
  355. margin: 0 20rpx;
  356. text:first-child {
  357. font-size: 30rpx;
  358. font-family: PingFangSC-Medium, PingFang SC;
  359. font-weight: 500;
  360. color: #222222;
  361. margin-bottom: 14rpx;
  362. }
  363. text:last-child {
  364. font-size: 22rpx;
  365. font-family: PingFangSC-Regular, PingFang SC;
  366. font-weight: 400;
  367. color: #777777;
  368. }
  369. }
  370. .img {
  371. width: 96rpx;
  372. height: 96rpx;
  373. border-radius: 10rpx;
  374. background-color: rgba(0, 0, 0, 0.1);
  375. }
  376. }
  377. }
  378. .fabu-luntan {
  379. width: 566rpx;
  380. height: 308rpx;
  381. padding: 40rpx 100rpx 0 100rpx;
  382. box-sizing: border-box;
  383. .fabu-item {
  384. .fabu-img {
  385. width: 112rpx;
  386. height: 112rpx;
  387. background: rgba(12, 102, 194, 0.1);
  388. margin-bottom: 32rpx;
  389. border-radius: 100%;
  390. image {
  391. width: 56rpx;
  392. height: 56rpx;
  393. }
  394. }
  395. .fabu-text {
  396. font-size: 28rpx;
  397. font-family: PingFangSC-Medium, PingFang SC;
  398. font-weight: 500;
  399. color: #333333;
  400. }
  401. }
  402. }
  403. .luntan-fabu {
  404. width: 96rpx;
  405. height: 96rpx;
  406. background: #0C66C2;
  407. box-shadow: 0rpx 12rpx 48rpx -20rpx #0C66C2;
  408. position: fixed;
  409. bottom: 44rpx;
  410. right: 24rpx;
  411. z-index: 10;
  412. border-radius: 100rpx;
  413. image {
  414. width: 45rpx;
  415. height: 45rpx;
  416. }
  417. }
  418. .luntan-list {
  419. padding: 20rpx 20rpx 0 24rpx;
  420. box-sizing: border-box;
  421. .luntan-item {
  422. background: #FFFFFF;
  423. border-radius: 20rpx;
  424. margin: 20rpx auto;
  425. padding: 0 20rpx;
  426. .item-down {
  427. height: 84rpx;
  428. .down-item {
  429. width: 214rpx;
  430. image {
  431. width: 33rpx;
  432. height: 33rpx;
  433. }
  434. .text1 {
  435. font-size: 26rpx;
  436. font-family: ArialMT;
  437. color: #777777;
  438. margin-left: 12rpx;
  439. }
  440. }
  441. }
  442. .luntan-img {
  443. margin-top: 20rpx;
  444. width: 100%;
  445. image {
  446. width: 210rpx;
  447. height: 210rpx;
  448. border-radius: 10rpx;
  449. // margin-right: 10rpx;
  450. margin-bottom: 10rpx;
  451. }
  452. }
  453. .luntan-img::after {
  454. width: 210rpx;
  455. }
  456. .quanzi-box {
  457. padding: 0 20rpx;
  458. height: 50rpx;
  459. background: #F6F6F6;
  460. border-radius: 28rpx;
  461. margin: 20rpx 0 0 0;
  462. display: inline-flex;
  463. image {
  464. width: 28rpx;
  465. height: 28rpx;
  466. }
  467. text {
  468. font-size: 24rpx;
  469. font-family: PingFangSC-Regular, PingFang SC;
  470. font-weight: 400;
  471. color: #555555;
  472. margin-left: 8rpx;
  473. }
  474. }
  475. .luntan-user {
  476. height: 130rpx;
  477. .guanzhu-btn {
  478. width: 112rpx;
  479. line-height: 48rpx;
  480. border-radius: 24rpx;
  481. border: 1rpx solid #0C66C2;
  482. text-align: center;
  483. font-size: 26rpx;
  484. font-family: PingFangSC-Regular, PingFang SC;
  485. font-weight: 400;
  486. color: #0C66C2;
  487. }
  488. .user-center {
  489. margin: 0 16rpx;
  490. min-width: 1rpx;
  491. text:first-child {
  492. font-size: 28rpx;
  493. font-family: PingFangSC-Medium, PingFang SC;
  494. font-weight: 500;
  495. color: #222222;
  496. margin-bottom: 4rpx;
  497. }
  498. text:last-child {
  499. font-size: 20rpx;
  500. font-family: PingFangSC-Regular, PingFang SC;
  501. font-weight: 400;
  502. color: #818389;
  503. }
  504. }
  505. .user-head {
  506. width: 72rpx;
  507. height: 72rpx;
  508. border-radius: 100rpx;
  509. }
  510. }
  511. }
  512. }
  513. .luntan-header {
  514. position: sticky;
  515. top: 0;
  516. left: 0;
  517. z-index: 99;
  518. background: linear-gradient(180deg, #EDF6FF 0%, #FFFFFF 100%);
  519. .index-bg {
  520. position: absolute;
  521. top: 0;
  522. left: 0;
  523. z-index: -1;
  524. width: 750rpx;
  525. height: 260rpx;
  526. }
  527. .header-tabs {
  528. height: 84rpx;
  529. .tabs-item {
  530. padding: 0 42rpx;
  531. text:first-child {
  532. font-size: 32rpx;
  533. font-family: PingFangSC-Medium, PingFang SC;
  534. font-weight: 500;
  535. color: #777777;
  536. margin-bottom: 10rpx;
  537. }
  538. text:last-child {
  539. width: 36rpx;
  540. height: 6rpx;
  541. border-radius: 4rpx;
  542. }
  543. }
  544. .tabs-item1 {
  545. text:first-child {
  546. color: #000000;
  547. }
  548. text:last-child {
  549. background-color: #0C66C2;
  550. }
  551. }
  552. }
  553. .luntan-navbar {
  554. flex: 1;
  555. padding: 0 32rpx;
  556. .navbar-right {
  557. .luntan-search {
  558. height: 68rpx;
  559. background: #F3F3F3;
  560. border-radius: 20rpx;
  561. padding: 0 24rpx;
  562. margin-left: 80rpx;
  563. input {
  564. // flex: 1;
  565. margin-left: 12rpx;
  566. font-size: 26rpx;
  567. }
  568. }
  569. .right-icon {
  570. margin-left: 22rpx;
  571. position: relative;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. page {
  578. background-color: #F6F6F6;
  579. }
  580. </style>