account-type-select.vue 4.3 KB

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