my-publish.vue 19 KB

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