index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div v-if="action === 'bind'" class="p-imei">
  3. <h3 class="ptc-title">
  4. You have a {{ state.currentOrder.product_name }} version of membership
  5. service to be bound
  6. </h3>
  7. <div class="ptc-wrapper">
  8. <div class="ptc-block">
  9. <div class="ptc-inner">
  10. <p class="label">IMEI</p>
  11. <p class="control">
  12. <input
  13. v-model="imei"
  14. class="ptc-input"
  15. placeholder="please enter"
  16. />
  17. </p>
  18. <p class="tip">
  19. <span class="pointer" @click="$router.push('view')"
  20. >How to view IMEI?</span
  21. >
  22. </p>
  23. </div>
  24. </div>
  25. <div class="ptc-button-group">
  26. <div class="ptc-inner">
  27. <button class="ptc-button" :loading="loading" @click="applyBind">
  28. BIND IMEI
  29. </button>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div v-else class="p-imei">
  35. <h3 class="ptc-title">View mobile IMEI</h3>
  36. <div class="ptc-block">
  37. <div class="guide ptc-inner">
  38. <div class="guide-txt">
  39. View on iPhone: Turn on the phone and click Settings-General-About
  40. this machine to check the IMEI number。
  41. </div>
  42. <div class="guide-img"></div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script lang="ts">
  48. import { defineComponent } from 'vue'
  49. import { getCurrentOrder } from '@/store'
  50. export default defineComponent({
  51. name: 'IMEI',
  52. async beforeRouteEnter(to) {
  53. await getCurrentOrder(to.query.id as string)
  54. },
  55. })
  56. </script>
  57. <script setup lang="ts">
  58. import { ref } from 'vue'
  59. import { useRoute, useRouter } from 'vue-router'
  60. import { bindIMEI } from '@/service/order'
  61. import { state, getUserInfo } from '@/store'
  62. import Toast from '@/components/toast'
  63. defineProps<{ action: 'bind' | 'view' }>()
  64. const router = useRouter()
  65. const imei = ref('')
  66. const loading = ref(false)
  67. const { id } = useRoute().query as any
  68. const fromPath = history.state.back || '/'
  69. async function applyBind() {
  70. if (!imei.value) return Toast('Please enter IMEI')
  71. loading.value = true
  72. try {
  73. const { message } = await bindIMEI({ id, imei: imei.value })
  74. Toast(message)
  75. getUserInfo()
  76. state.currentOrder.id = -1
  77. const matched = fromPath.match(/order\/(\d+)/)
  78. matched?.[1] === id ? router.back() : router.push(`/order/${id}`)
  79. } catch {}
  80. loading.value = false
  81. }
  82. </script>
  83. <style lang="scss">
  84. .p-imei {
  85. .label {
  86. font-size: 32px;
  87. color: #999;
  88. }
  89. .control {
  90. margin: 48px 0;
  91. }
  92. .tip {
  93. font-size: 32px;
  94. color: $primary-color;
  95. }
  96. .guide {
  97. &-txt {
  98. line-height: 44px;
  99. font-size: 32px;
  100. color: #333;
  101. }
  102. &-img {
  103. display: block;
  104. margin-top: 38px;
  105. height: 328px;
  106. background: #eee;
  107. }
  108. }
  109. }
  110. </style>