123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- <template>
- <div class="collection">
- <div class="d-body" v-if="paging.total > 0">
- <ul>
- <li
- class="collectionHover"
- @mouseenter="moveLike = i"
- @mouseleave="moveLike = null"
- @click="clickItem($event, item)"
- v-for="(item, i) in tableData"
- :key="i"
- >
- <div>
- <!-- 点赞和投票 -->
- <i class="like" v-show="moveLike === i">
- <img
- v-if="item.isLike"
- v-show="likeOFF.isLike"
- class="like_img"
- :src="require(`@/assets/dianzan/${theme}Z.png`)"
- alt=""
- title="取消点赞"
- @click="praiseNo(item.id)"
- />
- <img
- v-else
- v-show="likeOFF.isLike"
- class="like_img"
- src="../../assets/dianzan/dianzan.png"
- alt=""
- title="点赞"
- @click="praise(item.id)"
- />
- <img
- v-if="item.isVote"
- v-show="likeOFF.isVote"
- class="like_img"
- :src="require(`@/assets/dianzan/${theme}T.png`)"
- alt=""
- title="取消投票"
- @click="voteNo(item.id)"
- />
- <img
- v-else
- v-show="likeOFF.isVote"
- class="like_img"
- src="../../assets/dianzan/toupiao.png"
- alt=""
- title="投票"
- @click="vote(item.id)"
- />
- </i>
- <img :src="item.thumb" :alt="item.title" />
- </div>
- <div>
- <span :title="item.name">{{ item.name || "-" }}</span>
- <img :src="require('@/assets/images/xinjiang/enter.png')" alt="" />
- </div>
- </li>
- </ul>
- <Paging
- :key="likeOFF.id"
- class="paging"
- @changeCurrent="
- (data) => {
- this.$emit('changeCurrent', data);
- }
- "
- v-if="paging.total > 0"
- :paging="paging"
- />
- </div>
- <div class="norecord" v-else>暂无数据</div>
- </div>
- </template>
- <script>
- import "element-ui/lib/theme-chalk/index.css";
- import { Notification } from "element-ui";
- import {
- goodsLikeApi,
- goodsLikeDelApi,
- goodsVoteApi,
- goodsVoteDelApi,
- } from "@/config/api";
- import Paging from "@/components/Paging";
- export default {
- name: "GOODSLIKE",
- props: {
- tableData: Array,
- paging: Object,
- likeOFF: {
- type: Object,
- default: () => {},
- },
- },
- components: {
- Paging,
- },
- data() {
- return {
- moveLike: null,
- };
- },
- mounted() {},
- watch: {},
- methods: {
- clickItem(e, item) {
- if (
- e.path[0] &&
- (e.path[0].className === "like_img" || e.path[0].className === "like")
- )
- return;
- if (item.link) return window.open(item.link);
- this.$showBroadcast({
- item,
- zhuti: this.theme,
- });
- },
- // 点击点赞
- async praise(id) {
- let res = await goodsLikeApi({
- goodsId: id,
- goodsModuleId: this.likeOFF.id,
- });
- if (res.code === 0) {
- this.infoTitle("点赞成功", "success");
- this.$emit("upLike");
- }
- },
- //点击取消点赞
- async praiseNo(id) {
- let res = await goodsLikeDelApi(id);
- if (res.code === 0) {
- this.infoTitle("取消点赞成功", "success");
- this.$emit("upLike");
- }
- },
- // 点击投票
- async vote(id) {
- let res = await goodsVoteApi({
- goodsId: id,
- goodsModuleId: this.likeOFF.id,
- });
- if (res.code === 0) {
- this.infoTitle("投票成功", "success");
- this.$emit("upLike");
- }
- },
- // 点击取消投票
- async voteNo(id) {
- let res = await goodsVoteDelApi(id);
- if (res.code === 0) {
- this.infoTitle("取消投票成功", "success");
- this.$emit("upLike");
- }
- },
- // 封装消息提示信息
- infoTitle(title, type) {
- Notification({
- title,
- type,
- position: "bottom-right",
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .collection {
- position: relative;
- margin: 0 auto;
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- min-height: 30vh;
- .d-body {
- width: 100%;
- text-align: center;
- position: relative;
- padding-bottom: 30px;
- > ul {
- width: 100%;
- min-height: 70vh;
- text-align: left;
- > li {
- font-size: 0;
- display: inline-block;
- width: 310px;
- margin-right: 18px;
- text-align: center;
- margin-bottom: 18px;
- cursor: pointer;
- &:nth-child(3n) {
- margin-right: 0;
- }
- > div {
- background: linear-gradient(180deg, #a2a2a2 0%, #606060 100%);
- &:first-child {
- height: 200px;
- position: relative;
- overflow: hidden;
- > img {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 100%;
- }
- }
- &:last-child {
- height: 50px;
- padding: 0 12px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- background: #fff;
- color: #333;
- box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
- > span {
- width: calc(100% - 40px);
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- word-break: break-all;
- font-weight: bold;
- text-align: left;
- }
- > img {
- width: 30px;
- height: 30px;
- }
- }
- }
- &:hover {
- > div {
- &:last-child {
- > span {
- color: #fff;
- }
- }
- }
- }
- }
- }
- .paging {
- margin-top: 40px;
- font-weight: normal;
- }
- }
- .norecord {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- font-size: 16px;
- color: #000;
- }
- .collectionHover {
- position: relative;
- .like {
- padding: 5px;
- z-index: 999;
- position: absolute;
- right: 0;
- top: 0px;
- & > img {
- width: 24px;
- height: 24px;
- margin-right: 5px;
- }
- }
- }
- }
- </style>
|