<template>
  <view class="container">
    <!-- 客服方式 -->
    <view class="service-section">
      <view class="section-title">客服联系方式</view>
      
      <!-- 电话客服 -->
      <view class="service-card">
        <view class="service-item" @click="callPhone">
          <view class="service-left">
            <view class="service-icon phone-icon">
              <text class="icon-text">📞</text>
            </view>
            <view class="service-info">
              <text class="service-name">电话客服</text>
              <text class="service-desc">工作时间：周一至周五 9:00-18:00</text>
              <text class="service-number">400-123-4567</text>
            </view>
          </view>
          <text class="service-arrow">></text>
        </view>
      </view>

      <!-- 微信客服 -->
      <view class="service-card">
        <view class="service-item" @click="contactWechat">
          <view class="service-left">
            <view class="service-icon wechat-icon">
              <text class="icon-text">💬</text>
            </view>
            <view class="service-info">
              <text class="service-name">微信客服</text>
              <text class="service-desc">在线时间：周一至周日 8:00-22:00</text>
              <text class="service-number">微信号：electric_service</text>
            </view>
          </view>
          <text class="service-arrow">></text>
        </view>
      </view>

      <!-- 在线客服 -->
<!--      <view class="service-card">-->
<!--        <view class="service-item" @click="startOnlineChat">-->
<!--          <view class="service-left">-->
<!--            <view class="service-icon online-icon">-->
<!--              <text class="icon-text">💻</text>-->
<!--            </view>-->
<!--            <view class="service-info">-->
<!--              <text class="service-name">在线客服</text>-->
<!--              <text class="service-desc">即时响应，快速解决问题</text>-->
<!--              <text class="service-status online">● 在线</text>-->
<!--            </view>-->
<!--          </view>-->
<!--          <text class="service-arrow">></text>-->
<!--        </view>-->
<!--      </view>-->
    </view>

    <!-- 常见问题 -->
    <view class="faq-section">
      <view class="section-title">常见问题</view>
      <view class="faq-list">
        <view 
          class="faq-item" 
          v-for="(item, index) in faqList" 
          :key="index"
          @click="toggleFaq(index)"
        >
          <view class="faq-question">
            <text class="question-text">{{ item.question }}</text>
            <text class="question-arrow" :class="{ 'expanded': item.expanded }">></text>
          </view>
          <view class="faq-answer" v-if="item.expanded">
            <text class="answer-text">{{ item.answer }}</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 反馈建议 -->
<!--    <view class="feedback-section">-->
<!--      <view class="section-title">意见反馈</view>-->
<!--      <view class="feedback-card">-->
<!--        <textarea -->
<!--          class="feedback-input" -->
<!--          v-model="feedbackText"-->
<!--          placeholder="请描述您遇到的问题或建议..."-->
<!--          maxlength="500"-->
<!--        ></textarea>-->
<!--        <view class="feedback-footer">-->
<!--          <text class="char-count">{{ feedbackText.length }}/500</text>-->
<!--          <button class="submit-btn" @click="submitFeedback">提交反馈</button>-->
<!--        </view>-->
<!--      </view>-->
<!--    </view>-->
  </view>
</template>

<script>
export default {
  data() {
    return {
      feedbackText: '',
      faqList: [
        {
          question: '如何查看我的用电量？',
          answer: '您可以在首页点击"月报查询"或"年报查询"来查看详细的用电量统计信息。',
          expanded: false
        },
        {
          question: '电费报表如何导入？',
          answer: '进入"电费报表"页面，先下载模板，按照模板格式填写数据后，点击"导入报表"上传Excel文件即可。',
          expanded: false
        },
        {
          question: '忘记密码怎么办？',
          answer: '请联系客服人员重置密码，或通过注册手机号找回密码。',
          expanded: false
        },
        {
          question: '如何修改个人信息？',
          answer: '在"我的"页面点击个人资料卡片，或直接点击"个人资料"菜单进入修改页面。',
          expanded: false
        },
        {
          question: '数据多久更新一次？',
          answer: '用电数据每日更新，结算数据每月更新。如有特殊情况可联系客服手动刷新。',
          expanded: false
        }
      ]
    }
  },
  methods: {
    callPhone() {
      uni.makePhoneCall({
        phoneNumber: '400-123-4567',
        fail: () => {
          uni.showToast({
            title: '拨号失败',
            icon: 'none'
          })
        }
      })
    },
    contactWechat() {
      uni.showModal({
        title: '微信客服',
        content: '请添加微信号：electric_service\n或扫描二维码添加客服微信',
        confirmText: '复制微信号',
        success: (res) => {
          if (res.confirm) {
            uni.setClipboardData({
              data: 'electric_service',
              success: () => {
                uni.showToast({
                  title: '微信号已复制',
                  icon: 'success'
                })
              }
            })
          }
        }
      })
    },
    startOnlineChat() {
      uni.showToast({
        title: '在线客服功能开发中',
        icon: 'none'
      })
    },
    toggleFaq(index) {
      this.faqList[index].expanded = !this.faqList[index].expanded
    },
    submitFeedback() {
      if (!this.feedbackText.trim()) {
        uni.showToast({
          title: '请输入反馈内容',
          icon: 'none'
        })
        return
      }

      uni.showLoading({ title: '提交中...' })
      
      // 模拟提交过程
      setTimeout(() => {
        uni.hideLoading()
        uni.showToast({
          title: '反馈提交成功',
          icon: 'success'
        })
        this.feedbackText = ''
      }, 2000)
    },
    goBack() {
      uni.navigateBack()
    }
  }
}
</script>

<style scoped>
.container {
  background-color: #f5f5f5;
  min-height: 100vh;
}

.nav-bar {
  background-color: #007aff;
  color: white;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
}

.nav-back {
  font-size: 24px;
  font-weight: bold;
  width: 60px;
}

.nav-title {
  font-size: 18px;
  font-weight: bold;
  flex: 1;
  text-align: center;
}

.nav-right {
  width: 60px;
}

.service-section {
  margin: 15px;
}

.section-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
}

.service-card {
  background-color: white;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.service-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
}

.service-left {
  display: flex;
  align-items: center;
  flex: 1;
}

.service-icon {
  width: 50px;
  height: 50px;
  border-radius: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
}

.phone-icon {
  background-color: #e3f2fd;
}

.wechat-icon {
  background-color: #e8f5e8;
}

.online-icon {
  background-color: #fff3e0;
}

.icon-text {
  font-size: 24px;
}

.service-info {
  flex: 1;
}

.service-name {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  display: block;
  margin-bottom: 5px;
}

.service-desc {
  font-size: 12px;
  color: #666;
  display: block;
  margin-bottom: 5px;
}

.service-number {
  font-size: 14px;
  color: #007aff;
}

.service-status.online {
  font-size: 12px;
  color: #2ed573;
}

.service-arrow {
  color: #ccc;
  font-size: 16px;
}

.faq-section {
  margin: 15px;
}

.faq-list {
  background-color: white;
  border-radius: 10px;
  overflow: hidden;
}

.faq-item {
  border-bottom: 1px solid #f0f0f0;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
}

.question-text {
  font-size: 14px;
  color: #333;
  flex: 1;
}

.question-arrow {
  color: #ccc;
  font-size: 16px;
  transition: transform 0.3s;
}

.question-arrow.expanded {
  transform: rotate(90deg);
}

.faq-answer {
  padding: 0 15px 15px;
  border-top: 1px solid #f8f8f8;
}

.answer-text {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

.feedback-section {
  margin: 15px;
}

.feedback-card {
  background-color: white;
  border-radius: 10px;
  padding: 15px;
}

.feedback-input {
  width: 100%;
  min-height: 100px;
  font-size: 14px;
  color: #333;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.feedback-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.char-count {
  font-size: 12px;
  color: #999;
}

.submit-btn {
  background-color: #007aff;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 14px;
}

.submit-btn:active {
  background-color: #0056cc;
}
</style>
