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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<template>
<div>
<!-- scoringCategoryData != 0 -->
<div class="growthRecord" v-if="scoringCategoryData.length !== 0" @scroll="scrollEvent">
<div class="year-header" id="yearHeader" ref="yearHeader">{{ dataTimer }}</div>
<div class="growthRecord-content" v-for="(item, index) in scoringCategoryData" :key="index">
<!-- 年 -->
<div class="growthRecord-content-year">{{ item.year }}年</div>
<div class="growthRecord-content-children" :data-timer="itemChild.cur_date.split('-')[0]" v-for="(itemChild, itemIndex) in item.monthArr">
<!-- 月,日 -->
<div class="growthRecord-content-left" :style="{ opacity: itemChild.ataer == 1 ? '1' : '0' }"> <!-- style="opacity: 0;" -->
<span class="day">{{ itemChild.month.split('-')[1] }}</span><span class="mouth">{{ itemChild.month.split('-')[0] }}月</span>
</div>
<!-- 月日对应的content -->
<div class="growthRecord-content-right">
<div class="growthRecord-content-right-sleeping">{{ itemChild.element_title }}</div>
<div class="growthRecord-content-right-title">
<span class="title">{{ itemChild.category_name.split(' ')[0] + ' ' +itemChild.category_name.split(' ')[1] }}</span>
<img class="scoring-category-active" :src="scoringCategoryImage.scoringCategory1Active" alt="">
<span class="num">{{ itemChild.interest }}</span>
<img class="scoring-category-active" :src="scoringCategoryImage.scoringCategory2Active" alt="">
<span class="num">{{ itemChild.concent }}</span>
<img class="scoring-category-active" :src="scoringCategoryImage.scoringCategory3Active" alt="">
<span class="num">{{ itemChild.parent_child }}</span>
</div>
<div class="rowthRecord-content-sub" @click="xiajiantou(itemChild.id)">
<span class="fa-text" :data-id="itemChild.id" :data-int="1" v-html="itemChild.growth_record.replace(/\n/g, '<br/>')"></span>
<span class=""><img class="xiajiantou" :src="scoringCategoryImage.xiajiantou" alt=""></span> <!-- @click="xiajiantou(itemChild.id)" -->
</div>
<div class="timer">{{ itemChild.created_at.split(' ')[1] }}</div>
</div>
</div>
</div>
</div>
<!-- 数据为空时 -->
<div class="growthRecord-null" v-if="scoringCategoryData.length === 0">
<img class="data-null" :src="dataNull" alt="">
<div class="text-tishi">您还没有记录哦~</div>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import { getUserGrowthListApi } from "../service/api";
import { scoringCategory } from "../util/imgUrl";
import dataNull from '../assets/evaluate/null.png'
export default {
name: 'growthRecord',
data() {
return {
dataNull: dataNull, // 图片
dataTimer: '', // 获取滚动时间
textArew: false,
indexPa: -1,
scoringCategoryData: [], // 获取数据
scoringCategoryImage: scoringCategory, // 获取图片
}
},
methods: {
async userGrowthRecordList() {
const userGrowthRecordData = await getUserGrowthListApi();
if(userGrowthRecordData.length === 0) return
userGrowthRecordData.map(item => {
item.monthArr = [];
for(let k in item.month) {
// 相同日期显示一个
item.month[k][0].ataer = 1;
// 数据重新整合
for(let i = 0; i < item.month[k].length; i++) {
item.monthArr.push(item.month[k][i])
}
}
})
this.scoringCategoryData = userGrowthRecordData;
// 初始化滚动值
this.dataTimer = userGrowthRecordData[0].monthArr[0].cur_date.split('-')[0];
// 判断行数
this.$nextTick(() => {
var rowthRecord = document.querySelectorAll('.rowthRecord-content-sub')
for(var i = 0; i < rowthRecord.length; i++) {
let line = window.getComputedStyle(rowthRecord[i], null);
var lh = parseInt(line.lineHeight, 10);
var h = parseInt(line.height, 10);
var lc = Math.round(h / lh);
if(lc > 2) {
rowthRecord[i].querySelectorAll('.fa-text')[0].classList.add('text')
}else {
rowthRecord[i].querySelectorAll('.xiajiantou')[0].style.display = 'none';
}
}
})
},
/**
* 滚动监听
* @param e
*/
scrollEvent(e) {
let scroll = document.documentElement.scrollTop || document.body.scrollTop,
growthRecordContentChildren = document.querySelectorAll('.growthRecord-content-children');
for(let i = 0; i < growthRecordContentChildren.length; i++) {
let top = growthRecordContentChildren[i].offsetTop, // 获取 dom 离顶端的高度
height = growthRecordContentChildren[i].offsetHeight, // 获取 dom 高度
dataTimer = growthRecordContentChildren[i].getAttribute('data-timer'); // 获取 dom 里的时间
if(scroll >= top && scroll <= top + height)
this.dataTimer = dataTimer;
}
},
xiajiantou(itemIndex, index) {
let faText = document.querySelectorAll('.fa-text'),
xiajiantou = document.querySelectorAll('.xiajiantou')
for(var i = 0; i < faText.length; i++) {
if(faText[i].getAttribute('data-id') == itemIndex && faText[i].getAttribute('data-int') == 1) {
faText[i].style.display = 'inherit'
faText[i].setAttribute('data-int', 2)
xiajiantou[i].setAttribute('src', this.scoringCategoryImage.shangjiantopu)
}else if(faText[i].getAttribute('data-id') == itemIndex && faText[i].getAttribute('data-int') == 2){
faText[i].style.display = '-webkit-box'
faText[i].setAttribute('data-int', 1)
xiajiantou[i].setAttribute('src', this.scoringCategoryImage.xiajiantou)
}
}
},
},
mounted() {
this.introduce = '拥有财富、名声、权力,这世界上的一切的男人--哥尔·D·罗杰,在被行刑受死之前说了一句话,让全世界的人都涌向了大海。“想要我的宝藏吗?如果想要的话,那就到海上去找吧,我全部都放在那里。”,世界开始迎接“大海贼时代”的来临。拥有财富、名声、权力,这世界上的一切的男人 “海贼王”哥尔·D·罗杰,在被行刑受死之前说了一句话,让全世界的人都涌向了大海。“想要我的宝藏吗?如果想要的话,那就到海上去找吧,我全部都放在那里。”,世界开始迎接“大海贼时代”的来临。';
window.addEventListener('scroll', this.scrollEvent, false)
this.userGrowthRecordList()
}
}
</script>
<style lang="less" type="text/less">
@import "../util/public";
.growthRecord {
width: 100%;
padding: 20 * @toVw;
box-sizing: border-box;
.year-header {
width: 100%;
height: 30 * @toVw;
padding-left: 20 * @toVw;
position: fixed;
line-height: 30 * @toVw;
background: #F8F8F8;
top: 0;
left: 0;
z-index: 10;
font-size: 14 * @toVw;
}
.growthRecord-content {
width: 100%;
/* 年 */
.growthRecord-content-year {
padding: 16 * @toVw 0;
font-size: 24 * @toVw;
font-weight: 500;
color: #333333;
}
/* 月,日 */
.growthRecord-content-children {
width: 100%;
overflow: hidden;
padding-bottom: 15 * @toVw;
.growthRecord-content-left {
width: 60 * @toVw;
float: left;
.day {
font-size: 22 * @toVw;
font-weight: 500;
color: #333;
}
.mouth {
padding-left: 2px;
font-size: 14 * @toVw;
color: #333;
}
}
/* 月日对应的content */
.growthRecord-content-right {
width: calc(100% - 16vw);
padding: 12 * @toVw;
float: left;
background: #e2f3fe;
border-radius: 5 * @toVw;
box-sizing: border-box;
.growthRecord-content-right-sleeping {
padding-bottom: 11 * @toVw;
font-size: 14 * @toVw;
font-weight: 500;
color: #333;
}
.growthRecord-content-right-title {
.title {
padding-right: 12 * @toVw;
vertical-align: middle;
font-size: 13 * @toVw;
font-weight: 500;
color: #333;
}
.scoring-category-active {
width: 20 * @toVw;
height: 20 * @toVw;
padding-left: 13 * @toVw;
vertical-align: middle;
}
.num {
vertical-align: middle;
font-size: 13 * @toVw;
color: #666666;
}
}
.text {
word-wrap: break-word;
word-break: break-all;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.rowthRecord-content-sub {
position: relative;
padding-top: 10 * @toVw;
line-height: 21 * @toVw;
font-size: 14 * @toVw;
color: #666666;
.text1 {
overflow: auto;
}
.shouqi {
font-size: 14 * @toVw;
color: #40A9FF;
vertical-align: middle;
}
.xiajiantou {
width: 17 * @toVw;
height: 10 * @toVw;
position: absolute;
right: 0;
bottom: 2px;
}
}
.timer {
padding-top: 10 * @toVw;
color: #666666;
font-size: 12 * @toVw;
}
}
}
}
}
.growthRecord-null {
text-align: center;
padding-top: 168 * @toVw;
.data-null {
width: 120 * @toVw;
height: 120 * @toVw;
}
.text-tishi {
padding-top: 20 * @toVw;
font-size: 13 * @toVw;
color: #666;
}
}
</style>