<template>
  <view class="container">
    <unitv-page
      id="curriculumBuyPage"
      ref="curriculumBuyPage"
      class="curriculumBuyPage"
      :show="true"
    >
      <app-header />
      <view class="content">
        <view class="left">
          <view class="shop">
            <image src="/static/public_images/video_bg1.jpg" />
            <view class="name line-4">
              课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称课程名称
            </view>
          </view>
          <view class="money">
            <view class="price">￥123</view>
            <view class="tip">购买此课程</view>
          </view>
        </view>
        <view class="qrcode">
          <view class="image">
            <view class="payee">收款方：河北秦安安全科技有限公司</view>
            <canvas
              id="qrcode"
              canvas-id="qrcode"
              :style="{ width: canvasSize + 'px', height: canvasSize + 'px' }"
            />
            <view class="tip">使用微信扫一扫支付</view>
          </view>
        </view>
      </view>
    </unitv-page>
  </view>
</template>

<script>
import UQRCode from "uqrcodejs";

export default {
  data() {
    return {
      canvasSize: uni.upx2px(170),
    };
  },
  onShow() {
    if (this.$refs.curriculumBuyPage) {
      this.$refs.curriculumBuyPage.showPage();
    }
  },
  onReady() {
    const qr = new UQRCode();
    qr.data = "qrcode_url";
    qr.size = this.canvasSize;
    qr.make();
    qr.canvasContext = uni.createCanvasContext("qrcode");
    qr.drawCanvas();
    // setTimeout(() => {
    //   uni.navigateTo({
    //     url: "/pages/curriculum/buy_success",
    //   });
    // }, 10000);
  },
};
</script>

<style scoped lang="scss">
.content {
  display: flex;
  align-items: center;
  padding: 61rpx 77rpx 54rpx 45rpx;

  .left {
    width: 355rpx;

    .shop {
      width: 355rpx;
      height: 124rpx;
      background-image: url("/static/by_shop_bg.png");
      background-size: 100% 100%;
      background-repeat: no-repeat;
      display: flex;
      padding: 24rpx 12rpx;

      image {
        width: 133rpx;
        height: 75rpx;
        border-radius: 4rpx;
      }

      .name {
        flex: 1;
        font-size: 14rpx;
        padding-left: 12rpx;
      }
    }

    .money {
      margin-top: 10rpx;
      width: 355rpx;
      height: 54rpx;
      background-image: url("/static/by_shop_money_bg.png");
      background-size: 100% 100%;
      background-repeat: no-repeat;
      position: relative;
      color: rgba(115, 62, 2, 1);
      font-weight: bold;

      .price {
        font-size: 24rpx;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 17rpx;
      }

      .tip {
        font-size: 14rpx;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: 121rpx;
      }
    }
  }

  .qrcode {
    margin-left: 43rpx;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.17);
    border-radius: 4px;
    padding: 12rpx;

    .image {
      background-color: #fff;
      padding: 12rpx;
      color: #000;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;

      .payee {
        padding-bottom: 6rpx;
        font-size: 9rpx;
      }

      .tip {
        padding-top: 7rpx;
        color: rgba(7, 15, 48, 1);
        font-size: 13rpx;
      }
    }
  }
}
</style>
