<template>
  <view class="device-detail">
    <view class="device-detail__header">
      <u-icon
        size="36"
        class="arrow-left"
        name="arrow-left"
        @click="handleBack"
      ></u-icon>
      {{ title }}
    </view>
    <view class="device-detail__body">
      <view class="tabs">
        <view class="tab-container">
          <view class="tab-item" :class="activeTab === 'pestAnalysis'?'active':''" @click="handleTabClick('pestAnalysis')">
            管理员
          </view>
          <view class="tab-item" :class="activeTab === 'viewImage'?'active':''" @click="handleTabClick('viewImage')">
            设置
          </view>
        </view>
      </view>
      <view class="device-detail-content" v-if="activeTab === 'pestAnalysis'">
        <view class="device-detail-item">
          <text class="device-detail-label">联网模块</text>
          <view class="device-detail-btn-container">
            <view class="device-detail-btn">升级</view>
            <view class="device-detail-btn">重启</view>
            <view class="device-detail-btn">MQTT配置</view>
          </view>
        </view>
        <view class="device-detail-item">
          <text class="device-detail-label">板子设置</text>
          <view class="device-detail-btn-container">
            <view class="device-detail-btn">查看原始IMEI</view>
            <view class="device-detail-btn">更改IMEI</view>
          </view>
        </view>
        <view class="device-detail-item">
          <text class="device-detail-label">强制操作</text>
          <view class="device-detail-btn-container">
            <view class="device-detail-btn force-btn">拍照</view>
            <view class="device-detail-btn force-btn">升级</view>
            <view class="device-detail-btn force-btn">重启</view>
            <view class="device-detail-btn force-btn">震动关闭</view>
            <view class="device-detail-btn force-btn">震动开启</view>
          </view>
        </view>
      </view>
      <view class="device-detail-content" style="padding-bottom: 50rpx" v-if="activeTab === 'viewImage'">
        <view class="device-detail-viewImage">
          <text class="device-detail-label">联网模块</text>
          <u-switch v-model="checked" size="40" active-color="#0BBC58"></u-switch>
        </view>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">定时模式</text>
        </view>
        <u-radio-group v-model="value" @change="radioGroupChange" active-color="#0BBC58">
          <u-radio 
            :name="0"
          >光控
          </u-radio>
          <u-radio 
            :name="1"
          >时控
          </u-radio>
        </u-radio-group>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">落虫时间(min)</text>
        </view>
        <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">加热时间(min)</text>
        </view>
        <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">加热温度(℃)</text>
        </view>
        <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">高温保护阀值(℃)</text>
        </view>
        <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">低温保护阀值(℃)</text>
        </view>
        <u-slider v-model="value" style="width:100%" max="100" active-color="#0BBC58"></u-slider>
        <view class="device-detail-viewImage">
          <text class="device-detail-label">数据上传间隔(min)</text>
        </view>
        <u-slider v-model="value" style="width:100%;" max="100" active-color="#0BBC58"></u-slider>
      </view>
    </view>
    <view class="device-detail-btn-footer">
      <view class="device-detail-btn">保存</view>
    </view>
  </view>
</template>
<script>

export default {
  data(){
    return {
      value: 10,
      imageList: [],
      deviceInfo: {},
      time: '',
      activeTab: 'pestAnalysis',
      title: '设置控制',
      deviceType: '',
      location: '',
      checked: false
    }
  },
  methods: {
    handleBack() {
      uni.navigateBack({
        delta: 1
      });
    },
    handleTabClick(tab) {
      this.activeTab = tab;
    }
  }
}
</script>
<style scoped lang="scss">
.device-detail {
  display: flex;
  width: 100%;
  height: calc(100vh - 112rpx);
  padding-top: 112rpx;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, #ffffff00 0%, #F5F6FA 23.64%, #F5F6FA 100%), linear-gradient(102deg, #BFEADD 6.77%, #B8F1E7 40.15%, #B9EEF5 84.02%);
  .device-detail__header {
    width: 100%;
    font-size: 28rpx;
    color: #999;
    color: #042118;
    font-family: 'Source Han Sans CN VF';
    font-weight: 700;
    position: relative;
    text-align: center;
    .arrow-left {
      position: absolute;
      left: 32rpx;
      margin-right: 12rpx;
    }
  }
  .device-detail__body {
    width: calc(100% - 64rpx);
    margin: 0 auto;
    border-radius: 16rpx;
    overflow-x: hidden;
    overflow-y: auto;
    // 隐藏滚动条
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .tabs {
    margin: 24rpx 0;
    border-radius: 16rpx;
    padding: 16rpx 0;
    padding-top: 0;
    .tab-container{
      display: flex;
      width: 100%;
      height: 88rpx;
      line-height: 88rpx;
      text-align: center;
      font-size: 28rpx;
      font-weight: 700;
      color: #042118;
      font-family: 'Source Han Sans CN VF';
    }
    .tab-item {
      margin-right: 40rpx;
      color:#999999;
    }
    .active{
      position: relative;
      color: #303133;
      text-align: center;
      font-family: "Source Han Sans CN VF";
      font-size: 28rpx;
      font-weight: 700;
      &::after {
        content: '';
        position: absolute;
        bottom: 10rpx;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        height: 36rpx;
        border-bottom: 6rpx solid #303133;
      }
    }
  }
  .device-detail-content{
    display: flex;
    padding: 24rpx 32rpx;
    flex-direction: column;
    align-items: flex-start;
    gap: 20rpx;
    border-radius: 16rpx;
    background: #FFF;
    .device-detail-item{
      .device-detail-label{
        color: #303133;
        font-family: "Source Han Sans CN VF";
        font-size: 28rpx;
        font-weight: 400;
      }
      .device-detail-btn-container{
        display: flex;
        gap: 24rpx;
        margin-top: 12rpx;
      }
      .device-detail-btn{
        display: flex;
        padding: 10rpx 16rpx;
        justify-content: center;
        align-items: center;
        gap: 16rpx;
        border-radius: 16rpx;
        background: #0BBC58;
        color: #ffffff;
        font-family: "Source Han Sans CN VF";
        font-size: 24rpx;
        font-weight: 400;
      }
      .force-btn{
        background: #FB4E52;
      }
    }
    .device-detail-viewImage{
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 20rpx;
    }
  }
  .device-detail-btn-footer{
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 112rpx;
    line-height: 112rpx;
    text-align: center;
    font-size: 28rpx;
    font-weight: 700;
    color: #042118;
    font-family: 'Source Han Sans CN VF';
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    .device-detail-btn{
      display: flex;
      height: 80rpx;
      width: 90%;
      margin: 0 auto;
      padding: 0rpx 20rpx;
      justify-content: center;
      align-items: center;
      gap: 8rpx;
      border-radius: 16rpx;
      background:#0BBC58;
      color: #ffffff;
      text-align: center;
      font-family: "Source Han Sans CN VF";
      font-size: 14px;
      font-style: normal;
      font-weight: 500;
    }
  }
}
</style>