PayMethodPick.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div>
  3. <template v-for="(item, index) in payConfig" :key="index">
  4. <div
  5. class="pay-item"
  6. @click="pick(item)"
  7. v-if="item.show && (item.key === 'BALANCE' ? showBalance : true)"
  8. :key="index"
  9. :class="{ not: !item.enabled }"
  10. >
  11. <div class="img-icon">
  12. <img class="icon" :src="item.icon" alt="" />
  13. </div>
  14. <span>{{ item.name }}</span>
  15. <img
  16. class="choose-icon"
  17. :src="item.enabled ? (checked === item.key ? (isStar ? icons[3] : icons[1]) : icons[0]) : icons[2]"
  18. alt=""
  19. />
  20. </div>
  21. </template>
  22. </div>
  23. </template>
  24. <script>
  25. import { mapState, mapGetters } from 'vuex';
  26. export default {
  27. props: {
  28. modelValue: {},
  29. showBalance: {
  30. type: Boolean,
  31. default: true
  32. },
  33. onlyBalance: {
  34. type: Boolean,
  35. default: false
  36. },
  37. isStar: {
  38. type: Boolean,
  39. default: false
  40. }
  41. },
  42. computed: {
  43. ...mapState(['userInfo']),
  44. ...mapGetters(['iosReview'])
  45. },
  46. created() {
  47. if (this.value) {
  48. this.checked = this.value;
  49. }
  50. if (this.iosReview) {
  51. this.payConfig = [
  52. {
  53. name: '绿魔币 ',
  54. key: 'BALANCE',
  55. icon: 'https://cdn.raex.vip/image/2022-05-18-17-46-19eDglIIAy.png',
  56. show: true,
  57. enabled: true
  58. }
  59. ];
  60. this.checked = 'BALANCE';
  61. } else if (this.onlyBalance) {
  62. this.payConfig = [
  63. {
  64. name: '余额',
  65. key: 'BALANCE',
  66. icon: 'https://cdn.raex.vip/image/2022-05-18-17-46-19eDglIIAy.png',
  67. show: true,
  68. enabled: true
  69. }
  70. ];
  71. this.checked = 'BALANCE';
  72. } else {
  73. this.$http.get('/sysConfig/get/pay_config').then(res => {
  74. let configs = JSON.parse(res.value).filter(item => {
  75. if (item.key === 'BALANCE') {
  76. return this.userInfo && this.userInfo.walletEnabled;
  77. }
  78. return true;
  79. });
  80. if (this.$store.getters.inWechat) {
  81. configs.forEach(item => {
  82. if (item.key === 'ALIPAY') {
  83. item.key = 'ALIPAY_BRIDGE';
  84. }
  85. });
  86. }
  87. this.payConfig = configs.sort((a, b) => a.sort - b.sort);
  88. this.checked = (configs.find(i => i.show && i.enabled) || {}).key;
  89. });
  90. }
  91. },
  92. data() {
  93. return {
  94. checked: null,
  95. payConfig: [],
  96. icons: [
  97. require('@assets/svgs/icon_gouxuan_huise.svg'),
  98. require('@assets/icon_gouxuan_pre.png'),
  99. require('@assets/icon_gouxuan_huise1.png'),
  100. require('@assets/icon_gouxuan_pre2.png')
  101. ]
  102. };
  103. },
  104. methods: {
  105. pick(item) {
  106. if (item.show && item.enabled) {
  107. this.checked = item.key;
  108. } else {
  109. this.$toast('敬请期待');
  110. }
  111. }
  112. },
  113. watch: {
  114. value(val) {
  115. this.checked = val;
  116. },
  117. checked(val) {
  118. this.$emit('update:modelValue', val);
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="less" scoped>
  124. .pay-item {
  125. display: flex;
  126. align-items: center;
  127. height: 60px;
  128. border-bottom: 1px solid @tabBorder;
  129. .icon {
  130. height: 24px;
  131. width: 24px;
  132. object-fit: contain;
  133. display: block;
  134. }
  135. .img-icon {
  136. // width: 45px;
  137. .flex();
  138. justify-content: center;
  139. }
  140. span {
  141. font-size: 14px;
  142. font-weight: bold;
  143. color: @text0;
  144. line-height: 24px;
  145. flex-grow: 1;
  146. padding: 0 10px;
  147. }
  148. .choose-icon {
  149. width: 24px;
  150. height: 24px;
  151. }
  152. &.not {
  153. span {
  154. color: @text3;
  155. }
  156. }
  157. }
  158. </style>