useActivateStepsInjection.js 658 B

12345678910111213141516171819
  1. import {computed, ref} from 'vue'
  2. import {injectLocal, provideLocal} from "@vueuse/core";
  3. const key = Symbol('ACTIVATE_STEPS_SERVICE')
  4. export const useProvideActivateSteps = function () {
  5. const step = ref(0)
  6. const steps = ref(['校验会员卡', '确认信息', '绑卡完成'])
  7. const buttonText = computed(() => steps.value[step.value])
  8. const completed = computed(() => step.value == steps.value.length - 1)
  9. const loading = ref(false)
  10. const options = {steps, step, buttonText, loading, completed}
  11. provideLocal(key, options)
  12. return options
  13. }
  14. export const useInjectActivateSteps = function () {
  15. return injectLocal(key)
  16. }