<template>
  <!-- 选择地点 -->
  <main-page
    left-arrow
    @click-left="$router.go(-1)"
  >
    <div class="pt-14 px-4 pb-16">
      <div v-for="(tag,index) in tags" :key="index" class="rounded">
        <div class="border-b pl-2.5 pr-1 w-full py-2.5 flex items-center bg-white rounded" :class="classBorder(index)" @click="clickIcon(index)">
          <app-icon
            slot="icon"
            :icon-name="checked === index+'' ? 'radio-checked': 'radio'"
            class-name="w-4 h-4 mr-2 flex items-center"
          />
          <div class="text-sm rounded-full  px-2.5 mr-2.5" :class="tagColor(tag)">
            {{ tag.condition }}
          </div>
        </div>
      </div>
    </div>
  </main-page>
</template>

<script lang="ts">
import Vue from 'vue'
import { Icon } from 'vant'

Vue.use(Icon)
export default Vue.extend({
  name: 'OPriority',
  components: {
    'main-page': () => import('@/layout/main-page.vue'),
    'app-icon': () => import('@/components/common/Icon.vue')
  },
  data() {
    return {
      checked: '',
      tags: [
        { key: 'zero', condition: '(无)' },
        { key: 'urgent', condition: '紧急' },
        { key: 'important', condition: '重要' },
        { key: 'common', condition: '普通' },
        { key: 'low', condition: '较低' }
      ],
      count: 0
    }
  },
  computed: {

  },
  created() {
    // console.log(Mock, 'mock')

  },
  methods: {
    clickIcon(index:number) {
      this.count = this.tags.length
      if (this.checked === index + '') {
        this.checked = ''
      } else {
        this.checked = index + ''
      }
    },
    classBorder(index:number) {
      if (index === this.tags.length - 1) {
        return 'border-none '
      }
      if (index === 0) {
        return 'mt-3'
      }
    },
    tagColor(object: {key: string, condition: string}) {
      if (object.key === 'zero') {
        return ' '
      } else if (object.key === 'urgent') {
        return 'text-tag-red border border-tag-red '
      } else if (object.key === 'important') {
        return 'text-tag-yellow border border-tag-yellow'
      } else if (object.key === 'common') {
        return 'text-tag-green border border-tag-green '
      } else if (object.key === 'low') {
        return 'border border-current'
      } else {
        return '  '
      }
    }
  }
})
</script>

<style lang="less" scoped>

</style>
