PayMethodPick.vue 3.9 KB

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