|
@@ -1,18 +1,74 @@
|
|
|
<template>
|
|
|
<div class="collection">
|
|
|
- <div class="d-body" v-if="paging.total>0">
|
|
|
+ <div class="d-body" v-if="paging.total > 0">
|
|
|
<ul>
|
|
|
- <li class="collectionHover" @click="clickItem(item)" v-for="(item,i) in tableData" :key="i">
|
|
|
+ <li
|
|
|
+ class="collectionHover"
|
|
|
+ @mouseenter="moveLike=i"
|
|
|
+ @mouseleave="moveLike=null"
|
|
|
+ @click="clickItem($event, item)"
|
|
|
+ v-for="(item, i) in tableData"
|
|
|
+ :key="i"
|
|
|
+ >
|
|
|
<div>
|
|
|
- <img :src="item.thumb" :alt="item.title">
|
|
|
+ <!-- 点赞和投票 -->
|
|
|
+ <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="">
|
|
|
+ <span :title="item.name">{{ item.name || "-" }}</span>
|
|
|
+ <img :src="require('@/assets/images/xinjiang/enter.png')" alt="" />
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
- <Paging class="paging" @changeCurrent="data=>{this.$emit('changeCurrent',data)}" v-if="paging.total>0" :paging="paging" />
|
|
|
+ <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>
|
|
@@ -20,40 +76,95 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import Paging from '@/components/Paging'
|
|
|
+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 {
|
|
|
- props:{
|
|
|
- tableData:Array,
|
|
|
- paging:Object
|
|
|
+ name: "GOODSLIKE",
|
|
|
+ props: {
|
|
|
+ tableData: Array,
|
|
|
+ paging: Object,
|
|
|
+ likeOFF: {
|
|
|
+ type: Object,
|
|
|
+ default: () => {},
|
|
|
+ },
|
|
|
},
|
|
|
- components:{
|
|
|
- Paging
|
|
|
+ components: {
|
|
|
+ Paging,
|
|
|
},
|
|
|
- data(){
|
|
|
+ data() {
|
|
|
return {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ moveLike:null
|
|
|
+ };
|
|
|
},
|
|
|
- mounted(){
|
|
|
- },
|
|
|
- watch:{
|
|
|
-
|
|
|
- },
|
|
|
- methods:{
|
|
|
- clickItem(item){
|
|
|
+ mounted() {},
|
|
|
+ watch: {},
|
|
|
+ methods: {
|
|
|
+ clickItem(e, item) {
|
|
|
+ if (
|
|
|
+ e.path[0] &&
|
|
|
+ (e.path[0].className === "like_img" || e.path[0].className === "like")
|
|
|
+ )
|
|
|
+ return;
|
|
|
this.$showBroadcast({
|
|
|
item,
|
|
|
- zhuti:this.theme
|
|
|
- })
|
|
|
+ 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{
|
|
|
+.collection {
|
|
|
position: relative;
|
|
|
margin: 0 auto;
|
|
|
width: 100%;
|
|
@@ -61,17 +172,17 @@ export default {
|
|
|
justify-content: space-between;
|
|
|
align-items: flex-start;
|
|
|
min-height: 30vh;
|
|
|
-
|
|
|
- .d-body{
|
|
|
+
|
|
|
+ .d-body {
|
|
|
width: 100%;
|
|
|
text-align: center;
|
|
|
position: relative;
|
|
|
padding-bottom: 30px;
|
|
|
- >ul{
|
|
|
+ > ul {
|
|
|
width: 100%;
|
|
|
min-height: 70vh;
|
|
|
text-align: left;
|
|
|
- >li{
|
|
|
+ > li {
|
|
|
font-size: 0;
|
|
|
display: inline-block;
|
|
|
width: 310px;
|
|
@@ -79,25 +190,25 @@ export default {
|
|
|
text-align: center;
|
|
|
margin-bottom: 18px;
|
|
|
cursor: pointer;
|
|
|
- &:nth-child(3n){
|
|
|
+ &:nth-child(3n) {
|
|
|
margin-right: 0;
|
|
|
}
|
|
|
- >div{
|
|
|
- background: linear-gradient(180deg, #A2A2A2 0%, #606060 100%);
|
|
|
- &:first-child{
|
|
|
+ > div {
|
|
|
+ background: linear-gradient(180deg, #a2a2a2 0%, #606060 100%);
|
|
|
+ &:first-child {
|
|
|
height: 200px;
|
|
|
position: relative;
|
|
|
overflow: hidden;
|
|
|
- >img{
|
|
|
+ > img {
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
- transform: translate(-50%,-50%);
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
width: 100%;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- &:last-child{
|
|
|
+ &:last-child {
|
|
|
height: 50px;
|
|
|
padding: 0 12px;
|
|
|
display: flex;
|
|
@@ -106,7 +217,7 @@ export default {
|
|
|
background: #fff;
|
|
|
color: #333;
|
|
|
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
|
|
|
- >span{
|
|
|
+ > span {
|
|
|
width: calc(100% - 40px);
|
|
|
white-space: nowrap;
|
|
|
text-overflow: ellipsis;
|
|
@@ -115,17 +226,16 @@ export default {
|
|
|
font-weight: bold;
|
|
|
text-align: left;
|
|
|
}
|
|
|
- >img{
|
|
|
+ > img {
|
|
|
width: 30px;
|
|
|
height: 30px;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- &:hover{
|
|
|
- >div{
|
|
|
- &:last-child{
|
|
|
- >span{
|
|
|
+ &:hover {
|
|
|
+ > div {
|
|
|
+ &:last-child {
|
|
|
+ > span {
|
|
|
color: #fff;
|
|
|
}
|
|
|
}
|
|
@@ -133,19 +243,34 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .paging{
|
|
|
+ .paging {
|
|
|
margin-top: 40px;
|
|
|
font-weight: normal;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- .norecord{
|
|
|
+
|
|
|
+ .norecord {
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
- transform: translate(-50%,-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>
|