|
@@ -6,11 +6,11 @@
|
|
|
<div
|
|
<div
|
|
|
class="box"
|
|
class="box"
|
|
|
v-if="userInfo && userInfo.userMultipleChains && userInfo.userMultipleChains.length > 0">
|
|
v-if="userInfo && userInfo.userMultipleChains && userInfo.userMultipleChains.length > 0">
|
|
|
- <van-radio-group v-model="userInfo.chainCode" @change="chainChange">
|
|
|
|
|
|
|
+ <van-radio-group v-model="selectedChainIndex" @change="chainChange">
|
|
|
<van-radio
|
|
<van-radio
|
|
|
- v-for="value in userInfo.userMultipleChains"
|
|
|
|
|
- :key="value.chainCode"
|
|
|
|
|
- :name="value.chainCode">
|
|
|
|
|
|
|
+ v-for="(value, index) in userInfo.userMultipleChains"
|
|
|
|
|
+ :key="`${value.chainCode}-${index}`"
|
|
|
|
|
+ :name="index">
|
|
|
{{ value.chainName }}
|
|
{{ value.chainName }}
|
|
|
</van-radio>
|
|
</van-radio>
|
|
|
</van-radio-group>
|
|
</van-radio-group>
|
|
@@ -31,13 +31,32 @@ export default {
|
|
|
}),
|
|
}),
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
- return {};
|
|
|
|
|
|
|
+ return {
|
|
|
|
|
+ selectedChainIndex: null,
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ 'userInfo.userMultipleChains'(val) {
|
|
|
|
|
+ this.initSelectedChain(val);
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ this.initSelectedChain(this.userInfo && this.userInfo.userMultipleChains);
|
|
|
},
|
|
},
|
|
|
- created() {},
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
- chainChange(value) {
|
|
|
|
|
|
|
+ initSelectedChain(val) {
|
|
|
|
|
+ if (val && val.length > 0) {
|
|
|
|
|
+ const currentIndex = val.findIndex((item) => item.check);
|
|
|
|
|
+ this.selectedChainIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ chainChange(index) {
|
|
|
|
|
+ const chain = this.userInfo.userMultipleChains[index];
|
|
|
|
|
+ if (!chain) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
this.toastLoading(0, '切换中,请稍候...', true);
|
|
this.toastLoading(0, '切换中,请稍候...', true);
|
|
|
- switchChainIdentity({ chainCode: value }).then((res) => {
|
|
|
|
|
|
|
+ switchChainIdentity({ userMultipleChainId: chain.multipleChainId }).then((res) => {
|
|
|
this.toastLoading().clear();
|
|
this.toastLoading().clear();
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
store.dispatch('getUserInfo').then(() => {
|
|
store.dispatch('getUserInfo').then(() => {
|