record.vue
3.33 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
<div class="record-container" v-if="flag">
<scroll-view class="content" @ReachBottom="onReachBottom" ref="scrollView">
<template v-if="recordList.length > 0">
<div class="record-container-content">
<!-- <div class="font-16 color-3 fw5 line-22 m-l-4">2021-12-31</div> -->
<template v-for="(item, index) in recordList">
<div class="record-container-content-item" :key="index">
<div class="portrait">
<img :src="item.avatar" alt="" v-if="item.avatar" />
<img v-else src="../../assets/images/user.png" />
</div>
<div class="m-t-4 font-14 line-22">
<div class="color-3 customerName text-hide">{{ item.customerName }}</div>
<div class="color6 m-t-4">
{{ item.operationType == 1 ? '浏览了' : item.operationType == 2 ? '领取优惠券' : '下单购买' }}
<span class="color-3 m-l-4">{{ item.goodsName }}</span>
</div>
<div class="font-12 color9 m-t-4" v-if="item.operationType == 3">订单编号:{{ item.orderCode }}</div>
</div>
<div class="font-12 color9 time">{{ item.operationDate }}</div>
</div>
</template>
</div>
</template>
<template v-else>
<empty description="暂无数据" />
</template>
</scroll-view>
</div>
</template>
<script>
import { groupCustomer } from '@/api'
import { Notify } from 'vant'
import { util } from '../../utils'
import { mapActions } from 'vuex'
export default {
data() {
return {
flag: false,
recordList: [],
page: {
pageNum: 1,
pageSize: 10
}
}
},
mounted() {
this.showLoading()
this.getcustomerRecordList()
},
methods: {
...mapActions({
navigation: 'navigation'
}),
//重新登录
reLogin() {
/**登录过期 重新登录 */
util.clearSessionId()
this.navigation()
},
getcustomerRecordList() {
let list = this.recordList
groupCustomer.getcustomerRecordList({ ...this.page }).then(({ code, data, message }) => {
this.hideLoading()
if (code == 0) {
this.recordList = [...list, ...data.list]
if (this.page.pageNum > 1) this.$refs.scrollView.loading = false
if (data.list == 0 && this.flag) {
this.$refs.scrollView.finished = true
}
} else if(code == 21) {
this.reLogin()
}else{
Notify(message)
}
this.flag = true
})
},
onReachBottom() {
this.page.pageNum++
this.getcustomerRecordList()
}
}
}
</script>
<style lang="scss" scoped>
.record-container {
padding: 0 12px;
/deep/ .van-list {
background: #f7f7f7;
height: 100%;
.van-empty {
height: 100%;
}
}
&-content-item {
background: #ffffff;
border-radius: 6px;
margin: 8px 0;
padding: 8px 12px 12px 12px;
display: flex;
position: relative;
.customerName {
max-width: 160px;
}
.portrait {
width: 40px;
height: 40px;
margin-right: 6px;
img {
width: 100%;
border-radius: 50%;
}
}
.time {
position: absolute;
top: 14px;
right: 12px;
line-height: 18px;
}
}
}
</style>