|
@@ -23,13 +23,13 @@
|
|
<span class="color-warning">{{ props.params?.txt || '当前余额不足,请选择其他支付方式' }}</span>
|
|
<span class="color-warning">{{ props.params?.txt || '当前余额不足,请选择其他支付方式' }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div v-if="isShowQrCode" style="text-align: center;">
|
|
|
|
- <QrCode :text="payCodeUrl" :width="170" style="margin: 0 auto;" />
|
|
|
|
- <div v-if="showQrCode && payCodeUrl" style="color: var(--v-error-base);">扫码支付时请勿离开</div>
|
|
|
|
|
|
+ <div v-if="isQrCodePay" style="text-align: center;">
|
|
|
|
+ <QrCode :text="payQrCodeTet" :width="170" style="margin: 0 auto;" />
|
|
|
|
+ <div v-if="isQrCodePay && payQrCodeTet" style="color: var(--v-error-base);">扫码支付时请勿离开</div>
|
|
</div>
|
|
</div>
|
|
<div class="mt-10" style="text-align: center;">
|
|
<div class="mt-10" style="text-align: center;">
|
|
<v-btn
|
|
<v-btn
|
|
- v-if="(showQrCode && payCodeUrl) || isWalletPay"
|
|
|
|
|
|
+ v-if="(isQrCodePay && payQrCodeTet) || isWalletPay"
|
|
class="buttons" color="primary"
|
|
class="buttons" color="primary"
|
|
:loading="payLoading"
|
|
:loading="payLoading"
|
|
@click="paySubmit"
|
|
@click="paySubmit"
|
|
@@ -46,40 +46,62 @@ defineOptions({ name: 'pay-index'})
|
|
import { computed, ref } from 'vue'
|
|
import { computed, ref } from 'vue'
|
|
import radioGroupUI from '@/components/FormUI/radioGroup'
|
|
import radioGroupUI from '@/components/FormUI/radioGroup'
|
|
import QrCode from '@/components/QrCode'
|
|
import QrCode from '@/components/QrCode'
|
|
-import { definePayTypeList, showQrCode, walletPay } from './until/payType'
|
|
|
|
|
|
+import { definePayTypeList, qrCodePay, walletPay } from './until/payType'
|
|
|
|
+import { getEnableCodeList } from '@/api/common'
|
|
|
|
+import { useSharedState } from '@/store/sharedState'
|
|
const emit = defineEmits(['payTypeChange', ])
|
|
const emit = defineEmits(['payTypeChange', ])
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
params: {
|
|
params: {
|
|
type: Object,
|
|
type: Object,
|
|
default: () => {}
|
|
default: () => {}
|
|
},
|
|
},
|
|
- codeList: {
|
|
|
|
- type: Array,
|
|
|
|
- default: () => []
|
|
|
|
- },
|
|
|
|
|
|
+ // codeList: {
|
|
|
|
+ // type: Array,
|
|
|
|
+ // default: () => []
|
|
|
|
+ // },
|
|
needPrice: {
|
|
needPrice: {
|
|
type: [String, Number],
|
|
type: [String, Number],
|
|
default: 0
|
|
default: 0
|
|
},
|
|
},
|
|
})
|
|
})
|
|
|
|
|
|
-const payLoading = ref(false)
|
|
|
|
-const payCodeUrl = ref('')
|
|
|
|
|
|
+// 支付方式
|
|
const payType = ref('')
|
|
const payType = ref('')
|
|
-
|
|
|
|
const payTypeList = ref([])
|
|
const payTypeList = ref([])
|
|
-if (definePayTypeList?.length && props.codeList?.length) {
|
|
|
|
- props.codeList.forEach(code => {
|
|
|
|
- const item = definePayTypeList.find(p => p.code === code)
|
|
|
|
- if (item) {
|
|
|
|
- if (!payType.value) payType.value = code // 默认值赋值
|
|
|
|
- payTypeList.value.push(item)
|
|
|
|
|
|
+const sharedState = useSharedState()
|
|
|
|
+const codeList = ref(sharedState.payCodeList || [])
|
|
|
|
+const getCodeList = async () => {
|
|
|
|
+ try {
|
|
|
|
+ if (!codeList.value?.length) {
|
|
|
|
+ const list = await getEnableCodeList({appId: 10})
|
|
|
|
+ codeList.value = list || []
|
|
|
|
+ sharedState.setPayCodeList(codeList.value)
|
|
|
|
+ } else {
|
|
|
|
+ codeList.value = sharedState.payCodeList
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.log(error)
|
|
|
|
+ } finally {
|
|
|
|
+ if (definePayTypeList?.length && codeList.value?.length) {
|
|
|
|
+ codeList.value.forEach(code => {
|
|
|
|
+ const item = definePayTypeList.find(p => p.code === code)
|
|
|
|
+ if (item) {
|
|
|
|
+ if (!payType.value) payType.value = code // 默认值赋值
|
|
|
|
+ payTypeList.value.push(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+getCodeList()
|
|
|
|
|
|
-const isShowQrCode = computed(() => {
|
|
|
|
- return showQrCode.includes(payType.value)
|
|
|
|
|
|
+const payLoading = ref(false)
|
|
|
|
+const payQrCodeTet = ref('')
|
|
|
|
+
|
|
|
|
+const isQrCodePay = computed(() => {
|
|
|
|
+ const bool = qrCodePay.includes(payType.value)
|
|
|
|
+ if (bool) initPayQrCode() // 生成二维码内容
|
|
|
|
+ return bool
|
|
})
|
|
})
|
|
const isWalletPay = computed(() => {
|
|
const isWalletPay = computed(() => {
|
|
return walletPay.includes(payType.value)
|
|
return walletPay.includes(payType.value)
|
|
@@ -102,15 +124,16 @@ const balanceNotEnough = computed(() => {
|
|
const payTypeChange = (val) => {
|
|
const payTypeChange = (val) => {
|
|
payType.value = val
|
|
payType.value = val
|
|
emit('payTypeChange', val, balanceNotEnough)
|
|
emit('payTypeChange', val, balanceNotEnough)
|
|
- if (val !== '余额') {
|
|
|
|
- setTimeout(() => { payCodeUrl.value = '测试测试测试测试测试测试测试测试' }, 2000)
|
|
|
|
- }
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const initPayQrCode = () => { // 生成二维码内容
|
|
|
|
+ setTimeout(() => { payQrCodeTet.value = '测试测试测试测试测试测试测试测试' }, 2000)
|
|
}
|
|
}
|
|
|
|
|
|
const paySubmit = () => {
|
|
const paySubmit = () => {
|
|
emit('paySubmit', payType.value)
|
|
emit('paySubmit', payType.value)
|
|
}
|
|
}
|
|
-// payTypeChange('余额')
|
|
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.font-size-30 { font-size: 30px; }
|
|
.font-size-30 { font-size: 30px; }
|