opening.vue 9.27 KB
<template>
  <div class="main">
    <div class="box">
      <div class="opening-border">
          <div class="opening-border-p">合伙门店权益卡 <span>未开通</span></div>
          <div class="opening-border-p">尊享100+专属权益</div>
          <div class="opening-border-p price" v-if="price">¥<span>{{price}}</span>/年</div>
      </div>
      <div class="opening-vip-border">
        <img src="@a/images/title-100.png" alt="" class="vip-title-images">
        <div class="vip-shop-panel">
          <img src="@a/images/vip-more.png" alt="">
        </div>
        <div class="vip-more">更多权益,开通即享</div>
      </div>
      <div class="opening-other">
        <div class="opening-other-title">
          其他开通方式
        </div>
        <div class="opening-other-border" @click="jumpOpen">
          <div class="other-border-icon">
            <img src="@a/images/exchange.png" alt="">
          </div>
          <div class="other-border-desc">
            <div class="other-border-p1">兑换权益卡</div>
            <div class="other-border-p2">设备码兑换</div>
          </div>
        </div>
      </div>
    </div>
    <div class="opening-loading-panel" v-if="openingStatus">
      <div class="opening-popup">
        <div class="opening-header">
          <div class="opening-jump" @click="jumpPast">
            <span>跳过</span>
          </div>
        </div>
         <div class="opening-tips">
           支付成功 正在开卡中…
         </div>
        <div class="opening-loading">
          <van-loading color="#19C34E" size="40" class="opening-loading-icon"/>
        </div>
      </div>
    </div>
    <div class="opening-operation">
      <div class="opening-operation-price" v-if="price" @click="buyCard"><span>¥{{ price }}</span>立即开通</div>
      <div class="opening-operation-price disabled" v-else>暂不支持付费购买</div>
      <div class="opening-operation-desc">开通权益代表接受 <a @click="jumpAgree">《权益服务协议》</a></div>
    </div>
  </div>
</template>

<script>
import {cardRoll, equity} from "@r/api";
import WxConfig from '@u/WxConfig'
const WX = new WxConfig(['chooseWXPay']);
export default {
  name: "opening",
  data() {
    return {
      price: '',
      orderCode:'',
      openingStatus: false,
      merchantId: sessionStorage.getItem('GL_WX_MERCHANTID'),
    }
  },
  mounted() {
    this.showLoading();
    let para = {
      merchantId: this.merchantId
    }
    cardRoll.getCardMerchantid(para).then(res => {
      this.hideLoading()
      let { code, data, message } = res
      if (code == 0) {
        this.price = data.goodPrice;
        this.orderCode = data.orderCode;
      } else {
        this.showToast(message)
      }
    })
  },
  methods: {
    jumpOpen() {
      window.vm.$router.push({ name: 'common.activate' });
    },
    async buyCard() {
      let {sessionId} = JSON.parse(sessionStorage.getItem('GL_EQUITY_USER_INFO'));
      this.showLoading();
      let para = {
        merchantId: this.merchantId,
        orderCode: this.orderCode,
        payMannerId: 9,
        orderSource: 3,
        sessionId,
      }
      let payData = await cardRoll.getCardBuy(para).then(res => {
        this.hideLoading()
        let { code, data, message } = res
        if (code == 0) {
          return data
        } else {
          this.showToast(message)
        }
      })
      const { timeStamp,nonceStr, packages, signType, paySign } = payData;
      WX.chooseWXPay(timeStamp,nonceStr, packages, signType, paySign).then(res => {
        console.log(res);
        this.getCardInfo();
      })
    },
    getCardInfo() {
      this.openingStatus = true;
      equity.getCardInfo().then(res => {
        console.log(res)
        this.hideLoading()
        let { code, message } = res;
        this.openingStatus = false;
        if (code == 0) {
          sessionStorage.setItem('CODE_STATUS', 1);
          window.vm.$router.replace({ name: 'equity.index' });
        } else {
          sessionStorage.setItem('CODE_STATUS', 0)
          this.showToast(message)
        }
      })
    },
    jumpPast() {
      window.vm.$router.replace({ name: 'equity.index' });
      this.openingStatus = false;
    },
    jumpAgree() {
      window.vm.$router.push({ name: 'cardRoll.agreement' });
    }
  }
}
</script>

<style scoped lang="scss">
  .main {
    .box {
      padding: 20px;
      .opening-border {
        background-image: url('~@a/images/card.png');
        background-size: 100% 100%;
        border-radius: 16px;
        padding: 15px 20px;
        height: 125px;
        box-sizing: border-box;
        &-p {
          font-size: 16px;
          margin-bottom: 10px;
          color: #FFFFFF;
          text-shadow: 0 2px 4px rgba(254,96,0,0.24);
          display: flex;
          justify-content: space-between;
          &.price {
            font-size: 14px;
            justify-content: flex-start;
            font-weight: 700;
            line-height: 40px;
            >span {
              font-size: 26px;
              color: #FFFFFF;
            }
          }
          >span {
            font-size: 14px;
            color: #8B5A0F;
          }
        }
      }
      .opening-vip-border {
        height: 190px;
        margin-top: 60px;
        box-sizing: border-box;
        background: #FFFFFF;
        border: 1px solid #F5D890;
        box-shadow: 0 2px 8px 0 rgba(255,222,166,0.30);
        border-radius: 8px;
        position: relative;
        .vip-title-images {
          position: absolute;
          width: 200px;
          height: 40px;
          top: -30px;
          left: 50%;
          margin-left: -100px;
        }
        .vip-shop-panel {
          height: 140px;
          width: 312px;
          margin: 14px auto 8px auto;
        }
        .vip-more {
          font-size: 12px;
          color: #CE9B1F;
          letter-spacing: 0;
          text-align: center;
          line-height: 24px;
        }
      }
      .opening-other {
        margin: 20px auto;
        &-title {
          font-size: 16px;
          color: #666666;
          position: relative;
          height: 22px;
          padding-left: 15px;
          margin-bottom: 10px;
          &:before {
            content: '';
            position: absolute;
            top: 0px;
            left: 0px;
            width: 4px;
            height: 22px;
            background: #FFAE23;
          }
        }
        &-border {
          opacity: 0.86;
          border: 1px solid #FFA100;
          border-radius: 8px;
          width: 148px;
          height: 60px;
          display: flex;
          padding: 10px;
          box-sizing: border-box;
          align-items: center;
          justify-content: space-between;
          .other-border-icon {
            width: 36px;
            height: 25px;
          }
          .other-border-p1 {
            font-size: 14px;
            color: #FFA100;
            line-height: 20px;
          }
          .other-border-p2 {
            font-size: 12px;
            color: #6A6A6A;
            line-height: 20px;
          }
        }
      }
    }
    .opening-loading-panel {
      position: fixed;
      top: 0;
      left: 0;
      z-index: 2015;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.2);
      .opening-popup {
        width: 205px;
        height: 184px;
        border-radius: 8px;
        opacity: 0.94;
        position: fixed;
        max-height: 100%;
        overflow-y: auto;
        background-color: #fff;
        top: 50%;
        left: 50%;
        -webkit-transform: translate3d(-50%, -50%, 0);
        transform: translate3d(-50%, -50%, 0);
        .opening-header {
          text-align: right;
          padding: 10px;
          display: flex;
          justify-content: flex-end;
          .opening-jump {
            width: 32px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            border-radius: 14px;
            border: 1px solid #CDCDCD;
            box-sizing: border-box;
            font-size: 10px;
            color: #666666;
          }
        }
        .opening-tips {
          width: 96px;
          height: 44px;
          font-size: 16px;
          margin-left: 17px;
          font-weight: 500;
          color: #19C34E;
          line-height: 22px;
        }
        .opening-loading {
          text-align: center;
          margin: 10px auto;;
          .opening-loading-icon {
            font-size: 80px;
          }
        }
      }
    }
    .opening-operation {
      position: fixed;
      bottom: 0px;
      height: 65px;
      width: 100%;
      padding: 6px 0px;
      box-sizing: border-box;
      background: #FFFFFF;
      box-shadow: 0 -2px 4px 0 rgba(0,0,0,0.20);
      &-price {
        width: 342px;
        margin: 0px auto;
        height: 32px;
        opacity: 0.86;
        background: linear-gradient(129deg, #FF9900 0%, #FEBE00 76%, #FFBE00 100%);
        border-radius: 20px;
        font-size: 16px;
        color: #FFFFFF;
        letter-spacing: 0;
        text-align: center;
        line-height: 32px;
        &.disabled {
          background: #aaaaaa;
        }
      }
      &-desc {
        font-size: 12px;
        color: #565656;
        line-height: 23px;
        letter-spacing: 0;
        text-align: center;
        >a {
          text-decoration: underline;
        }
      }
    }
  }
</style>