123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <template>
- <view class="container" :class="{ show: loaded }">
- <view class="tabs dfsb">
- <view class="tab-item" :class="type == 'alipay' ? 'on' : ''" @click="setTabEvent('alipay')">支付宝</view>
- <!-- <view class="tab-item" :class="type == 'wechat' ? 'on' : ''" @click="setTabEvent('wechat')">微信</view> -->
- <view class="tab-item" :class="type == 'bank' ? 'on' : ''" @click="setTabEvent('bank')">银行卡</view>
- </view>
- <!-- 支付宝绑定 -->
- <view class="item" v-if="type == 'alipay'">
- <view class="input-item">
- <text class="input-item-title">实名姓名</text>
- <input type="text" v-model="reqData.alipay_name" placeholder="请输入收款人姓名" />
- </view>
- <view class="input-item">
- <text class="input-item-title">支付宝账号</text>
- <input type="text" v-model="reqData.alipay_num" placeholder="请输入支付宝账号" />
- </view>
- </view>
- <!-- <view v-if="type == 'alipay'" class="upload-box">
- <text class="upload-box-title">支付宝收款码</text>
- <view class="img-box" @click="choose_img_upload">
- <image :src="reqData.alipay_num.alipay_img_url || '../../static/bg/upload-icon.png'" mode="aspectFit">
- </image>
- </view>
- </view> -->
- <!-- 微信绑定 -->
- <!-- <view class="item" v-if="type == 'wechat'">
- <view class="input-item">
- <text class="input-item-title">收款人姓名</text>
- <input type="text" v-model="reqData.wechat_num.wechat_num1" placeholder="请输入收款人姓名" />
- </view>
- <view class="input-item">
- <text class="input-item-title">微信账号</text>
- <input type="text" v-model="reqData.wechat_num.wechat_num" placeholder="请输入微信账号" />
- </view>
- </view>
- <view v-if="type == 'wechat'" class="upload-box">
- <text class="upload-box-title">微信收款码</text>
- <view class="img-box" @click="choose_img_upload"><image :src="reqData.wechat_num.wechat_img_url || '../../static/bg/upload-icon.png'" mode="aspectFit"></image></view>
- </view> -->
- <!-- 银行卡绑定 -->
- <view class="item" v-if="type == 'bank'">
- <view class="input-item">
- <text class="input-item-title">姓名</text>
- <input type="text" v-model="reqData.bank_name" placeholder="请输入姓名" />
- </view>
- <view class="input-item">
- <text class="input-item-title">银行名称</text>
- <input type="text" v-model="reqData.bank_name" placeholder="例:中国工商银行" />
- </view>
- <view class="input-item">
- <text class="input-item-title">开户支行</text>
- <input type="text" v-model="reqData.open_bank" placeholder="请输入开户支行" />
- </view>
- <view class="input-item">
- <text class="input-item-title">银行卡号</text>
- <input type="number" v-model="reqData.bank_num" placeholder="请输入银行卡号" />
- </view>
- </view>
- <view class="btn-box"><u-button color="#ED742F" ref="confirmBtn" text="确认" @click="submitClickEvent"></u-button></view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- flag:'-1',
- type: 'alipay',
- loaded: false,
- reqData: {}
- };
- },
- onLoad(options) {
- this.flag=options.flag||'-1';
- this.loadData();
- this.loaded = true;
- },
- methods: {
- /**
- * 请求数据只是为了代码不那么乱
- * 分次请求未作整合
- */
- async loadData() {
- // type 类型: 1=支付宝 2=银行卡
- const res = await this.$api.request('/user_pay/payInfo',{
- type: this.type=='alipay'?1:2
- });
- if (res.code == '200') {
- this.loaded = true;
- let data = res.data;
- this.reqData = data;
- } else {
- this.$api.toast(res.msg);
- }
- },
- setTabEvent(type) {
- this.type = type;
- this.loadData();
- },
- submitClickEvent() {
- console.log(11,this.type == 'alipay');
- if (this.type == 'alipay') {
- this.saveAli();
- } else if (this.type == 'wechat') {
- this.saveWx();
- } else {
- this.saveBank();
- }
- },
- saveAli() {
- if (!this.reqData.alipay_name) {
- this.$api.toast('请输入姓名');
- return;
- }
- if (!this.reqData.alipay_num) {
- this.$api.toast('请输入支付宝账号');
- return;
- }
- this.setColletMoneyEvent(this.reqData);
- },
- saveWx() {
- let _this = this;
- if (!_this.reqData.wechat_num.wechat_num) {
- _this.$api.toast('请输入微信账号');
- return;
- }
- _this.setColletMoneyEvent(_this.reqData.wechat_num);
- },
- saveBank() {
- if (!this.reqData.bank_num) {
- this.$api.toast('请输入银行卡号');
- return;
- } else if (!this.reqData.open_bank) {
- this.$api.toast('请输入开户行名称');
- return;
- } else if (!this.reqData.bank_name) {
- this.$api.toast('请输入姓名');
- // return;
- // }else if (!this.reqData.bank_sub) {
- // this.$api.toast('请输入支行名称');
- return;
- }
- this.setColletMoneyEvent(this.reqData);
- },
- async setColletMoneyEvent(data) {
- let num = this.type == 'alipay' ? 1 : 2; // 2:银行卡 1:支付宝
- const res = await this.$api.request('/user_pay/setPay', {
- type: num,
- ...data
- });
- if (res.code == '200') {
- this.$api.toast(res.msg);
- setTimeout(() => {
- uni.navigateBack();
- }, 800);
- } else {
- this.$api.toast(res.msg);
- }
- },
- }
- };
- </script>
- <style>
- page {
- background-color: #f5f5f5;
- }
- </style>
- <style lang="scss" scoped>
- .container {
- width: 100%;
- height: auto;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding-top: 20rpx;
- opacity: 0;
- transition: opacity 0.2s;
- &.show {
- opacity: 1;
- }
- .tabs {
- width: 100%;
- height: 100rpx;
-
- background-color: #ffffff;
- .tab-item {
- flex: 1;
- height: 100rpx;
- font-size: 32rpx;
- color: #333;
- border-bottom: 1rpx solid #fff;
- &.on {
- border-bottom: 1rpx solid #ff2200;
- color: #ff2200;
- }
- }
- }
- .item {
- width: 100%;
- height: auto;
- padding: 30rpx 30rpx 0;
- background-color: #ffffff;
- .input-item {
- width: 100%;
- height: 100rpx;
- display: flex;
- align-items: center;
- border-bottom: 1px solid #eeeeee;
- &:last-child {
- border-bottom: none;
- }
- .input-item-title {
- font-size: 32rpx;
- color: #333;
- }
- input {
- text-align: right;
- flex: 1;
- font-size: 32rpx;
- color: #333;
- }
- }
- }
- }
- .upload-box {
- width: 750rpx;
- height: 414rpx;
- background-color: #ffffff;
- display: flex;
- flex-direction: column;
- align-items: center;
- .upload-box-title {
- width: 100%;
- padding: 30rpx;
- font-size: 32rpx;
- color: #333;
- }
- .img-box {
- width: 430rpx;
- height: 270rpx;
- background-color: #d8d8d8;
- border-radius: 4rpx;
- margin-top: 10rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- .btn-box {
- margin-top: 60rpx;
- width: 100%;
- height: auto;
- padding: 0 30rpx;
- }
- </style>
|