account-type-select.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <su-popup :show="show" class="ss-checkout-counter-wrap" @close="hideModal">
  3. <view class="ss-modal-box bg-white ss-flex-col">
  4. <view class="modal-header ss-flex-col ss-col-left">
  5. <text class="modal-title ss-m-b-20">选择提现方式</text>
  6. </view>
  7. <view class="modal-content ss-flex-1 ss-p-b-100">
  8. <radio-group @change="onChange">
  9. <label
  10. class="container-list ss-p-l-34 ss-p-r-24 ss-flex ss-col-center ss-row-center"
  11. v-for="(item, index) in typeList"
  12. :key="index"
  13. >
  14. <view class="container-icon ss-flex ss-m-r-20">
  15. <image :src="sheep.$url.static(item.icon)" />
  16. </view>
  17. <view class="ss-flex-1">{{ item.title }}</view>
  18. <radio
  19. :value="item.value"
  20. color="var(--ui-BG-Main)"
  21. :checked="item.value === state.currentValue"
  22. :disabled="!methods.includes(item.value)"
  23. />
  24. </label>
  25. </radio-group>
  26. </view>
  27. <view class="modal-footer ss-flex ss-row-center ss-col-center">
  28. <button class="ss-reset-button save-btn" @tap="onConfirm">确定</button>
  29. </view>
  30. </view>
  31. </su-popup>
  32. </template>
  33. <script setup>
  34. import { reactive, onBeforeMount, nextTick } from 'vue';
  35. import sheep from '@/sheep';
  36. const props = defineProps({
  37. modelValue: {
  38. type: Object,
  39. default() {},
  40. },
  41. show: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. methods: {
  46. type: Array,
  47. default: [],
  48. },
  49. });
  50. const emits = defineEmits(['update:modelValue', 'change', 'close']);
  51. const state = reactive({
  52. currentValue: '',
  53. });
  54. const typeList = [
  55. {
  56. icon: '/static/img/shop/pay/wechat.png',
  57. title: '微信零钱',
  58. value: 'wechat',
  59. },
  60. {
  61. icon: '/static/img/shop/pay/alipay.png',
  62. title: '支付宝账户',
  63. value: 'alipay',
  64. },
  65. {
  66. icon: '/static/img/shop/pay/bank.png',
  67. title: '银行卡转账',
  68. value: 'bank',
  69. },
  70. ];
  71. const getWalletAccountInfo = async () => {
  72. return new Promise(async (resolve, reject) => {
  73. let res = await sheep.$api.user.account.info({
  74. type: state.currentValue,
  75. });
  76. if (res.error === 0) {
  77. if (!props.methods.includes(res.data.type)) {
  78. return;
  79. }
  80. state.currentValue = res.data.type;
  81. emits('update:modelValue', {
  82. type: res.data.type,
  83. account_header: res.data.account_header,
  84. account_name: res.data.account_name,
  85. account_no: res.data.account_no,
  86. });
  87. } else {
  88. emits('update:modelValue', {
  89. type: state.currentValue,
  90. });
  91. }
  92. resolve();
  93. });
  94. };
  95. function onChange(e) {
  96. state.currentValue = e.detail.value;
  97. }
  98. const onConfirm = async () => {
  99. if (state.currentValue === '') {
  100. sheep.$helper.toast('请选择提现方式');
  101. return;
  102. }
  103. await getWalletAccountInfo();
  104. emits('close');
  105. };
  106. const hideModal = () => {
  107. emits('close');
  108. };
  109. onBeforeMount(async () => {
  110. await getWalletAccountInfo();
  111. });
  112. </script>
  113. <style lang="scss" scoped>
  114. .ss-modal-box {
  115. border-radius: 30rpx 30rpx 0 0;
  116. max-height: 1000rpx;
  117. .modal-header {
  118. position: relative;
  119. padding: 60rpx 40rpx 40rpx;
  120. .modal-title {
  121. font-size: 32rpx;
  122. font-weight: bold;
  123. }
  124. .close-icon {
  125. position: absolute;
  126. top: 10rpx;
  127. right: 20rpx;
  128. font-size: 46rpx;
  129. opacity: 0.2;
  130. }
  131. }
  132. .modal-content {
  133. overflow-y: auto;
  134. .container-list {
  135. height: 96rpx;
  136. border-bottom: 2rpx solid rgba(#dfdfdf, 0.5);
  137. font-size: 28rpx;
  138. font-weight: 500;
  139. color: #333333;
  140. .container-icon {
  141. width: 36rpx;
  142. height: 36rpx;
  143. }
  144. }
  145. }
  146. .modal-footer {
  147. height: 120rpx;
  148. .save-btn {
  149. width: 710rpx;
  150. height: 80rpx;
  151. border-radius: 40rpx;
  152. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  153. color: $white;
  154. }
  155. }
  156. }
  157. image {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. </style>