183 lines
4.3 KiB
Vue
183 lines
4.3 KiB
Vue
<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">
|
||
<text class="text-gray text-32" v-if="type == 1">注:请与当前登录微信信息一致</text>
|
||
<text class="text-gray text-32 mt-24">{{type == 0 ? '支付宝账号' : '微信账号'}}</text>
|
||
<view class="input-view">
|
||
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信'}账号`" border="surround" v-model="account" :customStyle="inputCss"></up-input>
|
||
</view>
|
||
<text class="text-gray text-32 mt-48">{{type == 0 ? '支付宝姓名' : '微信姓名'}}</text>
|
||
<view class="input-view">
|
||
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信真实'}姓名`" border="surround" v-model="name" :customStyle="inputCss"></up-input>
|
||
</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 {
|
||
components: { Header, TopSafe,MyBtn,AccountItem },
|
||
data() {
|
||
return {
|
||
topText:'',
|
||
type:0,
|
||
account:'',
|
||
name:'',
|
||
wxCode:'',
|
||
inputCss: {
|
||
"height": '80rpx',
|
||
"background": "#F3F3F3FF",
|
||
"border-radius": "30rpx",
|
||
"border": "0rpx",
|
||
"padding-left": "12rpx",
|
||
},
|
||
};
|
||
},
|
||
onLoad(option) {
|
||
if(option && option.type){
|
||
this.type = Number(option.type);
|
||
this.init();
|
||
}
|
||
},
|
||
methods: {
|
||
init() {
|
||
if(this.type == 0 ){
|
||
this.topText = '绑定支付宝账户';
|
||
}else if(this.type == 1){
|
||
this.topText = '绑定微信账户';
|
||
}
|
||
},
|
||
setBindWithdraw(){
|
||
if(!this.account){
|
||
this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: '账户不可为空',
|
||
});
|
||
return;
|
||
}
|
||
if(!this.name){
|
||
this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: '名字不可为空',
|
||
});
|
||
return;
|
||
}
|
||
let params = {
|
||
platform:this.type + 1,
|
||
accountNumber:this.account,
|
||
accountName:this.name
|
||
}
|
||
if(this.type == 1){
|
||
params['code'] = this.wxCode;
|
||
}
|
||
console.log('wxCode',params)
|
||
bindWithdraw(params).then(res=>{
|
||
if (res.bizcode === 100) {
|
||
this.$refs.uToastRef.show({
|
||
type: 'success',
|
||
message: '绑定成功',
|
||
});
|
||
this.account = '';
|
||
this.name = '';
|
||
setTimeout(()=>{
|
||
uni.navigateBack();
|
||
},1000)
|
||
} else {
|
||
this.$refs.uToastRef.show({
|
||
type: 'error',
|
||
message: res.msg,
|
||
});
|
||
return null;
|
||
}
|
||
})
|
||
},
|
||
onAdd(){
|
||
if(this.type == 1){
|
||
let _this = this;
|
||
uni.login({
|
||
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);
|
||
}
|
||
});
|
||
}else{
|
||
this.setBindWithdraw();
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.bottom-btn{
|
||
width: 100%;
|
||
margin-bottom:92rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
padding: 0 32rpx;
|
||
box-sizing: border-box;
|
||
position: relative;
|
||
|
||
}
|
||
.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;
|
||
.mid-view{
|
||
width:100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-y: auto;
|
||
box-sizing: border-box;
|
||
background-color: #fff;
|
||
border-radius: 16rpx;
|
||
padding: 48rpx 32rpx;
|
||
margin-top:24rpx;
|
||
.input-view{
|
||
width:100%;
|
||
height:100rpx;
|
||
background-color: #f5f5f5;
|
||
border-radius: 20rpx;
|
||
margin-top:32rpx;
|
||
display: flex;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
</style>
|