<template>
  <view class="login">
    <view class="center">
      <view class="logo_box">
        <image
          src="../../static/logo.png"
          style="width: 200rpx; height: 200rpx"
          mode="scaleToFill"
        />
      </view>
      <!-- <button class="submit_weixin btn" @tap="getPhoneNumber">微信登录</button> -->
      <!-- open-type="getPhoneNumber" -->
      <!-- @getphonenumber="getPhoneNumber" -->
      <button class="btn submit_phone" @tap="toPhone">手机号登录/注册</button>
      <!-- <button class="btn submit_phone">游客登陆</button> -->
      <view class="protocol">
        <image
          v-if="!isChoose"
          src="../../static/login_xuanze.png"
          mode="scaleToFill"
          style="width: 40rpx; height: 40rpx"
          @tap="isChoose = !isChoose"
        />
        <image
          v-if="isChoose"
          src="../../static/login_xuanze_true.png"
          mode="scaleToFill"
          style="width: 40rpx; height: 40rpx"
          @tap="isChoose = !isChoose"
        />
        <view class="protocolText" @tap.stop="isChoose = !isChoose">
          我已阅读并同意
          <view @tap.stop="toWeb(1)" style="color: #62afed">《用户协议》</view>
          <view @tap.stop="toWeb(2)" style="color: #62afed">《隐私政策》</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        // 是否同意协议
        isChoose: true,
      }
    },
    onLoad() {},
    methods: {
      // 获取手机号
      getPhoneNumber(e) {
        console.log(e)
        if (this.isChoose) {
          // uni.navigateTo({
          //   url: `/pages/index/enroll`,
          // })
          //   this.$api
          //     .post('/phoneLogin', {
          //       openid: this.$store.state.WXcode.openid,
          //       session_key: this.$store.state.WXcode.session_key,
          //       code: e.detail.code,
          //     })
          //     .then(r => {
          //       if (r) {
          uni.switchTab({
            url: `/pages/home/home`,
          })
          //       }
          //     })
        } else {
          uni.$u.toast('请先同意协议')
        }
        // uni.switchTab({
        //   url: `/pages/home/home`,
        // })
      },
      // 跳转协议详情
      toWeb() {
        uni.navigateTo({
          url: `/pages/index/webview?src=`,
        })
      },
      // 微信登录
      submitWX() {},
      // 手机号登录
      toPhone() {
        uni.navigateTo({
          url: `/pages/index/phoneLogin`,
        })
      },
    },
  }
</script>

<style lang="scss" scoped>
  .protocol {
    padding: 0 30rpx;
    position: fixed;
    display: flex;
    bottom: 60rpx;
    margin-top: 80rpx;
    align-items: center;

    .protocolText {
      display: flex;
      margin-left: 16rpx;
      font-size: 24rpx;

      text {
        color: #6678d7;
      }
    }
  }
  .logo_box {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .center {
    margin-top: 320rpx;
    padding: 24rpx;
  }
  .btn {
    height: 88rpx;
    border-radius: 40rpx;
    font-size: 28rpx;
    text-align: center;
    line-height: 88rpx;
    border: 0;
  }
  .submit_weixin {
    margin-top: 140rpx;
    background-color: #3478ff;
    color: white;
  }
  .submit_phone {
    margin-top: 48rpx;
    background-color: white;
    border: 2rpx solid #d2d2d2;
  }
  uni-button:after {
    border: 0;
  }
  button::after {
    border: 0;
  }
</style>
