|
@ -35,7 +35,7 @@ |
|
|
@click.stop="onCollect" |
|
|
@click.stop="onCollect" |
|
|
@touchstart.stop="() => {}" |
|
|
@touchstart.stop="() => {}" |
|
|
> |
|
|
> |
|
|
<view>收藏</view> |
|
|
|
|
|
|
|
|
<view>{{ isCollected ? '移除收藏' : '收藏' }}</view> |
|
|
</button> |
|
|
</button> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
@ -48,6 +48,10 @@ |
|
|
default() { |
|
|
default() { |
|
|
return {} |
|
|
return {} |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
isCollected: { |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
default: false, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
@ -65,13 +69,16 @@ |
|
|
return (this.data.currentPrice % this.priceInt).toFixed(2).slice(1) |
|
|
return (this.data.currentPrice % this.priceInt).toFixed(2).slice(1) |
|
|
}, |
|
|
}, |
|
|
collectBtnStyle() { |
|
|
collectBtnStyle() { |
|
|
let display = Math.ceil(this.displayX / 56 * 100) |
|
|
|
|
|
|
|
|
const width = this.isCollected ? 80 : 56 |
|
|
|
|
|
const background = this.isCollected ? '#26334E' : '#FF9035' |
|
|
|
|
|
|
|
|
|
|
|
let display = Math.ceil(this.displayX / this.collectBtnWidth * 100) |
|
|
|
|
|
|
|
|
display > 100 && (display = 100) |
|
|
display > 100 && (display = 100) |
|
|
|
|
|
|
|
|
const translateX = 100 - display |
|
|
const translateX = 100 - display |
|
|
|
|
|
|
|
|
return `transform: translateX(${translateX}%);` |
|
|
|
|
|
|
|
|
return `width: ${width}px; transform: translateX(${translateX}%); background: ${background};` |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
@ -108,13 +115,20 @@ |
|
|
}, |
|
|
}, |
|
|
onCollect() { |
|
|
onCollect() { |
|
|
console.log('onCollect') |
|
|
console.log('onCollect') |
|
|
|
|
|
|
|
|
// todo: fetch collect |
|
|
|
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
icon: 'success', |
|
|
|
|
|
title: '已收藏', |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (this.isCollected) { |
|
|
|
|
|
// todo: fetch cancel collect |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
icon: 'success', |
|
|
|
|
|
title: '已移除收藏', |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// todo: fetch collect |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
icon: 'success', |
|
|
|
|
|
title: '已收藏', |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
this.hiddenCollectBtn() |
|
|
this.hiddenCollectBtn() |
|
|
}, |
|
|
}, |
|
|
onRegistrate() { |
|
|
onRegistrate() { |
|
@ -216,12 +230,12 @@ |
|
|
top: 0; |
|
|
top: 0; |
|
|
right: 0; |
|
|
right: 0; |
|
|
row-gap: 8rpx; |
|
|
row-gap: 8rpx; |
|
|
width: 112rpx; |
|
|
|
|
|
|
|
|
// width: 112rpx; |
|
|
height: 100%; |
|
|
height: 100%; |
|
|
font-size: 24rpx; |
|
|
font-size: 24rpx; |
|
|
line-height: 1; |
|
|
line-height: 1; |
|
|
color: #FFFFFF; |
|
|
color: #FFFFFF; |
|
|
background: #FF9035; |
|
|
|
|
|
|
|
|
// background: #FF9035; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
</style> |
|
|
</style> |