优化代码

This commit is contained in:
dengjie
2023-01-29 14:15:43 +08:00
parent 161f23f2c3
commit 09bbce1780
3 changed files with 32 additions and 15 deletions

View File

@@ -89,6 +89,7 @@
},
onLoad() {
this.getIdeasAndNeeds()
console.log(uni.getStorageSync('loginToken'));
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
this.isLoad = false
// uni.navigateTo({
@@ -102,7 +103,7 @@
//获取创意发布
getIdeasAndNeeds() {
this.$apiServe.getIdeasAndNeeds(this.type).then(res => {
// console.log('获取创意发布&需求发布', res.data.data);
console.log('获取创意发布&需求发布', res.data.data);
let data = res.data.data
for (const item of data) {
item.pub_time = dateFormatXwDetail(item.pub_time)

View File

@@ -5,8 +5,8 @@
</u-image>
<view class="collect" @click="starTap">
<view class="star">
<u-image v-if="detailList.is_fav==0" src="/static/detail/xp_icon_wstar.png" width="28rpx"
height="28rpx">
<u-image v-if="detailList.is_fav==0||!detailList.is_fav" src="/static/detail/xp_icon_wstar.png"
width="28rpx" height="28rpx">
</u-image>
<u-image v-if="detailList.is_fav==1" src="/static/detail/xp_icon_star.png" width="28rpx"
height="28rpx">
@@ -100,10 +100,13 @@
//获取详情信息
getProductDetail() {
this.$apiServe.getProductDetail(this.id).then(res => {
// console.log('产品详情页', res.data)
console.log('产品详情页', res.data)
if (res.data.data.thumb) {
this.isThumb = true
}
if (res.data.code == 0) {
this.$toast.warn('没有权限访问')
}
if (res.data.data) {
let detail = res.data.data
detail.pub_time = dateFormatDetail(detail.pub_time)
@@ -118,6 +121,9 @@
},
//收藏按钮
starTap() {
if (this.detailList.is_fav === 1) {
this.$toast.warn('已收藏')
} else if (this.detailList.is_fav === 0) {
this.$apiServe.collect(this.id).then(res => {
// console.log('收藏成功', res.data)
if (res.data.code == 1) {
@@ -127,10 +133,20 @@
this.$toast.warn('收藏失败')
}
}).finally(_ => {})
}
},
//点赞按钮
heartTap() {
this.showHeart = !this.showHeart
// this.showHeart = !this.showHeart
this.$apiServe.thumb(this.id).then(res => {
console.log('点赞成功', res.data)
if (res.data.code == 1) {
this.showHeart = 1
this.$toast.warn('点赞成功')
} else {
this.$toast.warn('点赞失败')
}
}).finally(_ => {})
},
reOnLoad() {
if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {

View File

@@ -8,7 +8,7 @@ function isOutTime(res) {
})
}, 1000)
uni.removeStorageSync('userInfo')
uni.removeStorageSync('loginToken')
uni.removeStorageSync('token')
} else {
// uni.showToast(res.data.message);
}