<template>
  <view class="container">
    <u-popup :show="show" @close="close" @open="open" mode="center">
      <view class="popup">
        <view class="popup_header">欢迎使用小发同城</view>
        <view class="popup_body">
          <iframe
            width="100%"
            src="http://www2.gpxscs.cn/businessAgreementPrivacy"
            class="webview"
          />
        </view>
        <view class="tool">
          点击"同意"，即表示您已阅读并同意小发同城<text>《小发同城商家入驻协议》</text>和<text
            >《个人信息保护政策》</text
          >
        </view>
        <view class="popup_foot">
          <view class="btn btn_disagree" @click="disagreeHandle">不同意</view>
          <view class="btn btn_ok" @click="okHandle">同意</view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
export default {
  name: "LaunchPage",
  data() {
    return {
      show: false,
    };
  },
  mounted() {
    try {
      const val = uni.getStorageSync("isNeedAgreementDialog");
      if(val==='' || val===false){
        this.show = true;
      } else {
        uni.redirectTo({
            url: "/pages/index/index",
        });
      }
    } catch (e) {}
  },
  methods: {
    close() {
      this.show = false;
    },
    open() {
      this.show = true;
    },
    disagreeHandle() {
      uni.setStorage({
        key: "isNeedAgreementDialog",
        data: false,
        success: function () {
          plus.runtime.quit();
        },
      });
    },
    okHandle() {
      uni.setStorage({
        key: "isNeedAgreementDialog",
        data: true,
        success: function () {
          uni.redirectTo({
            url: "/pages/index/index",
          });
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  background: url("/static/xiaofa-bg.png") no-repeat;
  background-size: cover;
  height: 100vh;
}

/deep/ .u-popup__content {
  border-radius: 24rpx;
  margin: 40rpx;
}

.popup {
  padding: 20px;
  font-size: 30rpx;

  .popup_header {
    text-align: center;
    font-size: 36rpx;
    color: #222;
  }

  .popup_body {
    margin: 30rpx auto;
    overflow: hidden;

    .webview {
      border: none;
      overflow-x: hidden;
      height: 400rpx;
    }
  }

  .tool {
    padding-bottom: 30rpx;
    text {
      color: #03ad7a;
    }
  }

  .popup_foot {
    display: flex;
    align-items: center;
    justify-content: center;
    .btn {
      width: 150rpx;
      padding: 15rpx 36rpx;
      border: 1rpx solid #999;
      border-radius: 100rpx;
      text-align: center;
    }
    .btn_ok {
      margin-left: 24rpx;
      color: #fff;
      background: #03ad7a;
      border-color: #03ad7a;
    }
  }
}
</style>
