<wxs module="_">
  module.exports.formatter = function (value, precision) {
    console.log(value, precision);
    return value;
  }
</wxs>
<!--module/health/components/field-ruler/field-ruler.wxml-->
<view class="field-picker" bind:tap="onShow">
  <view class="field-picker__inner">
    <view wx:if="{{selected.length}}" class="scrollbar">
      <view class="item" wx:for="{{options}}" wx:key="*this">
        <text name="{{item.name}}">{{_.formatter(selected[index], options[index].precision)}}</text>
        <text style="margin-left: 2px;">{{item.unit}}</text>
      </view>
    </view>
    <view wx:else class=" placeholder">请选择</view>
  </view>
</view>

<input style="opacity: 0;" type="digit" wx:for="{{options}}" wx:key="id" name="{{item.id}}" value="{{selected[index]}}" />


<t-popup visible="{{visible}}" bind:visible-change="onCancel" placement="bottom" close-on-overlay-click="{{closeOnOverlayClick}}">
  <view class="popup__header">
    <view class="btn btn--cancel" aria-role="button" bind:tap="onCancel">取消</view>
    <view class="title">{{title}}</view>
    <view class="btn btn--confirm" aria-role="button" bind:tap="onConfirm">确定</view>
  </view>
  <view class="popup__content">
    <form-ruler wx:for="{{options}}" min="{{item.min}}" max="{{item.max}}" precision="{{item.precision}}" model:value="{{scrollValue[index]}}" default-value="{{visible ? selected[index] : 0}}" line="{{item.markLine}}">
      <view slot="before" wx:if="{{item.name !== title}}">{{item.name}}</view>
      <view slot="after">{{item.unit}}</view>
    </form-ruler>
  </view>
</t-popup>