vipCenter.vue 13.2 KB
Newer Older
王建威's avatar
王建威 committed
1 2 3 4 5 6
<template>
	<view class="main">
		<TopBar title="会员中心" bgColor="#2D3239" titleColor="#fff" />
		<view class="top_bg">
			<view class="swiper_content">
				<swiper style="height: 284rpx;" @change="swiperChange">
王建威's avatar
王建威 committed
7 8 9
					<swiper-item style="left: -30rpx;" :style="[0 === index ? {'left':0} : null]">
						<view class="swiper_card" :class="[{scale: 0 !== index}, `level${member_list[0].grade}`]" :style="[member_list.length === 1 ? {width: '100%'} : null]">
							<text class="now_level">{{member_list[0].grade_name}}</text>
王建威's avatar
王建威 committed
10
							<view class="card_flex">
王建威's avatar
王建威 committed
11
								<image :src="member_list[0].portrait || $defaultPortrait"></image>
王建威's avatar
王建威 committed
12
								<view>
王建威's avatar
王建威 committed
13 14
									<view class="customer_name">{{member_list[0].user_name}}</view>
									<view class="card_bar">
王建威's avatar
王建威 committed
15
										<view class="process_bar" 
王建威's avatar
王建威 committed
16
										:style="`width: ${Number(member_list[0].total_integral)*100/(Number(member_list[0].total_integral)+member_list[0].growth_diff).toFixed(2)}%`"></view>
王建威's avatar
王建威 committed
17
									</view>
王建威's avatar
王建威 committed
18
									<view class="diff" v-if="member_list.length > 1">{{member_list[0].total_integral}}/{{Number(member_list[0].total_integral)+member_list[0].growth_diff}} 升至{{member_list[1].grade_name}}</view>
王建威's avatar
王建威 committed
19 20 21
								</view>
							</view>
							<view class="card_bottom">
王建威's avatar
王建威 committed
22 23
								<text class="growth_diff" v-if="member_list.length > 1">您距离下一等级还需{{member_list[0].growth_diff}}经验值</text>
								<text v-else></text>
王建威's avatar
王建威 committed
24 25 26 27
								<view class="levelStrategy" @click="$jump('/pages/levelStrategy/levelStrategy' ,2)"><text class="picon" :class="`picon${member_list[0].grade}`"></text><text>升级攻略</text></view>
							</view>
						</view>
					</swiper-item>
王建威's avatar
王建威 committed
28
					<swiper-item style="left: -30rpx;" v-if="member_list.length > 1" :style="[1 === index ? {'left':0} : null]">
王建威's avatar
王建威 committed
29 30 31 32 33 34 35 36 37 38 39 40 41
						<view class="swiper_card" :class="[{scale: 1 !== index}, `level${member_list[1].grade}`]" :style="[member_list.length === 1 ? {width: '100%'} : null]">
							<text class="now_level">{{member_list[1].grade_name}}</text>
							<view class="card_flex">
								<image :src="member_list[1].portrait || $defaultPortrait"></image>
								<view>
									<view class="customer_name">{{member_list[1].user_name}}</view>
									<view class="card_bar"></view>
									<view class="diff">{{member_list[1].grade_name}}</view>
								</view>
							</view>
							<view class="card_bottom">
								<text></text>
								<view class="levelStrategy" @click="$jump('/pages/levelStrategy/levelStrategy' ,2)"><text class="picon" :class="`picon${member_list[1].grade}`"></text><text>升级攻略</text></view>
王建威's avatar
王建威 committed
42 43 44 45 46
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>
王建威's avatar
王建威 committed
47 48
			<view class="top_title" v-if="titleFlag">当前等级权益</view>
			<view class="now_benefit" v-for="(val, key) in member_list" v-if="key === index && val.grade_list !==null" :key="key" :style="[heightFlag ? {'height': height+'rpx'} : null]" :class="val.grade_list.length > 4 ? 'height1' : 'height2'">
王建威's avatar
王建威 committed
49 50 51 52
				<view class="benefit_item" v-for="(item, k) in val.grade_list" :key="k" :style="[key != 0 ? {color: 'rgba(255,255,255,0.4)'} : null]">
					{{item.short_title}}
					<text class="dia" v-if="key === 0"></text>
					<text v-else class="unlock"><text class="eosfont">&#xe645;</text>{{val.grade_name.substr(0,2)}}解锁</text>
王建威's avatar
王建威 committed
53 54 55 56 57 58 59 60 61 62
				</view>
			</view>
			<view class="collapse_btn" @click="moreBenefit()" v-if="moreFlag"><text v-if="!heightFlag">查看更多</text><text v-else>收起</text><text class="eosfont" v-if="!heightFlag">&#xe729;</text><text class="eosfont" v-else>&#xe728;</text></text></view>
		</view>
		<view class="more_bar">
			<text class="text1">兑换中心</text>
			<!-- <text class="text2">查看更多<text class="eosfont">&#xe608;</text></text> -->
		</view>
		<view class="goods_box">
			<view class="goods_item" v-for="(item, index) in integral_list" :key="index" @click="$jump(`${php}app=my_integral_goods&act=detail&id=${item.goods_id}&integral=${member_list[0].integral}`)">
王建威's avatar
王建威 committed
63
				<image class="goods_img" :src="item.goods_logo || $noGoodsImg"></image>
王建威's avatar
王建威 committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
				<text class="goods_name">{{item.goods_name}}</text>
				<text class="goods_price">{{item.goods_point}}积分</text>
			</view>
		</view>
	</view>
</template>

<script>
	import TopBar from '@/components/TopBar/TopBar.vue';
	import { php } from '@/common/host.js';
	export default {
		data() {
			return {
				height: 336,
				heightFlag: false,
				animationData: {},
				integral_list: [],
王建威's avatar
王建威 committed
81 82
				member_list: [{
					grade: '',
王建威's avatar
王建威 committed
83 84
					grade_name: '',
					grade_list: []
王建威's avatar
王建威 committed
85 86
				}, {
					grade: '',
王建威's avatar
王建威 committed
87 88
					grade_name: '',
					grade_list: []
王建威's avatar
王建威 committed
89
				}],
王建威's avatar
王建威 committed
90 91
				index: 0,
				moreFlag: true,
王建威's avatar
王建威 committed
92
				titleFlag: true,
王建威's avatar
王建威 committed
93 94 95 96 97 98 99 100 101 102 103 104 105
				php: php
			}
		},
		onLoad() {
			uni.request({
				url: '/uni/api/member/get_member_index',
				method: 'get',
				dataType: 'json',
				success: (res) => {
					if(res.data.code === 0) {
						this.integral_list = res.data.data.integral_list;
						this.member_list = res.data.data.member_list;
						this.changeHeight(res.data.data.member_list[0].grade_list, 0);
王建威's avatar
王建威 committed
106 107 108
					} else if (res.data.code === -1) {
						// 未登录状态
						this.$jump(`${php}app=member&act=login`)
王建威's avatar
王建威 committed
109 110 111 112 113 114 115 116 117 118 119
					}
				}
			});
			this.animation = uni.createAnimation();
		},
		methods: {
			moreBenefit() {
				this.heightFlag = !this.heightFlag;
			},
			changeHeight(data, index) {
				this.index = index;
王建威's avatar
王建威 committed
120 121 122 123 124 125
				if(data === null) {
					this.moreFlag = false;
					this.titleFlag = false;
					return
				}
				this.titleFlag = true;
王建威's avatar
王建威 committed
126 127 128 129 130 131 132
				if(data.length > 8) {
					this.moreFlag = true;
				} else {
					this.moreFlag = false;
				}
				let n = data.length % 4,
					init = Math.ceil(data.length / 4);
王建威's avatar
王建威 committed
133
				this.height = init * 160 + init * 16;
王建威's avatar
王建威 committed
134 135
			},
			swiperChange(e) {
王建威's avatar
王建威 committed
136 137
				var current  = e.detail.current;
				this.index = current;
王建威's avatar
王建威 committed
138 139 140 141 142 143
				if(this.member_list[current].grade_list === null) {
					this.moreFlag = false;
					this.titleFlag = false;
					return
				}
				this.titleFlag = true;
王建威's avatar
王建威 committed
144 145 146 147 148 149 150
				let length = this.member_list[current].grade_list.length;
				if(length > 8) {
					this.moreFlag = true;
				} else {
					this.moreFlag = false;
				}
				this.changeHeight(this.member_list[current].grade_list, current);
王建威's avatar
王建威 committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
			}
		},
		components: {
			TopBar
		}
	}
</script>

<style lang="less" scoped>
	.main {
		padding: 88rpx 0 76rpx;
		background-color: #FBFBFB;
		.top_bg {
			background-color: #2D3239;
			overflow: hidden;
			margin-top: -8rpx;
王建威's avatar
王建威 committed
167
			padding: 0 24rpx 24rpx;
王建威's avatar
王建威 committed
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
			border-radius: 0 0 24rpx 24rpx;
		}
		.swiper_content {
			margin-top: 16rpx;
			height: 284rpx;
			.scale {
				height: 256rpx !important;
				margin-top: 14rpx;
			}
			.swiper_card {
				width: 640rpx;
				height: 284rpx;
				box-shadow:0px 8rpx 24rpx 0px rgba(255,219,43,0.2);
				border-radius:16rpx;
				position: relative;
				overflow: hidden;
				transition: all 0.5s;
				.card_flex {
					display: flex;
					margin: 94rpx 0 0 30rpx;
					image {
						width: 92rpx;
						height: 92rpx;
						border-radius: 50%;
						margin-right: 24rpx;
					}
					.customer_name {
						color: #000000;
						font-size: 28rpx;
						font-family:PingFangSC-Medium,PingFang SC;
						font-weight:500;
						height: 40rpx;
						line-height: 40rpx;
					}
					.card_bar {
						width: 200rpx;
						height: 8rpx;
						border-radius: 4rpx;
						background-color: #FFF3B6;
						margin: 8rpx 0 ;
						overflow: hidden;
						.process_bar {
							background-color: #6E4C26;
							height: 100%;
						}
					}
					.diff {
						color: rgba(0,0,0,0.7);
						font-size: 24rpx;
						font-family:PingFangSC-Medium,PingFang SC;
						font-weight:500;
						height: 34rpx;
						line-height: 34rpx;
					}
				}
				.now_level {
					width: 128rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					border-radius: 20rpx 0 0 20rpx;
					background-color: red;
					color: #000000;
					font-size: 24rpx;
					position: absolute;
					right: 0;
					top: 24rpx;
					background-color: rgba(255,255,255,0.3);
				}
				.card_bottom {
					position: absolute;
					bottom: 0;
					left: 0;
					width: 100%;
					height: 64rpx;
					line-height: 64rpx;
					background-color: red;
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 0 24rpx;
					box-sizing: border-box;
					background-color: rgba(0,0,0,0.2);
					color: rgba(255,255,255,0.8);
					.levelStrategy {
						font-size: 24rpx;
						display: flex;
						align-items: center;
						.picon {
							width: 36rpx;
							height: 36rpx;
							display: inline-block;
						}
						.picon1 {
							background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/p1%403x.png') no-repeat;
							background-size: 100% 100%;
						}
						.picon2 {
							background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/p2%403x.png') no-repeat;
							background-size: 100% 100%;
						}
						.picon3 {
							background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/p3%403x.png') no-repeat;
							background-size: 100% 100%;
						}
						.picon4 {
							background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/p4%403x.png') no-repeat;
							background-size: 100% 100%;
						}
						.picon5 {
							background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/p5%403x.png') no-repeat;
							background-size: 100% 100%;
						}
					}
					.growth_diff {
						font-size: 24rpx;
						color: rgba(255,255,255,0.8);
					}
				}
			}
			.level1 {
王建威's avatar
王建威 committed
289
				background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/level1%402x.png') no-repeat;
王建威's avatar
王建威 committed
290 291 292
				background-size: 100% 100%;
			}
			.level2 {
王建威's avatar
王建威 committed
293
				background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/level2%402x.png') no-repeat;
王建威's avatar
王建威 committed
294 295 296
				background-size: 100% 100%;
			}
			.level3 {
王建威's avatar
王建威 committed
297
				background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/level3%402x.png') no-repeat;
王建威's avatar
王建威 committed
298 299 300
				background-size: 100% 100%;
			}
			.level4 {
王建威's avatar
王建威 committed
301
				background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/level4%402x.png') no-repeat;
王建威's avatar
王建威 committed
302 303 304
				background-size: 100% 100%;
			}
			.level5 {
王建威's avatar
王建威 committed
305
				background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/level5%402x.png') no-repeat;
王建威's avatar
王建威 committed
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
				background-size: 100% 100%;
			}
		}
		.top_title {
			color: #D6A35D;
			font-size: 40rpx;
			height: 56rpx;
			line-height: 56rpx;
			font-family:PingFangSC-Medium,PingFang SC;
			font-weight:500;
			position: relative;
			margin-top: 40rpx;
		}
		.top_title:after {
			width: 80rpx;
			height: 6rpx;
			border-radius: 4rpx;
			background-color: #D6A35D;
			content: '';
			position: absolute;
			left: 0;
			bottom: -12rpx;
		}
		.now_benefit {
			display: flex;
			flex-wrap: wrap;
			margin-top: 54rpx;
			overflow: hidden;
			transition: height 0.3s;
			.benefit_item {
				width: 160rpx;
				height: 160rpx;
				background-color: rgba(0,0,0,0.5);
				border-radius: 16rpx;
				margin-bottom: 16rpx;
				color: #F6CA8D;
				font-size: 28rpx;
				padding: 16rpx;
				box-sizing: border-box;
				position: relative;
				overflow: hidden;
				margin-left: 20rpx;
王建威's avatar
王建威 committed
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
				.unlock {
					font-size: 16rpx;
					color: rgba(255,255,255,0.4);
					display: flex;
					align-items: center;
					justify-content: center;
					width: 120rpx;
					height: 36rpx;
					line-height: 36rpx;
					position: absolute;
					bottom: 16rpx;
					left: 20rpx;
					background-color: #2E3136;
					border-radius: 18rpx;
				}
王建威's avatar
王建威 committed
363 364 365 366 367 368 369 370 371 372
				.dia {
					position: absolute;
					right: -10rpx;
					bottom: -10rpx;
					width: 60rpx;
					height: 60rpx;
					background: url('https://dbc-static.oss-cn-beijing.aliyuncs.com/static/dia.png') no-repeat;
					background-size: 100% 100%;
				}
			}
王建威's avatar
王建威 committed
373 374 375
			.benefit_item::-webkit-scrollbar {
				display: none;
			}
王建威's avatar
王建威 committed
376 377 378 379
			.benefit_item:nth-of-type(4n-3) {
				margin-left: 0;
			}
		}
王建威's avatar
王建威 committed
380 381 382 383 384 385
		.height1 {
			height: 352rpx;
		}
		.height2 {
			height: 176rpx;
		}
王建威's avatar
王建威 committed
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
		.collapse_btn {
			width: 408rpx;
			height: 68rpx;
			line-height: 64rpx;
			text-align: center;
			border-radius: 34rpx;
			border: 2px solid #F6CA8D;
			box-sizing: border-box;
			color: #F6CA8D;
			font-size: 28rpx;
			font-family:PingFangSC-Medium,PingFang SC;
			font-weight:500;
			margin: 24rpx auto 42rpx;
		}
		.more_bar {
			width: 702rpx;
			margin: 30rpx auto;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.text1 {
				font-size: 40rpx;
				color: #21232C;
				height: 56rpx;
				line-height: 56rpx;
				font-family:PingFangSC-Medium,PingFang SC;
				font-weight:500;
			}
			.text2 {
				color: #333333;
				font-size: 28rpx;
				height: 40rpx;
				line-height: 40rpx;
				display: flex;
				align-items: center;
				text {
					color: grey;
					font-weight: lighter;
					margin-left: 6rpx;
				}
			}
		}
		.goods_box {
			width: 702rpx;
			margin: 0 auto;
			background-color: #fff;
			padding: 0 24rpx 32rpx;
			box-sizing: border-box;
			display: flex;
			flex-wrap: wrap;
			overflow: hidden;
			.goods_item {
				width: 208rpx;
				margin-top: 24rpx;
				.goods_img {
					width: 208rpx;
					height: 208rpx;
					border-radius: 16rpx;
				}
				.goods_name {
					color: #21232C;
					font-size: 26rpx;
					line-height: 36rpx;
					width: 100%;
					font-family:PingFangSC-Medium,PingFang SC;
					font-weight:500;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				.goods_price {
					color: #C28F4B;
					font-size: 28rpx;
					height: 40rpx;
					line-height: 40rpx;
				}
			}
			.goods_item:nth-of-type(3n-1) {
				margin: 24rpx 14rpx 0;
			}
		}
	}
</style>