const api = require('../../utils/api')

Page({
  data: {
    info: null,
    loading: true,
    error: null
  },

  onLoad() {
    this.loadCustomInfo()
  },

  onBack() {
    wx.navigateBack()
  },

  async loadCustomInfo() {
    this.setData({ loading: true, error: null })
    
    try {
      const res = await api.common.getBrandConfig()
      console.log('[custom] 定制服务配置响应:', res)
      
      if (res.success && res.data) {
        const data = res.data
        const customService = data.custom_service || {}
        
        this.setData({
          info: {
            title: '定制服务',
            content: customService.value || ''
          }
        })
        console.log('[custom] 定制服务信息:', this.data.info)
      } else {
        this.setData({ error: res.error || '加载失败' })
      }
    } catch (err) {
      console.error('[custom] 加载失败:', err)
      this.setData({ error: err.message || '加载失败' })
    } finally {
      this.setData({ loading: false })
    }
  }
})
