<template>
  <view class="upgrade-page">
    <!-- 顶部导航栏 -->
    <view class="nav-bar" :style="{height: navBarTotalHeight + 'px', paddingTop: statusBarHeight + 'px'}">
      <view class="nav-bar-inner">
        <view class="back-icon" @tap="navigateBack">
          <uni-icons type="left" size="22" color="#222" />
        </view>
        <view class="nav-bar-title">回收侠·推客联盟</view>
        <view class="nav-bar-right">
          <uni-icons type="more-filled" size="22" color="#222" />
        </view>
      </view>
    </view>
    <!-- 打钩标签区 -->
    <view class="feature-tags" :style="{marginTop: navBarTotalHeight + 'px'}">
      <view class="tag" v-for="(t, i) in featureTags" :key="i">
        <text class="check">✓</text>
        <text class="text">{{t}}</text>
      </view>
    </view>
    <!-- 主内容区 -->
    <view class="main-content">
      <view class="upgrade-card">
        <view class="upgrade-title-row">
          <text class="upgrade-title">申请推广官</text>
          <view class="contact-service" @tap="contactService">
            <uni-icons type="headphones" size="22" color="#df8155" />
            <text class="contact-text">联系客服</text>
          </view>
        </view>
        <!-- 表单区 -->
        <view class="form-item">
          <text class="label">姓名</text>
          <input class="input" type="text" placeholder="请输入" v-model="formData.name" />
        </view>
        <view class="form-item">
          <text class="label">电话</text>
          <input class="input" type="number" placeholder="请输入" v-model="formData.phone" />
        </view>
        <view class="form-item" @tap="showPicker('promotionTime')">
          <text class="label">每日可花推广时间</text>
          <view class="picker-value">
            <text :class="{'placeholder': !formData.promotionTime}">{{formData.promotionTime || '请选择'}}</text>
            <uni-icons type="right" size="18" color="#bbb" />
          </view>
        </view>
        <view class="desc-text">
          "支付费用后，您将成为更高等级的推广官，享受更高额度的佣金及相关权益，包括但不限于优先推广资源、专属培训课程、一对一业务指导等"。
        </view>
      </view>
    </view>
    <!-- 底部按钮区 -->
    <view class="bottom-btns">
      <button class="btn gray">升级推广官</button>
      <button class="btn green" @tap="submitForm">提交</button>
    </view>
    <!-- 选择器弹窗 -->
    <view class="picker-popup" v-if="showPickerPopup">
      <view class="popup-mask" @tap="hidePicker"></view>
      <view class="popup-content">
        <view class="popup-header">
          <text class="reset" @tap="resetPicker">重置</text>
          <text class="title">每日可花推广时间</text>
        </view>
        <picker-view class="picker-view" :value="[currentPickerIndex]" @change="onPickerChange" :indicator-style="indicatorStyle">
          <picker-view-column>
            <view class="picker-item" v-for="(item, index) in pickerOptions" :key="index" :class="{'selected-item': index === currentPickerIndex}">{{item}}</view>
          </picker-view-column>
        </picker-view>
        <button class="confirm-btn" @tap="confirmPicker">确认</button>
      </view>
    </view>
  </view>
</template>

<script>
import pullRefreshMixin from '@/pages/mixins/pullRefreshMixin.js'

export default {
  mixins: [pullRefreshMixin],
  data() {
    return {
      statusBarHeight: 0,
      navBarHeight: 44,
      navBarTotalHeight: 44,
      featureTags: ['收益高', '品类全', '到账快', '城市多'],
      formData: {
        name: '',
        phone: '',
        promotionTime: ''
      },
      showPickerPopup: false,
      currentPickerIndex: 0,
      indicatorStyle: 'height: 88rpx; border: none;',
      pickerOptions: ['2小时', '3小时', '4小时', '5小时', '6小时']
    }
  },
  onLoad() {
    const sysInfo = uni.getSystemInfoSync()
    this.statusBarHeight = sysInfo.statusBarHeight
    this.navBarHeight = 44
    this.navBarTotalHeight = this.statusBarHeight + this.navBarHeight
  },
  methods: {
    async onRefresh() {
      // 模拟刷新数据
      await new Promise(resolve => setTimeout(resolve, 1000))
      uni.stopPullRefresh()
    },
    navigateBack() {
      uni.navigateBack()
    },
    contactService() {
      uni.navigateTo({ url: '/pages/subcomponent/admin_faq' })
    },
    showPicker() {
      this.showPickerPopup = true
    },
    hidePicker() {
      this.showPickerPopup = false
    },
    onPickerChange(e) {
      const index = e.detail.value[0]
      this.currentPickerIndex = index
    },
    confirmPicker() {
      this.formData.promotionTime = this.pickerOptions[this.currentPickerIndex]
      this.hidePicker()
    },
    resetPicker() {
      this.currentPickerIndex = 0
    },
    submitForm() {
      uni.showToast({ title: '提交成功', icon: 'success' })
    }
  }
}
</script>

<style lang="scss" scoped>
.upgrade-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #eaffe6 0%, #fff 30%);
  padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
}

.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100vw;
  background: linear-gradient(to right, #b2f08d 0%, #39e9d2 100%);
  box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.03);
  .nav-bar-inner {
    display: flex;
    align-items: center;
    height: 44px;
    width: 100vw;
    position: relative;
  }
  .back-icon, .nav-bar-right {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
  }
  .back-icon { left: 0; }
  .nav-bar-right { right: 0; }
  .nav-bar-title {
    flex: 1;
    text-align: center;
    font-size: 36rpx;
    font-weight: bold;
    color: #222;
    letter-spacing: 2rpx;
    line-height: 44px;
  }
}

.feature-tags {
  position: relative;
  z-index: 1;
  margin: 0 32rpx;
  margin-top: 0;
  margin-bottom: 0;
  background: linear-gradient(to right, #b2f08d 0%, #39e9d2 100%);
  border-radius: 32rpx;
  box-shadow: 0 4rpx 24rpx rgba(60, 167, 250, 0.08);
  padding: 0 24rpx;
  height: 80rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .tag {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    .check {
      width: 36rpx;
      height: 36rpx;
      background: #fff;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 28rpx;
      color: #13ac47;
      font-weight: bold;
      margin-right: 10rpx;
      box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.08);
    }
    .text {
      color: #fff;
      font-size: 28rpx;
      font-weight: bold;
    }
  }
}

.main-content {
  margin-top: -48rpx;
  padding-top: 88rpx;
  background: linear-gradient(180deg, #eaffe6 0%, #fff 30%);
  min-height: 100vh;
  width: 100vw;
  box-sizing: border-box;
  position: relative;
  z-index: 11;
  border-radius: 40rpx 40rpx 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.upgrade-card {
  width: 92vw;
  max-width: 700rpx;
  margin: 40rpx auto 0 auto;
  background: #fff;
  border-radius: 32rpx;
  box-shadow: 0 8rpx 32rpx rgba(60, 167, 250, 0.08);
  padding: 40rpx 32rpx 32rpx 32rpx;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  .upgrade-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32rpx;
    .upgrade-title {
      font-size: 32rpx;
      font-weight: bold;
      color: #222;
    }
    .contact-service {
      display: flex;
      align-items: center;
      padding: 4rpx 12rpx;
      border-radius: 12rpx;
      border: 2rpx solid #df8155;
      background: #fff0d2;
      .contact-text {
        color: #df8155;
        font-size: 22rpx;
        margin-left: 4rpx;
      }
      uni-icons {
        font-size: 20rpx !important;
      }
    }
  }
  .form-item {
    margin-bottom: 32rpx;
    .label {
      font-size: 28rpx;
      color: #222;
      margin-bottom: 12rpx;
      display: block;
    }
    .input {
      width: 100%;
      height: 72rpx;
      background: transparent;
      padding: 0;
      font-size: 30rpx;
      border: none;
      border-bottom: 1rpx solid #eee;
      &::placeholder {
        color: #bbb;
        font-size: 30rpx;
      }
    }
    .picker-value {
      width: 100%;
      height: 72rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1rpx solid #eee;
      .placeholder {
        color: #bbb;
      }
      text {
        font-size: 30rpx;
        color: #222;
      }
    }
  }
  .desc-text {
    font-size: 26rpx;
    color: #666;
    line-height: 1.6;
    margin-top: 32rpx;
    text-align: center;
  }
}

.bottom-btns {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 24rpx 32rpx calc(env(safe-area-inset-bottom) + 24rpx) 32rpx;
  background: #fff;
  z-index: 100;
  .btn {
    flex: 1;
    height: 88rpx;
    border-radius: 44rpx;
    font-size: 32rpx;
    font-weight: bold;
    margin: 0 12rpx;
    border: none;
    box-shadow: none;
    &.gray {
      background: linear-gradient(180deg, #f8f8f8 0%, #f2f4f6 100%);
      color: #222;
      border: 2rpx solid #e5e5e5;
    }
    &.green {
      background: linear-gradient(90deg, #b2f08d, #39e9d2);
      color: #222;
      border: none;
    }
  }
}

.picker-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  .popup-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
  }
  .popup-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 24rpx 24rpx 0 0;
    padding-bottom: calc(env(safe-area-inset-bottom) + 40rpx);
    .popup-header {
      display: flex;
      align-items: center;
      padding: 30rpx;
      position: relative;
      justify-content: center;
      border-bottom: 1rpx solid #f5f5f5;
      .title {
        font-size: 32rpx;
        color: #333;
        font-weight: normal;
      }
      .reset {
        position: absolute;
        left: 30rpx;
        font-size: 28rpx;
        color: #666;
      }
    }
    .picker-view {
      width: 100%;
      height: 440rpx;
      background: #fff;
      .picker-item {
        height: 88rpx;
        line-height: 88rpx;
        text-align: center;
        font-size: 28rpx;
        color: #999;
        font-weight: normal;
      }
    }
    .confirm-btn {
      margin: 30rpx;
      height: 88rpx;
      line-height: 88rpx;
      background: linear-gradient(90deg, #91dba5, #7ed4a6);
      color: #fff;
      font-size: 32rpx;
      border-radius: 44rpx;
      border: none;
    }
  }
}
</style> 