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
125
126
127
128
129
130
131
132
133
134
135
136
| <template>
| <div class="historyBox">
| <div class="titleBox">浏览历史</div>
| <div class="iconBox" @click="deleteAll">
| <i class="iconfont icon-shanchu"></i>
| </div>
| <div class="itemBox">
| <div
| class="historyItem"
| v-for="(item, index) in this.$store.state.historyBook"
| :key="index"
| @click="toDetail(item)"
| >
| <div class="nameBox"> {{ item.name }}</div>
| <div class="deleteIcon" @click="deleteHistory(index)">×</div>
| </div>
| </div>
| </div>
| </template>
|
| <script>
| export default {
| name: "history",
| data() {
| return {
| dataList: [],
| };
| },
| methods: {
| //去详情
| toDetail(row) {
| this.$router.replace({
| name: "bookStore-detail",
| query: { id: row.id, cmsPath: row.rootCmsItemId },
| });
| this.$emit("reloadPage", row);
| },
| deleteHistory(index) {
| this.$confirm("是否删除当前浏览记录?", "提示", {
| confirmButtonText: "确定",
| cancelButtonText: "取消",
| type: "warning",
| })
| .then(() => {
| this.$store.commit("deleteHistoryBook", index);
| this.$message({
| type: "success",
| message: "删除成功!",
| });
| })
| .catch(() => {});
| },
| deleteAll() {
| this.$confirm("是否删除当前浏览记录?", "提示", {
| confirmButtonText: "确定",
| cancelButtonText: "取消",
| type: "warning",
| })
| .then(() => {
| this.$store.commit("deleteAllHistory");
| this.$message({
| type: "success",
| message: "删除成功!",
| });
| })
| .catch(() => {});
| },
| },
| created() {
| // this.dataList = this.$store.state.historyBook;
| },
| };
| </script>
|
| <style scoped>
| .historyBox {
| position: relative;
| width: 377px;
| margin-top: 10px;
| border-top: 1px solid #00873c;
| }
|
| .titleBox {
| height: 60px;
| background: #d8f7e6;
| line-height: 60px;
| padding: 0 40px;
| font-weight: 700;
| color: #00873c;
| font-size: 18px;
| }
| .itemBox {
| padding: 0 40px;
| background-color: #fff;
| max-height: 1000px;
| overflow-y: auto;
| }
| .historyItem {
| height: 50px;
| line-height: 50px;
| width: 100%;
| background-color: #fff;
| border-bottom: 1px solid #eeeeee;
| color: #333333;
| position: relative;
|
|
| }
| .historyItem .nameBox {
| width: 80%;
| overflow: hidden;
| white-space: nowrap;
| text-overflow: ellipsis;
| }
| .deleteIcon {
| position: absolute;
| right: 10px;
| top: 0px;
| display: none;
| }
| .historyItem:hover div {
| display: block;
| color: #00873c;
| cursor: pointer;
| }
| .historyItem:hover {
| color: #00873c;
| }
| .iconBox {
| position: absolute;
| top: 20px;
| right: 20px;
| cursor: pointer;
| color: red;
| }
| </style>
|
|