home.vue
17.7 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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
<template>
<!--<cheader title="我的" class="ghost" fixed v-ref:header>
<i slot="left" class="icon icon-setting" id="setting"></i>
</cheader>-->
<div class="my-header" v-if="data.nickName">
<a class="user-info auth" id="user-info" href='/me/mydetails'>
<img class="user-avatar" :src="headIco" @error="setEmptyimg">
<span class="username">{{ data.nickName }}</span>
<div class="account-mg">账号管理<span class="icon icon-right"></span></div>
</a>
<!--<a class="vip-level level-{{data.vipLevel}}" v-if="data.vipLevel" href='/me/grade'></a>-->
</div>
<div class="my-header unlisted" v-else>
<span class="auth username">登录/注册</span>
</div>
<a class="change-channel">
<span class="label">切换购物频道</span>
<span class="channel">MEN<span class="icon icon-right"></span></span>
</a>
<div class="group-list">
<div class="user-count">
<a class="auth uc-item" href="/me/collection">
<p class="num">{{productNum}}</p>
<p class="label">商品收藏</p>
</a>
<a class="auth uc-item" href="/me/collection?tab=article">
<p class="num">{{editorialNum}}</p>
<p class="label">资讯收藏</p>
</a>
<a class="auth uc-item" href="/me/records?type={{recordNum}}">
<p class="num">{{recordNum}}</p>
<p class="label">浏览记录</p>
</a>
</div>
</div>
<div class="my-order">
<!--<a class="order-title auth" href="/me/order?type=1">
我的订单
<span class="read-order">
查看全部订单 <span class="icon icon-right"></span>
</span>
</a>-->
<div class="order-type clearfix">
<a class="type-item auth" href="/me/order?type=2">
<span class="icon icon-card"></span>
<span class="item-name">待付款</span>
<span class="num" v-if="data.wait_pay_num">{{data.wait_pay_num}}</span>
</a>
<a class="type-item auth" href='/me/order?type=3'>
<span class="icon icon-bag2"></span>
<span class="item-name">待发货</span>
<span class="num" v-if="data.wait_cargo_num">{{data.wait_cargo_num}}</span>
</a>
<a class="type-item auth" href="/me/order?type=4">
<span class="icon icon-logistics"></span>
<span class="item-name">待收货</span>
<span class="num" v-if="data.send_cargo_num">{{data.send_cargo_num}}</span>
</a>
<a class="type-item auth" href="/me/return">
<span class="icon icon-money"></span>
<span class="item-name">退换货</span>
<span class="num" v-if="data.refund_exchange_num">{{data.refund_exchange_num}}</span>
</a>
<a class="type-item auth" href="/me/order?type=1">
<span class="icon icon-money"></span>
<span class="item-name">全部订单</span>
<span class="num" v-if="data.refund_exchange_num">{{data.refund_exchange_num}}</span>
</a>
</div>
</div>
<!--<div class="group-list">
<a class="glist-item auth" href="/me/collection">
我的收藏
<span class="num">商品/品牌/资讯 <span class="icon icon-right"></span></span>
</a>
<a class="glist-item auth" href="/me/records?type={{recordNum}}">
浏览记录
<span class="num">{{recordNum}}<span class="icon icon-right"></span></span>
</a>
</div>-->
<!--<div class="group-list">
<a class="glist-item auth" href="/me/mycurrency">
有货币
<span class="num">{{data.yoho_coin_num}} <span class="icon icon-right"></span></span>
</a>
</div>-->
<div class="group-list address-item">
<a class="glist-item auth" id="address" v-if="data.nickName">
地址管理
<span class="num">{{data.address_num}} <span class="icon icon-right"></span></span>
</a>
<p class="glist-item" v-else>
地址管理
</p>
</div>
<div class="group-list">
<a class="glist-item" href="/help">
帮助中心
<span class="num"><span class="icon icon-right"></span></span>
</a>
<p class="glist-item">
电话客服
<span class="num tel">400-889-9646<span class="icon icon-right"></span></span>
</p>
<p class="glist-item ghost" id="setting">
设置
<span class="num"><span class="icon icon-right"></span></span>
</p>
</div>
<div class="group-list">
<img class="home-banner">
</div>
</template>
<script>
const yoho = require('yoho');
const $ = require('jquery');
const interceptClick = require('common/intercept-click');
const cheader = require('component/header.vue');
const cookie = require('yoho-cookie');
function getRecordsNum(that) {
// 浏览记录数量
$.ajax({
url: '/me/recordNum'
}).then(result => {
if (result.code === 200) {
that.recordNum = result.data;
}
});
}
module.exports = {
data() {
return {
data: {},
headIco: '',
recordNum: '',
productNum: '',
editorialNum: ''
};
},
components: {
cheader
},
methods: {
setEmptyimg() {
// 图片报错时,给个默认透明图片
this.headIco = 'data:image/png;base64,R0lGODlhFAAUAIAAAP///wAAACH5BAEAAAAALAAAAAAUABQAAAIRhI+py+0Po5y02ouz3rz7rxUAOw==';
},
reload() {
$('#address').off('click', this.addressClick);
$('.auth').off('click', this.authClick);
$('.auth').removeClass('no-intercept');
if (yoho.isLogin()) {
$.ajax({
url: '/me/userdata'
}).then(result => {
this.data = result || {};
if (this.data.headIco) {
this.headIco = this.data.headIco || 0;
}
});
$.ajax({
url: '/me/favoriteNum'
}).then(result => {
this.productNum = result.data.product_favorite_total;
});
$('#address').on('click', this.addressClick);
// 之前是否有访客浏览
if (cookie.get('_browseskn_h5')) {
$.ajax({
url: '/me/addRecords'
}).then(result => {
if (result.code === 200) {
getRecordsNum(this);
}
});
} else {
getRecordsNum(this);
}
} else {
this.data = {
nickName: false
};
this.productNum = 0;
this.editorialNum = 0;
this.recordNum = 0;
this.setEmptyimg();
$('.auth').addClass('no-intercept');
$('.auth').on('click', this.authClick);
}
},
addressClick() {
yoho.goAddress({
type: '2'
});
return false;
},
authClick(e) {
const id = $(e.target).attr('id');
const href = $(e.target).attr('href');
yoho.goLogin('', () => {
this.reload();
setTimeout(() => {
if (id === 'address') {
yoho.goAddress({
type: '2'
});
} else if (href !== '/me/mydetails') {
interceptClick.intercept(href);
}
}, 200);
});
return false;
},
toggle() {
let ghost = true;
let ghost2 = false;
let ghost3 = false;
if (window.scrollY > 40) {
ghost = false;
ghost2 = false;
ghost3 = false;
} else if (window.scrollY > 25) {
ghost = false;
ghost3 = true;
} else if (window.scrollY > 10) {
ghost = false;
ghost2 = true;
}
this.$refs.header.$el.classList.toggle('ghost', ghost);
this.$refs.header.$el.classList.toggle('ghost-2', ghost2);
this.$refs.header.$el.classList.toggle('ghost-3', ghost3);
}
},
ready() {
this.reload();
$('#setting').on('click', function() {
yoho.goSetting();
return false;
});
window.addEventListener('touchmove', () => {
this.toggle();
});
window.addEventListener('scroll', () => {
this.toggle();
});
document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
this.reload();
}
});
}
};
</script>
<style>
.my-page {
color: #444;
background: #f0f0f0;
a {
color: #000;
}
.blk-header-main {
position: absolute;
left: 0;
right: 0;
}
.top-box {
.blk-header {
background-color: transparent;
border-bottom: 0;
}
}
.top-change {
.blk-header {
background-color: #fff;
}
}
.my-header {
height: 260px;
/*background: resolve("me/header-bg.png");*/
background: #fff;
background-size: cover;
padding: 0 30px;
}
.user-info {
float: left;
position: relative;
top: 56px;
color: #000;
font-size: 34px;
height: 190px;
text-align: left;
.user-avatar {
display: inline-block;
position: relative;
width: 170px;
height: 170px;
border-radius: 50%;
margin: 0 auto;
/* border: 3px solid #b0b0b0; */
background: resolve("me/user-icon.png");
background-size: 100%;
vertical-align: middle;
}
}
.account-mg {
display: inline-block;
position: relative;
top: 10px;
font-size: 32px;
.icon-right {
margin-left: 10px;
}
}
.vip-level {
display: block;
width: 100px;
height: 36px;
position: relative;
top: 160px;
left: 325px;
}
.level-1,
.level-2 {
background-size: 100%;
}
.level-1 {
background: resolve("me/vip-1.png");
}
.level-2 {
background: resolve("me/vip-2.png");
}
.level-3 {
background: resolve("me/vip-3.png");
}
.level-1,
.level-2,
.level-3 {
background-size: 100%;
}
.username {
width: 326px;
display: inline-block;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 32px;
position: relative;
top: 10px;
}
.unlisted {
padding: 0;
.username {
width: 300px;
height: 88px;
line-height: 88px;
display: block;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 32px;
margin: 0 auto;
position: relative;
top: 84px;
border: 1px solid #434343;
}
}
.my-order {
margin-bottom: 20px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
background: #fff;
.order-title {
display: block;
padding: 0 30px;
font-size: 34px;
line-height: 88px;
position: relative;
&.highlight {
background: #eee;
}
.read-order {
color: #b0b0b0;
font-size: 30px;
float: right;
}
&:after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 92%;
height: 0;
border-top: 1px solid #eee;
margin-left: 28px;
}
}
.order-type {
padding: 20px 30px;
text-align: center;
height: 150px;
.icon {
font-size: 45px;
margin-bottom: 10px;
display: block;
}
.type-item {
position: relative;
float: left;
color: #444;
font-size: 24px;
line-height: 1.5;
width: 86px;
margin-top: 13px;
margin-left: 60px;
&.highlight {
background: #eee;
}
&:first-child {
margin-left: 0;
}
&:last-child {
width: 98px;
}
.num {
position: absolute;
top: -35px;
right: -20px;
width: 72px;
height: 72px;
font-size: 34px;
line-height: 72px;
color: #fff;
background: #ff081c;
text-align: center;
border-radius: 50%;
transform: scale(0.5);
}
}
}
}
.group-list {
margin-bottom: 20px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
background: #fff;
&:last-child {
border-bottom: none;
}
.glist-item {
display: block;
position: relative;
padding: 0 30px;
font-size: 34px;
line-height: 88px;
overflow: hidden;
&.highlight {
background: #eee;
}
&:after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 0;
border-top: 1px solid #eee;
}
&:last-child:after {
content: none;
}
}
.icon {
font-size: 34px;
vertical-align: top;
}
.num {
color: #b0b0b0;
float: right;
}
.tel {
/*padding-right: 10px;*/
.icon-right {
margin-left: 10px;
}
}
}
.address-item {
margin-bottom: 0;
border-bottom: none;
}
.change-channel {
height: 88px;
width: 100%;
background: #020202;
line-height: 88px;
padding: 0 30px;
box-sizing: border-box;
font-size: 32px;
display: block;
.label {
float: left;
color: #fff;
}
.channel {
float: right;
color: #fff;
}
}
.user-count {
padding: 0 60px;
background: #fff;
text-align: center;
.uc-item {
display: inline-block;
margin: 24px 44px;
text-align: center;
.num {
margin: 14px 0;
font-size: 24px;
width: 100%;
color: #000;
}
.label {
margin: 14px 0;
font-size: 24px;
width: 100%;
}
}
}
.home-banner {
max-width: 100%;
display: block;
margin: 30px auto;
}
}
.app.ios {
.blk-header {
padding-top: 60px;
}
}
</style>