index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="resume-box" :class="{'fullShow': fullShow}">
  3. <div class="resume-header" v-if="showTitle">
  4. <div class="resume-title">余额充值</div>
  5. </div>
  6. <div class="d-flex align-center mb-10 mt-5">
  7. <div
  8. v-for="(item, index) in list"
  9. :key="index"
  10. class="packagesItem cursor-pointer mx-3"
  11. :class="{'active': current === (index+1)}"
  12. style="width: 200px;"
  13. @click="handleSelect(item, index)"
  14. >
  15. <div class="d-flex flex-column align-center pb-5" style="position: relative;">
  16. <div
  17. class="my-4 mt-8 font-size-16 font-weight-bold titleColor"
  18. :style="{'color': current === (index + 1) ? '#ff4747' : '#000'}"
  19. >
  20. {{ item.name }}
  21. </div>
  22. <!-- <div class="font-weight-bold priceBox">
  23. <span v-if="item.custom">
  24. <input
  25. v-model="item.payPrice"
  26. type="text"
  27. class="custom-input-num"
  28. :style="{'color': current === (index + 1) ? '#ff4747' : '#000'}"
  29. @keyup.enter="handleCustomEnter"
  30. @focus="item.tip = '输入完成后请按Enter键确认'"
  31. >
  32. </span>
  33. <span class="font28" v-else>{{ item.payPrice }}</span>
  34. </div> -->
  35. <div class="dailyPrice font-size-12 mt-3">
  36. <span v-if="!item.custom">¥{{ payCalculation(item.payPrice, 'realPay') }}</span>
  37. <span v-else>{{ item.tip }}</span>
  38. </div>
  39. <div class="vip">
  40. <svg-icon v-if="current === (index+1)" name="diamond-active" size="50"></svg-icon>
  41. <svg-icon v-else name="diamond" size="50"></svg-icon>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <initPay
  47. v-if="current"
  48. :info="itemInfo"
  49. @paySuccess="current = 0"
  50. ></initPay>
  51. </div>
  52. </template>
  53. <script setup>
  54. defineOptions({ name: 'personalRecharge-index'})
  55. import { payCalculation } from '@/utils/position'
  56. import { ref } from 'vue'
  57. import { getUserWalletRechargeList } from '@/api/recruit/personal/myWallet.js'
  58. import initPay from './initPay.vue'
  59. defineProps({
  60. showTitle: {
  61. type: Boolean,
  62. default: true
  63. }
  64. })
  65. import { useRoute } from 'vue-router'; const route = useRoute()
  66. const fullShow = ref(route.path === '/personalRecharge' ? true : false)
  67. const current = ref(0)
  68. const price = ref(0)
  69. const list = ref([])
  70. const getListData = async () => {
  71. const data = await getUserWalletRechargeList()
  72. list.value = data || []
  73. // const end = { name: '自定义充值', payPrice: 100, custom: true, tip: '输入完成后请按Enter键确认' }
  74. // list.value = data ? [...data, end] : [end]
  75. }
  76. getListData()
  77. // const handleCustomEnter = (e) => {
  78. // const num = e.target.value
  79. // const custom = list.value.find(k => k.custom)
  80. // if (num < 100) {
  81. // custom.tip = '最低充值金额为100元'
  82. // custom.price = 100
  83. // return
  84. // }
  85. // price.value = num
  86. // }
  87. const timer = ref(null)
  88. const itemInfo = ref(null)
  89. let count = 1; const interval = 2000;
  90. const handleSelect = (item, index) => {
  91. count = 1
  92. itemInfo.value = item
  93. current.value = index + 1
  94. price.value = item.payPrice
  95. timer.value = setInterval(() => { clearIntervalFun() }, interval)
  96. }
  97. // 一段时间后清除二维码轮询
  98. const clearIntervalFun = () => {
  99. // console.log('一段时间后清除二维码轮询', (count * interval))
  100. count++
  101. if ((count * interval) >= 30000 && timer.value) {
  102. current.value = 0
  103. clearInterval(timer.value); timer.value = null
  104. }
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .fullShow {
  109. width: 1100px;
  110. background-color: #fff;
  111. margin: 0 auto;
  112. min-height: 720px;
  113. }
  114. .packagesItem {
  115. border: 1px solid var(--color-f3);
  116. border-radius: 8px;
  117. background-color: var(--color-f2f4f742);
  118. }
  119. .dailyPrice {
  120. border-radius: 14px;
  121. background-color: #dde3e94f;
  122. padding: 2px 18px;
  123. color: var(--color-666);
  124. }
  125. .active {
  126. border: 2px solid #cf990c;
  127. background: linear-gradient(rgb(255, 242, 214) 8.86%, rgb(255, 225, 177) 100%);;
  128. .priceBox {
  129. color: var(--v-error-base);
  130. }
  131. .dailyPrice {
  132. color: var(--v-error-base);
  133. background-color: #fff4e7;
  134. }
  135. }
  136. .custom-input-num {
  137. border: none;
  138. outline: none;
  139. background-color: transparent;
  140. max-width: 100%;
  141. text-align: center;
  142. font-weight: 700;
  143. }
  144. .vip {
  145. width: 50px;
  146. height: 50px;
  147. position: absolute;
  148. top: 0;
  149. right: 0;
  150. overflow: hidden;
  151. border-radius: 8px
  152. }
  153. :deep(.v-slide-group__content) {
  154. background: none !important;
  155. }
  156. </style>