<template>
  <view class="customer-service">
    <!-- 顶部导航栏 -->

	<view class="nav-bar">
	  <view class="back-icon" @tap="navigateBack">
	    <uni-icons type="left" size="20"></uni-icons>
	  </view>
	  <view class="title">联系客服</view>
	</view>

    <!-- 主要内容区域 -->
    <view class="content">
      <!-- 问候语 -->
      <view class="greeting">
        <text class="title">Hi, {{greeting}}</text>
        <text class="subtitle">您好！如需帮助，请优先选择以下方式联系我们。</text>
      </view>

      <!-- 联系方式列表 -->
      <view class="contact-list">
        <view class="contact-item" @tap="handleOnlineService">
          <text class="label">在线客服</text>
          <text class="iconfont arrow">></text>
        </view>
        <view class="contact-item" @tap="handlePhoneService">
          <text class="label">客服电话</text>
          <text class="iconfont arrow">></text>
        </view>
        <view class="contact-item">
          <text class="label">客服邮箱</text>
          <text class="iconfont arrow">></text>
        </view>
      </view>

      <!-- 详细信息 -->
      <view class="info-section">
        <view class="info-item">
          <text class="label">工作时间：</text>
          <text class="value">周一至周日 09:00-18:00</text>
        </view>
        <view class="info-item">
          <text class="label">客服电话：</text>
          <text class="value">0731-599327-8899</text>
        </view>
        <view class="info-item">
          <text class="label">在线客服：</text>
          <text class="value">点击页面右下角"在线客服"，我们将及时为您解答疑问。</text>
        </view>
        <view class="info-item">
          <text class="label">客服邮箱：</text>
          <text class="value">hanhaihuishouhf@hh.com</text>
        </view>
      </view>

      <!-- 常见问题 -->
      <view class="faq-section">
        <view class="faq-entry" @tap="navigateToFAQ">
          <text class="label">常见问题</text>
          <text class="iconfont arrow">></text>
        </view>
        <view class="faq-tip">
          <text>如有任何问题或建议，请随时与我们联系，我们将竭诚为您服务！</text>
        </view>
      </view>
    </view>

    <!-- 底部按钮 -->
    <view class="bottom-btn">
      <button class="online-service-btn" @tap="handlePhoneService">联系在线客服</button>
    </view>

    <!-- 电话弹窗 -->
    <view class="phone-popup" v-if="showPhonePopup">
      <view class="popup-mask" @tap="hidePhonePopup"></view>
      <view class="popup-content">
        <view class="popup-header">
          <text class="close" @tap="hidePhonePopup">关闭</text>
          <text class="title">客服电话</text>
        </view>
        <view class="phone-number" @tap="makePhoneCall">
          <text>0731-599327-8899</text>
		  <uni-icons type="phone-filled" size="23" class="phone-icon"></uni-icons>
        </view>
      </view>
    </view>
	<email-popup 
	  :show="showEmailPopup" 
	  @close="handleCloseEmailPopup"
	/>
  </view>
</template>

<script>
	import emailPopup from '@/wxcomponents/email-popup/email-popup.vue'	
	
export default {
	components: {
	   emailPopup
	 },
  data() {
    return {
      greeting: '下午好',
      showPhonePopup: false,
	  showEmailPopup:false
    }
  },
  created() {
    this.updateGreeting()
  },
  methods: {
	  // 显示弹窗
	      openEmailPopup() {
	        this.showEmailPopup = true
	      },
	      // 关闭弹窗
	      handleCloseEmailPopup() {
	        this.showEmailPopup = false
	      },
	  navigateBack() {
	    uni.navigateBack()
	  },
    updateGreeting() {
      const hour = new Date().getHours()
      if (hour < 12) {
        this.greeting = '上午好'
      } else if (hour < 18) {
        this.greeting = '下午好'
      } else {
        this.greeting = '晚上好'
      }
    },
    navigateBack() {
      uni.navigateBack()
    },
    navigateToFAQ() {
      // 跳转到常见问题页面
      uni.navigateTo({
        url: '/pages/customer-service/faq'
      })
    },
    handleOnlineService() {
      // 处理在线客服逻辑
      console.log('打开在线客服')
	  
    },
    handlePhoneService() {
      this.showPhonePopup = true
    },
    hidePhonePopup() {
      this.showPhonePopup = false
    },
    makePhoneCall() {
      uni.makePhoneCall({
        phoneNumber: '0731-599327-8899'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.customer-service {
  min-height: 100vh;
  background: linear-gradient(to bottom,#fff3da,5%,#ffffff);
  padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
}

.nav-bar {
    display: flex;
    align-items: center;
    // justify-content: space-between;
    height: 88rpx;
    padding-top: var(--status-bar-height);
  
    .title {
      font-family: PingFang SC;
      font-weight: 500;
      font-size: 16px;
      line-height: 140%;
      letter-spacing: 0%;
      text-align: center;
      vertical-align: middle;
      color: #333;
	  // margin: 0 auto;
      margin-left: 30%;
    }
  
    .back-icon, .more-icon {
      width: 88rpx;
      height: 88rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      
      .iconfont {
        font-size: 40rpx;
        color: #333;
      }
    }
  }

.content {
  padding: 40rpx 30rpx;
  background: #fff;
  width: 80%;
  margin: 0 auto;
  .greeting {
    margin-bottom: 60rpx;

    .title {
      font-size: 48rpx;
      font-weight: bold;
      color: #333;
      display: block;
      margin-bottom: 20rpx;
    }

    .subtitle {
      font-size: 28rpx;
      color: #999;
    }
  }

  .contact-list {
    background: #fff;
    border-radius: 20rpx;
    margin-bottom: 40rpx;

    .contact-item {
      height: 110rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 30rpx;
      border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);

      &:last-child {
        border-bottom: none;
      }

      .label {
        font-size: 32rpx;
        color: #333;
      }

      .arrow {
        font-size: 24rpx;
        color: #999;
        opacity: 0.5;
      }
    }
  }

  .info-section {
    margin-bottom: 40rpx;
    padding: 0 20rpx;
    .info-item {
      margin-bottom: 30rpx;
      display: flex;
      align-items: flex-start;

      .label {
        font-size: 28rpx;
        color: #666;
        white-space: nowrap;
      }

      .value {
        font-size: 28rpx;
        color: #666;
        flex: 1;
      }
    }
  }

  .faq-section {
    background: #fff;
    border-radius: 20rpx;
    margin-bottom: 40rpx;

    .faq-entry {
      height: 110rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 30rpx;

      .label {
        font-size: 32rpx;
        color: #333;
      }

      .arrow {
        font-size: 24rpx;
        color: #999;
        opacity: 0.5;
      }
    }

    .faq-tip {
      padding: 30rpx;
      font-size: 26rpx;
      color: #999;
      text-align: center;
      line-height: 1.6;
      border-top: 1rpx solid rgba(0, 0, 0, 0.05);
    }
  }
}

.bottom-btn {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 20rpx 30rpx;
  padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);

  .online-service-btn {
    width: 100%;
    height: 88rpx;
    line-height: 88rpx;
    background: #FFA500;
    color: #fff;
    font-size: 32rpx;
    border-radius: 44rpx;
    border: none;
  }
}

.phone-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  // height: 30%;
  .popup-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
  }

  .popup-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 20rpx 20rpx 0 0;
    overflow: hidden;
    transform: translateY(0);
    transition: transform 0.3s ease-out;

    .popup-header {
      position: relative;
      height: 160rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      border-bottom: 1rpx solid #f5f5f5;

      .title {
        font-size: 34rpx;
        color: #333;
        font-weight: 500;
      }

      .close {
        position: absolute;
        left: 30rpx;
        font-size: 32rpx;
        color: #333;
      }
    }

    .phone-number {
      height: 140rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 40rpx;
      margin-bottom: env(safe-area-inset-bottom);

      text {
        font-size: 36rpx;
        color: #333;
        font-weight: 400;
      }

      .phone-icon {
        width: 44rpx;
        height: 44rpx;
        background: #f5f5f5;
        padding: 20rpx;
        border-radius: 50%;
      }
    }
  }

  &.popup-enter-active,
  &.popup-leave-active {
    transition: opacity 0.3s;
    .popup-content {
      transition: transform 0.3s ease-out;
    }
  }

  &.popup-enter,
  &.popup-leave-to {
    opacity: 0;
    .popup-content {
      transform: translateY(100%);
    }
  }
}
</style> 