collectionItem.vue
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<template>
<router-link to="{ name: 'goodsDetail', params: { productId: 0 }}" tag="li">
<div class="record-item">
<img :src="imgSrc" class="record-img"/>
<div class="record-info">
<p class="record-title">{{item.productName}}</p>
<p class="record-coin">联盟币:{{item.productListPrice}}</p>
</div>
<div class="record-time">{{item.favoriateTime}}
<span @click.stop="openConfirm(item.favoriateId,item.type)" class="cancel-collect">取消收藏</span>
</div>
</div>
</router-link>
</template>
<script type="text/ecmascript-6">
import {formatImg} from '../../utils/commonUtil';
import {MessageBox, Toast} from 'mint-ui';
import {getmyCollectionList, clearmyCollectionList, addCancelCollection} from '../../vuex/actions';
export default {
data() {
return {}
},
props: {
item: '',
pageNum: ''
},
computed: {
imgSrc(){
return formatImg.formatSRC(this.item.productPhoto, 100, 100);
}
},
methods: {
openConfirm(id, type) {
var self = this;
MessageBox.confirm('确定取消收藏?', '提示').then(action => {
self.addCancelCollection(id, type).then(function () {
Toast({
message: '取消成功',
position: 'bottom',
duration: 5000
});
self.clearmyCollectionList().then(function () {
self.getmyCollectionList(0, self.pageNum);
})
});
});
}
},
vuex: {
getters: {},
actions: {
getmyCollectionList,
clearmyCollectionList,
addCancelCollection
}
}
}
</script>