MrShi
13 小时以前 a690229b69cfa0aba5a0352772c2bdc1cf9fdab0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<template>
    <view class="box">
        <view class="item">
            <view class="item-label"><text style="color: red;">*</text> 户名</view>
            <view class="item-input">
                <input type="text"  :focus='focus' @blur="focus=false"  v-model="form.name" placeholder="请输入开户人姓名" />
            </view>
        </view>
        <view class="item">
            <view class="item-label"><text style="color: red;">*</text>账号</view>
            <view class="item-input">
                <input type="number" :focus='focus1' @blur="focus1=false"  v-model="form.bankAccount" placeholder="请输入银行卡号" />
            </view>
        </view>
        <view class="item">
            <view class="item-label"><text style="color: red;">*</text>银行</view>
            <view class="item-input">
                <input type="text" :focus='focus2' @blur="focus2=false"  v-model="form.bankName" placeholder="请输入开户行支行名称" />
            </view>
        </view>
        <view class="item" style="display: flex; align-items: center; justify-content: space-between;">
            <view class="item-label" style="color: #222222;">设为默认银行</view>
            <u-switch v-model="form.isDefault" :activeValue="1" :inactiveValue="0" activeColor="#004096"></u-switch>
        </view>
        <view style="width: 100%; height: calc(env(safe-area-inset-bottom) + 108rpx);"></view>
        <!-- <view class="button disable">保存</view> -->
        <view class="footer">
            <view class="footer-btn1" v-if="form.id" @click="confirm()">删除银行</view>
            <view class="footer-btn2" @click="confirmEdit()">确认</view>
        </view>
        <u-popup :show="show" round="15" :safeAreaInsetBottom="false" mode="center">
            <view class="tc">
                <view class="tc-contemt">
                    <view class="tc-contemt-title">删除操作提示</view>
                    <view class="tc-contemt-nr">
                        您确认删除该银行账户信息吗?
                    </view>
                </view>
                <view class="tc-btn">
                    <view class="tc-btn-item" @click="confirm() ">我再想想</view>
                    <view class="tc-btn-item" style="color: red;" @click="confirmDel">确认删除</view>
                </view> 
            </view>
        </u-popup>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    export default {
        computed: {
            ...mapState(['navHeight', 'statusbarHeight','shopInfo', 'shopToken'])
        },
        data() {
            return { 
                id:null,  
                shop:{},
                show:false,
                focus:false,
                focus1:false,
                focus2:false,
                loading:false,
                form:{
                    id:null,
                    bankName:null,
                    bankAccount:null,
                    name:null,
                    isDefault:0
                }
            };
        }, 
        onLoad(options) {
            this.form={}
            this.shop  ={}
            this.show =false
            this.focus=false
            this.focus1=false
            this.focus2=false
            this.loading=false
            this.checkShopLogin()
            this.shop = this.shopInfo || {} 
            this.form={
                    id:null,
                    bankName:null,
                    bankAccount:null,
                    name:null,
                    isDefault:0
                }
            if(options.item){
                try{
                    var tt = JSON.parse(options.item)
            console.log("tt",tt)
                    this.form.id=tt.id||''
                    this.form.bankName=tt.bankName ||''
                    this.form.bankAccount=tt.bankAccount||''
                    this.form.name=tt.name||''
                    this.form.isDefault=tt.isDefault||0
                }catch(e){
                }
            }
            if(this.form.id){
                uni.setNavigationBarTitle({
                    title:'编辑提现银行卡'
                })
            }else{
                uni.setNavigationBarTitle({
                    title:'添加提现银行卡'
                })
            }
        },
        methods:{
            confirm(){
                this.show = !this.show
            },
            confirmEdit(){
            
                if(!this.form.name){
                    uni.showToast({
                        'title': '请输入户名',icon:'none'
                    })
                    this.focus=true
                    this.loading=false
                    return
                }
                if(!this.form.bankAccount){
                    uni.showToast({
                        'title': '请输入账号',icon:'none'
                    })
                    this.focus1=true
                    this.loading=false
                    return
                }
                 if(!this.form.bankName){
                     uni.showToast({
                         'title': '请输入银行信息',icon:'none'
                     })
                     this.focus2=true
                     this.loading=false
                     return
                 }
                  
                var that =this
                this.$u.api.saveBank(this.form)
                    .then(res => {
                        if (res.code === 200) { 
                            uni.showToast({
                                title:'操作成功',
                                icon:'success'
                            })
                            uni.$emit('editBank',{})
                            uni.navigateBack({delta:1})
                        }
                    }).catch(e=>{
                        uni.showToast({
                            title:'操作失败',
                            icon:'error'
                        })
                    })
            },
            async confirmDel(){
                this.show = !this.show
                var that =this
                this.form.tokenType =1
                let res = await that.$u.api.deleteBank({ id: this.form.id ,tokenType:1  });
                if (res.code === 200 ) { 
                    this.show = false
                    uni.$emit('editBank',{})
                    uni.navigateBack({delta:1})
                }   
            },
            async checkShopLogin(){
                var that =this
                if( this.shopInfo ==null || this.shopInfo.id==null ||  this.shopToken==null || this.shopToken==''){
                    uni.navigateTo({
                        url: '/pages/login/login'
                    })
                } 
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .box {
        width: 100%;
        padding: 0 30rpx;
        box-sizing: border-box;
        .footer {
            width: 100%;
            padding: 0 30rpx;
            box-sizing: border-box;
            position: fixed;
            bottom: calc(env(safe-area-inset-bottom) + 20rpx);
            left: 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .footer-btn1 {
                flex: 1;
                height: 88rpx;
                line-height: 88rpx;
                text-align: center;
                border-radius: 44rpx;
                font-weight: 500;
                font-size: 32rpx;
                color: #E4001D;
                border: 1rpx solid #E4001D;
                margin-right: 22rpx;
            }
            .footer-btn2 {
                flex: 1;
                height: 88rpx;
                line-height: 88rpx;
                text-align: center;
                font-weight: 500;
                font-size: 32rpx;
                color: #FFFFFF;
                background: #004096;
                border-radius: 44rpx;
            }
        }
        .disable {
            background: #EFEFEF !important;
            color: #CCCCCC !important;
        }
        .button {
            width: calc(100vw - 60rpx);
            height: 88rpx;
            line-height: 88rpx;
            text-align: center;
            background: #004096;
            border-radius: 44rpx;
            font-weight: 600;
            font-size: 32rpx;
            color: #FFFFFF;
            position: fixed;
            left: 30rpx;
            bottom: calc(env(safe-area-inset-bottom) + 20rpx);
        }
        .item {
            width: 100%;
            padding: 30rpx 0;
            box-sizing: border-box;
            border-bottom: 1rpx solid #E5E5E5;
            .item-label {
                width: 100%;
                font-weight: 400;
                font-size: 28rpx;
                color: #666666;
            }
            .item-input {
                width: 100%;
                margin-top: 24rpx;
                input {
                    width: 100%;
                    font-weight: 400;
                    font-size: 30rpx; 
                }
            }
        }
    }
</style>