pay-type-pop.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <u-popup :show="show" @close="close" closeOnClickOverlay round="20rpx" closeable v-if="showType=='popup'">
  3. <view class="pop_cont">
  4. <view class="center bold">支付方式</view>
  5. <view class="column mt30">
  6. <view class="pay_item align-center" v-for="(item,index) in pay_list" :key="index"
  7. @click="emits('update:payment_type',item.type)">
  8. <view class="align-center flex-1">
  9. <u--image showLoading :src="item.cover" width="54rpx" height="54rpx" lazy-load></u--image>
  10. <text class="ml20">{{item.name}}</text>
  11. </view>
  12. <view :class="payment_type==item.type?['radio','radio_act']:['radio']">
  13. <u-icon name="checkmark" color="#fff"></u-icon>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="mtb30">
  18. <u-button type="primary" @click="onConfirm" shape="circle" color="linear-gradient(
  19. 102deg, #F1AE73 0%, #EC5232 100%)">立即支付</u-button>
  20. </view>
  21. </view>
  22. </u-popup>
  23. <view class="pop_cont" v-else>
  24. <view class="bold">支付方式</view>
  25. <view class="column mt30">
  26. <view class="pay_item align-center" v-for="(item,index) in pay_list" :key="index"
  27. @click="emits('update:payment_type',item.name)">
  28. <view class="align-center flex-1">
  29. <u--image showLoading :src="item.cover" width="54rpx" height="54rpx" lazy-load></u--image>
  30. <text class="ml20 ">{{item.name}}</text>
  31. </view>
  32. <view :class="payment_type==item.type?['radio','radio_act']:['radio']">
  33. <u-icon name="checkmark" color="#fff"></u-icon>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import {
  41. onMounted,
  42. ref,
  43. watchEffect,
  44. } from "vue";
  45. import {
  46. checkLogin
  47. } from "@/core/app";
  48. import {
  49. useRequestPayment
  50. } from '@/hooks/useRequestPayment/useRequestPayment.js'
  51. name: "pay-type-pop"
  52. const emits = defineEmits(['update:show', 'update:payment_type', 'confirm', 'close'])
  53. const props = defineProps({
  54. show: {
  55. type: Boolean,
  56. default: false
  57. },
  58. payment_type: {
  59. type: String,
  60. default: 'wxpay',
  61. },
  62. showType: {
  63. type: String,
  64. default: 'popup', //popup:弹出框 cell:显示到页面
  65. },
  66. showPayList: { //支付列表
  67. type: Array,
  68. default: () => ['wxpay']
  69. },
  70. userMoney: {
  71. type: String,
  72. default: '0',
  73. }
  74. })
  75. const pay_list = ref([])
  76. const {
  77. getPayItem,
  78. getPayListData
  79. } = useRequestPayment()
  80. onMounted(async () => {
  81. pay_list.value = await getPayListData()
  82. pay_list.value = pay_list.value.filter(item => {
  83. if (item.type == 'wechat_applet') item.type = 'wxpay'
  84. if (props.showPayList.includes(item.type)) return item
  85. })
  86. let balanceData = pay_list.value.find(item => item.type == 'balance')
  87. if (!balanceData) return
  88. if (props.userMoney) {
  89. balanceData.label = `余额(${props.userMoney})`
  90. } else {
  91. let userInfo = uni.getStorageSync('userInfo-qianyue')
  92. if (userInfo && props.showPayList.includes('balance')) {
  93. balanceData.label = `余额(${userInfo.money})`
  94. }
  95. }
  96. })
  97. // 关闭pop
  98. const close = () => {
  99. emits('close', false)
  100. }
  101. const onConfirm = () => {
  102. emits('confirm', props.payment_type)
  103. }
  104. </script>
  105. <style lang="scss">
  106. .pop_cont {
  107. width: calc(100% - 60rpx);
  108. padding: 30rpx;
  109. .pay_item {
  110. padding: 20rpx;
  111. }
  112. .radio {
  113. display: flex;
  114. align-items: center;
  115. flex-direction: column;
  116. justify-content: center;
  117. width: 40rpx;
  118. height: 40rpx;
  119. border-radius: 50%;
  120. border: 1rpx solid #b5b5b5;
  121. transition: .2s;
  122. background: #b5b5b5;
  123. }
  124. .radio_act {
  125. background: #EB6446;
  126. border: 1rpx solid rgba(0, 0, 0, 0);
  127. }
  128. }
  129. </style>