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.
 
 
 
 
 
 

969 lines
24 KiB

<template>
<view class="wishlist_body margin-top-40">
<view class="status_bar">
<uni-nav-bar left-icon="left" :rightText="isDelete?'Done':'Delete'" :fixed="true" :border="false"
title="Wishlist" color="#fff" backgroundColor="#000000" @clickLeft="back" @clickRight="clickRight()"/>
</view>
<view class="wishlist padding-top-40">
<view class="wishlist_item" v-for="(item,index) in goodsList" :key="item.goods_id" >
<view class="wishlist_item_img "@click="isDelete?selectGoods(item.goods_id,index): goDetails(item.goods_id)">
<image :src="item.goods_img" mode="" class="wishlist_item_img_goods"></image>
<image src="../../static/img/select1.png" @click="deleteTap(item)" mode=" " class="select" v-if="isDelete && item.goods_id==deletelist[index].id || isAll"></image>
<image src="../../static/img/select.png" mode="" class="select" v-else-if=" isDelete &&item.goods_id!=deletelist[index].id"></image>
<!-- <image :src="Src" @click="deleteTap(item)" mode=" " v-model="item.goods_id" class="select" v-if="isDelete || item.goods_id==goods_id"></image> -->
</view>
<view class="wishlist_item_bottom">
<text style="margin-left: 4px;">US${{item.promote_price?item.promote_price:item.shop_price}}</text>
<image src="../../static/icon/cat_white.png" mode="" style="margin-right: 0px;" class="wishlist_item_bottom_icon" @click="isCart=true,getDate(item)"></image>
<!-- <text>US${{item.promote_price?item.promote_price:item.shop_price}}</text> -->
<!-- <image src="../../static/icon/cat_white.png" mode="" class="wishlist_item_bottom_icon" @click="isCart=true,getDate(item)"></image> -->
<!-- <image src="../../static/img/delete.png" mode="" class="wishlist_item_bottom_icon" @click="removeL(item)"> --></image>
</view>
</view>
</view>
<view class="empty_item1" v-if="!goodsList">
<view class="empty_item_img">
<image src = "../../static/img/heart_white.png" mode=""></image>
</view>
<view>Full refund for the first order for new members~</view>
<view>
<button @click="goPage()">go shopping</button>
</view>
</view>
<view class="wishlist_foot" v-show="isDelete">
<view class="wishlist_foot_left" @click="isAllTap()">
<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=" !goods_id" @click="$refs.alertDialog.open()" :class="(goods_id)?'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 class="addCard" v-show="isCart">
<image src="/static/img/close1.png" mode="" class="addCard_close" @click="isCart=false"></image>
<scroll-view class="spike1 " scroll-x="true" :show-scrollbar="false">
<image :src="item.img_url" mode="" class="addCard_scroll img_border" v-for="(item,index) in goodsDate.gallery_list" :key="index" @click="clickImg(index)"></image>
</scroll-view>
<scroll-view class="addCard_body"scroll-y="true">
<view >{{goodsDate.goods_name}} </view>
<view class="addCard_price">US${{goodsDate.is_promote==0? shop_price :goodsDate.promote_price}}</view>
<view v-for="(item,index) in goods_attr_list" :key="item.attr_id">
<view >{{item.name}}</view>
<view class="color_select variations_select_size">
<!-- <view class="select_size_item"
v-for="(item1,index1) in item.goods_attrs"
:key="item1.goods_attr_id"
:class="goods_attr_list[index].goods_attr_id==item1.goods_attr_id?'active_color':''"
@click="selectAttr(item.attr_id,item1.goods_attr_id,index)">
{{item1.attr_value}}
</view> -->
<view class="color_select_item" v-for="(item1,index1) in item.list" :key="item1.attr_value"
:class="goods_attr_list[index].goods_attr_id==item1.goods_attr_id?'active_color':''" @click="selectAttr(item.attr_id,item1.goods_attr_id,index1,item1.attr_price)">
<view class="color_select_item_zoom">
<image src="/static/icon/big2.png" @click="clickImg(index1)" mode=""v-if="item1.attr_img!=''"></image>
</view>
<image :src="item1.attr_img" mode="" v-if="item1.attr_img!=''" ></image>
<view class="color_select_item_bottom" v-if="item1.attr_img!=''">【{{ item1.attr_value}}】</view>
<view class="color_select_item_bottom" v-if="!item1.attr_img">{{ item1.attr_value}}</view>
</view>
</view>
</view>
<!-- <view >Size</view>
<view class="variations_select_size">
<view class="select_size_item">34</view>
<view class="select_size_item">35</view>
<view class="select_size_item">36</view>
<view class="select_size_item">37</view>
<view class="select_size_item">38</view>
<view class="select_size_item">M</view>
<view class="select_size_item">L</view>
</view> -->
<view class="quantity">
<text>Quantity</text>
<uni-number-box background="#FFFFFF" v-model="cartQuery.goods_number" :min="1"></uni-number-box>
</view>
</scroll-view>
<!-- <view class="quantity">
<text>Quantity</text>
<uni-number-box background="#FFFFFF" v-model="cartQuery.goods_number" :min="1"></uni-number-box>
</view> -->
<button @click="addCart">ADD TO CART</button>
</view>
<view class="bootom_last" v-if="bootom == 1">-THE END-</view>
</view>
</template>
<script>
import {defaultRequest2} from '../../api/index.js'
export default {
data() {
return {
isDelete:false,
goodsList:[],
goods_id:'',
isAll:false,
isCart:false,
Src:'../../static/img/select.png',
deletelist:[],
Select_one:0,
goodsDate:{
comment_summary:[
{comment_summary:'',commentlabel: ""}
],
gallery_list:[
{content:''}
],
},
commonlist:[],
//选择规格的数组
goods_attr_list:[],
// 获取该分类的其他商品的请求参数
catQuery:{
_action:'getgoods',
cat:'',
page_index:1,
page_size:10
},
shop_price:0,
Is_attr:0,//是否有规格
// 添加到购物车请求参数
cartQuery:{
_action:'addtocart',
goods_id:'',
goods_parent_id:0,
goods_number:1,
goods_attr_id:'',
goods_is_package:0
},
query:{
_action:'getgoodsdetail',
goods_id:''
},
info: [],
bootom:0,
}
},
methods:{
onReachBottom(e){
console.log(111)
this.bootom = 1
},
selectGoods(id,index){
if(id==this.goods_id){
this.goods_id=''
}else{
this.goods_id=id
}
if(this.isAll ==true){
this.isDelete=true
}
let i = index
console.log(i)
let list = ({
id:this.goodsList[i].goods_id,
index:i
})
let tag = 1
const _list = JSON.stringify(list)
const _delete = JSON.stringify(this.deletelist)
console.log( _list, _delete)
console.log(_delete.includes(_list))
for(let i =0;i<this.deletelist.length;i++){
if(this.deletelist[i].id == list.id){
this.deletelist[i].id =''
this.deletelist[i].index =''
tag = 0
}
}
if(tag!=0){
// this.deletelist.push(list)
this.deletelist[index].id = list.id
this.deletelist[index].index = list.index
console.log(this.deletelist)
uni.setStorage({
key: 'deletelist',
data: JSON.stringify(this.deletelist)
});
}
let list2 =[]
this.deletelist.map( item =>{
if(item.id!=''){
console.log(111)
list2.push(item)
}
})
console.log(list2)
if(list2.length>0&&list2.length !== this.goodsList.length){
this.Select_one = 1
this.goods_id = 1
this.isAll = false
}
else if(list2.length == this.goodsList.length){
this.isAll = true
}else if(list2.length == 0){
this.isAll = false
this.Select_one = 0
this.goods_id = ''
this.deletelist[index].id = ''
list2 =[]
}
// this.$store.commit('addSave', list)
// if(this.$store.state.goodslist.includes(list)){
// const i = this.$store.state.goodslist.indexOf(list)
// this.$store.state.goodslist = this.$store.state.goodslist.splice(i,1)
// console.log(i)
// }
},
deleteTap(u){
this.goods_id = item.goods_id
},
goPage(){
uni.switchTab({
url:'../index/index'
})
},
isAllTap(){
this.isAll = !this.isAll
if(this.isAll == false){
this.goods_id = ''
for(let i =0;i<this.deletelist.length;i++){
this.deletelist[i].id =''
this.deletelist[i].index =''
}
}else{
this.goods_id = 1
for(let i =0;i<this.goodsList.length;i++){
this.deletelist[i].index = i
this.deletelist[i].id = this.goodsList[i].goods_id
}
console.log(this.deletelist)
}
},
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',
duration: 2000
})
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
this.goodsList.map( item =>{
this.deletelist.push({
index:'',
id:''
})
})
}
})
},
// 添加收藏
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',
duration: 2000
})
}
})
},
// 取消收藏
async removeLike(){
// let data={_action:'unsetfaviouritegoods',goods_id:this.goods_id}
// if(this.isAll)data.goods_id=0
let list =[]
let res
this.deletelist.map( item =>{
if(item.id!=''){
console.log(111)
list.push(item)
}
})
console.log(list)
res = await Promise.all(list.map(async (item) => {
// 等待异步操作完成,返回执行结果
return await defaultRequest2({
_action: 'unsetfaviouritegoods',
goods_id: item.id
})
}));
console.log(res)
if(res[0].error==0){
console.info(1234)
setTimeout(() =>{
uni.showToast({
title:'ok!',
icon:'none',
duration: 2000
})
},1000)
this.getList()
// uni.startPullDownRefresh()
this.isAll = false
this.isDelete = false
}
},
back(){
uni.navigateBack()
},
clickRight(){
// this.isDelete=!this.isDelete
// this.isAll=false
if(this.goodsList){
this.isAll= false
this.isDelete=!this.isDelete
}
},
// 获取商品详情数据
getDate(item){
this.isCart = true
console.log(item)
this.goodsDate = []
this.goods_attr_list = []
this.cartQuery.goods_id = item.goods_id
this.query.goods_id= item.goods_id
defaultRequest2(this.query).then(res=>{
if(res.error==0){
console.log(res.data)
this.goodsDate=res.data
console.log(this.goodsDate.attr_list)
// 评论
// if(this.goodsDate.comment_list)
// {
// if(this.goodsDate.comment_list.length<2){
// this.commonlist.push(this.goodsDate.comment_list[0])
// }else if(this.goodsDate.comment_list.length == 0){
// this.commonlist = []
// }
// else{
// for(let i =0;i<2;i++){
// this.commonlist.push(this.goodsDate.comment_list[i])
// }
// }
// }
// console.log(this.commonlist)
this.shop_price = this.goodsDate.shop_price
this.goodsDate.gallery_list.map(item=>{
item.content=''
this.info.push(item.img_url)
// this.Attr_list = this.goodsDate.attr_list[0].goods_attrs
})
this.Is_attr = this.goodsDate.attr_list.length
if(this.Is_attr>0){
console.log(this.goodsDate.attr_list)
console.log(this.Is_attr)
let Size_list
let Attr_list
this.goodsDate.attr_list.map(item=>{
console.log(item)
// if(item.attr_name){
// this.sizenum=item.goods_attrs.length
// }
// if(item.attr_name=="Color"){
// this.colorNum=item.goods_attrs.length
// console.log(this.colorNum)
// Attr_list = item.goods_attrs
// let i = 0
// Attr_list.map( item =>{
// this.Attr_list +=item.attr_value + '、'
// i++
// })
// this.Attr_list= this.Attr_list.substring(0, this.Attr_list.length-1)
// console.log(i)
// this.max = i
// }
// else if(item.attr_name=="Size"){
// Size_list = item.goods_attrs
// console.log(this.sizenum)
// Size_list.map( item =>{
// this.Size_list +=item.attr_value + ' '
// })
// this.Size_list= this.Size_list.substring(0, this.Size_list.length-1)
// }
let data={name:item.attr_name,goods_attr_id:'',attr_id:item.attr_id,list:item.goods_attrs}
this.goods_attr_list.push(data)
console.log(this.goods_attr_list)
let list = []
this.goods_attr_list.map( item =>{
item.list.map(item1 =>{
if(!item1.attr_img){
this.tag = 1
}
})
})
})
}else{
this.goods_attr_list=[]
this.Is_attr = 0
}
// this.catQuery.cat=res.data.cat_id
}
})
},
// 选择规格
selectAttr(attr_id,goods_attr_id,index1,attr_price){
this.current = index1
let sum = this.goodsDate.shop_price
if(attr_price){
sum = parseInt(sum) + parseInt(attr_price)
console.log(sum)
}
this.shop_price = sum
let data={attr_id:attr_id,goods_attr_id:goods_attr_id}
if(this.goods_attr_list.length==0){
this.goods_attr_list.push(data)
}else{
// 判断是否有新的规格加入
let isNew=false
for(let i in this.goods_attr_list){
let item=this.goods_attr_list[i]
if(item.attr_id==attr_id){
if(item.goods_attr_id==goods_attr_id){
this.goods_attr_list[i].goods_attr_id=''
}else{
this.goods_attr_list[i].goods_attr_id=goods_attr_id
}
isNew=false
break
}else{
isNew=true
}
}
if(isNew){
this.goods_attr_list.splice(index,0,data)
}
}
},
// 添加到购物车
addCart(){
if(this.Is_attr>0){
let goods_attr_id=''
this.goods_attr_list.map(item=>{
if(item.goods_attr_id!=''){
goods_attr_id+=item.goods_attr_id+','
}
})
let isall = 1
this.goods_attr_list.map(item =>{
//console.log(item.goods_attr_id)
if(item.goods_attr_id==''){
isall = 0
}
})
if(isall == 0){
uni.showToast({
title:'Please select the product specification',
icon:'none',
duration: 2000
})
return
}
this.cartQuery.goods_attr_id=goods_attr_id.substring(0,goods_attr_id.lastIndexOf(','));
}
console.log(this.cartQuery)
defaultRequest2(this.cartQuery).then(res=>{
console.log(res)
if(res.error==0){
this.isCart = false
this.cartQuery.goods_attr_id = ''
if(res.data[0].success){
setTimeout( ()=>{
uni.showToast({
title:'Successfully added',
icon:'none',
duration: 2000
})
},500)
}
this.getCartNum()
}
})
},
// 点击预览图片
clickImg(index,e) {
// console.log(e.length)
let list = []
if(e){
if(typeof(e) ==='object')
{
for(let i in e ){
console.log(e[i].afile)
list.push(e[i].afile)
console.log(list)
}}
else{
e.map( item =>
{
list.push(item.attr_img)
})
}
wx.previewImage({
urls: list, //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
current: index, // 当前显示图片的http链接,默认是第一个
indicator:'number',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
}
else{
wx.previewImage({
urls: this.info, //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
current: index, // 当前显示图片的http链接,默认是第一个
indicator:'number',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
}
},
},
onLoad() {
let that = this;
let s = 0;
let time = setInterval(() => {
uni.getNetworkType({
success: (res) => {
console.log(res.networkType, s);
if (res.networkType == 'none') {
uni.showToast({
icon: 'none',
title: 'Please connect to the network',
duration: 3000,
})
} else if (res.networkType !== 'none') {
that.typee = 2;
clearInterval(time);
}
}
})
s++;
}, 1000);
this.getList()
// uni.startPullDownRefresh()
// uni.clearStorage()
this.deletelist = []
// let list = await uni.getStorage({
// key: 'deletelist'
// });
// if (list.length>1) {
// this.deletelist = JSON.parse(list[1].data);
// console.log(this.deletelist);
// }
},
onPullDownRefresh(){
this.getList()
setTimeout(function() {
uni.stopPullDownRefresh();
}, 2000);
}
}
</script>
<style>
page{
height: 100vh;
background-color: #000;
}
</style>
<style lang="scss" scoped>
.padding-top-40{
padding-top: 40rpx;
}
.margin-top-40{
margin-top: 40rpx;
}
.status_bar {
// height: var(--status-bar-height);
width: 100%;
height: 90rpx;
position: fixed;
top:0;
padding-top: 66rpx;
background-color: #000;
z-index: 999;
}
.img_radis{
border-radius: 10rpx !important;
}
.uni-navbar{
font-size: 32rpx;
font-weight: bold;
}
.empty_item1{
height: 500rpx;
padding: 20rpx 100rpx;
margin:50rpx auto;
color:#fff;
font-size: 24rpx;
text-align: center;
.empty_item_img{
height: 180rpx;
width: 180rpx;
margin: 0 auto;
margin-bottom: 30rpx;
image{
height: 100%;
width: 100%;
}
}
button {
font-size: 24.33rpx;
font-weight: 500;
background-color: #fff;
color: #000;
width: 240rpx;
height: 65.67rpx;
border-radius: 20rpx !important;
line-height: 65.67rpx;
border-radius: 0;
margin-top: 33.33rpx;
}
.uni-button{
border-radius: 20rpx !important;
}
}
.addCard{
z-index: 999;
position: fixed;
bottom: 0;
left: 0;
background-color: white;
padding-left: 29.33rpx;
padding-right: 29.33rpx;
box-sizing: border-box;
padding-top: 77.67rpx;
color:#000;
width: 100%;
// font-size: 30.67rpx;
font-weight: 400;
padding-bottom: 44.67rpx;
.addCard_close{
width: 21.33rpx;
height: 21.33rpx;
position: absolute;
right: 24.67rpx;
top: 18.67rpx;
}
.spike1{
margin-top: 0;
margin-bottom: 20rpx;
padding-bottom: 0;
border-bottom: none;
.addCard_scroll{
width: 286.67rpx;
height: 286.67rpx;
margin-left: 10.67rpx;
&:first-child{
margin-left: 0;
}
&:last-child{
margin-right: 15rpx;
}
}
}
.addCard_body{
padding-right: 31.33rpx;
max-height: 60vh;
min-height: 400rpx;
.addCard_price{
font-size: 44rpx;
font-weight: bold;
margin-top: 17.33rpx;
margin-bottom: 51.33rpx;
}
.color_select{
display: flex;
color: #666666;
flex-wrap: wrap;
margin-bottom: 59.33rpx;
.color_select_item{
margin-top: 22rpx;
position: relative;
background-color: #F9F7FA;
border-radius: 6.67rpx;
margin-right: 12.67rpx;
width: 134.67rpx;
image{
width: 134.67rpx;
height: 133.33rpx;
border-radius: 6.67rpx 6.67rpx 0 0;
}
.color_select_item_zoom{
width: 20.33rpx;
height: 20.33rpx;
// background-color: rgba(0, 0, 0, 0.3);
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 12.67rpx;
top: 9.33rpx;
z-index: 99;
image{
width: 100%;
height: 100%;
}
}
.color_select_item_bottom{
padding: 10rpx 0rpx;
font-size: 24rpx;
text-align: center;
}
}
.active_color{
color: #fff;;
background-color: #000;
border: 1px solid #000000;
}
}
.variations_select_size{
margin-left: 0;
margin-top: 26.67rpx;
margin-bottom: 40.67rpx;
.select_size_item{
background-size: cover;
margin-bottom: 16.67rpx !important;
&:nth-child(4n+4){
margin-right: 0;
}
}
}
}
}
.quantity{
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 43.33rpx;
.uni-numbox{
border: 1px solid #999999;
border-radius: 14rpx;
height: 42.67rpx;
/deep/ .uni-numbox__minus{
border-radius: 14rpx;
}
/deep/.uni-numbox__plus{
border-radius: 14rpx;
}
/deep/.uni-numbox__value{
border-left: 1px solid #999999;
border-right: 1px solid #999999;
height: 100%;
width: 63.33rpx;
font-size: 21.33rpx;
}
}
}
button{
width: 100%;
height: 73.33rpx;
line-height: 73.33rpx;
background-color: #191919;
color: white;
font-weight: bold;
font-size: 26.67rpx;
}
.spike1{
white-space: nowrap;
width: 100%;
margin-top: 36.67rpx;
padding-bottom: 34rpx;
// border-bottom: 1px solid #E2E2E2;
::-webkit-scrollbar {
width: 0;
height: 0;
// background-color: transparent;
}
.spike1_item{
width: 480rpx;
background-color: #1b1b1b;
padding: 27.33rpx 37.67rpx;
margin-right: 19.33rpx;
font-size: 20rpx;
border-radius: 10rpx;
// border:1rpx solid #ccc;
display: inline-block;
// color: #737373;
color: #fff;
&:last-child{
margin-right: 0;
}
view{
margin-bottom: 10rpx;
}
.text_bold_200{
font-size: 24rpx;
font-weight: 50;
}
.spike1_item_title{
// font-weight: bold;
font-size: 28rpx;
.text_black{
color: black;
display: inline-block;
margin-left: 10rpx;
}
.text_red{
color: #B22234;
display: inline-block;
margin-left: 10rpx;
}
}
}
.spike1_item1{
// color: #191919;
color: #fff;
font-size: 29.33rpx;
margin-right: 16.67rpx;
width: 200rpx;
display: inline-block;
font-weight: bold;
.spike1_item_img{
width: 200rpx;
height: 200rpx;
background-color: #999999;
}
.spike1_item_bottom{
padding-left: 9.33rpx;
margin-top: 22.67rpx;
.spike1_item_text{
// color: #9D9D9D;
color: #fff;
font-size: 21.33rpx;
text-decoration: line-through;
}
.spike1_item_text1{
// color: #9D9D9D;
color: #fff;
font-size: 21.33rpx;
}
}
.spike1_item_bottom1{
padding-left: 9.33rpx;
margin-top: 19.33rpx;
font-weight: bold;
.spike1_item_text{
// color: #000000;
color: #fff;
font-size: 16rpx;
font-weight: 400;
margin-bottom: 20.67rpx;
white-space: break-spaces;
}
}
}
.spike1_item:last-child{
margin-right: 0;
}
}
.bootom_last{
height: 100rpx;
width: 100%;
color: #fff;
background-color: #000;
font-size: 25rpx;
padding-bottom:40rpx;
line-height: 100rpx;
text-align: center;
}
</style>