<wxs module="m1">
  function getConditionTypeTipMap(Num) {
    return {
      // BarragePwd:[], // 弹幕
      Quiz: ['提交全部答题', '至少提交' + Num + '道答题'],
      Questionnaire: ['提交全部问卷', '至少提交' + Num + '个问卷'],
      CheckIn: ['提交全部签到', '至少提交' + Num + '个签到'],
      Vote: ['提交全部投票', '至少提交' + Num + '个投票'],
      RightQuiz: ['答对全部答题', '至少答对' + Num + '道答题'],
    }
  };
  function getValidStr(arr) {
    if (!arr.length) return '';
    for (var i = 0; i < arr.length; i++) {
      if (arr[i] && arr[i].length > 0) {
        return arr[i];
      }
    }
    return '';
  };
  function getBySplit(text = '') { // locale
    if (!text) {
      return '';
    }
    // 根据管道符分隔
    var idx = 0; // lanType[locale] ?? LANG[locale];
    // 全角和半角的管道符
    var textList = text.split('/\||｜/');
    return getValidStr([textList[idx], textList[idx - 1], textList[0], text]);
  };
  var getTip = function (item) {
    var tip = '';
    if (item.key === 'BarragePwd') {
      tip = '发布弹幕口令：' + getBySplit(item.value);
    } else if (item.key === 'Order') {
      tip = getBySplit(item.value.OrderName || '');
    } else {
      var tipIdx = item.value === 'all' ? 0 : 1;
      var ConditionTypeTipMap = getConditionTypeTipMap(item.value);
      tip = ConditionTypeTipMap[item.key][tipIdx];
    }
    return tip;
  }
  var getShowNumberStr = function (data, status) {
    if (!data || !data.formatDataList || !data.formatDataList.length) return '';
    if (status === 1) {
      return data.formatDataList.length + '/' + data.formatDataList.length;
    }
    if (data.UndoAwardCondition) {
      return data.formatDataList.filter(function (item) { return item.completed; }).length + '/' + data.formatDataList.length;
    }
    return data.formatDataList.length;
  }
  var getComplete = function (item, status) {
    return item.completed || (status === 1);
  }
  module.exports.getTip = getTip;
  module.exports.getShowNumberStr = getShowNumberStr;
  module.exports.getComplete = getComplete;
</wxs>
<view class="lottery-detail-condition-box{{ IsUseDarkTheme ? ' lottery-detail-condition-box-dark' : ''}}{{data.AwardThemeUrl === 'lotteryBox' ? ' lottery-detail-condition-box-box' : ''}}{{ data.AwardThemeUrl === 'slotMachine' ? ' lottery-detail-condition-box-machine' : ''}}">
  <view class="lottery-conditional-item-title">
    做任务参与抽奖
    <view class="lottery-conditional-item-title-num">{{m1.getShowNumberStr(data, status)}}</view>
  </view>
  <view wx:for="{{data.formatDataList}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.key}}">
    <view wx:if="{{data.attendFailFlag || data.attendedFlag}}" class="lottery-detail-text lottery-condition-unAttend {{item.completed ? 'completed' : ''}}">
      <view>
        <mp-icon wx:if="{{m1.getComplete(item, status)}}" icon="done" color="#00aa2a" size="{{14}}" class="done" />
        <view wx:else class="circle"></view>
        <view>{{m1.getTip(item)}}</view>
      </view>
      <view class="lottery-detail-text-status">
        {{item.key === 'BarragePwd' ? '自动发送' : m1.getComplete(item, status) ? '已完成' : '待完成'}}
      </view>
    </view>
    <view wx:else class="lottery-detail-text">
      <view>
        <view class="circle"></view>
        <view>{{m1.getTip(item)}}</view>
      </view>
    </view>
  </view>
</view>