<view class="page">
  <view class="notice">客户名先随手填简称即可，下一步会按别名表精确匹配并要求你人工确认。</view>

  <view class="card">
    <view class="card-title">基本信息</view>
    <view class="field">
      <text class="field-label">活动日期</text>
      <picker mode="date" value="{{form.date}}" bindchange="onDate">
        <view class="picker">{{form.date}}</view>
      </picker>
    </view>
    <view class="field">
      <text class="field-label">客户名称<text class="req">*</text></text>
      <input class="input" value="{{form.customerInput}}" data-field="customerInput" bindinput="onInput" placeholder="输入客户简称 / 全称 / 别名" />
    </view>
    <view class="field">
      <text class="field-label">活动类型 <text style="color:#9ca3af;font-size:23rpx">（可不选，空值就空着）</text></text>
      <view class="chips">
        <view class="chip {{form.activityType === item ? 'on' : ''}}" wx:for="{{activityTypes}}" wx:key="*this" data-value="{{item}}" bindtap="onType">{{item}}</view>
      </view>
      <view wx:if="{{form.activityType}}" class="btn btn-light" style="margin-top:4rpx;padding:14rpx" bindtap="clearType">清除活动类型（留空）</view>
    </view>
    <view class="field">
      <text class="field-label">联系人</text>
      <input class="input" value="{{form.contact}}" data-field="contact" bindinput="onInput" placeholder="本次沟通的联系人" />
    </view>
  </view>

  <view class="card">
    <view class="card-title">业务场景</view>
    <view class="chips">
      <view class="chip {{form.scene === item.key ? 'on' : ''}}" wx:for="{{scenes}}" wx:key="key" data-value="{{item.key}}" bindtap="onScene">{{item.name}}</view>
    </view>
  </view>

  <view class="card" wx:if="{{form.scene === 'demand'}}">
    <view class="card-title">项目需求挖掘</view>
    <view class="card-sub">老商机：匹配该客户的 V1 商机；如无关联商机，系统会引导新建。</view>
    <view class="field">
      <text class="field-label">与客户沟通的细节 / 项目需求</text>
      <textarea class="textarea" value="{{form.demandText}}" data-field="demandText" bindinput="onInput" placeholder="应用场景、技术平台、项目状态、时间节点、参数要求" />
    </view>
    <view class="field">
      <text class="field-label">竞对信息</text>
      <input class="input" value="{{form.competitor}}" data-field="competitor" bindinput="onInput" placeholder="竞对名称 / 已达成指标" />
    </view>
  </view>

  <view class="card" wx:if="{{form.scene === 'test'}}">
    <view class="card-title">测试结果跟进</view>
    <view class="field">
      <text class="field-label">测试单号</text>
      <input class="input" value="{{form.testNo}}" data-field="testNo" bindinput="onInput" placeholder="填写测试单号" />
    </view>
    <view class="field">
      <text class="field-label">货号</text>
      <input class="input" value="{{form.testSku}}" data-field="testSku" bindinput="onInput" placeholder="本次测试的货号" />
    </view>
    <view class="field">
      <text class="field-label">测试结果的客户原话描述</text>
      <textarea class="textarea" value="{{form.testResultText}}" data-field="testResultText" bindinput="onInput" placeholder="客户对结果的原话描述" />
    </view>
    <view class="field">
      <text class="field-label">竞对信息（货号 / 规格及价格）</text>
      <input class="input" value="{{form.competitorSku}}" data-field="competitorSku" bindinput="onInput" placeholder="竞对货号" />
      <input class="input" style="margin-top:14rpx" value="{{form.competitorSpec}}" data-field="competitorSpec" bindinput="onInput" placeholder="竞对规格及价格" />
    </view>
    <view class="field">
      <text class="field-label">结果图 / 结果文件（可选）</text>
      <view class="card-sub" style="margin-bottom:8rpx">一期记录附件名称，不上传文件；附件上传待接入云存储后开放。</view>
      <input class="input" value="{{form.attachmentNames}}" data-field="attachmentNames" bindinput="onInput" placeholder="例：下机文件.xlsx、结果图.png" />
    </view>
    <view class="field">
      <text class="field-label">是否调整商机进度</text>
      <view class="chips">
        <view class="chip {{form.adjustProgress === item ? 'on' : ''}}" wx:for="{{yesNo}}" wx:key="*this" data-value="{{item}}" bindtap="onAdjust">{{item}}</view>
      </view>
    </view>
    <view wx:if="{{form.adjustProgress === '是'}}" class="field">
      <text class="field-label">进度调整</text>
      <view class="chips">
        <view class="chip {{form.progressDirection === item ? 'on' : ''}}" wx:for="{{progressOptions}}" wx:key="*this" data-value="{{item}}" bindtap="onProgress">{{item}}</view>
      </view>
      <view wx:if="{{form.progressDirection === '关闭'}}" class="notice" style="margin-top:12rpx;margin-bottom:0">关闭商机需主管审核，保存后会自动生成一条关闭审核单。</view>
    </view>
  </view>

  <view class="card" wx:if="{{form.scene === 'profile'}}">
    <view class="card-title">客户档案完善</view>
    <view class="card-sub">按《客户管理.xmind》字段：客户概况、组织架构与决策链、决策模式、内部痛点、客户产品和商机管理。保存活动后可到「客户 360」逐项补录。</view>
    <view class="field">
      <text class="field-label">本次补充的档案要点</text>
      <textarea class="textarea" value="{{form.profileNote}}" data-field="profileNote" bindinput="onInput" placeholder="例：研发总监偏好性能数据、采购每年有降本考核" />
    </view>
  </view>

  <view class="card" wx:if="{{form.scene === 'order'}}">
    <view class="card-title">订单跟进</view>
    <view class="field">
      <text class="field-label">货号</text>
      <input class="input" value="{{form.orderSku}}" data-field="orderSku" bindinput="onInput" placeholder="选择在该客户商机中出现过的货号" />
    </view>
    <view class="field">
      <text class="field-label">规格</text>
      <view class="chips">
        <view class="chip {{form.specType === item ? 'on' : ''}}" wx:for="{{specTypes}}" wx:key="*this" data-value="{{item}}" bindtap="onSpecType">{{item}}</view>
      </view>
    </view>
    <view wx:if="{{form.specType === '特殊要求'}}" class="field">
      <text class="field-label">客户不接受标准规格的原因</text>
      <view class="chips">
        <view class="chip {{form.specReason === item ? 'on' : ''}}" wx:for="{{specReasons}}" wx:key="*this" data-value="{{item}}" bindtap="onSpecReason">{{item}}</view>
      </view>
      <input class="input" style="margin-top:12rpx" value="{{form.specDesc}}" data-field="specDesc" bindinput="onInput" placeholder="具体的要求描述" />
    </view>
    <view class="field">
      <text class="field-label">数量</text>
      <input class="input" type="number" value="{{form.quantity}}" data-field="quantity" bindinput="onInput" placeholder="预计数量" />
    </view>
    <view class="field">
      <text class="field-label">议价概况</text>
      <input class="input" value="{{form.competitorPrice}}" data-field="competitorPrice" bindinput="onInput" placeholder="竞对价格" />
      <input class="input" style="margin-top:14rpx" value="{{form.ourPriceStrategy}}" data-field="ourPriceStrategy" bindinput="onInput" placeholder="我司报价策略及结果" />
    </view>
    <view class="field">
      <text class="field-label">预计拿货时间</text>
      <input class="input" value="{{form.expectDate}}" data-field="expectDate" bindinput="onInput" placeholder="例：2027Q1" />
    </view>
  </view>

  <view class="card" wx:if="{{form.scene === 'other'}}">
    <view class="card-title">其他</view>
    <view class="field">
      <text class="field-label">通用文本框描述</text>
      <textarea class="textarea" value="{{form.otherText}}" data-field="otherText" bindinput="onInput" placeholder="详细描述本次业务活动内容" />
    </view>
  </view>

  <view class="card">
    <view class="card-title">活动内容（通用）</view>
    <view class="field">
      <textarea class="textarea" value="{{form.content}}" data-field="content" bindinput="onInput" placeholder="本次活动的整体记录" />
    </view>
  </view>

  <view wx:if="{{errorMsg}}" class="notice" style="background:#fce8e6;border-color:#f3b3b0;color:#a50e0e">{{errorMsg}}</view>
  <view class="btn btn-primary" bindtap="save">保存并匹配商机</view>
  <view class="btn btn-ghost" bindtap="goBack">返回工作台</view>
</view>
