my-publish.vue 17 KB

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