my-publish.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <view class="flex-common-css">
  3. <Nav title="我的发布" titleColor="#333" bgckgroundBox='#fff'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-css content-box box-sizing-border" @scrolltolower="scrolltolower">
  5. <view v-if="listData.length <= 0" class="scroll-view-css">
  6. <EnBlank :customSrc='true'>
  7. <template v-slot:blankImg>
  8. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  9. </template>
  10. </EnBlank>
  11. </view>
  12. <view class="item-box box-sizing-border b-rad-20 mb-20 bgc-f flex-justify-space" v-for="(item,index) in listData"
  13. :key="index" @click="goToUrl(item)">
  14. <image class="item-head-img flex-shrink0 b-rad-50 mr-16" :src="item.head_img" mode="aspectFill"></image>
  15. <view class="itme-right common-view-css box-border-box">
  16. <view class="item-name flex-justify-space mb-16">
  17. <view class="">
  18. <view class="mb-4 fc-3 fs-28">
  19. {{item.nickname}}
  20. </view>
  21. <view class="fs-24 fc-9">
  22. {{item.created_date}}
  23. </view>
  24. </view>
  25. <view class="align-items-center">
  26. <image class="rd-img mr-8" src="@/static/img/my/rd.png" mode=""></image>
  27. <view class="fs-26 fc-9">
  28. {{item.heat}}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="text-overflow-ellipsis-t item-content fs-30 fc-3 mb-16">
  33. {{item.content}}
  34. </view>
  35. <view class="item-img-box mb-20 align-items-center flex-wrap-wrap">
  36. <image class="b-rad-12" v-for="imgUrl in item.image" :src="imgUrl" mode="aspectFill"
  37. :class="item.image.length==1?'item-img-one':item.image.length==2?'item-img-two':'item-img-three'">
  38. </image>
  39. </view>
  40. <view class="align-items-center mb-40">
  41. <view class="label-box align-items-center mr-20 b-rad-200 bgc-F2F2F2">
  42. <image class="wz mr-8" src="@/static/img/my/wz.png" mode=""></image>
  43. <view class="fs-24 fc-9">
  44. {{item.school_name}}
  45. </view>
  46. </view>
  47. <view class="label-box align-items-center b-rad-200 bgc-F2F2F2">
  48. <image class="wz mr-8" src="@/static/img/my/ht.png" mode=""></image>
  49. <view class="fs-24 fc-9">
  50. {{item.topic_name}}
  51. </view>
  52. </view>
  53. </view>
  54. <view class="flex-justify-space">
  55. <view class="align-items-center" @click.stop="handUp(1,item)">
  56. <uni-icons class="mr-8" type="hand-up" size="22" :color="item.is_like==1?'#FD5C02':'#999'"></uni-icons>
  57. <view class="fs-24 fc-9">
  58. {{item.like}}
  59. </view>
  60. </view>
  61. <view class="align-items-center" @click.stop="openMsg(item,0)">
  62. <image class="but-icons mr-8" src="@/static/img/my/hf.png" mode=""></image>
  63. <view class="fs-24 fc-9">
  64. {{item.remark}}
  65. </view>
  66. </view>
  67. <uni-icons color="#999999" type="trash" size="20" @click.stop="alumniDelClick(item)"></uni-icons>
  68. </view>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. <movable-area class="add-box" v-show="false">
  73. <movable-view direction="all" y="300">
  74. <view class="add-but b-rad-50 text-align-center" @click="addInfo()">
  75. <uni-icons type="plusempty" color="#fff" size="30"></uni-icons>
  76. </view>
  77. </movable-view>
  78. </movable-area>
  79. <uni-popup ref="popmsg" type="bottom">
  80. <view class="pop-box pop-msg box-border-box p-24">
  81. <!-- 输入框 -->
  82. <view class="pop-input" v-if="isShowIpnut">
  83. <view class="head-pop flex-justify-space align-items-center mb-24 box-border-box p-24">
  84. <view class="fs-28 fw-600 fc-41ABF5"></view>
  85. <view class="fs-36 fc-0 fw-600">评论</view>
  86. <uni-icons @click.stop="closeInput()" type="closeempty" size="24"></uni-icons>
  87. </view>
  88. <view class="scroll-view-css">
  89. <view class="bgc-f box-border-box p-32">
  90. <view class="fs-34 fw-600 mb-20">评论</view>
  91. <textarea v-model="msgData.content" maxlength="100" class=" fs-24" placeholder='友善评论,文明发言'></textarea>
  92. </view>
  93. </view>
  94. <view class="box-border-box p-24">
  95. <view class="save-box" @click.stop="save()">评论</view>
  96. </view>
  97. </view>
  98. <!-- ----- -->
  99. <view class="head-pop flex-justify-space align-items-center mb-24">
  100. <view class=""></view>
  101. <view class="fs-36 fc-0 fw-600">评论内容</view>
  102. <uni-icons @click.stop="closeMsg()" type="closeempty" size="24"></uni-icons>
  103. </view>
  104. <view v-if="remarkData.list.length === 0" class="scroll-view-css">
  105. <EnBlank :customSrc='true'>
  106. <template v-slot:blankImg>
  107. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  108. </template>
  109. </EnBlank>
  110. </view>
  111. <view v-else class="scroll-view-css box-border-box plr-24">
  112. <view class="list-box flex-justify-space" v-for="(item,i) in remarkData.list" :key="i">
  113. <image class="list-box-img" :src="item.head_img" mode="scaleToFill"></image>
  114. <view class="flex-1 p-b-20">
  115. <view class=" flex-justify-space">
  116. <view class=" b-b-F9F9F9 mr-20">
  117. <view class="fs-28 fw-400 fc-9 mb-8 align-items-center">
  118. {{item.nickname}}
  119. <span v-if="item.is_author == 1" class='only-box text-align-center fs-24 fc-41ABF5 ml-10'>作者</span>
  120. <view class="ml-10" v-if="item.is_self == 1" @click="delInfo(item)">
  121. <uni-icons type="trash" size="18"></uni-icons>
  122. </view>
  123. </view>
  124. <view class="fs-30 fw-400 mb-8" @click.stop="openInput(1,item)">
  125. {{item.content}}
  126. </view>
  127. <view class="fs-24 fw-400 fc-9 mb-8">{{item.created_date}}</view>
  128. </view>
  129. <view class="display-flex" @click.stop="handUp(2,item)">
  130. <uni-icons type="hand-up" size="20" :color="item.is_like==1?'#FD5C02':'#999'"></uni-icons>
  131. <view class="fs-24 fw-400 mt-5" :class="item.is_like==1?'fc-FD5C02':'fc-9'">
  132. {{item.like}}
  133. </view>
  134. </view>
  135. </view>
  136. <view v-if="item.isOpen" class="fs-24 fc-6 text-align-center mb-12" @click="openReply(1,item)">展开更多评论
  137. </view>
  138. <!-- 回复 -->
  139. <view class="mb-16" v-if="item.replyList.length > 0">
  140. <view class="list-box flex-justify-space" v-for="(info,index) in item.replyList" :key="index">
  141. <image class="list-box-img" :src="info.head_img" mode="scaleToFill"></image>
  142. <view class="flex-1">
  143. <view class=" flex-justify-space">
  144. <view class=" b-b-F9F9F9 mr-20">
  145. <view class="fs-28 fw-400 fc-9 mb-8 align-items-center">
  146. {{info.nickname}}
  147. <span v-if="info.is_author == 1"
  148. class='only-box text-align-center fs-24 fc-41ABF5 ml-10'>作者</span>
  149. <view class="ml-10" v-if="info.is_self == 1" @click="delInfo(info)">
  150. <uni-icons type="trash" size="18"></uni-icons>
  151. </view>
  152. </view>
  153. <view class="fs-30 fw-400 mb-8" @click.stop="openInput(2,info)">
  154. {{info.content}}
  155. </view>
  156. <view class="fs-24 fw-400 fc-9 mb-8">{{info.created_date}}</view>
  157. </view>
  158. <view class="display-flex" @click.stop="handUp(2,info)">
  159. <uni-icons type="hand-up" size="20" :color="info.is_like==1?'#FD5C02':'#999'"></uni-icons>
  160. <view class="fs-24 fw-400 mt-5" :class="info.is_like==1?'fc-FD5C02':'fc-9'">{{info.like}}</view>
  161. </view>
  162. </view>
  163. </view>
  164. </view>
  165. <view v-if="item.replyList.length < item.count" class="fs-24 fc-6 text-align-center mb-12"
  166. @click="openReply(2,item)">展开更多评论</view>
  167. </view>
  168. </view>
  169. </view>
  170. <view v-if="remarkData.list.length < remarkData.total" class="text-align-center fs-26"
  171. @click="scrolltolowerList">加载更多评论</view>
  172. </view>
  173. <view class="input-box text-align-left fs-28 fc-9 box-border-box plr-24" @click.stop="openInput(0,'')">
  174. 友善评论,文明发言</view>
  175. </view>
  176. </uni-popup>
  177. </view>
  178. </template>
  179. <script>
  180. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  181. import {
  182. alumnMyAlumni,
  183. setAlumniLike,
  184. getRemarkList,
  185. setCreateRemark,
  186. alumniDel,
  187. setRemarkLike,
  188. delRemark
  189. } from "@/api/alumni.js"
  190. import tools from "@/service/tools";
  191. export default {
  192. components: {
  193. EnBlank
  194. },
  195. data() {
  196. return {
  197. listData: [],
  198. isShowIpnut: false,
  199. // 一级评论
  200. remarkData: {
  201. remark_id: '',
  202. news_id: '',
  203. total: 0,
  204. list: [],
  205. page: 1,
  206. },
  207. // 发起评论
  208. msgData: {
  209. news_id: '',
  210. remark_id: '',
  211. content: '',
  212. reply_id: '',
  213. },
  214. // 回复评论
  215. replyData: {
  216. page: 1,
  217. },
  218. isAJAX: false,
  219. total: 0,
  220. page: 1
  221. };
  222. },
  223. onLoad(data) {},
  224. mounted() {
  225. this.alumnMyAlumni()
  226. },
  227. methods: {
  228. goToUrl(item) {
  229. uni.navigateTo({
  230. url: "/pages-school/circle-info?news_id=" + item.news_id
  231. })
  232. },
  233. alumniDelClick(item) {
  234. // 删除帖子
  235. alumniDel({
  236. news_id: item.news_id
  237. }).then((res) => {
  238. if (res.code == 1) {
  239. tools.success(res.msg)
  240. this.listData = []
  241. this.page = 1;
  242. this.alumnMyAlumni()
  243. } else {
  244. tools.error(res.msg)
  245. }
  246. })
  247. },
  248. // 加载更多评论
  249. scrolltolowerList() {
  250. if (this.remarkData.list.length < this.remarkData.total) {
  251. this.remarkData.page += 1;
  252. this.getMsg();
  253. }
  254. },
  255. // 点赞
  256. handUp(type, item) {
  257. if (this.isAJAX) {
  258. return
  259. }
  260. this.isAJAX = true;
  261. let is_like = item.is_like == 1 ? 0 : 1;
  262. if (type == 1) {
  263. // 点赞贴子
  264. setAlumniLike({
  265. news_id: item.news_id,
  266. is_like: is_like
  267. }).then((res) => {
  268. this.handUpFun(res, item, is_like)
  269. })
  270. } else {
  271. // 点赞评论
  272. setRemarkLike({
  273. news_id: item.news_id,
  274. is_like: is_like,
  275. remark_id: item.id
  276. }).then((res) => {
  277. this.handUpFun(res, item, is_like)
  278. })
  279. }
  280. },
  281. // 点赞公共回复
  282. handUpFun(res, item, is_like) {
  283. if (res.code === 1) {
  284. item.is_like = is_like;
  285. if (is_like == 0) {
  286. item.like -= 1
  287. } else {
  288. item.like += 1
  289. }
  290. this.isAJAX = false;
  291. tools.success(res.msg);
  292. } else {
  293. this.isAJAX = false;
  294. tools.error(res.msg);
  295. }
  296. },
  297. openInput(type, item) {
  298. if (type == 0) {
  299. this.msgData.remark_id = 0;
  300. } else if (type == 1) {
  301. this.msgData.remark_id = item.id;
  302. this.msgData.reply_id = item.m_id;
  303. } else {
  304. this.msgData.remark_id = item.remark_id;
  305. this.msgData.reply_id = item.m_id;
  306. }
  307. this.isShowIpnut = true;
  308. },
  309. save() {
  310. if (this.isAJAX) {
  311. return
  312. }
  313. this.isAJAX = true;
  314. setCreateRemark(this.msgData).then((res) => {
  315. if (res.code == 1) {
  316. tools.success('评论成功')
  317. setTimeout(() => {
  318. this.isAJAX = false;
  319. this.closeInput()
  320. if (this.msgData.remark_id == 0) {
  321. this.remarkData.list = [];
  322. this.remarkData.page = 1;
  323. this.getMsg();
  324. // this.list = [];
  325. // this.fromData.page = 1;
  326. this.listData = []
  327. this.page = 1;
  328. this.alumnMyAlumni()
  329. } else {
  330. this.remarkData.list = [];
  331. this.remarkData.page = 1;
  332. this.getMsg();
  333. }
  334. }, 1500)
  335. } else {
  336. this.isAJAX = false;
  337. tools.error(res.msg)
  338. }
  339. })
  340. },
  341. closeInput() {
  342. this.isShowIpnut = false;
  343. this.msgData.remark_id = '';
  344. this.msgData.content = '';
  345. this.msgData.reply_id = '';
  346. },
  347. // 打开评论
  348. openMsg(item) {
  349. uni.navigateTo({
  350. url: "/pages-school/circle-info?news_id=" + item.news_id
  351. })
  352. // this.remarkData.news_id = item.news_id;
  353. // this.msgData.news_id = item.news_id;
  354. // this.remarkData.remark_id = 0;
  355. // this.getMsg();
  356. },
  357. // 获取回复列表
  358. openReply(type, item) {
  359. // type 1获取其他 2加载更多
  360. if (this.isAJAX) {
  361. return
  362. }
  363. this.isAJAX = true;
  364. if (type == 1) {
  365. item.replyList = [];
  366. this.replyData.page = 1;
  367. } else {
  368. this.replyData.page += 1;
  369. }
  370. getRemarkList({
  371. news_id: item.news_id,
  372. remark_id: item.id,
  373. page: this.replyData.page
  374. }).then((res) => {
  375. if (res.code === 1) {
  376. this.isAJAX = false;
  377. item.replyList = [...item.replyList, ...res.data.items];
  378. item.isOpen = false;
  379. } else {
  380. this.isAJAX = false;
  381. tools.error(res.msg)
  382. }
  383. })
  384. },
  385. closeMsg() {
  386. this.$refs.popmsg.close();
  387. this.remarkData.list = [];
  388. this.remarkData.page = 1;
  389. this.msgData.news_id = '';
  390. this.remarkData.remark_id = '';
  391. },
  392. delInfo(item) {
  393. if (this.isAJAX) {
  394. return
  395. }
  396. this.isAJAX = true;
  397. delRemark({
  398. remark_id: item.id
  399. }).then((res) => {
  400. if (res.code === 1) {
  401. tools.success('删除成功')
  402. setTimeout(() => {
  403. this.isAJAX = false;
  404. this.remarkData.list = [];
  405. this.remarkData.page = 1;
  406. this.getMsg();
  407. // this.list = [];
  408. // this.fromData.page = 1;
  409. // this.getList();
  410. this.listData = []
  411. this.page = 1;
  412. this.alumnMyAlumni()
  413. }, 1500)
  414. } else {
  415. this.isAJAX = false;
  416. tools.error(res.msg)
  417. }
  418. })
  419. },
  420. // 获取评论
  421. getMsg() {
  422. if (this.isAJAX) {
  423. return
  424. }
  425. this.isAJAX = true;
  426. getRemarkList({
  427. news_id: this.remarkData.news_id,
  428. remark_id: this.remarkData.remark_id,
  429. page: this.remarkData.page
  430. }).then((res) => {
  431. if (res.code === 1) {
  432. this.isAJAX = false;
  433. this.remarkData.list = [...this.remarkData.list, ...res.data.items];
  434. this.remarkData.total = res.data.total;
  435. this.remarkData.list.forEach((v) => {
  436. v.replyList = [];
  437. if (v.count > 0) {
  438. v.isOpen = true;
  439. }
  440. })
  441. this.$refs.popmsg.open();
  442. } else {
  443. this.isAJAX = false;
  444. tools.error(res.msg)
  445. }
  446. })
  447. },
  448. scrolltolower() {
  449. console.log('触底');
  450. },
  451. alumnMyAlumni() {
  452. alumnMyAlumni({
  453. page: this.page
  454. }).then((res) => {
  455. if (res.code == 1) {
  456. if (res.data.items.length > 0) {
  457. this.listData.push(...res.data.items)
  458. }
  459. }
  460. })
  461. }
  462. },
  463. }
  464. </script>
  465. <style lang="scss" scoped>
  466. .item-content {
  467. max-width: 558rpx;
  468. }
  469. .content-box {
  470. padding: 20rpx 24rpx;
  471. }
  472. .item-box {
  473. padding: 24rpx;
  474. }
  475. .item-name {
  476. align-items: flex-start;
  477. }
  478. .item-head-img {
  479. width: 80rpx;
  480. height: 80rpx;
  481. }
  482. .rd-img {
  483. width: 40rpx;
  484. height: 40rpx;
  485. }
  486. .label-box {
  487. padding: 0 12rpx;
  488. height: 38rpx;
  489. line-height: 38rpx;
  490. }
  491. .wz {
  492. width: 32rpx;
  493. height: 32rpx;
  494. }
  495. .but-icons {
  496. width: 40rpx;
  497. height: 40rpx;
  498. }
  499. .item-img-box {
  500. width: calc(100% + 6rpx);
  501. }
  502. .item-img-one {
  503. width: 360rpx;
  504. height: 360rpx;
  505. }
  506. .item-img-two {
  507. width: 276rpx;
  508. height: 276rpx;
  509. margin: 0 6rpx 0 0;
  510. }
  511. .item-img-three {
  512. width: 182rpx;
  513. height: 182rpx;
  514. margin: 0 6rpx 6rpx 0;
  515. }
  516. .add-box {
  517. position: fixed;
  518. right: 98rpx;
  519. top: 10vh;
  520. max-width: 88rpx;
  521. height: 80vh;
  522. z-index: 999;
  523. }
  524. .add-but {
  525. width: 88rpx;
  526. height: 88rpx;
  527. line-height: 88rpx;
  528. background: linear-gradient(284deg, #0290FC 0%, #01D8FF 100%);
  529. }
  530. .pop-box {
  531. width: 100%;
  532. height: 50vh;
  533. background-color: #fff;
  534. border-radius: 24rpx 24rpx 0rpx 0rpx;
  535. display: flex;
  536. flex-direction: column;
  537. .item-box {
  538. width: 100%;
  539. height: 92rpx;
  540. border-radius: 200rpx;
  541. line-height: 92rpx;
  542. text-align: center;
  543. margin-bottom: 24rpx;
  544. }
  545. }
  546. .pop-msg {
  547. height: 70vh;
  548. position: relative;
  549. .pop-input {
  550. position: absolute;
  551. width: 100%;
  552. height: 70vh;
  553. background-color: #fff;
  554. bottom: 0;
  555. left: 0;
  556. border-top: 1rpx solid #ccc;
  557. border-radius: 20rpx 20rpx 0 0;
  558. display: flex;
  559. flex-direction: column;
  560. .save-box {
  561. text-align: center;
  562. line-height: 88rpx;
  563. font-weight: 600;
  564. font-size: 32rpx;
  565. color: #FFFFFF;
  566. width: 100%;
  567. height: 80rpx;
  568. border-radius: 200rpx;
  569. background: linear-gradient(105deg, #57CAFF 0%, #41ABF5 100%);
  570. }
  571. }
  572. .head-pop {
  573. padding-bottom: 34rpx !important;
  574. border-bottom: 1rpx solid #F2F2F2;
  575. }
  576. .list-box {
  577. .list-box-img {
  578. width: 80rpx;
  579. height: 80rpx;
  580. border-radius: 50%;
  581. margin-right: 16rpx;
  582. }
  583. .only-box {
  584. padding: 4rpx 16rpx;
  585. background: rgba(65, 171, 245, 0.1);
  586. border-radius: 8rpx 8rpx 8rpx 8rpx;
  587. }
  588. .msg-img {
  589. width: 144rpx;
  590. height: 144rpx;
  591. border-radius: 12rpx;
  592. margin-right: 5rpx;
  593. margin-bottom: 5rpx;
  594. }
  595. .msg-img:nth-child(3n) {
  596. margin-right: 0rpx;
  597. }
  598. .msg-img-1 {
  599. width: 100rpx !important;
  600. height: 100rpx !important;
  601. }
  602. }
  603. }
  604. </style>