import dateUtil from "@/util/dateUtil.js";
export default {
  taskVoMsg: function (str) {
    let taskVo = JSON.parse(sessionStorage.getItem('taskVo'))
    console.log(taskVo,"taskVo");
    let activityType = sessionStorage.getItem("activityType");
    let startTime = dateUtil.formatTime(taskVo.orderStartTime, "yyyy-MM-dd hh:mm:ss");
    let endTime = dateUtil.formatTime(taskVo.orderEndTime, "yyyy-MM-dd hh:mm:ss");
    let title = ''
    let complete = ''
    let priceTypeText = ''
    let categoryText = ['单笔金额', '单笔件数', '单日金额', '单日件数', '累计金额', '累计件数']
    let unit = ''
    let timesText = ''
    let completeCountText = ''
    let isGame = false
    if(activityType == '10107'){
      taskVo.completeCount = taskVo.cycleTaskNum
    }
    if (taskVo.skuType == '1') {
      title = "指定商品";
    } else if (taskVo.skuType == '2') {
      title = "指定商品";
    } else {
      title = "店铺内任意商品";
    }
    if (taskVo.orderStatus == '0') {
      complete = '已付款'
    } else if (taskVo.orderStatus == '1') {
      complete = '已发货'
    } else if (taskVo.orderStatus == '2') {
      complete = '交易完成'
    }
    if (taskVo.category == "1" || taskVo.category == "3" || taskVo.category == "5") {
      if (taskVo.priceType == '0') {
        priceTypeText = '，价格类型【京东价】'
      } else if (taskVo.priceType == '1') {
        priceTypeText = '，价格类型【实付价】'
      }
    }
    if (taskVo.category == '1' || taskVo.category == '3' || taskVo.category == '5') {
      unit = '元'
    } else {
      unit = '件'
    }
    if (activityType == '10095' || activityType == '10094' || activityType == '10093' || activityType == '10091' || activityType == '10089' || activityType == '10086' || activityType == '10084' || activityType == '10035' || activityType == '10059' || activityType == '10082' || activityType == '10092') {
      isGame = true
    }
    let isGameText = isGame ? '次游戏机会' : '次抽奖机会'
    if (taskVo.drawType == '0') {
      timesText = categoryText[taskVo.category - 1] + '，' + '满' + taskVo.sendVoList[0].full + unit + '，' + '赠送' + taskVo.sendVoList[0].sendTimes + isGameText + '，'
    } else if (taskVo.drawType == '1') {
      timesText = categoryText[taskVo.category - 1] + '，' + '每满' + taskVo.sendVoList[0].full + unit + '，' + '赠送' + taskVo.sendVoList[0].sendTimes + isGameText + '，' 
      // + categoryText[taskVo.category - 1] + '按倍数增加，则多赠送' + taskVo.sendVoList[0].sendTimes + isGameText + '，'
    } else if (taskVo.drawType == '2') {
      taskVo.sendVoList.forEach((ele,index)=>{
          if(index == 0){
          timesText = timesText + categoryText[taskVo.category - 1] + '，' + '满' + ele.full + unit + '，' + '赠送' + ele.sendTimes + isGameText + '；'
        }else{
          timesText = timesText  + '满' + ele.full + unit + '，' + '赠送' + ele.sendTimes + isGameText + '；'
        }
      })
    }
    if ((taskVo.category == "3" && taskVo.drawType == "0") || taskVo.category == "4" && taskVo.drawType == "0") {
      completeCountText = '用户在本活动内，最多可完成' + taskVo.completeCount + '次本下单任务，单日最多可完成1次，'
    }else if(taskVo.category == "1" && taskVo.drawType == "0"){
      completeCountText = '用户在本活动内，最多可完成' + taskVo.completeCount + '次本下单任务，'
    }else if(taskVo.drawType == "2"){
      if(taskVo.category == "1" || taskVo.category == "2"){
         completeCountText = '用户在本活动内，单笔订单最多可获得'+taskVo.sendVoList[taskVo.sendVoList.length-1].sendTimes + isGameText + '，'
      }else if(taskVo.category == "3" || taskVo.category == "4"){
         completeCountText = '用户在本活动内，单日累计最多可获得'+taskVo.sendVoList[taskVo.sendVoList.length-1].sendTimes + isGameText + '，'
      }else if(taskVo.category == "5" || taskVo.category == "6"){
         completeCountText = '用户在本活动内，活动累计最多可获得'+taskVo.sendVoList[taskVo.sendVoList.length-1].sendTimes + isGameText + '，'
      }
    }else {
      completeCountText = '用户在本活动内，最多可完成' + taskVo.completeCount + '次本下单任务，'
    }
    // completeCountText
   var msg = ''
    if(activityType == '10107'){
      let orderStatusMsg = ''
      if(taskVo.orderStatus == 0){
        orderStatusMsg = '付款完成时间'
      }else{
        orderStatusMsg = '确认收货（订单完成）时间'
      }
      msg = '已成功报名且订单的' + orderStatusMsg + '在' + startTime + '~' + endTime  + '期间内，订单商品为' + title + '，' + timesText + completeCountText
      + '且订单状态为' + complete + priceTypeText
        + '，虚拟订单没有物流信息，暂不支持参与活动'
    }else{
      // var msg = '在';
      msg ='在' +startTime + '~' + endTime + '期间，订单商品为' + title + '，' + timesText + completeCountText
        + '且订单状态为' + complete + priceTypeText
      + '，虚拟订单没有物流信息，暂不支持参与活动'
    }
    return msg;
  },
}
