index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!-- -->
  2. <template>
  3. <div class="rules-box">
  4. <button class="ui-button primary" @click="confirmRules" :class="{ disabled: !next }">{{ rulesIndex >= 2 ? $t('common.endPoint') : $t('common.startPoint') }}({{ rulesIndex }}/2)</button
  5. ><button class="ui-button cancel" @click="cancelRules">{{ $t('common.cancel') }}</button>
  6. </div>
  7. <Toast v-if="showTips" type="warn" :content="showTips" :close="() => (showTips = null)" />
  8. </template>
  9. <script setup>
  10. import { reactive, toRefs, onBeforeMount, onMounted, ref, defineEmits } from 'vue'
  11. import Toast from '@/components/dialog/Toast'
  12. import i18n from '@/i18n'
  13. const showTips = ref(null)
  14. const { t } = i18n.global
  15. const rulesIndex = ref(1)
  16. const emits = defineEmits(['close'])
  17. const confirmRules = () => {
  18. next.value = false
  19. window.kankan.TagManager.confirmMeasure(rulesIndex.value)
  20. if (rulesIndex.value < 2) {
  21. showTips.value = t('toast.ruleConfirmTips')
  22. rulesIndex.value++
  23. } else {
  24. cancelRules()
  25. }
  26. }
  27. const cancelRules = () => {
  28. emits('close')
  29. rulesIndex.value = 1
  30. }
  31. const next = ref(false)
  32. onMounted(() => {
  33. window.kankan.TagManager.on('tagManager.markTagPos', res => {
  34. next.value = true
  35. })
  36. })
  37. </script>
  38. <style lang="scss" scoped>
  39. .rules-box {
  40. position: fixed;
  41. z-index: 1001;
  42. bottom: 20px;
  43. left: 50%;
  44. transform: translateX(-50%);
  45. min-width: 150px;
  46. .ui-button {
  47. margin-bottom: 10px;
  48. &:last-of-type {
  49. margin-bottom: 0;
  50. }
  51. &.cancel {
  52. background: rgba(92, 92, 92, 0.51) !important;
  53. color: #fff !important;
  54. border: none !important;
  55. }
  56. }
  57. }
  58. .ui-button.primary {
  59. background-color: var(--colors-primary-base) !important;
  60. color: var(--colors-normal-fill-hover);
  61. border: none;
  62. opacity: 1;
  63. }
  64. </style>