<template>
  <view class="container">
    <view class="card hero">
      <view class="brand">智约美服</view>
      <view class="slogan muted">AI 一键预约，24 小时接单</view>
    </view>

    <view class="card box">
      <view class="wx row">
        <view class="wx-icon">W</view>
        <view class="wx-text">
          <view class="t1">微信一键登录</view>
          <view class="t2 muted">用于同步订单、卡券与会员档案</view>
        </view>
      </view>
      <view class="btn btn-primary login" @tap="doLogin">同意授权并登录</view>
    </view>

    <view class="foot muted">
      <text @tap="goPrivacy">《用户隐私协议》</text>
      <text class="dot"> · </text>
      <text @tap="goTerms">《服务协议》</text>
    </view>
  </view>
</template>

<script>
const KEY = 'zy_authed_v1'

export default {
  onShow() {
    const ok = !!uni.getStorageSync(KEY)
    if (ok) {
      uni.switchTab({ url: '/pages/home/index' })
    }
  },
  methods: {
    doLogin() {
      uni.setStorageSync(KEY, 1)
      uni.switchTab({ url: '/pages/home/index' })
    },
    goPrivacy() {
      uni.navigateTo({ url: '/pages/legal/privacy' })
    },
    goTerms() {
      uni.navigateTo({ url: '/pages/legal/terms' })
    }
  }
}
</script>

<style lang="scss" scoped>
.hero {
  padding: 40rpx 28rpx;
  background: linear-gradient(135deg, rgba(17, 24, 39, 1) 0%, rgba(59, 130, 246, 1) 100%);
  border: 0;
  color: #fff;
}
.brand {
  font-size: 54rpx;
  font-weight: 950;
  letter-spacing: 2rpx;
}
.slogan {
  margin-top: 14rpx;
  color: rgba(255, 255, 255, 0.82);
  font-size: 28rpx;
}
.box {
  margin-top: 22rpx;
  padding: 26rpx;
}
.wx {
  align-items: flex-start;
}
.wx-icon {
  width: 84rpx;
  height: 84rpx;
  border-radius: 22rpx;
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
  font-weight: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 18rpx;
}
.t1 {
  font-size: 36rpx;
  font-weight: 950;
}
.t2 {
  margin-top: 10rpx;
  font-size: 26rpx;
}
.login {
  margin-top: 22rpx;
}
.foot {
  margin-top: 24rpx;
  text-align: center;
  font-size: 26rpx;
}
.dot {
  opacity: 0.6;
}
</style>

