my-publish.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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.stop="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="text-overflow-ellipsis-t 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. <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. uni.navigateTo({
  238. })
  239. },
  240. alumniDelClick(item) {
  241. // 删除帖子
  242. alumniDel({
  243. news_id: item.news_id
  244. }).then((res) => {
  245. if (res.code == 1) {
  246. tools.success(res.msg)
  247. this.listData = []
  248. this.page = 1;
  249. this.alumnMyAlumni()
  250. } else {
  251. tools.error(res.msg)
  252. }
  253. })
  254. },
  255. // 加载更多评论
  256. scrolltolowerList() {
  257. if (this.remarkData.list.length < this.remarkData.total) {
  258. this.remarkData.page += 1;
  259. this.getMsg();
  260. }
  261. },
  262. // 点赞
  263. handUp(type, item) {
  264. if (this.isAJAX) {
  265. return
  266. }
  267. this.isAJAX = true;
  268. let is_like = item.is_like == 1 ? 0 : 1;
  269. if (type == 1) {
  270. // 点赞贴子
  271. setAlumniLike({
  272. news_id: item.news_id,
  273. is_like: is_like
  274. }).then((res) => {
  275. this.handUpFun(res, item, is_like)
  276. })
  277. } else {
  278. // 点赞评论
  279. setRemarkLike({
  280. news_id: item.news_id,
  281. is_like: is_like,
  282. remark_id: item.id
  283. }).then((res) => {
  284. this.handUpFun(res, item, is_like)
  285. })
  286. }
  287. },
  288. // 点赞公共回复
  289. handUpFun(res, item, is_like) {
  290. if (res.code === 1) {
  291. item.is_like = is_like;
  292. if (is_like == 0) {
  293. item.like -= 1
  294. } else {
  295. item.like += 1
  296. }
  297. this.isAJAX = false;
  298. tools.success(res.msg);
  299. } else {
  300. this.isAJAX = false;
  301. tools.error(res.msg);
  302. }
  303. },
  304. openInput(type, item) {
  305. if (type == 0) {
  306. this.msgData.remark_id = 0;
  307. } else if (type == 1) {
  308. this.msgData.remark_id = item.id;
  309. this.msgData.reply_id = item.m_id;
  310. } else {
  311. this.msgData.remark_id = item.remark_id;
  312. this.msgData.reply_id = item.m_id;
  313. }
  314. this.isShowIpnut = true;
  315. },
  316. save() {
  317. if (this.isAJAX) {
  318. return
  319. }
  320. this.isAJAX = true;
  321. setCreateRemark(this.msgData).then((res) => {
  322. if (res.code == 1) {
  323. tools.success('评论成功')
  324. setTimeout(() => {
  325. this.isAJAX = false;
  326. this.closeInput()
  327. if (this.msgData.remark_id == 0) {
  328. this.remarkData.list = [];
  329. this.remarkData.page = 1;
  330. this.getMsg();
  331. // this.list = [];
  332. // this.fromData.page = 1;
  333. this.listData = []
  334. this.page = 1;
  335. this.alumnMyAlumni()
  336. } else {
  337. this.remarkData.list = [];
  338. this.remarkData.page = 1;
  339. this.getMsg();
  340. }
  341. }, 1500)
  342. } else {
  343. this.isAJAX = false;
  344. tools.error(res.msg)
  345. }
  346. })
  347. },
  348. closeInput() {
  349. this.isShowIpnut = false;
  350. this.msgData.remark_id = '';
  351. this.msgData.content = '';
  352. this.msgData.reply_id = '';
  353. },
  354. // 打开评论
  355. openMsg(item) {
  356. uni.navigateTo({
  357. url: "/pages-school/circle-info?news_id=" + item.news_id
  358. })
  359. // this.remarkData.news_id = item.news_id;
  360. // this.msgData.news_id = item.news_id;
  361. // this.remarkData.remark_id = 0;
  362. // this.getMsg();
  363. },
  364. // 获取回复列表
  365. openReply(type, item) {
  366. // type 1获取其他 2加载更多
  367. if (this.isAJAX) {
  368. return
  369. }
  370. this.isAJAX = true;
  371. if (type == 1) {
  372. item.replyList = [];
  373. this.replyData.page = 1;
  374. } else {
  375. this.replyData.page += 1;
  376. }
  377. getRemarkList({
  378. news_id: item.news_id,
  379. remark_id: item.id,
  380. page: this.replyData.page
  381. }).then((res) => {
  382. if (res.code === 1) {
  383. this.isAJAX = false;
  384. item.replyList = [...item.replyList, ...res.data.items];
  385. item.isOpen = false;
  386. } else {
  387. this.isAJAX = false;
  388. tools.error(res.msg)
  389. }
  390. })
  391. },
  392. closeMsg() {
  393. this.$refs.popmsg.close();
  394. this.remarkData.list = [];
  395. this.remarkData.page = 1;
  396. this.msgData.news_id = '';
  397. this.remarkData.remark_id = '';
  398. },
  399. delInfo(item) {
  400. if (this.isAJAX) {
  401. return
  402. }
  403. this.isAJAX = true;
  404. delRemark({
  405. remark_id: item.id
  406. }).then((res) => {
  407. if (res.code === 1) {
  408. tools.success('删除成功')
  409. setTimeout(() => {
  410. this.isAJAX = false;
  411. this.remarkData.list = [];
  412. this.remarkData.page = 1;
  413. this.getMsg();
  414. // this.list = [];
  415. // this.fromData.page = 1;
  416. // this.getList();
  417. this.listData = []
  418. this.page = 1;
  419. this.alumnMyAlumni()
  420. }, 1500)
  421. } else {
  422. this.isAJAX = false;
  423. tools.error(res.msg)
  424. }
  425. })
  426. },
  427. // 获取评论
  428. getMsg() {
  429. if (this.isAJAX) {
  430. return
  431. }
  432. this.isAJAX = true;
  433. getRemarkList({
  434. news_id: this.remarkData.news_id,
  435. remark_id: this.remarkData.remark_id,
  436. page: this.remarkData.page
  437. }).then((res) => {
  438. if (res.code === 1) {
  439. this.isAJAX = false;
  440. this.remarkData.list = [...this.remarkData.list, ...res.data.items];
  441. this.remarkData.total = res.data.total;
  442. this.remarkData.list.forEach((v) => {
  443. v.replyList = [];
  444. if (v.count > 0) {
  445. v.isOpen = true;
  446. }
  447. })
  448. this.$refs.popmsg.open();
  449. } else {
  450. this.isAJAX = false;
  451. tools.error(res.msg)
  452. }
  453. })
  454. },
  455. scrolltolower() {
  456. console.log('触底');
  457. },
  458. alumnMyAlumni() {
  459. alumnMyAlumni({
  460. page: this.page
  461. }).then((res) => {
  462. if (res.code == 1) {
  463. if (res.data.items.length > 0) {
  464. this.listData.push(...res.data.items)
  465. }
  466. }
  467. })
  468. }
  469. },
  470. }
  471. </script>
  472. <style lang="scss" scoped>
  473. .item-content{
  474. max-width: 558rpx;
  475. }
  476. .content-box {
  477. padding: 20rpx 24rpx;
  478. }
  479. .item-box {
  480. padding: 24rpx;
  481. }
  482. .item-name {
  483. align-items: flex-start;
  484. }
  485. .item-head-img {
  486. width: 80rpx;
  487. height: 80rpx;
  488. }
  489. .rd-img {
  490. width: 40rpx;
  491. height: 40rpx;
  492. }
  493. .label-box {
  494. padding: 0 12rpx;
  495. height: 38rpx;
  496. line-height: 38rpx;
  497. }
  498. .wz {
  499. width: 32rpx;
  500. height: 32rpx;
  501. }
  502. .but-icons {
  503. width: 40rpx;
  504. height: 40rpx;
  505. }
  506. .item-img-box {
  507. width: calc(100% + 6rpx);
  508. }
  509. .item-img-one {
  510. width: 360rpx;
  511. height: 360rpx;
  512. }
  513. .item-img-two {
  514. width: 276rpx;
  515. height: 276rpx;
  516. margin: 0 6rpx 0 0;
  517. }
  518. .item-img-three {
  519. width: 182rpx;
  520. height: 182rpx;
  521. margin: 0 6rpx 6rpx 0;
  522. }
  523. .add-box {
  524. position: fixed;
  525. right: 98rpx;
  526. top: 10vh;
  527. max-width: 88rpx;
  528. height: 80vh;
  529. z-index: 999;
  530. }
  531. .add-but {
  532. width: 88rpx;
  533. height: 88rpx;
  534. line-height: 88rpx;
  535. background: linear-gradient(284deg, #0290FC 0%, #01D8FF 100%);
  536. }
  537. .pop-box {
  538. width: 100%;
  539. height: 50vh;
  540. background-color: #fff;
  541. border-radius: 24rpx 24rpx 0rpx 0rpx;
  542. display: flex;
  543. flex-direction: column;
  544. .item-box {
  545. width: 100%;
  546. height: 92rpx;
  547. border-radius: 200rpx;
  548. line-height: 92rpx;
  549. text-align: center;
  550. margin-bottom: 24rpx;
  551. }
  552. }
  553. .pop-msg {
  554. height: 70vh;
  555. position: relative;
  556. .pop-input {
  557. position: absolute;
  558. width: 100%;
  559. height: 70vh;
  560. background-color: #fff;
  561. bottom: 0;
  562. left: 0;
  563. border-top: 1rpx solid #ccc;
  564. border-radius: 20rpx 20rpx 0 0;
  565. display: flex;
  566. flex-direction: column;
  567. .save-box {
  568. text-align: center;
  569. line-height: 88rpx;
  570. font-weight: 600;
  571. font-size: 32rpx;
  572. color: #FFFFFF;
  573. width: 100%;
  574. height: 80rpx;
  575. border-radius: 200rpx;
  576. background: linear-gradient(105deg, #57CAFF 0%, #41ABF5 100%);
  577. }
  578. }
  579. .head-pop {
  580. padding-bottom: 34rpx !important;
  581. border-bottom: 1rpx solid #F2F2F2;
  582. }
  583. .list-box {
  584. .list-box-img {
  585. width: 80rpx;
  586. height: 80rpx;
  587. border-radius: 50%;
  588. margin-right: 16rpx;
  589. }
  590. .only-box {
  591. padding: 4rpx 16rpx;
  592. background: rgba(65, 171, 245, 0.1);
  593. border-radius: 8rpx 8rpx 8rpx 8rpx;
  594. }
  595. .msg-img {
  596. width: 144rpx;
  597. height: 144rpx;
  598. border-radius: 12rpx;
  599. margin-right: 5rpx;
  600. margin-bottom: 5rpx;
  601. }
  602. .msg-img:nth-child(3n) {
  603. margin-right: 0rpx;
  604. }
  605. .msg-img-1 {
  606. width: 100rpx !important;
  607. height: 100rpx !important;
  608. }
  609. }
  610. }
  611. </style>