coin-detail.vue
1.89 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
62
63
64
65
<template>
<div class="coin-detail" v-if="coinList && coinList.length">
<p>明细列表</p>
<ul class="coin-detail-list" v-infinite-scroll="getCoinData()" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<li v-for="coin in coinList">
<div class="coin-source">
<p>{{coin.message}}</p>
<time>{{coin.date}}</time>
</div>
<div class="coin-num"><i v-if="coin.num>0">+</i>{{coin.num}}</div>
</li>
</ul>
</div>
</template>
<script>
'use strict';
const $ = require('jquery');
const tip = require('common/tip');
module.exports = {
data() {
return {
page: 0,
limit: 15,
pageTotal: 1,
coinList: [],
busy: false,
};
},
ready() {
this.getCoinData();
},
methods: {
getCoinData() {
this.busy = true;
if (this.page >= this.pageTotal) {
return;
}
$.ajax({
url: '/me/coin-detail',
data: {
page: ++this.page,
limit: this.limit
}
}).then(result => {
if (result.code === 200) {
this.busy = false;
if (result.data.coinlist.length > 0) {
this.$set('coinList', this.coinList.concat(result.data.coinlist));
this.pageTotal = result.data.page_total;
}
}
}).fail(() => {
tip('网络错误');
});
}
}
};
</script>
<style>
@import "../../scss/me/_coin.css";
</style>