Repository navigation
Expand file tree
/
Copy pathuser.vue
More file actions
644 lines (602 loc) · 17.5 KB
/
Copy pathuser.vue
File metadata and controls
644 lines (602 loc) · 17.5 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
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<template>
<view class="user">
<!--头部-->
<view class="user-section">
<image class="bg" :src="userBg"></image>
<!--用户信息-->
<view class="user-info-box">
<view
class="portrait-box"
@tap="navTo(userInfo ? '/pages/user/userinfo/userinfo' : 'login')"
>
<image
class="portrait"
:src="userInfo.head_portrait || headImg"
></image>
<text class="username" v-if="hasLogin">
{{
userInfo.nickname ||
userInfo.realname ||
'暂无昵称'
}}
</text>
<text class="username" v-else>登录/注册</text>
</view>
</view>
<!--vip信息-->
<view class="vip-card-box">
<image class="card-bg" :src="vipCardBg"></image>
<view class="tit">
<i class="iconfont iconiLinkapp-"/>
欢迎来到RageFrame微商城
</view>
<text class="e-m">RageFrame 版权所有</text>
</view>
</view>
<!-- 个人中心 内容区-->
<view
class="cover-container"
:style="[{
transform: coverTransform,
transition: coverTransition
}]"
@touchstart="coverTouchstart"
@touchmove="coverTouchmove"
@touchend="coverTouchend"
>
<image class="arc" :src="arc"></image>
<!--余额 优惠券 积分信息-->
<view class="promotion-center">
<list-cell icon="iconwallett" iconColor="#e07472" @eventClick="navTo('/pages/user/account/account')"
title="我的账户"></list-cell>
<view class="tj-sction">
<view class="tj-item" v-for="item in amountList" :key="item.title" @tap="navTo(item.url)">
<text class="num" :class="item.value > 0 ? 'red' : ''">
{{ item.value }}
</text>
<text>{{ item.title }}</text>
</view>
</view>
</view>
<!-- 我的订单 -->
<view class="promotion-center">
<list-cell icon="iconfapiaoguanli" iconColor="#e07472"
@eventClick="navTo(`/pages/index/search/search?keyword=搜索我的订单&type=order`)" title="搜索订单"></list-cell>
<view class="order-section">
<view
class="order-item"
v-for="item in orderSectionList"
:key="item.title"
@tap="navTo(item.url)"
hover-class="common-hover"
:hover-stay-time="50">
<i class="iconfont" :class="item.icon"/>
<text>{{ item.title }}</text>
<rf-badge type="error" size="small" class="badge" :text="item.num"></rf-badge>
</view>
</view>
</view>
<!-- 浏览历史 -->
<view class="history-section">
<list-cell icon="iconlishijilu" iconColor="#5eba8f" @eventClick="navTo('/pages/user/footprint/footprint')"
title="我的足迹"></list-cell>
<view v-if="hasLogin">
<scroll-view scroll-x class="h-list" v-if="footPrintList.length > 0">
<view class="h-item" v-for="item in footPrintList" :key="item.id">
<image class="h-item-img" @tap.stop="navTo(`/pages/product/product?id=${item.product.id}`)"
:src="item.product.picture" mode="aspectFill"></image>
<view class="h-item-text in2line">{{ item.product.name }}</view>
</view>
</scroll-view>
<view class="no-foot-print" v-else-if="footPrintList.length === 0" @tap="navTo('/pages/product/list')">
<i class="iconfont iconshare no-foot-print-icon"/>
先去浏览一些吧~
</view>
</view>
<view class="no-foot-print" v-else @tap="navTo('/pages/user/footprint/footprint')">
<i class="iconfont iconmima no-foot-print-icon"/>
登陆后查看
</view>
</view>
<!--设置中心-->
<view class="promotion-center">
<list-cell icon="iconshezhi1" iconColor="#e07472" @eventClick="navTo('/pages/set/set')"
title="设置中心"></list-cell>
<view class="tj-sction">
<!-- 分类列表 -->
<view class="category-list">
<view
class="category"
v-for="(item, index) in settingList"
:key="index"
@tap.stop="navTo(item.url)"
>
<view v-if="item.title!=='分享'">
<view class="img">
<text class="iconfont" :style="{color: item.color}" :class="item.icon"></text>
</view>
<view class="text">{{ item.title }}</view>
</view>
<button class="share-btn" open-type="share" @tap.tap="shareToH5" v-else>
<view class="img">
<text class="iconfont" :style="{color: item.color}" :class="item.icon"></text>
</view>
<view class="text">{{ item.title }}</view>
</button>
</view>
</view>
</view>
</view>
</view>
<!--页面加载动画-->
<rf-loading v-if="loading"></rf-loading>
</view>
</template>
<script>
/**
* @des 个人中心
*
* @author stav stavyan@qq.com
* @date 2020-01-10 11:41
* @copyright 2019
*/
import {footPrintList, memberInfo} from '@/api/userInfo';
import listCell from '@/components/rf-list-cell';
import {mapMutations} from 'vuex';
import rfBadge from '@/components/rf-badge/rf-badge'
let startY = 0, moveY = 0, pageAtTop = true;
export default {
components: {
listCell,
rfBadge
},
data() {
return {
settingList: this.$mConstDataConfig.settingList,
orderSectionList: this.$mConstDataConfig.orderSectionList,
amountList: this.$mConstDataConfig.amountList,
headImg: this.$mAssetsPath.headImg,
vipCardBg: this.$mAssetsPath.vipCardBg,
arc: this.$mAssetsPath.arc,
userBg: this.$mAssetsPath.userBg,
coverTransform: 'translateY(0px)',
coverTransition: '0s',
moving: false,
userInfo: { // 用户信息
promoter: null // 分销商信息
},
footPrintList: [], // 足迹列表
loading: true,
hasLogin: false
}
},
// 小程序分享
onShareAppMessage() {
return {
title: '欢迎来到RageFrame商城',
path: '/pages/index/index'
}
},
async onShow() {
// 初始化数据
this.initData();
},
// #ifndef MP
onNavigationBarButtonTap(e) {
const index = e.index;
if (index === 0) {
this.navTo('/pages/set/set');
} else if (index === 1) {
// #ifdef APP-PLUS
const pages = getCurrentPages();
const page = pages[pages.length - 1];
const currentWebview = page.$getAppWebview();
currentWebview.hideTitleNViewButtonRedDot({
index
});
// #endif
this.$mRouter.push({route: '/pages/index/notice/notice'});
}
},
// #endif
methods: {
// h5分享
shareToH5() {
// #ifdef H5
this.$mHelper.toast('请复制连接进行分享');
// #endif
},
...mapMutations(['login']),
// 数据初始化
async initData() {
this.hasLogin = this.$mStore.getters.hasLogin;
if (this.hasLogin) {
await this.getMemberInfo();
} else {
this.loading = false;
this.resetSectionData();
}
},
// 设置购物车数量角标
async initCartItemCount() {
if (parseInt(uni.getStorageSync('cartNum'), 10) > 0) {
await uni.setTabBarBadge({
index: this.$mConstDataConfig.cartIndex,
text: uni.getStorageSync('cartNum')
});
} else {
uni.removeStorageSync('cartNum');
uni.removeTabBarBadge({index: this.$mConstDataConfig.cartIndex});
}
},
// 获取用户信息
async getMemberInfo() {
await this.$http.get(memberInfo).then(async r => {
this.loading = false;
this.userInfo = r.data;
await uni.setStorageSync('cartNum', r.data.cart_num);
// 获取足迹列表
await this.getFootPrintList();
await this.setSectionData(r.data);
await this.initCartItemCount();
}).catch(() => {
this.hasLogin = false;
this.userInfo = {};
this.resetSectionData();
this.loading = false;
});
},
// 清空个人中心的各模块状态
resetSectionData() {
uni.removeTabBarBadge({index: this.$mConstDataConfig.cartIndex});
this.amountList[0].value = 0;
this.amountList[1].value = 0;
this.amountList[2].value = 0;
this.orderSectionList[0].num = 0;
this.orderSectionList[1].num = 0;
this.orderSectionList[2].num = 0;
this.orderSectionList[3].num = 0;
this.orderSectionList[4].num = 0;
},
// 给个人中心的各模块赋值
setSectionData(data) {
const orderSynthesizeNumArr = [];
for (let item in data.order_synthesize_num) {
orderSynthesizeNumArr.push(data.order_synthesize_num[item])
}
for (let i = 0; i < this.orderSectionList.length; i++) {
this.orderSectionList[i].num = orderSynthesizeNumArr[i].toString();
}
this.amountList[0].value = data.account.user_money || 0;
this.amountList[1].value = data.coupon_num || 0;
this.amountList[2].value = data.account.user_integral || 0;
// 更新userInfo缓存
uni.setStorageSync('userInfo', data);
},
// 获取足迹列表
async getFootPrintList() {
await this.$http.get(`${footPrintList}`).then(r => {
this.footPrintList = r.data
});
},
// 统一跳转接口,拦截未登录路由
navTo(route) {
if (!route) {
return;
}
if (!this.hasLogin) {
uni.showModal({
content: '你暂未登陆,是否跳转登录页面?',
success: (confirmRes) => {
if (confirmRes.confirm) {
this.$mRouter.push({route: '/pages/public/logintype'});
}
}
});
} else {
this.$mRouter.push({route});
}
},
/**
* 会员卡下拉和回弹
* 1.关闭bounce避免ios端下拉冲突
* 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
* transition设置0.1秒延迟,让css来过渡这段空窗期
* 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
*/
coverTouchstart(e) {
if (pageAtTop === false) {
return;
}
this.coverTransition = 'transform .1s linear';
startY = e.touches[0].clientY;
},
coverTouchmove(e) {
moveY = e.touches[0].clientY;
let moveDistance = moveY - startY;
if (moveDistance < 0) {
this.moving = false;
return;
}
this.moving = true;
if (moveDistance >= 80 && moveDistance < 100) {
moveDistance = 80;
}
if (moveDistance > 0 && moveDistance <= 80) {
this.coverTransform = `translateY(${moveDistance}px)`;
}
},
coverTouchend() {
if (this.moving === false) {
return;
}
this.moving = false;
this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
this.coverTransform = 'translateY(0px)';
}
}
}
</script>
<style lang='scss' scoped>
page {
background-color: $page-color-base;
}
.user {
.user-section {
background-color: $page-color-base;
height: 520upx;
padding: 100upx 30upx 0;
position: relative;
.bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
filter: blur(1px);
opacity: .7;
}
.user-info-box {
height: 180upx;
display: flex;
align-items: center;
position: relative;
z-index: 1;
justify-content: space-between;
.portrait-box {
display: flex;
align-items: center;
.portrait {
width: 130upx;
height: 130upx;
border: 5upx solid #fff;
border-radius: 50%;
}
.username {
font-size: $font-lg + 6upx;
color: $color-white;
margin-left: 20upx;
}
button {
background-color: transparent;
font-size: $font-lg + 6upx;
color: $font-color-dark;
border: none;
}
button::after {
border: none;
}
}
}
.vip-card-box {
display: flex;
flex-direction: column;
color: #f7d680;
height: 240upx;
background: linear-gradient(to left, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
border-radius: 16upx 16upx 0 0;
overflow: hidden;
position: relative;
padding: 20upx 24upx;
.card-bg {
position: absolute;
top: 20upx;
right: 0;
width: 380upx;
height: 260upx;
}
.tit {
font-size: $font-base+2upx;
color: #f7d680;
margin-bottom: 28upx;
.iconfont {
color: #f6e5a3;
display: inline-block;
margin-right: 16upx;
}
}
}
}
.cover-container {
margin-top: -150upx;
padding: 0 30upx 20upx;
position: relative;
background-color: $page-color-base;
.arc {
position: absolute;
left: 0;
top: -34upx;
width: 100%;
height: 36upx;
}
.promotion-center {
background: #fff;
margin: 20upx 0;
/*分类列表*/
.category-list {
width: 100%;
padding: 0 0 30upx 0;
border-bottom: solid 2upx #f6f6f6;
display: flex;
flex-wrap: wrap;
.category {
width: 33.3%;
margin-top: 50upx;
display: flex;
justify-content: center;
flex-wrap: wrap;
.img {
width: 100%;
display: flex;
justify-content: center;
.iconfont {
font-size: $font-lg + 24upx;
}
}
.text {
width: 100%;
display: flex;
justify-content: center;
font-size: 24upx;
color: #3c3c3c;
}
.share-btn {
height: 142upx;
text-align: left;
background: none;
padding: 0;
margin: 0;
}
.share-btn:after {
border: none;
border-radius: none;
}
}
}
}
.tj-sction {
@extend %section;
display: flex;
.tj-item {
@extend %flex-center;
flex: 1;
flex-direction: column;
margin: 30upx 0;
font-size: $font-sm;
color: #75787d;
/*border-right: 2upx solid rgba(0, 0, 0, 0.2);*/
}
/*.tj-item:last-child {*/
/*border-right: none;*/
/*}*/
.num {
font-size: $font-base;
color: $font-color-dark;
}
.red {
color: $base-color;
}
}
.order-section {
@extend %section;
padding: 28upx 0;
.order-item {
@extend %flex-center;
width: 120upx;
height: 120upx;
border-radius: 10upx;
font-size: $font-sm;
color: $font-color-dark;
position: relative;
}
.badge {
position: absolute;
top: 0;
right: 4upx;
}
.iconfont {
font-size: 48upx;
color: #fa436a;
}
.icon-shouhoutuikuan {
font-size: 44upx;
}
}
.history-section {
background: #fff;
border-radius: 10upx;
.sec-header {
display: flex;
align-items: center;
font-size: $font-base;
color: $font-color-dark;
.iconfont {
color: #5eba8f;
margin-right: 16upx;
line-height: 40upx;
}
.content {
flex: 1;
}
.iconyou {
font-size: $font-base + 2upx;
color: $font-color-base;
margin-left: $uni-spacing-row-sm;
}
}
.h-list {
white-space: nowrap;
padding: 20upx 30upx 0;
.h-item {
display: inline-block;
font-size: $font-sm;
color: $font-color-base;
width: 160upx;
margin-right: 20upx;
border-radius: 10upx;
.h-item-img {
width: 160upx;
height: 160upx;
}
.h-item-text {
font-size: $font-sm;
}
}
}
.no-foot-print {
text-align: center;
padding: 48upx 0;
.no-foot-print-icon {
color: $base-color;
font-size: $font-lg + 2upx;
margin-right: 10upx;
}
}
.share-btn {
height: 102upx;
text-align: left;
background: none;
padding: 0;
margin: 0;
}
.share-btn:after {
border: none;
border-radius: none;
}
}
}
}
%flex-center {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
%section {
justify-content: space-around;
display: flex;
align-content: center;
background: #fff;
border-radius: 10upx;
}
</style>