index.vue 15.1 KB
Newer Older
刘奕 committed
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
<template>

  <div class="member-info" ref="member-info" :style="{
        'padding-top':getPaddingList[0]['value']+'px',
        'padding-bottom':getPaddingList[1]['value']+'px',
        'padding-left':getPaddingList[2]['value']+'px',
        'padding-right':getPaddingList[3]['value']+'px'}">
    <div class="infoCard" v-if="loginFlag" :style="{
        'border-radius':boderRadius,
        'background':backgroundColor,
        'box-shadow':datas.componentData['shadowShow']?'0px 0px 5px '+datas.componentData['shadowSize']+'px #ccc':''
        }">
      <div class="bg-img">
        <img :style="{'border-radius':boderRadius}" v-if="datas.componentData['backgroundImgShow']" :src="backgroundImage" alt />
      </div>
      <div class="mainContent">
        <div class="infoDetail flex">
          <div class="infoCardLeft flex">
            <div class="userPic" @click="toInfo">
              <img v-if="userData.headPortraitUrl && userData.headPortraitUrl!=''" :src="userData.headPortraitUrl" class="Img" />
              <img v-else src="http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/jpg/39ada9cc-aff3-4842-8376-9f49e36c5811.jpg" class="Img" alt />
            </div>
            <div class="info flex" @click="toOpenNewCard(myCartList[0],0)">
              <div class="infoTop flex">
                <div class="name">{{userData.nickname || userData.mobilephone}}</div>
                <div class="vipType flex">
刘奕 committed
27
                  <img src="https://mayi-newshop.oss-cn-shanghai.aliyuncs.com/product/R7x3myNiHF.png" class="vipTypeIcon">
刘奕 committed
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
                  <div v-if="myCartList.length>0">{{myCartList[0].title}}</div>
                </div>
              </div>
              <div class="vipTip" v-if="myCartList.length>0">
                <div>{{myCartList[0].recommendText}}</div>
                <!-- <div v-if="myCartList[0].receiveStatus==0">
                  <div class="ov_btn" :class="{'notMet':myCartList[0].receiveWay == 1}">
                    <template v-if="myCartList[0].receiveWay == 1">未满足条件</template>
                    <template v-else>{{myCartList[0].openButtonText || '立即开通'}}</template>
                  </div>
                </div>
                <div v-else-if="myCartList[0].receiveStatus==1">
                  <div class="ov_btn">
                    <template v-if="myCartList[0].receiveWay == 2">立即续费</template>
                    <template v-else>查看权益</template>
                  </div>
                </div>
                <div v-else-if="myCartList[0].receiveStatus==2">
                  <div class="ov_btn" :class="{'notMet':myCartList[0].receiveWay != 2}">
                    <template v-if="myCartList[0].receiveWay != 2">已失效</template>
                    <template v-else>立即续费</template>
                  </div>
                </div> -->
              </div>
            </div>
          </div>
          <div class="memberCode flex" v-show="datas.componentData.showStyle == 2 || datas.componentData.showStyle == 4" @click="toMobileCard()">
            <div class="line"></div>
刘奕 committed
56
            <img class="code" src="https://mayi-newshop.oss-cn-shanghai.aliyuncs.com/product/HyGQDa5S4i.png" />
刘奕 committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
          </div>
        </div>
        <div class="otherDetail flex" v-show="datas.componentData.showStyle == 3 || datas.componentData.showStyle == 4">
          <div class="integral" v-show="datas.componentData.memberCodeShow == true" @click="handleClick(1)">我的积分:{{userData.cardBonus}}</div>
          <div class="ticket" v-show="datas.componentData.ticketShow == true" @click="handleClick(3)">我的券包:{{electronicCardNum}}</div>
        </div>
      </div>
    </div>
    <div class="noLogin" v-else>
      <div class="noLoginCard flex" :style="{
        'border-radius':boderRadius,
        'background':backgroundColor,
        'box-shadow':datas.componentData['shadowShow']?'0px 0px 5px '+datas.componentData['shadowSize']+'px #ccc':''
        }">
        <div class="bg-img">
          <img :style="{'border-radius':boderRadius}" v-if="datas.componentData['backgroundImgShow']" :src="backgroundImage" alt />
        </div>
        <div class="noLoginMain flex">
          <div class="left flex">
            <div class="bc2" v-if="shopInfo.logoUrl && datas.componentData.noLoginshowStyle == 1">
              <img :src="shopInfo.logoUrl" alt />
            </div>
            <div class="leftText">
刘奕 committed
80
              <div class="text">
刘奕 committed
81
                Hi~
刘奕 committed
82 83
              </div>
              <div class="text">{{datas.componentData['noLoginText']}}</div>
刘奕 committed
84 85
            </div>
          </div>
刘奕 committed
86
          <div class="right" @click="toLogin" :style="{'color':datas.componentData['noLoginBtnTextColor']}">
刘奕 committed
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
            登录/注册
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import memberInfo from '@/api/memberInfo'
import { DFSImg } from '@/utils/index'
const app = getApp()

export default {
  name: 'member-info',
  props: {
    //默认
    //渲染环境
    render: {
      type: Boolean,
      default: false,
    },
    datas: {
      type: Object,
      default: () => {
        return {
          componentData: {},
        }
      },
      validator: (value) => {
        return true
      },
    },
  },
  data() {
    return {
      //用户数据
      userData: {
        type: Object,
        default: () => {
          return {
            belongToShopCode: 'shzb',
            belongToShopId: '89',
            belongToShopName: '真北店',
            birth: null,
            cardBonus: '53',
            certifiedStatus: '0',
            cityCode: '310100',
            cityId: '457',
            detailedAddress: '',
            districtCode: '310107',
            districtId: '2933',
            email: '',
            gender: '1',
            headPortraitUrl:
              'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/jpg/39ada9cc-aff3-4842-8376-9f49e36c5811.jpg',
            mobilephone: '12345678900',
            nickname: '用户昵称',
            originName: '',
            electronicCardNum: 0,
            cardBonus: 0,
          }
        },
      },
      myCartList: [],
      certified: false,
      openVipLogoUrl: null,
      electronicCardNum: 0,
      loginFlag: false,
      shopInfo: {
        logoUrl: '',
      },
    }
  },
  components: {},
  computed: {
    backgroundColor() {
      return this.datas.componentData['backgroundColorShow']
        ? this.datas.componentData['backgroundColor']
        : 'rgba(255, 255, 255, 1)'
    },
    boderRadius() {
      return (2 * this.datas.componentData['radius']) / 100 + 'em'
    },
    getPaddingList() {
      return this.datas.componentData.paddingList
    },
    globalDataShopInfo() {
      return this.mpApp.globalData.shopInfo
    },
    backgroundImage() {
      return DFSImg(this.datas.componentData.backgroundImage, 640, null, 1)
    },
  },
  watch: {
    globalDataShopInfo: {
      handler(newVal, oldVal) {
        if (newVal) {
          console.log(newVal, oldVal, '------------------globalDataShopInfo')
          this.shopInfo = this.mpApp.globalData.shopInfo
          if (this.shopInfo && this.shopInfo.logoUrl) {
            this.shopInfo.logoUrl = DFSImg(this.shopInfo.logoUrl, 400, 400)
          }
          console.log(this.shopInfo, 'this.shopInfo')
        }
      },
      immediate: true,
    },
  },
  created() {
    if (wx.getStorageSync('sessionid')) {
      memberInfo.getUserInfo().then((res) => {
        console.log(res, ' this.userData ')
        if (res.data.code == 200) {
          this.userData = res.data.data
          console.log(this.userData, ' this.userData ')
        }
      })
      // TODO 新版会员卡无列表
      memberInfo.getV3PortalShopCard().then((res) => {
        this.myCartList = []
        if (res.data.code == 200) {
          if (res.data.data) {
            this.myCartList.push(res.data.data)
            this.myCartList.forEach((item, index) => {
              if (item.receiveStatus == 1) {
                this.certified = true
                this.openVipLogoUrl = item.openVipLogo
              }
            })
          }
        }
      })
      // 是否开通会员积分
      memberInfo.QueryIsOpen().then((res) => {
        if (res.data.code == 200) {
          this.integralStatus = res.data.data ? true : false
        } else {
          this.integralStatus = false
        }
      })

      //获取电子卡卷
      memberInfo
        .getUnUseElectronicCard({ pageNum: 1, pageSize: 1 })
        .then((res) => {
          if (res.data.code == 200) {
            this.electronicCardNum = res.data.total || 0
          }
        })
      this.loginFlag = true
    } else {
      this.loginFlag = false
    }
    console.log(this.loginFlag, 'this.loginFlag')
  },
  mounted() {},
  methods: {
    DFSRightImg(systemCode, path, w, h) {
      if (path == null || path == '') {
        if (systemCode == 'FREE_SHIPPING') {
          return 'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/0a6acac3-31ee-46b2-80af-7e2e73b271ac.png'
        } else if (systemCode == 'DISCOUNT') {
          return 'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/efe72515-9a4e-4ca5-8773-248d3430a851.png'
        } else if (systemCode == 'DISTRIBUTION') {
          return 'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/effb2c9a-e661-4794-9412-664e4755b89e.png'
        } else if (systemCode == 'OPEN_VIP_LOGO') {
          return 'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/d3b636a9-a269-46c2-8912-ac6cacba9171.png'
        } else {
          return ''
        }
      }
      return path
    },
    toLogin() {
      // 跳转登录页
      // let backUrl = '/home/main'

      let url = `/pages/login/main`
      wx.navigateTo({
        url: url,
      })
    },
    // 新版会员卡跳转链接
    toOpenNewCard(item, index) {
      console.log(this.userData, 'this.userData.mobilephone')
      let query = {
        cardId: item.id,
        userTel: this.userData.mobilephone,
        memberInfo: true,
      }
      app.$themeToLink({
        type: 1,
        link: `/personalCenter/membershipCard?cardId=${query.cardId}&userTel=${query.userTel}&memberInfo=true`,
      })
    },
    toInfo() {
      app.$themeToLink({
        type: 1,
        link: `/personalCenter/userInfo?memberInfo=true`,
      })
    },
    toMobileCard() {
李嘉林 committed
290 291 292
      app.$themeToLink({
        type: 1,
        link: `/personalCenter/vip/vipMobileCard`,
刘奕 committed
293
      })
李嘉林 committed
294 295 296
      // wx.navigateTo({
      //   url: '/pages/memberCode/main',
      // })
刘奕 committed
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
    },
    handleClick(id) {
      if (id == 0) {
        this.toPages('/personalCenter/coupon/myCoupon')
      } else if (id == 1) {
        app.$themeToLink({
          type: 1,
          link: `/pointShop/pointCenter`,
        })
      } else if (id == 2) {
        this.toPages('/giftCards/giftCardList')
      } else if (id == 3) {
        app.$themeToLink({
          type: 1,
          link: `/myCoupon/electronicVolume`,
        })
      } else {
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.member-info {
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}
.infoCard {
  background: #fff;
  border-radius: 2px;
  padding: 24px 18px 19px 13px;
  box-sizing: border-box;
  position: relative;
  .bg-img {
    height: 100%;
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      position: absolute;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
    }
  }
  .mainContent {
    width: 100%;
    height: 100%;
    position: relative;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    .infoDetail {
      align-items: center;
      justify-content: space-between;

      .infoCardLeft {
        align-items: center;
        .userPic {
          width: 44px;
          height: 44px;
          border-radius: 50%;
          // overflow: hidden;
          border: 1px solid #fff;
          position: relative;
          .Img {
            height: 100%;
            width: 100%;
            border-radius: 50%;
          }
        }
        .info {
          flex-direction: column;
          justify-content: space-between;
          margin-left: 10px;
          .infoTop {
            align-items: center;
          }
          .name {
            height: 16px;
            font-size: 12px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333333;
            line-height: 16px;
          }
          .vipType {
            align-items: center;
            height: 16px;
            background: linear-gradient(90deg, #61626b 0%, #323339 100%);
            padding: 0 8px;
            box-sizing: border-box;
            border-radius: 8px;
            font-size: 12px;

            font-weight: 400;
            color: #facf58;
            line-height: 16px;
            margin-left: 5px;
            .vipTypeIcon {
              height: 12px;
              width: 12px;
              margin-right: 2px;
            }
          }
          .vipTip {
            height: 16px;
            font-size: 12px;

            font-weight: 400;
            color: #999999;
            line-height: 16px;
            margin-top: 14px;
          }
        }
      }
      .memberCode {
        align-items: center;
        .line {
          width: 1px;
          height: 48px;
          background: #d8d8d8;
        }
        .code {
          width: 40px;
          height: 40px;
          margin-left: 13px;
        }
      }
    }
    .otherDetail {
      align-items: center;
      justify-content: space-between;
      margin-top: 21px;
      padding: 0px 24px;
      box-sizing: border-box;
      .integral {
        height: 17px;
        font-size: 12px;
        font-weight: 400;
        color: #333333;
        line-height: 17px;
      }
      .ticket {
        height: 17px;
        font-size: 12px;
        font-weight: 400;
        color: #333333;
        line-height: 17px;
      }
    }
  }
}
.noLogin {
  width: 100%;
  .noLoginCard {
    justify-content: space-between;
    align-items: center;
    padding: 24px 18px 19px 13px;
    box-sizing: border-box;
    position: relative;
    .bg-img {
      height: 100%;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
      }
    }
    .noLoginMain {
      width: 100%;
      height: 100%;
      position: relative;
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      align-items: center;
      justify-content: space-between;
      .left {
刘奕 committed
482
        align-items: center;
刘奕 committed
483 484 485 486 487 488 489 490 491
        .bc2 {
          width: 64px;
          height: 64px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .leftText {
刘奕 committed
492
           div {
刘奕 committed
493 494 495 496
            font-size: 13px;
            font-weight: 600;
            line-height: 21px;
            color: var(--main-color);
刘奕 committed
497 498
            width: 148px;
            max-width: 148px;
刘奕 committed
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
          }
          margin-left: 10px;
        }
      }
      .right {
        width: 86px;
        height: 32px;
        background: var(--main-color);
        border-radius: 16px;
        line-height: 32px;
        text-align: center;
        font-size: 12px;
        font-weight: 500;
        color: #333333;
      }
    }
  }
}
</style>