my-publish.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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">
  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="text-overflow-ellipsis-t 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. <uni-icons color="#999999" type="trash" size="20" @click.stop="alumniDelClick(item)"></uni-icons>
  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"
  94. placeholder='友善评论,文明发言'></textarea>
  95. </view>
  96. </view>
  97. <view class="box-border-box p-24">
  98. <view class="save-box" @click.stop="save()">评论</view>
  99. </view>
  100. </view>
  101. <!-- ----- -->
  102. <view class="head-pop flex-justify-space align-items-center mb-24">
  103. <view class=""></view>
  104. <view class="fs-36 fc-0 fw-600">评论内容</view>
  105. <uni-icons @click.stop="closeMsg()" type="closeempty" size="24"></uni-icons>
  106. </view>
  107. <view v-if="remarkData.list.length === 0" class="scroll-view-css">
  108. <EnBlank :customSrc='true'>
  109. <template v-slot:blankImg>
  110. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  111. </template>
  112. </EnBlank>
  113. </view>
  114. <view v-else class="scroll-view-css box-border-box plr-24">
  115. <view class="list-box flex-justify-space" v-for="(item,i) in remarkData.list" :key="i">
  116. <image class="list-box-img" :src="item.head_img" mode="scaleToFill"></image>
  117. <view class="flex-1 p-b-20">
  118. <view class=" flex-justify-space">
  119. <view class=" b-b-F9F9F9 mr-20">
  120. <view class="fs-28 fw-400 fc-9 mb-8 align-items-center">
  121. {{item.nickname}}
  122. <span v-if="item.is_author == 1"
  123. class='only-box text-align-center fs-24 fc-41ABF5 ml-10'>作者</span>
  124. <view class="ml-10" v-if="item.is_self == 1" @click="delInfo(item)">
  125. <uni-icons type="trash" size="18"></uni-icons>
  126. </view>
  127. </view>
  128. <view class="fs-30 fw-400 mb-8" @click.stop="openInput(1,item)">
  129. {{item.content}}
  130. </view>
  131. <view class="fs-24 fw-400 fc-9 mb-8">{{item.created_date}}</view>
  132. </view>
  133. <view class="display-flex" @click.stop="handUp(2,item)">
  134. <uni-icons type="hand-up" size="20"
  135. :color="item.is_like==1?'#FD5C02':'#999'"></uni-icons>
  136. <view class="fs-24 fw-400 mt-5" :class="item.is_like==1?'fc-FD5C02':'fc-9'">
  137. {{item.like}}
  138. </view>
  139. </view>
  140. </view>
  141. <view v-if="item.isOpen" class="fs-24 fc-6 text-align-center mb-12"
  142. @click="openReply(1,item)">展开更多评论</view>
  143. <!-- 回复 -->
  144. <view class="mb-16" v-if="item.replyList.length > 0">
  145. <view class="list-box flex-justify-space" v-for="(info,index) in item.replyList"
  146. :key="index">
  147. <image class="list-box-img" :src="info.head_img" mode="scaleToFill"></image>
  148. <view class="flex-1">
  149. <view class=" flex-justify-space">
  150. <view class=" b-b-F9F9F9 mr-20">
  151. <view class="fs-28 fw-400 fc-9 mb-8 align-items-center">
  152. {{info.nickname}}
  153. <span v-if="info.is_author == 1"
  154. class='only-box text-align-center fs-24 fc-41ABF5 ml-10'>作者</span>
  155. <view class="ml-10" v-if="info.is_self == 1" @click="delInfo(info)">
  156. <uni-icons type="trash" size="18"></uni-icons>
  157. </view>
  158. </view>
  159. <view class="fs-30 fw-400 mb-8" @click.stop="openInput(2,info)">
  160. {{info.content}}
  161. </view>
  162. <view class="fs-24 fw-400 fc-9 mb-8">{{info.created_date}}</view>
  163. </view>
  164. <view class="display-flex" @click.stop="handUp(2,info)">
  165. <uni-icons type="hand-up" size="20"
  166. :color="info.is_like==1?'#FD5C02':'#999'"></uni-icons>
  167. <view class="fs-24 fw-400 mt-5"
  168. :class="info.is_like==1?'fc-FD5C02':'fc-9'">{{info.like}}</view>
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. <view v-if="item.replyList.length < item.count"
  174. class="fs-24 fc-6 text-align-center mb-12" @click="openReply(2,item)">展开更多评论</view>
  175. </view>
  176. </view>
  177. </view>
  178. <view v-if="remarkData.list.length < remarkData.total" class="text-align-center fs-26"
  179. @click="scrolltolowerList">加载更多评论</view>
  180. </view>
  181. <view class="input-box text-align-left fs-28 fc-9 box-border-box plr-24" @click.stop="openInput(0,'')">
  182. 友善评论,文明发言</view>
  183. </view>
  184. </uni-popup>
  185. </view>
  186. </template>
  187. <script>
  188. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  189. import {
  190. alumnMyAlumni,
  191. setAlumniLike,
  192. getRemarkList,
  193. setCreateRemark,
  194. alumniDel,
  195. setRemarkLike,
  196. delRemark
  197. } from "@/api/alumni.js"
  198. import tools from "@/service/tools";
  199. export default {
  200. components: {
  201. EnBlank
  202. },
  203. data() {
  204. return {
  205. listData: [],
  206. isShowIpnut: false,
  207. // 一级评论
  208. remarkData: {
  209. remark_id: '',
  210. news_id: '',
  211. total: 0,
  212. list: [],
  213. page: 1,
  214. },
  215. // 发起评论
  216. msgData: {
  217. news_id: '',
  218. remark_id: '',
  219. content: '',
  220. reply_id: '',
  221. },
  222. // 回复评论
  223. replyData: {
  224. page: 1,
  225. },
  226. isAJAX: false,
  227. total: 0,
  228. page: 1
  229. };
  230. },
  231. onLoad(data) {},
  232. mounted() {
  233. this.alumnMyAlumni()
  234. },
  235. methods: {
  236. goToUrl() {
  237. },
  238. alumniDelClick(item) {
  239. // 删除帖子
  240. alumniDel({
  241. news_id: item.news_id
  242. }).then((res) => {
  243. if (res.code == 1) {
  244. tools.success(res.msg)
  245. this.listData = []
  246. this.page = 1;
  247. this.alumnMyAlumni()
  248. } else {
  249. tools.error(res.msg)
  250. }
  251. })
  252. },
  253. // 加载更多评论
  254. scrolltolowerList() {
  255. if (this.remarkData.list.length < this.remarkData.total) {
  256. this.remarkData.page += 1;
  257. this.getMsg();
  258. }
  259. },
  260. // 点赞
  261. handUp(type, item) {
  262. if (this.isAJAX) {
  263. return
  264. }
  265. this.isAJAX = true;
  266. let is_like = item.is_like == 1 ? 0 : 1;
  267. if (type == 1) {
  268. // 点赞贴子
  269. setAlumniLike({
  270. news_id: item.news_id,
  271. is_like: is_like
  272. }).then((res) => {
  273. this.handUpFun(res, item, is_like)
  274. })
  275. } else {
  276. // 点赞评论
  277. setRemarkLike({
  278. news_id: item.news_id,
  279. is_like: is_like,
  280. remark_id: item.id
  281. }).then((res) => {
  282. this.handUpFun(res, item, is_like)
  283. })
  284. }
  285. },
  286. // 点赞公共回复
  287. handUpFun(res, item, is_like) {
  288. if (res.code === 1) {
  289. item.is_like = is_like;
  290. if (is_like == 0) {
  291. item.like -= 1
  292. } else {
  293. item.like += 1
  294. }
  295. this.isAJAX = false;
  296. tools.success(res.msg);
  297. } else {
  298. this.isAJAX = false;
  299. tools.error(res.msg);
  300. }
  301. },
  302. openInput(type, item) {
  303. if (type == 0) {
  304. this.msgData.remark_id = 0;
  305. } else if (type == 1) {
  306. this.msgData.remark_id = item.id;
  307. this.msgData.reply_id = item.m_id;
  308. } else {
  309. this.msgData.remark_id = item.remark_id;
  310. this.msgData.reply_id = item.m_id;
  311. }
  312. this.isShowIpnut = true;
  313. },
  314. save() {
  315. if (this.isAJAX) {
  316. return
  317. }
  318. this.isAJAX = true;
  319. setCreateRemark(this.msgData).then((res) => {
  320. if (res.code == 1) {
  321. tools.success('评论成功')
  322. setTimeout(() => {
  323. this.isAJAX = false;
  324. this.closeInput()
  325. if (this.msgData.remark_id == 0) {
  326. this.remarkData.list = [];
  327. this.remarkData.page = 1;
  328. this.getMsg();
  329. // this.list = [];
  330. // this.fromData.page = 1;
  331. this.listData = []
  332. this.page = 1;
  333. this.alumnMyAlumni()
  334. } else {
  335. this.remarkData.list = [];
  336. this.remarkData.page = 1;
  337. this.getMsg();
  338. }
  339. }, 1500)
  340. } else {
  341. this.isAJAX = false;
  342. tools.error(res.msg)
  343. }
  344. })
  345. },
  346. closeInput() {
  347. this.isShowIpnut = false;
  348. this.msgData.remark_id = '';
  349. this.msgData.content = '';
  350. this.msgData.reply_id = '';
  351. },
  352. // 打开评论
  353. openMsg(item) {
  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. .content-box {
  469. padding: 20rpx 24rpx;
  470. }
  471. .item-box {
  472. padding: 24rpx;
  473. }
  474. .item-name {
  475. align-items: flex-start;
  476. }
  477. .item-head-img {
  478. width: 80rpx;
  479. height: 80rpx;
  480. }
  481. .rd-img {
  482. width: 40rpx;
  483. height: 40rpx;
  484. }
  485. .label-box {
  486. padding: 0 12rpx;
  487. height: 38rpx;
  488. line-height: 38rpx;
  489. }
  490. .wz {
  491. width: 32rpx;
  492. height: 32rpx;
  493. }
  494. .but-icons {
  495. width: 40rpx;
  496. height: 40rpx;
  497. }
  498. .item-img-box {
  499. width: calc(100% + 6rpx);
  500. }
  501. .item-img-one {
  502. width: 360rpx;
  503. height: 360rpx;
  504. }
  505. .item-img-two {
  506. width: 276rpx;
  507. height: 276rpx;
  508. margin: 0 6rpx 0 0;
  509. }
  510. .item-img-three {
  511. width: 182rpx;
  512. height: 182rpx;
  513. margin: 0 6rpx 6rpx 0;
  514. }
  515. .add-box {
  516. position: fixed;
  517. right: 98rpx;
  518. top: 10vh;
  519. max-width: 88rpx;
  520. height: 80vh;
  521. z-index: 999;
  522. }
  523. .add-but {
  524. width: 88rpx;
  525. height: 88rpx;
  526. line-height: 88rpx;
  527. background: linear-gradient(284deg, #0290FC 0%, #01D8FF 100%);
  528. }
  529. .pop-box {
  530. width: 100%;
  531. height: 50vh;
  532. background-color: #fff;
  533. border-radius: 24rpx 24rpx 0rpx 0rpx;
  534. display: flex;
  535. flex-direction: column;
  536. .item-box {
  537. width: 100%;
  538. height: 92rpx;
  539. border-radius: 200rpx;
  540. line-height: 92rpx;
  541. text-align: center;
  542. margin-bottom: 24rpx;
  543. }
  544. }
  545. .pop-msg {
  546. height: 70vh;
  547. position: relative;
  548. .pop-input {
  549. position: absolute;
  550. width: 100%;
  551. height: 70vh;
  552. background-color: #fff;
  553. bottom: 0;
  554. left: 0;
  555. border-top: 1rpx solid #ccc;
  556. border-radius: 20rpx 20rpx 0 0;
  557. display: flex;
  558. flex-direction: column;
  559. .save-box {
  560. text-align: center;
  561. line-height: 88rpx;
  562. font-weight: 600;
  563. font-size: 32rpx;
  564. color: #FFFFFF;
  565. width: 100%;
  566. height: 80rpx;
  567. border-radius: 200rpx;
  568. background: linear-gradient(105deg, #57CAFF 0%, #41ABF5 100%);
  569. }
  570. }
  571. .head-pop {
  572. padding-bottom: 34rpx !important;
  573. border-bottom: 1rpx solid #F2F2F2;
  574. }
  575. .list-box {
  576. .list-box-img {
  577. width: 80rpx;
  578. height: 80rpx;
  579. border-radius: 50%;
  580. margin-right: 16rpx;
  581. }
  582. .only-box {
  583. padding: 4rpx 16rpx;
  584. background: rgba(65, 171, 245, 0.1);
  585. border-radius: 8rpx 8rpx 8rpx 8rpx;
  586. }
  587. .msg-img {
  588. width: 144rpx;
  589. height: 144rpx;
  590. border-radius: 12rpx;
  591. margin-right: 5rpx;
  592. margin-bottom: 5rpx;
  593. }
  594. .msg-img:nth-child(3n) {
  595. margin-right: 0rpx;
  596. }
  597. .msg-img-1 {
  598. width: 100rpx !important;
  599. height: 100rpx !important;
  600. }
  601. }
  602. }
  603. </style>