This commit is contained in:
lnn19986213 2024-05-15 16:17:48 +08:00
parent 50dc1510fa
commit dfeb3f467e
4 changed files with 170 additions and 122 deletions

View File

@ -36,7 +36,7 @@
<view class="art_item" v-for="(v, i) in workList" :key="i">
<view class="art_item_top">
<image :src="v.file" mode="" @click="toDetail(v.id,v.goodsId)"></image>
<view class="like" @click="like(v.id, v.isGreat)">
<view class="like" @click="like(v.id, v.isGreat,i)">
<view :class="v.isGreat ? 'img_selected' : 'img'">
<!-- 红心 -->
</view>
@ -86,6 +86,7 @@
pages: 1,
size: 20,
lineBg: '../../static/scrollLine.png',
likeBtn: true,
};
},
onLoad(option) {
@ -189,32 +190,42 @@
})
},
//
like(val1, val2) {
if (val2) {
this.http.request('/worksGreat/delGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.pages = 1
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
this.http.request('/worksGreat/addGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.pages = 1
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
like(val1, val2, num) {
if(this.likeBtn){
this.likeBtn = false
if (val2) {
this.http.request('/worksGreat/delGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].isGreat = false
this.workList[num].likes--
this.load = false
this.likeBtn = true
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
} else {
this.http.request('/worksGreat/addGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].isGreat = true
this.workList[num].likes++
this.load = false
this.likeBtn = true
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
}
}
},
//
toDetail(val1,val2){

View File

@ -136,7 +136,8 @@
scrollTop: 0,
old: {
scrollTop: 0
}
},
likeBtn: true,
};
},
onReady() {
@ -330,33 +331,45 @@
},
//
like(val1, val2, num) {
if (val2) {
this.workList[num].isGreat = false
this.http.request('/worksGreat/delGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].likes--
this.load = false
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
this.workList[num].isGreat = true
this.http.request('/worksGreat/addGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].likes++
this.load = false
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
if (this.likeBtn) {
this.likeBtn = false
if (val2) {
this.http.request('/worksGreat/delGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].isGreat = false
this.workList[num].likes--
this.load = false
this.likeBtn = true
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
} else {
this.http.request('/worksGreat/addGreat?type=1&workId=' + val1, "POST").then(res => {
if (res.code == 200) {
this.workList[num].isGreat = true
this.workList[num].likes++
this.load = false
this.likeBtn = true
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
}
}
},
//
toDetail(val, num) {

View File

@ -146,7 +146,9 @@
contractUrl: '',
isFollow: '',
userId: '',
cover: ''
cover: '',
likeBtn: true,
colBtn: true
}
},
onLoad(op) {
@ -228,6 +230,8 @@
this.userId = this.detailData.user.id
}
_this.load = false
this.likeBtn = true
this.colBtn = true
}
}).catch(e => {
uni.showToast({
@ -238,55 +242,67 @@
},
//
clickHeart() {
if (this.detailData.isGreat) {
this.http.request('/worksGreat/delGreat?type=1&workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
this.http.request('/worksGreat/addGreat?type=1&workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
if(this.likeBtn){
this.likeBtn = false
if (this.detailData.isGreat) {
this.http.request('/worksGreat/delGreat?type=1&workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
} else {
this.http.request('/worksGreat/addGreat?type=1&workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.likeBtn = true
})
}
}
},
//
clickStar() {
if (this.detailData.isColl) {
this.http.request('/worksCollection/delCollection?workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
this.http.request('/worksCollection/addCollection?workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
if(this.colBtn){
this.colBtn = false
if (this.detailData.isColl) {
this.http.request('/worksCollection/delCollection?workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.colBtn = true
})
} else {
this.http.request('/worksCollection/addCollection?workId=' + this.detailData.id, "POST").then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.colBtn = true
})
}
}
},
toUser(val1,val2,val3,val4){
uni.navigateTo({

View File

@ -237,6 +237,7 @@
shopCarId: '',
}],
buyType: '',
colBtn: true
}
},
onLoad(option) {
@ -292,6 +293,7 @@
this.scores = res.data.scores
}
this.load = false
this.colBtn = true
}
}).catch(e => {
uni.showToast({
@ -333,31 +335,37 @@
},
//
ClickStart() {
if (this.serveList.follow) {
this.http.request('/worksCollection/delCollection?workId=' + this.serveList.domainInfo.id, "POST")
.then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
this.http.request('/worksCollection/addCollection?workId=' + this.serveList.domainInfo.id, "POST")
.then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
if(this.colBtn){
this.colBtn = false
if (this.serveList.follow) {
this.http.request('/worksCollection/delCollection?workId=' + this.serveList.domainInfo.id, "POST")
.then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.colBtn = true
})
} else {
this.http.request('/worksCollection/addCollection?workId=' + this.serveList.domainInfo.id, "POST")
.then(res => {
if (res.code == 200) {
this.getData()
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
this.colBtn = true
})
}
}
},
//
goAllPingjia() {