Files

192 lines
4.4 KiB
Vue
Raw Permalink Normal View History

2025-12-16 09:13:48 +08:00
<template>
<view class="content">
<TopSafe bgColor="rgba(0,0,0,0)"></TopSafe>
<Header :title="topText" bgColor="rgba(0,0,0,0)" />
<view class="setting-view">
<view class="mid-view">
2026-05-22 11:03:04 +08:00
<text class="text-gray text-32" v-if="type == 1">注:请与当前登录微信信息一致</text>
2026-07-31 10:55:02 +08:00
<text class="text-gray text-32 mt-24">{{ type == 0 ? '支付宝账号' : '微信账号' }}</text>
2025-12-16 09:13:48 +08:00
<view class="input-view">
2026-07-31 10:55:02 +08:00
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信'}账号`" border="surround" v-model="account"
:customStyle="inputCss"></up-input>
2025-12-16 09:13:48 +08:00
</view>
2026-07-31 10:55:02 +08:00
<text class="text-gray text-32 mt-48">{{ type == 0 ? '支付宝姓名' : '微信姓名' }}</text>
2025-12-16 09:13:48 +08:00
<view class="input-view">
2026-07-31 10:55:02 +08:00
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信真实'}姓名`" border="surround" v-model="name"
:customStyle="inputCss"></up-input>
2025-12-16 09:13:48 +08:00
</view>
</view>
</view>
<view class="bottom-btn">
<MyBtn text="添加" @ok="onAdd"></MyBtn>
</view>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
import { bindWithdraw } from '@/api/common.js';
import Header from '@/components/common/header.vue';
import { clear } from '@/utils/auth.js';
import TopSafe from '@/components/common/top-safe.nvue'
import MyBtn from '@/components/common/my-btn.vue'
import func from '@/utils/func.js';
import AccountItem from './components/account-item.vue'
export default {
2026-07-31 10:55:02 +08:00
components: { Header, TopSafe, MyBtn, AccountItem },
2025-12-16 09:13:48 +08:00
data() {
return {
2026-07-31 10:55:02 +08:00
topText: '',
type: 0,
account: '',
name: '',
wxCode: '',
2025-12-16 09:13:48 +08:00
inputCss: {
"height": '80rpx',
"background": "#F3F3F3FF",
"border-radius": "30rpx",
"border": "0rpx",
"padding-left": "12rpx",
},
};
},
onLoad(option) {
2026-07-31 10:55:02 +08:00
if (option && option.type) {
2025-12-16 09:13:48 +08:00
this.type = Number(option.type);
this.init();
}
},
methods: {
init() {
2026-07-31 10:55:02 +08:00
if (this.type == 0) {
2025-12-16 09:13:48 +08:00
this.topText = '绑定支付宝账户';
2026-07-31 10:55:02 +08:00
} else if (this.type == 1) {
2025-12-16 09:13:48 +08:00
this.topText = '绑定微信账户';
}
},
2026-07-31 10:55:02 +08:00
setBindWithdraw() {
if (!this.account) {
2025-12-16 09:13:48 +08:00
this.$refs.uToastRef.show({
type: 'error',
message: '账户不可为空',
});
return;
}
2026-07-31 10:55:02 +08:00
if (!this.name) {
2025-12-16 09:13:48 +08:00
this.$refs.uToastRef.show({
type: 'error',
message: '名字不可为空',
});
return;
}
let params = {
2026-07-31 10:55:02 +08:00
platform: this.type + 1,
accountNumber: this.account,
accountName: this.name
2025-12-16 09:13:48 +08:00
}
2026-07-31 10:55:02 +08:00
if (this.type == 1) {
2025-12-16 09:13:48 +08:00
params['code'] = this.wxCode;
}
2026-07-31 10:55:02 +08:00
// #ifdef MP-WEIXIN
params.platform = 3;
// #endif
console.log('wxCode', params)
bindWithdraw(params).then(res => {
2025-12-16 09:13:48 +08:00
if (res.bizcode === 100) {
this.$refs.uToastRef.show({
type: 'success',
message: '绑定成功',
});
this.account = '';
this.name = '';
2026-07-31 10:55:02 +08:00
setTimeout(() => {
2025-12-16 09:13:48 +08:00
uni.navigateBack();
2026-07-31 10:55:02 +08:00
}, 1000)
2025-12-16 09:13:48 +08:00
} else {
this.$refs.uToastRef.show({
type: 'error',
message: res.msg,
});
return null;
}
})
},
2026-07-31 10:55:02 +08:00
onAdd() {
if (this.type == 1) {
2025-12-16 09:13:48 +08:00
let _this = this;
uni.login({
2026-07-31 10:55:02 +08:00
provider: 'weixin',
onlyAuthorize: true,
success: function (loginRes) {
_this.wxCode = loginRes.code;
console.log('aaaaa', loginRes.code)
console.log('bbbb', loginRes)
_this.setBindWithdraw();
},
fail: (err) => {
console.log('login', err);
}
2025-12-16 09:13:48 +08:00
});
2026-07-31 10:55:02 +08:00
} else {
2025-12-16 09:13:48 +08:00
this.setBindWithdraw();
}
2026-07-31 10:55:02 +08:00
2025-12-16 09:13:48 +08:00
}
}
}
</script>
<style lang="scss" scoped>
2026-07-31 10:55:02 +08:00
.bottom-btn {
2025-12-16 09:13:48 +08:00
width: 100%;
2026-07-31 10:55:02 +08:00
margin-bottom: 92rpx;
2025-12-16 09:13:48 +08:00
display: flex;
flex-direction: column;
align-items: center;
padding: 0 32rpx;
box-sizing: border-box;
position: relative;
2026-07-31 10:55:02 +08:00
2025-12-16 09:13:48 +08:00
}
2026-07-31 10:55:02 +08:00
2025-12-16 09:13:48 +08:00
.setting-view {
width: 100%;
height: calc(100% - 88rpx - 92rpx - 88rpx - var(--status-bar-height));
display: flex;
flex-direction: column;
align-items: center;
overflow-y: auto;
padding: 0 32rpx;
box-sizing: border-box;
position: relative;
2026-07-31 10:55:02 +08:00
.mid-view {
width: 100%;
2025-12-16 09:13:48 +08:00
display: flex;
flex-direction: column;
overflow-y: auto;
box-sizing: border-box;
background-color: #fff;
border-radius: 16rpx;
padding: 48rpx 32rpx;
2026-07-31 10:55:02 +08:00
margin-top: 24rpx;
.input-view {
width: 100%;
height: 100rpx;
2025-12-16 09:13:48 +08:00
background-color: #f5f5f5;
border-radius: 20rpx;
2026-07-31 10:55:02 +08:00
margin-top: 32rpx;
2025-12-16 09:13:48 +08:00
display: flex;
flex-direction: row;
align-items: center;
2026-07-31 10:55:02 +08:00
2025-12-16 09:13:48 +08:00
}
}
2026-07-31 10:55:02 +08:00
2025-12-16 09:13:48 +08:00
}
</style>