index.vue 13.6 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
<template>
  <view>
    <global-loading />

    <view
        class="memberCenter"
        v-if="isShow"
    >
      <view
          class="memberBg"
          :style="{backgroundImage:'url('+memberListData[activeIndex].memberLevelBackground+')', 'padding-top': paddingTop + 'px'}"
      >
        <view
            class="member-top"
            :style="{'top': topHeight + 'px'}"
        >
          <view class="memberTopInfo">
            <view class="backBox">
              <image
                  src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/back_img04.png"
                  class="back"
                  @click="back"
              ></image>
            </view>
            <view class="memberTit fs30 font-color-FFF">会员中心</view>
          </view>
        </view>
        <view class="memberBox">
          <view class="posBox">
            <view class="memberBoxTop">
              <view class="memberTopPos">
                <swiper
                    class="swiper pro-box"
                    next-margin="30rpx"
                    previous-margin="30rpx"
                    :current="activeIndex"
                    :indicator-dots="false"
                    :autoplay="false"
                    @change="swiperChange"
                >
                  <swiper-item
                      class="pro-item-warp"
                      v-for="(item, index) in memberListData"
                      :key="index"
                  >
                    <view class="box">
                      <view
                          class="memberTopBg"
                          :style="{backgroundImage:'url('+item.memberLevelBackground+')'}"
                      >
                        <view class="flex-display flex-sp-between">
                          <view class="nameBox">
                            <view class="name fs36">{{ memberData.name }}</view>
                            <view class="level">
                              <image :src="item.memberLevelIcon"></image>
                            </view>
                          </view>
                          <view class="avatarBox">
                            <image :src="memberData.headImage"></image>
                          </view>
                        </view>
                        <view class="growing">
                          <view class="growingValue flex-display flex-sp-between">
                            <label class="fs24 fs-weight-400 font-color-333">当前会员成长值
                              {{ memberData.growth }}</label>
                            <label
                                class="fs24 fs-weight-400 font-color-333 mar-left-20"
                                v-if="nextGrowth !== 0 && nextGrowth !== item.growth"
                            >{{ nextGrowth }}</label>
                          </view>
                          <view
                              class="progressBar"
                              v-if="memberData.growth < nextGrowth"
                          >
                            <view style="width: 100%">
                              <progress
                                  activeColor="#FFEBC4"
                                  :percent="getPercent(memberData.growth, nextGrowth)"
                                  active
                                  stroke-width="2"
                              />
                            </view>
                          </view>
                          <view
                              class="currentName"
                              v-else
                          >
                            以超越该等级
                          </view>
                          <!--                      <view class="flex-display flex-sp-between">-->
                          <!--                        <label class="fs24 font-color-71521B">{{memberData.memberLevelName}}</label>-->
                          <!--                        <label class="fs24 font-color-71521B">{{memberData.nextLevelName}}</label>-->
                          <!--                      </view>-->
                        </view>
                      </view>
                    </view>
                  </swiper-item>
                </swiper>
              </view>
            </view>
          </view>
        </view>
        <view class="equity">
			<view class="equityTit">积分消费情况</view>
			<view v-for="(item,index) in jifenList">
				<view style="border-bottom: 1px dashed #E8E8F0;display: flex;justify-content: space-between;align-items: center;padding: 10px 0;">
					<view class="" style="color: #434343;font-size: 14px;">
						{{item.sceneName}}
					</view>
					<view style="color: #464646;">
						{{item.num}}积分
					</view>
				</view>
				
			</view>
          <!-- <view class="equityBox">
            <view class="equityTit">我的权益</view>
            <view class="equityList">
              <view
                  class="equityItem"
                  v-for="item of equityList"
                  :key="item.memberId"
              >
                <image :src="item.memberIcon"></image>
                <view class="fs26">{{ item.memberName }}</view>
              </view>
            </view>
          </view> -->
        </view>
        <view class="signIn">
<!--          <view class="signInList">
            <view class="signTit fs30 font-color-333">快速成长</view>
            <view class="signInBox">
              <view class="signItem flex-items flex-sp-between">
                <view class="itemLeft flex-items">
                  <view class="leftIcon">
                    <image src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/img//member/memberList2.png"></image>
                  </view>
                  <view class="leftInfo">
                    <label class="fs28 font-color-333">购物</label>
                    <view class="fs24 font-color-999">购买商品获取相应成长值</view>
                  </view>
                </view>
                <view
                    class="rightBtn"
                    @click="goToShopping"
                >去购物
                </view>
              </view>
            </view>
          </view> -->
        </view>
      </view>
    </view>
  </view>
</template>

<script>
const NET = require('../../utils/request')
const API = require('../../config/api')
export default {
  name: "index",
  data() {
    return {
      memberData: {},
      equityList: [],
      levelInfo: {},
      isShow: false,
      memberListData: [],
      nextGrowth: 0,
      activeIndex: 0,
      topHeight: 10,
      paddingTop: 50,
	  jifenList:[]
    }
  },
  onLoad() {
    // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
    let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
    this.topHeight = menuButtonInfo.top
    this.paddingTop = this.paddingTop + this.topHeight
    // #endif
    // #ifdef APP
    this.topHeight = 50
    this.paddingTop = 100
    // #endif

    // 定时器防止app一开始进入时页面混乱问题
    setTimeout(() => {
      this.getMemberShipList()
    }, 200)
    this.memberData = uni.getStorageSync('storage_userInfo');
    this.getMemberByMemberLevel()
    this.getMemberList()
	let memerId=uni.getStorageSync('memerId');
	NET.request(API.pointsDetails, {memerId:memerId,type:2}, 'POST').then(item => {
		if(item.code == '200'){
			this.jifenList = JSON.parse(item.data).data.list
			console.log(JSON.parse(item.data).data.list,'12312312')
		}
	})
  },
  methods: {
    swiperChange(item) {
      console.log(item.detail.current, 'index')
      this.activeIndex = item.detail.current
      console.log(typeof this.activeIndex, typeof (this.memberListData.length - 1))
      let num = 0
      num = this.activeIndex + 1
      if (num === this.memberListData.length) {
        this.nextGrowth = this.memberListData[this.activeIndex].growth
      } else {
        console.log('caonima ')
        this.nextGrowth = this.memberListData[this.activeIndex + 1].growth
      }
      this.equityList = this.memberListData[this.activeIndex].membershipList
    },
    getMemberList() {
      NET.request(API.memberList, {}, 'GET').then(res => {
        this.memberListData = res.data
        this.memberListData.forEach((item, index) => {
          if (item.memberLevelId === this.memberData.memberLevelId) {
            this.activeIndex = index
            let num = 0
            num = this.activeIndex + 1
            if (num === this.memberListData.length) {
              this.nextGrowth = this.memberListData[this.activeIndex].growth
            } else {
              this.nextGrowth = this.memberListData[this.activeIndex + 1].growth
            }
            this.equityList = this.memberListData[this.activeIndex].membershipList
          }
        })
      }).catch(res => {
      })
    },
    getMemberShipList() {
      // 获取会员信息
      // uni.showLoading({
      //   mask: true,
      //   title: '加载中...',
      // })
      NET.request(API.getMemberShipList, {}, 'GET').then(res => {
        uni.hideLoading()
        this.equityList = res.data
        this.isShow = true
      }).catch(res => {
      })
    },
    // 去首页
    goToShopping() {
      uni.switchTab({
        url: '../../pages/tabbar/index/index'
      })
    },
    getPercent(num, total) {
      num = parseFloat(num);
      total = parseFloat(total);
      if (isNaN(num) || isNaN(total)) {
        return "-";
      }
      return total <= 0 ? "0%" : Math.round((num / total) * 10000) / 100.0;
    },
    // 获取会员等级
    getMemberByMemberLevel() {
      NET.request(`${ API.getMemberByMemberLevel }/${ this.memberData.memberLevelId }`, {}, 'GET').then(res => {
        this.levelInfo = res.data
        uni.setStorageSync('storage_levelInfo', this.levelInfo);
      }).catch(res => {
      })
    },
    // 返回上一级
    back() {
      uni.navigateBack()
    }
  }
}
</script>

<style
    lang="scss"
    scoped
>
.memberCenter {
  background-size: contain;
  min-height: 800rpx;

  .memberBg {
    background-repeat: no-repeat;
    padding-top: 50rpx;
  }

  .memberBox {
    width: 100%;
    //background: #523e3a;
    border-radius: 25rpx;
    background-size: contain;
    position: relative;
    box-sizing: border-box;

    .memberBoxTop {
      position: relative;

      .memberTopPos {
        overflow: hidden;

        .pro-box {
          height: 300rpx;
        }

        .swiper {
          .box {
            height: 300rpx;
            padding: 4rpx 10rpx;
          }
        }
      }

      .memberTopBg {
        background-size: cover;
        background-repeat: no-repeat;
        border-radius: 30rpx;
        padding: 40rpx 30rpx 30rpx 30rpx;
        box-shadow: 0 0 5rpx rgba(90, 90, 90, .5);
        height: 290rpx;

        .currentName {
          font-size: 26rpx;
          margin-top: 50rpx;
          color: #71521B;
        }
      }
    }

    .avatarBox {
      image {
        width: 110rpx;
        height: 110rpx;
        border: 5rpx solid #FFFFFF;
        border-radius: 50%;
      }
    }

    .nameBox {
      .name {
        color: #333333;
        margin-right: 30rpx;
        margin-bottom: 10rpx;
      }

      .level {
        image {
          width:60rpx;
          height: 50rpx;
        }
      }
    }

    .growing {
      .growingValue {
        margin-top: 30rpx;
      }

      .progressBar {
        height: 20rpx;
        width: 100%;
        margin: 20rpx 0;
      }
    }
  }
.equityTit {
        font-weight: bold;
        height: 92rpx;
        line-height: 92rpx;
      }
  .equity {
    border-radius: 25rpx 25rpx 0 0;
    padding: 30rpx;
    background: #F8F8F8;
    margin-top: 50rpx;

    .equityBox {
      background: #FFFFFF;
      min-height: 326rpx;
      border-radius: 20rpx;
      padding: 10rpx 30rpx 30rpx 30rpx;

      .equityTit {
        font-weight: bold;
        height: 92rpx;
        line-height: 92rpx;
      }

      .equityList {
        border-top: 2rpx solid #F3F4F5;
        display: flex;
        flex-flow: wrap;
        padding-top: 30rpx;
        text-align: center;

        .equityItem {
          width: 25%;
          color: #666666;

          image {
            width: 92rpx;
            height: 92rpx;
          }
        }
      }
    }
  }

  .signIn {
    padding: 0 30rpx 30rpx 30rpx;
    background: #F8F8F8;

    .signInList {
      background: #FFFFFF;
      border-radius: 20rpx;
      padding: 0 30rpx 30rpx 30rpx;

      .signTit {
        font-weight: bold;
        height: 92rpx;
        line-height: 92rpx;
      }

      .signInBox {
        .signItem {
          border-top: 2rpx solid #F3F4F5;
          padding: 30rpx 0;

          .itemLeft {
            image {
              width: 92rpx;
              height: 92rpx;
              margin-right: 30rpx;
            }
          }
        }

        .rightBtn {
          width: 160rpx;
          height: 58rpx;
          line-height: 58rpx;
          background: #333333;
          border-radius: 10rpx;
          color: #FFEBC4;
          text-align: center;
        }
      }
    }
  }

  .member-top {
    width: 100%;
    position: fixed;
    z-index: 99;
    left: 0;

    .memberTopInfo {
      position: relative;
      width: 100%;
      height: 60rpx;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .backBox {
      position: absolute;
      left: 10rpx;
      top: 0rpx;

      .back {
        width: 50rpx;
        height: 50rpx;
        padding: 0rpx 10rpx;
      }
    }
  }
}
</style>
<style>
page {
  background: #F8F8F8;
}

.progressBar /deep/ .uni-progress-bar {
  background-color: rgb(235, 235, 235, 0.6) !important;
  height: 5rpx !important;
  border-radius: 22rpx;
}

.progressBar /deep/ .uni-progress-bar .uni-progress-inner-bar {
  border-radius: 22rpx;
}
</style>