| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <template>
- <div>
- <template v-for="(item, index) in payConfig" :key="index">
- <div
- class="pay-item"
- @click="pick(item)"
- v-if="item.show && (item.key === 'BALANCE' ? showBalance : true)"
- :key="index"
- :class="{ not: !item.enabled }"
- >
- <div class="img-icon">
- <img class="icon" :src="item.icon" alt="" />
- </div>
- <span>{{ item.name }}</span>
- <img
- class="choose-icon"
- :src="item.enabled ? (checked === item.key ? (isStar ? icons[3] : icons[1]) : icons[0]) : icons[2]"
- alt=""
- />
- </div>
- </template>
- </div>
- </template>
- <script>
- import { mapState, mapGetters } from 'vuex';
- export default {
- props: {
- modelValue: {},
- showBalance: {
- type: Boolean,
- default: true
- },
- onlyBalance: {
- type: Boolean,
- default: false
- },
- isStar: {
- type: Boolean,
- default: false
- }
- },
- computed: {
- ...mapState(['userInfo']),
- ...mapGetters(['iosReview'])
- },
- created() {
- if (this.value) {
- this.checked = this.value;
- }
- if (this.iosReview) {
- this.payConfig = [
- {
- name: '绿魔币 ',
- key: 'BALANCE',
- icon: 'https://cdn.raex.vip/image/2022-05-18-17-46-19eDglIIAy.png',
- show: true,
- enabled: true
- }
- ];
- this.checked = 'BALANCE';
- } else if (this.onlyBalance) {
- this.payConfig = [
- {
- name: '余额',
- key: 'BALANCE',
- icon: 'https://cdn.raex.vip/image/2022-05-18-17-46-19eDglIIAy.png',
- show: true,
- enabled: true
- }
- ];
- this.checked = 'BALANCE';
- } else {
- this.$http.get('/sysConfig/get/pay_config').then(res => {
- let configs = JSON.parse(res.value).filter(item => {
- if (item.key === 'BALANCE') {
- return this.userInfo && this.userInfo.walletEnabled;
- }
- return true;
- });
- if (this.$store.getters.inWechat) {
- configs.forEach(item => {
- if (item.key === 'ALIPAY') {
- item.key = 'ALIPAY_BRIDGE';
- }
- });
- }
- this.payConfig = configs.sort((a, b) => a.sort - b.sort);
- this.checked = (configs.find(i => i.show && i.enabled) || {}).key;
- });
- }
- },
- data() {
- return {
- checked: null,
- payConfig: [],
- icons: [
- require('@assets/svgs/icon_gouxuan_huise.svg'),
- require('@assets/icon_gouxuan_pre.png'),
- require('@assets/icon_gouxuan_huise1.png'),
- require('@assets/icon_gouxuan_pre2.png')
- ]
- };
- },
- methods: {
- pick(item) {
- if (item.show && item.enabled) {
- this.checked = item.key;
- } else {
- this.$toast('敬请期待');
- }
- }
- },
- watch: {
- value(val) {
- this.checked = val;
- },
- checked(val) {
- this.$emit('update:modelValue', val);
- }
- }
- };
- </script>
- <style lang="less" scoped>
- .pay-item {
- display: flex;
- align-items: center;
- height: 60px;
- border-bottom: 1px solid @tabBorder;
- .icon {
- height: 24px;
- width: 24px;
- object-fit: contain;
- display: block;
- }
- .img-icon {
- // width: 45px;
- .flex();
- justify-content: center;
- }
- span {
- font-size: 14px;
- font-weight: bold;
- color: @text0;
- line-height: 24px;
- flex-grow: 1;
- padding: 0 10px;
- }
- .choose-icon {
- width: 24px;
- height: 24px;
- }
- &.not {
- span {
- color: @text3;
- }
- }
- }
- </style>
|