You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

143 lines
3.7 KiB

<template>
<view class="wishlist_body">
<view class="status_bar"></view>
<uni-nav-bar left-icon="left" :rightText="isDelete?'Done':'Delete'" title="Wishlist" color="#000000" @clickLeft="back" @clickRight="clickRight()"/>
<view class="wishlist">
<view class="wishlist_item" v-for="(item,index) in goodsList" :key="index" >
<view class="wishlist_item_img"@click="isDelete?selectGoods(item.goods_id): goDetails(item.goods_id)">
<image :src="item.goods_img" mode="" class="wishlist_item_img_goods"></image>
<image src="../../static/img/select1.png" mode="" class="select" v-if="isDelete && item.goods_id==goods_id || isAll"></image>
<image src="../../static/img/select.png" mode="" class="select" v-else-if="isDelete && item.goods_id!=goods_id"></image>
</view>
<view class="wishlist_item_bottom">
<text>US${{item.promote_price?item.promote_price:item.shop_price}}</text>
<image src="../../static/img/delete1.png" mode="" class="wishlist_item_bottom_icon" @click="removeL(item)"></image>
</view>
</view>
</view>
<view class="wishlist_foot" v-show="isDelete">
<view class="wishlist_foot_left" @click="isAll=!isAll">
<image src="../../static/img/select2.png" mode="" v-if="!isAll"></image>
<image src="../../static/img/select1.png" mode="" v-else></image>
<text>All</text>
</view>
<view class="wishlist_foot_right">
<button :disabled="!isAll" @click="$refs.alertDialog.open()" :class="isAll?'wishlist_foot_right_button':''">DELETE</button>
</view>
</view>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="error" cancelText="Close" confirmText="Sure" title="Tips" content="Cancel the collection of this product?"
@confirm="removeLike()" ></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {defaultRequest2} from '../../api/index.js'
export default {
data() {
return {
isDelete:false,
goodsList:[],
goods_id:'',
isAll:false
}
},
methods:{
selectGoods(id){
if(id==this.goods_id){
this.goods_id=''
}else{
this.goods_id=id
}
if(this.isAll ==true){
this.isDelete=true
}
},
removeL(e){
console.log(e.goods_id)
let data={_action:'unsetfaviouritegoods',goods_id:e.goods_id}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
title:'ok!',
icon:'none'
})
this.getList()
}
})
},
goDetails(id){
uni.navigateTo({
url:"../productDetails/index?goodid="+id
})
},
getList(){
let data={_action:'getfaviouritegoods',page_index:1,page_size:30}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
this.goodsList=res.data
}
})
},
// 添加收藏
addLike(id){
let data={_action:'setfaviouritegoods',goods_id:id}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
title:res.message,
icon:'none'
})
}
})
},
// 取消收藏
removeLike(){
let data={_action:'unsetfaviouritegoods',goods_id:this.goods_id}
if(this.isAll)data.goods_id=0
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
title:res.message,
icon:'none'
})
this.isAll = false
this.isDelete = false
this.getList()
}
})
},
back(){
uni.navigateBack()
},
clickRight(){
// this.isDelete=!this.isDelete
// this.isAll=false
if(this.goodsList){
this.isAll=false
this.isDelete=!this.isDelete
}
}
},
onLoad() {
this.getList()
}
}
</script>
<style lang="scss" scoped>
page{
}
.uni-navbar{
font-size: 32rpx;
font-weight: bold;
}
</style>