taskPlan.vue 3.66 KB
<template>
  <div class='taskPlan'>
    <div class='headline'>任务计划</div>
    <el-tabs v-model='activeName' type='card'>
      <el-tab-pane v-for='(item,index) in taskPlanList' :key='index'
                   :label="item.activityTime =='-1'?'完整周期' : item.activityTime" :name='item.activityTime'>
        <div class='taskInfo' v-for='(displayList,idx) in  item.platformMerchantMissionResponseList' :key='idx'>
          <p class='taskType'>{{ displayList.missonTypeName }}</p>
          <p>{{ displayList.missionName }}</p>
          <p>{{ displayList.missonDesc }}</p>

          <template
            v-if='displayList.platformMerchantMissionMaterialResponseList && displayList.platformMerchantMissionMaterialResponseList.length'>
            <div v-for='(sub,idx,) in displayList.platformMerchantMissionMaterialResponseList' :key='idx'>
              <template v-if="sub.materialType == '1'">
                <p v-html='tramWord(sub.materialContent)'></p>
              </template>
              <template v-if="sub.materialType == '2'">
                <img class='displayImg' :src='sub.materialContent'>
              </template>
              <template v-if="sub.materialType == '3'">
                <video class='displayImg' :src='sub.materialContent' />
              </template>
              <template v-if="sub.materialType == '4'">
                <p>{{ sub.materialContent }}</p>
              </template>
            </div>
          </template>
          <div class='showInfoForm'>
            <span v-if='displayList.rewardTypeName'>奖励模式:{{ displayList.rewardTypeName }}</span>
            <span v-if='displayList.rewardCountName'>奖励次数:{{ displayList.rewardCountName }}</span>
            <span v-if="displayList.rewardCountName == '重复累计'">
              重复次数:{{ displayList.repeatCount  == '-1' ? '无限制' : displayList.repeatCount }}
            </span>
            <span v-if='displayList.triggerValue'>触发值:{{ displayList.triggerValue }}</span>
            <span v-if='displayList.rewardScore'>奖励积分值:{{ displayList.rewardScore }}</span>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import emoji from '@/utils/emo'

export default {
  name: 'taskPlan',
  props: {
    taskPlanList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      activeName: ''
    }
  },
  watch: {
    taskPlanList:{
      handler(newVal,oldVal){
        if (!oldVal || newVal !== oldVal) {
          this.activeName = newVal && newVal[0].activityTime
          this.taskPlanList = newVal
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods:{
    tramWord(val) {
      let htm = val.replace(/\[([\u4E00-\u9FA56]{1,4}|OK|NO|666)]/gi, function(res) {
        let word = res.replace(/\[|\]/gi, '')
        const list = emoji.flat(Infinity)
        let index = parseInt(list.indexOf(word)) + 1
        if (index < 10) {
          index = '00' + index
        } else if (index >= 10 && index < 100) {
          index = '0' + index
        }
        return `<img style='width:25px;height:25px' src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
      })
      return htm
    },
  }
}
</script>

<style scoped>
.taskPlan{
  margin-top: 20px;
}
.headline {
  font-weight: 600;
  padding-bottom: 20px;
}

.taskInfo {
  border: 1px solid #E4E7ED;
  padding-left: 20px;
  padding-right: 20px;
  margin-bottom: 16px;
}

.taskType {
  font-weight: 600;
}

.displayImg {
  width: 500px;
  height: 300px
}

.showInfoForm {
  margin-top: 10px;
  width: 700px;
}

.showInfoForm > span {
  display: inline-block;
  padding-bottom: 8px;
  width: 50%;
}
</style>