<!--pages/business/loan-products/form/form.wxml-->
<view class="form-container">
  <view class="form-header">
    <text class="form-title">{{mode === 'add' ? '新增商品' : '修改信息'}}</text>
  </view>

  <view class="form-content">
    <!-- 基本信息 -->
    <view class="form-section">
      <view class="section-title">基本信息</view>
      
      <view class="form-item">
        <text class="form-label">
          产品名称
          <text class="required-asterisk">*</text>
        </text>
        <input 
          class="form-input" 
          placeholder="请输入产品名称"
          value="{{formData.productName}}"
          data-field="productName"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">产品代码</text>
        <input 
          class="form-input" 
          placeholder="请输入产品代码"
          value="{{formData.productCode}}"
          data-field="productCode"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">
          产品类型
          <text class="required-asterisk">*</text>
        </text>
        <picker 
          class="form-picker"
          data-field="productType"
          bindchange="onPickerChange"
          value="{{productTypeIndex}}"
          range="{{typeOptions}}"
          range-key="label"
        >
          <view class="picker-text">
            {{currentProductTypeLabel}}
          </view>
        </picker>
      </view>
    </view>

    <!-- 贷款信息 -->
    <view class="form-section">
      <view class="section-title">贷款信息</view>
      
      <view class="form-item">
        <text class="form-label">
          最小贷款额度
          <text class="required-asterisk">*</text>
        </text>
        <input 
          class="form-input" 
          placeholder="请输入最小贷款额度"
          type="number"
          value="{{formData.minLoanAmount}}"
          data-field="minLoanAmount"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">
          最大贷款额度
          <text class="required-asterisk">*</text>
        </text>
        <input 
          class="form-input" 
          placeholder="请输入最大贷款额度"
          type="number"
          value="{{formData.maxLoanAmount}}"
          data-field="maxLoanAmount"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">最小贷款期限</text>
        <input 
          class="form-input" 
          placeholder="请输入最小贷款期限（月）"
          type="number"
          value="{{formData.minLoanTerm}}"
          data-field="minLoanTerm"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">最大贷款期限</text>
        <input 
          class="form-input" 
          placeholder="请输入最大贷款期限（月）"
          type="number"
          value="{{formData.maxLoanTerm}}"
          data-field="maxLoanTerm"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">
          利率
          <text class="required-asterisk">*</text>
        </text>
        <input 
          class="form-input" 
          placeholder="请输入利率（%）"
          type="digit"
          value="{{formData.interestRate}}"
          data-field="interestRate"
          bindinput="onInputChange"
        />
      </view>
    </view>

    <!-- 服务信息 -->
    <view class="form-section">
      <view class="section-title">服务信息</view>
      
      <view class="form-item">
        <text class="form-label">服务区域</text>
        <input 
          class="form-input" 
          placeholder="请输入服务区域"
          value="{{formData.serviceArea}}"
          data-field="serviceArea"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">服务电话</text>
        <input 
          class="form-input" 
          placeholder="请输入服务电话"
          value="{{formData.servicePhone}}"
          data-field="servicePhone"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">
          风险等级
          <text class="required-asterisk">*</text>
        </text>
        <picker 
          class="form-picker"
          data-field="riskLevel"
          bindchange="onPickerChange"
          value="{{riskLevelIndex}}"
          range="{{riskLevelOptions}}"
          range-key="label"
        >
          <view class="picker-text">
            {{currentRiskLevelLabel}}
          </view>
        </picker>
      </view>
      
      <view class="form-item">
        <text class="form-label">所需材料</text>
        <textarea 
          class="form-textarea" 
          placeholder="请输入所需材料"
          value="{{formData.requiredDocuments}}"
          data-field="requiredDocuments"
          bindinput="onInputChange"
        />
      </view>
      
      <view class="form-item">
        <text class="form-label">产品描述</text>
        <textarea 
          class="form-textarea" 
          placeholder="请输入产品描述"
          value="{{formData.productDescription}}"
          data-field="productDescription"
          bindinput="onInputChange"
        />
      </view>
    </view>

    <!-- 状态设置 -->
    <view class="form-section">
      <view class="section-title">状态设置</view>
      
      <view class="form-item switch-item">
        <text class="form-label">在售状态</text>
        <switch 
          checked="{{formData.onSaleStatus}}"
          data-field="onSaleStatus"
          bindchange="onSwitchChange"
        />
      </view>
    </view>
  </view>

  <!-- 操作按钮 -->
  <view class="form-actions">
    <button class="action-btn cancel-btn" bindtap="cancel">取消</button>
    <button class="action-btn submit-btn" bindtap="submitForm" disabled="{{loading}}">
      {{loading ? '提交中...' : (mode === 'add' ? '新增' : '修改')}}
    </button>
  </view>

  <!-- 加载提示 -->
  <view class="loading-overlay" wx:if="{{loading}}">
    <view class="loading-content">
      <text class="loading-text">加载中...</text>
    </view>
  </view>
</view>
