<template>
  <view class="showModel" v-if="disjunctor">
    <view class="showModel__wrap">
      <view class="showModel__header">
        <!-- 我的二维码 -->
				<view>
					{{qrCode.title}}
				</view>
      </view>
      <view class="showModel__article">
        <view class="showModel__content">
          <image :src="qrCode.outQrcode" mode="widthFix" style="width: 100%;" @longpress="disableLongPress"></image>
        </view>
      </view>
			<view class="df-fl">
				<view @click="getQrCode('reload')" class="reload">刷新</view>
				<view class="df-fl">
					有效期：
					<uni-countdown ref="countDown" @timeup="timeupChange" :second="refreshQRCodeTime" :showDay="false" :showHour="false" :showMinute="false"/>
					秒
				</view>
			</view>
      <view class="showModel__footer">
        <view class="showModel__know" @click="know" hover-class="seimin-btn-hover">关闭</view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    get,
    post,
    webHandle
  } from "../../http/http.js";
  export default {
    data() {
      return {
        qrCode: '',
				disjunctor:false,
				refreshQRCodeTime:null
      };
    },
    props: {
			orderId:null
    },
    methods: {
      // 关闭
      know() {
				this.disjunctor = false
        this.$emit("know");
      },
			// 倒计时结束
			timeupChange(){
				this.getQrCode('reload')
			},
			// 禁止长按
			disableLongPress(e) {
				// 阻止默认行为
				e.preventDefault();
				// 阻止事件冒泡
				e.stopPropagation();
			},
      // 获取我的二维码
      getQrCode(type){
        uni.showLoading({
          title: "加载中",
          mask: true,
        });
        post("/questionnaire/qrCode/0", {
					gdId: this.orderId
				}).then((result) => {
            uni.hideLoading();
            if (result.status == 200) {
							if(type=='reload'){
								this.$refs.countDown.update()
							}
							this.qrCode = result.data;
							this.refreshQRCodeTime = result.refreshQRCodeTime
							this.disjunctor = true
            } else if(result.status == 405){
							
						}else{
              uni.showToast({
                icon: "none",
                title: result.msg || "接口获取数据失败！",
              });
            }
          })
      }
    },
    mounted() {
      this.getQrCode();
    }
  };
</script>

<style lang="less" scoped>
  .showModel {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 999999;

    .showModel__wrap {
      width: 560rpx;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      background-color: #fff;
      border-radius: 12rpx;

      .showModel__header {
        font-size: 36rpx;
        color: #000;
        height: 84rpx;
        display: flex;
        justify-content: center;
        align-items: center;
      }
			.reload{
				margin: 0 20rpx;
				color: #49b856;
			}
			.df-fl{
				display: flex;
				justify-content: center;
				margin-bottom: 20rpx;
			}
      .showModel__article {
        color: #000;
        margin: 0 auto 25rpx;
        width: 488rpx;
        background-color: rgb(249, 250, 251);
        border: 2rpx solid rgb(229, 233, 237);
        border-radius: 12rpx;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        &.p0 {
          padding: 0;
        }

        &.p1 {
          text-align: left;
        }

        .showModel__icon {
          font-size: 138rpx;
          margin-bottom: 32rpx;

          &.showModel__icon--success {
            color: rgb(52, 179, 73);
          }

          &.showModel__icon--warn {
            color: rgb(245, 165, 35);
          }

          &.showModel__icon--error {
            color: rgb(255, 58, 82);
          }
        }

        .showModel__content {
          font-size: 36rpx;
          word-break: break-all;
          width: 100%;
					background: rgba(0,0,0,0);
					z-index: 999;
					image{
						pointer-events:none;
					}
        }

        .showModel__info {
          font-size: 32rpx;
          color: rgb(102, 102, 102);
        }

        .specialCloseFlag {
          width: 90%;
          height: 100%;
          padding: 16rpx;
        }

        .radio-wrap {
          .radio-item {
            margin-top: 16rpx;

            /deep/ .uni-radio-input-checked {
              background-color: #49b856 !important;
              border-color: #49b856 !important;
            }
          }
        }
      }

      .showModel__footer {
        box-sizing: border-box;
        height: 100rpx;
        border-top: 2rpx solid rgb(229, 233, 237);
        display: flex;
        align-items: center;

        view {
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 36rpx;
          color: rgb(102, 102, 102);
          position: relative;

          &:nth-of-type(2)::before {
            content: "";
            position: absolute;
            left: 0;
            bottom: 0;
            width: 2rpx;
            height: 87rpx;
            background-color: rgb(229, 233, 237);
          }
        }

        .showModel__ok {
          flex: 1;
          color: rgb(73, 184, 86);
        }

        .showModel__cancel {
          flex: 1;
        }

        .showModel__know {
          flex: 1;
          color: rgb(73, 184, 86);
        }
      }
    }
  }
</style>
