修改前端样式效果

pull/1/head
xiaofeng 2019-07-16 23:50:02 +08:00
parent 631a571a03
commit 76839f3684
2 changed files with 111 additions and 89 deletions

View File

@ -292,6 +292,20 @@
}
});
},
initHasUserSpuFavorite(spuId){
if (!checkLogin()) {
this.hasCollectionType = 0;
return;
}
//
hasUserSpuFavorite(spuId).then(data => {
let hasCollection = data;
// alert("==" + hasCollection);
if (hasCollection) {
this.hasCollectionType = 1;
}
});
},
onClickCart() {
this.$router.push('/cart');
@ -430,6 +444,7 @@
// attrValueMap
this.attrValueMap.set(attr.attrValueId, attr.attrValueName);
}
}
// debugger;
this.vanSku = vanSku;
@ -439,6 +454,9 @@
this.initialSku.quantity = 1;
// sku
this.doCalcSkuPrice(this.initialSku.id);
this.initHasUserSpuFavorite(id);
});
//
if (checkLogin()) {
@ -453,7 +471,7 @@
<style lang="less">
.goods {
.active {
color: #e50f3d;
color: #f44;
}
padding-bottom: 50px;

View File

@ -1,102 +1,106 @@
<template>
<div>
<headerNav title="我的收藏"/>
<van-list
v-model="loading"
:finished="finished"
@load="onLoad"
<div>
<headerNav title="我的收藏"/>
<van-list
v-model="loading"
:finished="finished"
@load="onLoad"
>
<div v-for="(item,index) in list" :key="index">
<!-- <van-swipe-cell :right-width="65" :on-close="onClose(item)">-->
<!-- <product-card :product='item' />-->
<!-- <span>{{item.spuName}}</span>-->
<!-- <span slot="right" >删除</span>-->
<!-- </van-swipe-cell>-->
<van-card
:price="formatPrice(item.price)"
:desc="item.sellPoint"
:title="item.spuName"
:thumb="item.spuImage"
/>
</div>
</van-list>
</div>
<div v-for="(item,index) in list" :key="index">
<van-swipe-cell :right-width="65" :on-close="onClose(item)">
<van-card
:price="formatPrice(item.price)"
:desc="item.sellPoint"
:title="item.spuName"
:thumb="item.spuImage"
@click="skipProductSpuInfo(item.spuId)"
>
</van-card>
<template slot="right">
<van-button square type="danger" text="删除"/>
</template>
</van-swipe-cell>
</div>
</van-list>
</div>
</template>
<script>
// import { Card } from 'vant';
import { GetFavoritePage ,DelFavorite} from "../../../api/user.js";
// Vue.use(Card);
export default {
data(){
return{
loading:false,
finished:false,
list:[],
page:0,
pageSize:10
}
},
methods:{
formatPrice(data) {
return (data / 100).toFixed(2);
},
onClose(item){
return function(clickPosition, instance) {
switch (clickPosition) {
case 'left':
case 'cell':
case 'outside':
instance.close();
break;
case 'right':
this.$dialog.confirm({
message: '确定删除吗?'
}).then(() => {
DelFavorite(item.spuId).then(response=>{
this.$toast('删除成功');
this.$router.go(0);
})
instance.close();
}).catch(() => {
// on cancel
});
break;
}
import {GetFavoritePage, DelFavorite} from "../../../api/user.js";
export default {
data() {
return {
loading: false,
finished: false,
list: [],
page: 0,
pageSize: 10
}
},
onLoad() {
let pageNo = this.page + 1;
GetFavoritePage(pageNo,this.pageSize).then(response=>{
this.page = pageNo;
this.list.push(...response.list);
// response.list.forEach(item => {
// this.list.push(item);
// });
this.loading = false;
if(this.list.length >= response.total){
this.finished = true;
methods: {
formatPrice(data) {
return (data / 100).toFixed(2);
},
skipProductSpuInfo(data) {
// return getProductSpuInfo(data);
this.$router.push('/product/'+data);
},
onClose(item) {
return function (clickPosition, instance) {
switch (clickPosition) {
case 'left':
case 'cell':
case 'outside':
instance.close();
break;
case 'right':
this.$dialog.confirm({
message: '确定删除吗?'
}).then(() => {
DelFavorite(item.spuId).then(response => {
this.$toast('删除成功');
this.$router.go(0);
})
instance.close();
}).catch(() => {
// on cancel
});
break;
}
}
},
onLoad() {
let pageNo = this.page + 1;
GetFavoritePage(pageNo, this.pageSize).then(response => {
this.page = pageNo;
this.list.push(...response.list);
// response.list.forEach(item => {
// this.list.push(item);
// });
this.loading = false;
if (this.list.length >= response.total) {
this.finished = true;
}
})
}
},
}
})
}
},
}
</script>
<style lang="less">
.van-swipe-cell{
&__left,
&__right {
color: #FFFFFF;
font-size: 15px;
width: 65px;
height: 100px;
display: inline-block;
text-align: center;
line-height: 100px;
background-color: #F44;
.van-swipe-cell {
&__left,
&__right {
color: #FFFFFF;
font-size: 15px;
width: 65px;
height: 100px;
display: inline-block;
text-align: center;
line-height: 100px;
background-color: #F44;
}
}
}
</style>