123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- <template>
- <div class="reporter">
- <Header
- :headerBg="'#00ADEF'"
- :headerBorder="'#5C5C5C'"
- :userBg="'rgba(0, 0, 0, 0.24)'"
- :LoginNavIndex="3"
- />
- <!-- <ul class="option">
- <li class="option-item" :class="[typeValue===indexo?'active':'']" v-for="(itemo,indexo) in optionList" :key="indexo" @click="handleClick(indexo)">
- <span>{{itemo.label}}</span>
- </li>
- </ul> -->
- <div class="content-top">
- <img src="../../assets/reporter-logo.png" />
- <el-input placeholder="搜索" v-model="searchInput" maxlength="100">
- <i
- slot="suffix"
- class="el-input__icon el-icon-search"
- @click="getData(1)"
- style="cursor: pointer"
- ></i>
- </el-input>
- <el-button
- type="primary"
- @click="changePublist"
- size="small"
- v-if="userMessage"
- >发布</el-button
- >
- <span v-else></span>
- </div>
- <ul>
- <li
- class="label-item"
- :class="[labelActiveIndex === indexL ? 'active' : '']"
- v-for="(itemL, indexL) in labelList"
- :key="indexL"
- @click="changeLabelIndex(indexL)"
- >
- # {{ itemL }}
- </li>
- </ul>
- <div class="waterfall">
- <vue-waterfall-easy
- ref="waterfall"
- :imgsArr="imgsArr"
- @scrollReachBottom="getData"
- >
- <div class="info" slot-scope="props">
- <div @click="lookDetail(props.value.id)">
- <el-image
- class="image"
- :src="props.value.cover_img_url"
- :fit="'cover'"
- :style="{
- width: '246px',
- height: Math.random() * (260 - 180) + 180 + 'px',
- borderRadius: '8px',
- }"
- v-if="props.value.cover_img_url"
- >
- <div
- slot="placeholder"
- class="image-slot"
- :style="'line-height:130px'"
- >
- 加载中<span class="dot">...</span>
- </div>
- </el-image>
- <h3>
- {{ props.value.art_title }}
- </h3>
- <p>
- {{ props.value.art_content }}
- </p>
- </div>
- <!-- <p>鼓浪屿实行最大承载量控制,每天最高5万人次,其中,游客3.5万人次,市民1.5万人次。鼓浪屿派出所出动无人机开展高空巡查,对重点区域动态监测客流,靠前化解风险隐患,守护群众安全。</p> -->
- <div class="creator-info">
- <el-image
- :src="
- props.value.creator_img_url
- ? props.value.creator_img_url
- : require('../../assets/avatar.png')
- "
- fit="cover"
- style="width: 24px; height: 24px; margin-right: 12px"
- >
- </el-image>
- <span class="name">{{ props.value.creator_name }}</span>
- <div class="ding-box">
- <svg-icon
- @click="handleLike(props.value)"
- icon-class="like"
- className="like-icon"
- v-if="props.value.ding_opt === 1"
- ></svg-icon>
- <svg-icon
- @click="handleLike(props.value)"
- icon-class="like-line"
- className="chat"
- v-else
- ></svg-icon>
- <span>{{ props.value.ding_count }}</span>
- <svg-icon
- @click="lookDetail(props.value.id)"
- icon-class="chat-line"
- className="chat"
- ></svg-icon>
- <span>{{ props.value.comment_count }}</span>
- </div>
- <el-dropdown trigger="click" @command="handleChange">
- <span class="el-dropdown-link">
- <img src="../../assets/dropdown-icon.png" />
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item :command="'edit&&&' + props.value.id"
- >编辑</el-dropdown-item
- >
- <el-dropdown-item
- :command="'delete&&&' + props.value.id"
- class="red-btn"
- >删除</el-dropdown-item
- >
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- <div slot="waterfall-over"></div>
- </vue-waterfall-easy>
- </div>
- <div class="nodata" v-if="imgsArr.length === 0">
- <img src="../../assets/nodata.png" />
- <p>还没有发布内容</p>
- </div>
- <el-dialog
- :visible.sync="publishFlag"
- :show-close="false"
- :close-on-click-modal="false"
- width="800px"
- :modal="false"
- class="login-dialog publish-report-box"
- v-if="publishFlag"
- >
- <publish-report
- :editId="editId"
- :info="reportInfo"
- @closeDialog="closeDialog"
- ></publish-report>
- </el-dialog>
- <el-dialog
- :visible.sync="reportDetailFlag"
- :show-close="false"
- :close-on-click-modal="false"
- width="1286px"
- :modal="false"
- class="login-dialog"
- v-if="reportDetailFlag"
- >
- <report-detail
- :info="reportInfo"
- @closeDetail="closeDetail"
- ></report-detail>
- </el-dialog>
- </div>
- </template>
- <script>
- //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- //例如:import 《组件名称》from ‘《组件路径》';
- import Header from "../../components/Header.vue";
- import vueWaterfallEasy from "vue-waterfall-easy";
- import { getLogin } from "@/api/ajax";
- import PublishReport from "./components/PublishReport.vue";
- import ReportDetail from "./components/ReportDetail.vue";
- import { getToken } from "@/utils/auth";
- export default {
- //import引入的组件需要注入到对象中才能使用
- components: { Header, vueWaterfallEasy, PublishReport, ReportDetail },
- props: {},
- data() {
- //这里存放数据
- return {
- optionList: [
- {
- label: "栏目 1",
- },
- {
- label: "栏目 2",
- },
- {
- label: "栏目 3",
- },
- {
- label: "栏目 4",
- },
- {
- label: "栏目 5",
- },
- // ,
- // {
- // label: '合刊',
- // img: 'hekan',
- // number: '6'
- // }
- ],
- typeValue: 0,
- loading: false,
- imgsArr: [],
- page: 0,
- pageSize: 50,
- pageNumber: 1,
- publishFlag: false, // 发布弹窗
- searchInput: "",
- labelList: [],
- labelActiveIndex: null,
- reportDetailFlag: false,
- reportInfo: null,
- userMessage: getToken() ? JSON.parse(getToken()) : null,
- };
- },
- //计算属性 类似于data概念
- computed: {},
- //监控data中数据变化
- watch: {},
- //方法集合
- methods: {
- handleClick(value) {
- this.typeValue = value;
- },
- getData(page) {
- if (page) {
- this.pageNumber = page;
- this.imgsArr = [];
- }
- let MethodName = "/PaperServer/Client/Xjz/XjzArticleList";
- let data = {
- page_capacity: this.pageSize,
- cur_page: this.pageNumber,
- art_tag:
- this.labelActiveIndex !== null
- ? this.labelList[this.labelActiveIndex]
- : "",
- };
- getLogin(MethodName, data).then((res) => {
- if (res.status === 1) {
- this.labelList = res.tags;
- this.imgsArr = this.imgsArr.concat(res.data.list);
- if (this.imgsArr.length === 0) return;
- if (this.pageNumber === res.data.total_page) {
- this.$refs.waterfall.waterfallOver();
- } else {
- this.pageNumber++;
- }
- }
- });
- },
- // 点击发布按钮
- changePublist() {
- this.editId = "";
- this.reportInfo = null;
- this.publishFlag = true;
- },
- // 点击label
- changeLabelIndex(index) {
- if (this.labelActiveIndex === index) {
- this.labelActiveIndex = null;
- } else {
- this.labelActiveIndex = index;
- }
- this.getData(1);
- },
- closeDialog() {
- this.publishFlag = false;
- this.getData(1);
- },
- // 查看详情
- lookDetail(id, flag) {
- let MethodName = "/PaperServer/Client/Xjz/XjzArticleDetail";
- let data = {
- id: id,
- };
- getLogin(MethodName, data).then((res) => {
- if (res.status === 1) {
- this.reportInfo = res.data;
- if (flag) {
- this.publishFlag = true;
- } else {
- this.reportDetailFlag = true;
- }
- }
- });
- },
- closeDetail() {
- this.reportDetailFlag = false;
- },
- async handleChange(com) {
- const arr = com.split("&&&");
- if (arr[0] === "edit") {
- await this.lookDetail(arr[1], true);
- this.editId = arr[1];
- } else {
- this.handleDel(arr[1]);
- }
- },
- //删除小记者文章
- handleDel(id) {
- this.$confirm("确定删除吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- let MethodName = "/PaperServer/Client/Xjz/XjzArticleDel";
- let data = {
- id: id,
- };
- getLogin(MethodName, data).then((res) => {
- if (res.status === 1) {
- this.getData(1);
- }
- });
- });
- },
- // 点赞/取消赞
- handleLike(item) {
- let MethodName = "/PaperServer/Client/Xjz/XjzArticleOptDing";
- let data = {
- bound_id: item.id,
- ding_opt: item.ding_opt === 1 ? 0 : 1,
- };
- getLogin(MethodName, data).then((res) => {
- if (res.status === 1) {
- item.ding_count =
- item.ding_opt === 1 ? item.ding_count - 1 : item.ding_count + 1;
- item.ding_opt = item.ding_opt === 1 ? 0 : 1;
- this.$forceUpdate();
- }
- });
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- this.getData();
- let _this = this;
- let input = document.querySelector("input");
- input.addEventListener("keyup", function (event) {
- // 判断是否按下回车键
- if (event.keyCode === 13) {
- // 回车键被按下,执行你想要的操作
- _this.getData(1);
- }
- });
- },
- //生命周期-创建之前
- beforeCreated() {},
- //生命周期-挂载之前
- beforeMount() {},
- //生命周期-更新之前
- beforUpdate() {},
- //生命周期-更新之后
- updated() {},
- //生命周期-销毁之前
- beforeDestory() {},
- //生命周期-销毁完成
- destoryed() {},
- //如果页面有keep-alive缓存功能,这个函数会触发
- activated() {},
- };
- </script>
- <style lang="scss" scoped>
- /* @import url(); 引入css类 */
- .reporter {
- background: #f7f8fa;
- height: calc(100vh - 64px);
- .option {
- list-style: none;
- display: flex;
- justify-content: center;
- margin: 0;
- padding: 0;
- background: #00adef;
- li {
- display: flex;
- align-items: center;
- border-radius: 30px;
- height: 36px;
- padding: 7px 20px;
- margin: 8px 4px;
- cursor: pointer;
- &:hover {
- background: rgba(255, 255, 255, 0.08);
- }
- &.active {
- background: rgba(255, 255, 255, 0.08);
- .icon-img,
- span,
- b {
- color: rgba(255, 255, 255, 0.9);
- }
- }
- .icon-img {
- width: 14px;
- height: 14px;
- margin: 1px 8px 0 0;
- color: rgba(255, 255, 255, 0.5);
- }
- span {
- color: rgba(255, 255, 255, 0.5);
- font-size: 14px;
- line-height: 22px;
- }
- b {
- font-weight: 400;
- font-size: 14px;
- line-height: 22px;
- color: rgba(255, 255, 255, 0.5);
- margin-left: 5px;
- }
- }
- }
- .main {
- width: 1200px;
- margin: 0 auto;
- padding: 24px 0 0 0;
- .searchChangebox {
- display: flex;
- justify-content: space-between;
- .searchChange-box {
- display: flex;
- }
- .searchChange {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 4px 12px;
- height: 32px;
- margin-right: 16px;
- border: 1px solid #e5e6eb;
- border-radius: 20px;
- &.active {
- background: #175dff;
- > span {
- color: #ffffff;
- }
- .sort {
- > div {
- svg {
- color: #5e89ef;
- &.active {
- color: #ffffff;
- }
- }
- }
- }
- }
- > span {
- font-weight: 400;
- font-size: 16px;
- line-height: 22px;
- color: #000;
- margin-right: 4px;
- }
- .sort {
- cursor: pointer;
- height: 20px;
- > div {
- font-size: 0;
- svg {
- width: 11px;
- height: 11px;
- color: #c2c2c2;
- padding: 3px 2px 2px 2px;
- &.icon-down {
- height: 9px;
- padding: 0 2px 2px 2px;
- }
- }
- }
- }
- }
- .input-search {
- width: 220px;
- }
- }
- .show-title {
- color: #1f2c5c;
- margin: 24px 0 0 0;
- font-weight: 500;
- font-size: 24px;
- line-height: 32px;
- b {
- margin-left: 16px;
- color: #ed5f00;
- }
- }
- .list {
- margin-top: 28px;
- display: flex;
- flex-wrap: wrap;
- height: calc(100vh - 256px);
- overflow-y: scroll;
- &::-webkit-scrollbar {
- display: none;
- }
- > div {
- width: 200px;
- border-radius: 8px;
- overflow: hidden;
- background: #ffffff;
- margin-bottom: 24px;
- }
- .tips {
- width: 100%;
- text-align: center;
- font-size: 12px;
- color: #929ca8;
- }
- }
- }
- .waterfall {
- position: absolute;
- top: 216px;
- bottom: 0;
- left: 0;
- width: 100%;
- }
- .info {
- text-align: center;
- font-size: 0;
- h3 {
- margin: 8px 0;
- overflow: hidden;
- color: #000;
- font-size: 14px;
- font-weight: 500;
- line-height: 22px;
- word-break: break-word;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- text-overflow: ellipsis;
- overflow: hidden;
- text-align: left;
- padding: 0 8px;
- }
- > div {
- > p {
- color: rgba(0, 0, 0, 0.65);
- font-size: 14px;
- font-weight: 400;
- line-height: 22px;
- word-break: break-word;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- text-overflow: ellipsis;
- overflow: hidden;
- text-align: left;
- padding: 0 8px;
- margin: 0 0 8px 0;
- }
- }
- .creator-info {
- text-align: left;
- padding: 0 8px;
- display: flex;
- align-items: center;
- > span {
- color: #2f3742;
- font-size: 14px;
- font-weight: 400;
- line-height: 22px;
- flex: 1;
- overflow: hidden;
- }
- .ding-box {
- color: rgba(0, 0, 0, 0.3);
- font-size: 12px;
- font-weight: 400;
- line-height: 20px;
- display: flex;
- align-items: center;
- .svg-icon {
- width: 16px;
- height: 16px;
- &.chat {
- color: rgba(0, 0, 0, 0.65);
- }
- &.like-icon {
- color: #f62727;
- }
- }
- span {
- margin: 0 8px 0 3px;
- }
- }
- }
- }
- .content-top {
- display: flex;
- justify-content: space-between;
- padding: 32px 0;
- max-width: 1440px;
- margin: 0 auto;
- > img {
- height: 32px;
- }
- .el-input {
- width: 480px;
- border-radius: 40px;
- background: #fff;
- }
- .el-button {
- width: 108px;
- text-align: center;
- border-radius: 40px;
- font-size: 14px;
- }
- }
- ul {
- padding: 0;
- max-width: 1440px;
- margin: 0 auto;
- display: flex;
- li.label-item {
- padding: 4px 12px;
- border-radius: 20px;
- margin-right: 8px;
- cursor: pointer;
- color: #787878;
- font-size: 12px;
- font-weight: 400;
- line-height: 20px;
- &.active {
- background: #ececec;
- color: #000000;
- }
- }
- }
- .el-dropdown-link {
- width: 16px;
- height: 16px;
- border-radius: 4px;
- display: inline-block;
- margin-top: 2px;
- &.el-dropdown-selfdefine:focus:active {
- background: #e6e6e6;
- }
- > img {
- width: 16px;
- height: 16px;
- }
- }
- }
- :deep .el-dropdown-menu__item {
- line-height: 24px;
- padding: 2px 8px;
- border-radius: 3px;
- width: 56px;
- text-align: center;
- &:hover {
- color: #000;
- }
- }
- .red-btn {
- color: #ec1f1f;
- &:hover {
- color: #ec1f1f;
- }
- }
- </style>
- <style lang="scss">
- .reporter {
- .el-input__inner {
- border-radius: 40px;
- border: none;
- }
- }
- .publish-report-box {
- .el-dialog__body {
- padding: 24px;
- }
- }
- .vue-waterfall-easy {
- // width: 1440px !important;
- // margin-left: -720px !important;
- .img-inner-box {
- box-shadow: none !important;
- }
- .img-box {
- padding: 12px !important;
- width: 270px !important;
- }
- }
- </style>
|