feat(withdraw): 后台支持提现总开关与方式过滤并升级钱包与提现页面体验
这个提交包含在:
@@ -5,10 +5,10 @@
|
||||
<text class="modal-title ss-m-b-20">选择提现方式</text>
|
||||
</view>
|
||||
<view class="modal-content ss-flex-1 ss-p-b-100">
|
||||
<radio-group @change="onChange">
|
||||
<radio-group @change="onChange" v-if="filteredTypeList.length > 0">
|
||||
<label
|
||||
class="container-list ss-p-l-34 ss-p-r-24 ss-flex ss-col-center ss-row-center"
|
||||
v-for="(item, index) in typeList"
|
||||
v-for="(item, index) in filteredTypeList"
|
||||
:key="index"
|
||||
>
|
||||
<view class="container-icon ss-flex ss-m-r-20">
|
||||
@@ -20,10 +20,12 @@
|
||||
:value="item.value"
|
||||
color="var(--ui-BG-Main)"
|
||||
:checked="item.value === state.currentValue"
|
||||
:disabled="!methods.includes(item.value)"
|
||||
/>
|
||||
</label>
|
||||
</radio-group>
|
||||
<view v-else class="empty-tip ss-p-40 ss-text-center" style="padding: 40rpx; text-align: center; color: #999; font-size: 26rpx;">
|
||||
暂无可用的提现方式
|
||||
</view>
|
||||
</view>
|
||||
<view class="modal-footer ss-flex ss-row-center ss-col-center">
|
||||
<button class="ss-reset-button save-btn" @tap="onConfirm">确定</button>
|
||||
@@ -33,7 +35,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, onBeforeMount, nextTick } from 'vue';
|
||||
import { reactive, onBeforeMount, computed, watch } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -47,7 +49,7 @@
|
||||
},
|
||||
methods: {
|
||||
type: Array,
|
||||
default: [],
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
const emits = defineEmits(['update:modelValue', 'change', 'close']);
|
||||
@@ -71,23 +73,89 @@
|
||||
value: 'bank',
|
||||
},
|
||||
];
|
||||
|
||||
// 仅展示后台已开启的提现方式(后台关闭的在此彻底隐藏)
|
||||
const filteredTypeList = computed(() => {
|
||||
if (!Array.isArray(props.methods) || props.methods.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return typeList.filter((item) => props.methods.includes(item.value));
|
||||
});
|
||||
|
||||
function syncCurrentValue() {
|
||||
const validMethods = Array.isArray(props.methods) ? props.methods : [];
|
||||
// 1. 若当前已选中的值在后台开启的列表中,优先保留
|
||||
if (props.modelValue?.type && validMethods.includes(props.modelValue.type)) {
|
||||
state.currentValue = props.modelValue.type;
|
||||
return;
|
||||
}
|
||||
// 2. 若 state.currentValue 仍属于有效开启列表,保留
|
||||
if (state.currentValue && validMethods.includes(state.currentValue)) {
|
||||
return;
|
||||
}
|
||||
// 3. 若仅有 1 种开启的提现方式,默认选中
|
||||
if (validMethods.length === 1) {
|
||||
state.currentValue = validMethods[0];
|
||||
return;
|
||||
}
|
||||
// 4. 若开启了多种但未选择或选择已失效,且开启列表非空,默认选择首项
|
||||
if (validMethods.length > 0 && !validMethods.includes(state.currentValue)) {
|
||||
state.currentValue = validMethods[0];
|
||||
return;
|
||||
}
|
||||
state.currentValue = '';
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.methods,
|
||||
() => {
|
||||
syncCurrentValue();
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
syncCurrentValue();
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.show,
|
||||
(val) => {
|
||||
if (val) {
|
||||
syncCurrentValue();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const getWalletAccountInfo = async () => {
|
||||
if (!state.currentValue) return;
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let res = await sheep.$api.user.account.info({
|
||||
type: state.currentValue,
|
||||
});
|
||||
if (res.code === 1) {
|
||||
if (!props.methods.includes(res.data.type)) {
|
||||
return;
|
||||
}
|
||||
state.currentValue = res.data.type;
|
||||
emits('update:modelValue', {
|
||||
type: res.data.type,
|
||||
account_header: res.data.account_header,
|
||||
account_name: res.data.account_name,
|
||||
account_no: res.data.account_no,
|
||||
try {
|
||||
let res = await sheep.$api.user.account.info({
|
||||
type: state.currentValue,
|
||||
});
|
||||
} else {
|
||||
if (res.code === 1) {
|
||||
if (!props.methods.includes(res.data.type)) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
state.currentValue = res.data.type;
|
||||
emits('update:modelValue', {
|
||||
type: res.data.type,
|
||||
account_header: res.data.account_header,
|
||||
account_name: res.data.account_name,
|
||||
account_no: res.data.account_no,
|
||||
});
|
||||
} else {
|
||||
emits('update:modelValue', {
|
||||
type: state.currentValue,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
emits('update:modelValue', {
|
||||
type: state.currentValue,
|
||||
});
|
||||
@@ -105,6 +173,10 @@
|
||||
sheep.$helper.toast('请选择提现方式');
|
||||
return;
|
||||
}
|
||||
if (!props.methods.includes(state.currentValue)) {
|
||||
sheep.$helper.toast('该提现方式暂未开启');
|
||||
return;
|
||||
}
|
||||
await getWalletAccountInfo();
|
||||
emits('close');
|
||||
};
|
||||
@@ -114,7 +186,10 @@
|
||||
};
|
||||
|
||||
onBeforeMount(async () => {
|
||||
await getWalletAccountInfo();
|
||||
syncCurrentValue();
|
||||
if (state.currentValue) {
|
||||
await getWalletAccountInfo();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户