my-publish.vue 18 KB

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