1. extract common onShow login check to dedicated method redirectTologinOnShowLifecycle 2. add fallback callback for login failure to navigate back on wechat mini program 3. update all page login redirect calls to use the new unified method 4. add debug logs for redirect and auth flow tracing
451 lines
10 KiB
Vue
451 lines
10 KiB
Vue
<template>
|
|
<view :style="themeColor">
|
|
<mescroll-uni ref="mescroll" @getData="getData" v-if="storeToken">
|
|
<block slot="list">
|
|
<view class="nc-info-list-content">
|
|
<view class="list-item balance-item" @click="setBalanceDefault()"
|
|
v-if="type == 'fenxiao' && payList && payList.balance">
|
|
<view class="item-top">
|
|
<view class="item-left">
|
|
<view class="title-text">{{ $lang('withdrawToBalance') }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<block v-if="dataList.length > 0">
|
|
<view class="list-item" v-for="(item, index) in dataList" :key="index">
|
|
<view class="item-top">
|
|
<view class="item-left">
|
|
<view class="title-text">{{ item.withdraw_type_name }}</view>
|
|
<view class="info-content">
|
|
<text class="top-title">{{ item.realname }}</text>
|
|
<text class="top-num">{{ item.mobile }}</text>
|
|
</view>
|
|
<view class="content-bottom">
|
|
<block v-if="item.withdraw_type == 'alipay'">
|
|
{{ $lang('withdrawalAccountLabel', { account: item.bank_account }) }}
|
|
</block>
|
|
<block v-if="item.withdraw_type == 'bank'">
|
|
{{ $lang('bankNameLabel', { bankName: item.branch_bank_name }) }}
|
|
</block>
|
|
</view>
|
|
</view>
|
|
<view class="item-btn" @click.stop="editAccount('edit', item.id)">{{ $lang('update') }}</view>
|
|
</view>
|
|
|
|
<view class="item-bottom">
|
|
<view class="account-default" @click="setDefault(item.id, item.is_default)">
|
|
<text class="default">{{ $lang('setAsDefault') }}</text>
|
|
<switch v-if="item.is_default == 1" checked disabled style="transform:scale(0.7)"
|
|
:color="themeStyle.main_color" />
|
|
<switch v-else style="transform:scale(0.7)" :color="themeStyle.main_color" />
|
|
</view>
|
|
<view class="account-btn">
|
|
<text class="delete" v-if="item.is_default != 1" @click="deleteAccount(item.id)">
|
|
<text class="iconfont iconicon7"></text>
|
|
</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</block>
|
|
</view>
|
|
<view
|
|
v-if="dataList.length <= 0 && (type != 'fenxiao' || (type == 'fenxiao' && payList && !payList.balance))"
|
|
class="empty-box">
|
|
<image :src="$util.img('public/uniapp/member/account/empty.png')" mode="widthFix" show-menu-by-longpress></image>
|
|
<view class="tips">{{ $lang('emptyTip') }}</view>
|
|
<button type="primary" class="add-account" @click="editAccount('add')">{{ $lang('newAddAccount')
|
|
}}</button>
|
|
</view>
|
|
</block>
|
|
</mescroll-uni>
|
|
<view class="btn-add" v-if="dataList.length > 0 || (type == 'fenxiao' && payList && payList.balance)">
|
|
<button class="add-account" type="primary" @click="editAccount('add')">{{ $lang('newAddAccount') }}</button>
|
|
</view>
|
|
<loading-cover ref="loadingCover"></loading-cover>
|
|
<ns-login ref="login"></ns-login>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
dataList: [], //账号列表
|
|
back: '', // 返回页
|
|
redirect: 'redirectTo', // 跳转方式
|
|
type: 'member',
|
|
payList: null
|
|
};
|
|
},
|
|
onLoad(option) {
|
|
if (option.back) this.back = option.back;
|
|
if (option.type) this.type = option.type;
|
|
if (option.redirect) this.redirect = option.redirect;
|
|
},
|
|
onShow() {
|
|
if (!this.storeToken) {
|
|
this.redirectTologinOnShowLifecycle('/pages_tool/member/account');
|
|
return;
|
|
}
|
|
this.getTransferType();
|
|
if (this.$refs.mescroll) this.$refs.mescroll.refresh();
|
|
},
|
|
methods: {
|
|
// 编辑提现账户信息
|
|
editAccount(type, id) {
|
|
let data = {};
|
|
data.type = this.type;
|
|
if (type == 'edit') data.id = id;
|
|
if (this.back) data.back = this.back;
|
|
this.$util.redirectTo('/pages_tool/member/account_edit', data);
|
|
},
|
|
deleteAccount(id) {
|
|
uni.showModal({
|
|
title: this.$lang('operationTip'),
|
|
content: this.$lang('confirmDeleteAccount'),
|
|
success: res => {
|
|
if (res.confirm) {
|
|
this.$api.sendRequest({
|
|
url: '/api/memberbankaccount/delete',
|
|
data: {
|
|
id: id
|
|
},
|
|
success: result => {
|
|
if (result.code == 0) {
|
|
this.$util.showToast({
|
|
title: this.$lang('deleteSuccess')
|
|
});
|
|
this.$refs.mescroll.refresh();
|
|
} else {
|
|
this.$util.showToast({
|
|
title: this.$lang('deleteFailed')
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
setDefault(id, is_default) {
|
|
if (is_default == 1) return;
|
|
this.$api.sendRequest({
|
|
url: '/api/memberbankaccount/setdefault',
|
|
data: {
|
|
id
|
|
},
|
|
success: res => {
|
|
if (res.data >= 0) {
|
|
if (this.back != '') {
|
|
this.$util.redirectTo(this.back, {}, this.redirect);
|
|
} else {
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.show();
|
|
this.dataList = [];
|
|
this.$refs.mescroll.refresh();
|
|
}
|
|
} else {
|
|
this.$util.showToast({
|
|
title: res.message
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
setBalanceDefault() {
|
|
this.$util.redirectTo(this.back, {
|
|
'is_balance': 1
|
|
}, this.redirect);
|
|
},
|
|
getData(mescroll) {
|
|
this.$api.sendRequest({
|
|
url: '/api/memberbankaccount/page',
|
|
data: {
|
|
page_size: mescroll.size,
|
|
page: mescroll.num
|
|
},
|
|
success: res => {
|
|
let newArr = [];
|
|
let msg = res.message;
|
|
if (res.code == 0 && res.data) {
|
|
newArr = res.data.list;
|
|
} else {
|
|
this.$util.showToast({
|
|
title: msg
|
|
});
|
|
}
|
|
mescroll.endSuccess(newArr.length);
|
|
//设置列表数据
|
|
if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
|
|
this.dataList = this.dataList.concat(newArr); //追加新数据
|
|
|
|
let withdrawType = {
|
|
bank: this.$lang('withdrawTypeBank'),
|
|
alipay: this.$lang('withdrawTypeAlipay'),
|
|
wechatpay: this.$lang('withdrawTypeWechat')
|
|
};
|
|
|
|
this.dataList.forEach(item => {
|
|
item.withdraw_type_name = withdrawType[item.withdraw_type] ? withdrawType[
|
|
item.withdraw_type] : '';
|
|
});
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
},
|
|
fail: res => {
|
|
mescroll.endErr();
|
|
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
|
}
|
|
});
|
|
},
|
|
getTransferType() {
|
|
let url = this.type == "member" ? "/api/memberwithdraw/transferType" :
|
|
"/fenxiao/api/withdraw/transferType";
|
|
this.$api.sendRequest({
|
|
url: url,
|
|
success: res => {
|
|
if (res.code >= 0 && res.data) {
|
|
this.payList = res.data;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
watch: {
|
|
storeToken: function (nVal, oVal) {
|
|
if (nVal) {
|
|
this.$refs.mescroll.refresh();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.empty-box {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
image {
|
|
width: 50%;
|
|
}
|
|
|
|
.tips {
|
|
color: #999999;
|
|
font-size: 26rpx;
|
|
}
|
|
|
|
.get-account,
|
|
.add-account {
|
|
width: 50%;
|
|
height: 78rpx;
|
|
line-height: 78rpx;
|
|
border-radius: 78rpx;
|
|
margin-top: 50rpx;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.get-account {
|
|
width: 50%;
|
|
background: #fff;
|
|
color: $base-color;
|
|
border: 2rpx solid $base-color;
|
|
margin-top: 20rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
}
|
|
|
|
.mescroll-downwarp+.empty-box {
|
|
height: calc(100vh - 260rpx);
|
|
}
|
|
|
|
|
|
.btn-add {
|
|
margin-top: 60rpx;
|
|
bottom: 0;
|
|
width: 100%;
|
|
background: #fff;
|
|
position: fixed;
|
|
padding: 0 30rpx;
|
|
box-sizing: border-box;
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
z-index: 10;
|
|
|
|
.add-account {
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
border-radius: 80rpx;
|
|
margin: 30rpx 0 30rpx;
|
|
font-size: $font-size-toolbar;
|
|
|
|
text {
|
|
margin-right: 10rpx;
|
|
font-size: $font-size-base;
|
|
}
|
|
}
|
|
}
|
|
|
|
.zw {
|
|
margin-top: 250rpx;
|
|
}
|
|
|
|
.list-item {
|
|
margin: 0 0;
|
|
padding: 24rpx $margin-both;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background-color: #fff;
|
|
margin-bottom: 18rpx;
|
|
border-radius: 10rpx;
|
|
overflow: hidden;
|
|
position: relative;
|
|
|
|
&.balance-item {
|
|
.item-top {
|
|
border: none;
|
|
padding: 0;
|
|
}
|
|
}
|
|
|
|
&:first-child {
|
|
margin-top: 18rpx;
|
|
}
|
|
|
|
.item-mr {
|
|
font-size: $font-size-activity-tag;
|
|
color: #fff;
|
|
height: 150rpx;
|
|
width: 150rpx;
|
|
display: flex;
|
|
align-items: flex-end;
|
|
justify-content: center;
|
|
position: absolute;
|
|
right: -90rpx;
|
|
top: -90rpx;
|
|
transform: rotate(45deg);
|
|
}
|
|
|
|
.item-top {
|
|
border-bottom: 2rpx solid $color-line;
|
|
padding-bottom: 26rpx;
|
|
display: flex;
|
|
flex-direction: row;
|
|
|
|
.item-left {
|
|
display: flex;
|
|
flex-direction: column;
|
|
width: calc(100% - 100rpx);
|
|
|
|
.title-text {
|
|
font-size: 30rpx;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.info-content {
|
|
display: flex;
|
|
|
|
.top-title {
|
|
font-size: 26rpx;
|
|
margin-right: 15rpx;
|
|
}
|
|
|
|
.top-num {
|
|
font-size: 26rpx;
|
|
}
|
|
}
|
|
|
|
.content-bottom {
|
|
font-size: 26rpx;
|
|
height: 50rpx;
|
|
}
|
|
}
|
|
|
|
.item-btn {
|
|
width: 100rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
color: #999;
|
|
font-size: 24rpx;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
}
|
|
|
|
.item-bottom {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding-top: 24rpx;
|
|
|
|
.account-default {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 24rpx;
|
|
line-height: 1;
|
|
color: #666666;
|
|
|
|
.default {}
|
|
|
|
.iconfont {
|
|
line-height: 1;
|
|
}
|
|
}
|
|
|
|
.account-btn {
|
|
font-size: $font-size-base;
|
|
line-height: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
|
|
.edit {
|
|
text {
|
|
vertical-align: center;
|
|
margin-right: 10rpx;
|
|
font-size: 30rpx;
|
|
}
|
|
}
|
|
|
|
.delete {
|
|
background: #F1F1F1;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border-radius: 50%;
|
|
padding: 10rpx;
|
|
text-align: center;
|
|
width: 48rpx;
|
|
height: 48rpx;
|
|
box-sizing: border-box;
|
|
|
|
text {
|
|
font-size: 26rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
<style lang="scss">
|
|
::v-deep .mescroll-upwarp {
|
|
padding-bottom: 150rpx;
|
|
}
|
|
</style>
|
|
<style>
|
|
.item-bottom>>>.uni-switch-wrapper .uni-switch-input {
|
|
height: 48rpx !important;
|
|
width: 88rpx !important;
|
|
}
|
|
|
|
.item-bottom>>>.uni-switch-wrapper .uni-switch-input:after {
|
|
height: 44rpx !important;
|
|
width: 44rpx !important;
|
|
}
|
|
|
|
.item-bottom>>>.uni-switch-wrapper .uni-switch-input:before {
|
|
background-color: #EDEDED !important;
|
|
height: 44rpx !important;
|
|
width: 90rpx !important;
|
|
}
|
|
</style> |