doum
11 小时以前 6e56c64e4b6b77b8acc61d34392c1fa0418ff499
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
<template>
    <view class="box">
        <view class="list">
            <view :class="item.id == selectBank.id?'list-item active':'list-item'" v-for="(item,index) in bankList" :key="index" >
                <view class="list-item-a" v-if="item.id == selectBank.id"  @click="selectBankDo(item)">
                    <u-icon name="checkmark" color="#004096" size="18"></u-icon>
                </view>
                <view class="list-item-b"  @click="selectBankDo(item)">
                    {{item.bankInfo || ''}}
                </view>
                <view class="list-item-c" @click="jumpEditBank(item)">修改</view>
            </view>
            <view v-if="!bankList ||!bankList.length" class="nomore" style="margin-top: 100rpx;">尚未添加银行账户</view>
        </view>
        <view style="width: 100%; height: calc(env(safe-area-inset-bottom) + 108rpx);"></view>
        <view class="button" @click="jumpEditBank()">添加提现银行</view>
    </view>
</template>
 
<script>
    import { mapState } from 'vuex'
    export default {
        computed: {
            ...mapState(['navHeight', 'statusbarHeight','shopInfo', 'shopToken'])
        },
        data() {
            return { 
                bankList:[],
                selectBank:{},
                id:null,  
                shop:{},
                info:{}
            };
        }, 
        onLoad(options) {
            this.info={}
            this.shop  ={}
            this.bankList = []
            this.selectBank=[]
            this.checkShopLogin()
            this.shop = this.shopInfo || {} 
            if(options.item){
                try{
                    this.selectBank = JSON.parse(options.item)
                }catch(e){
                    
                }
            }
            this.getBankList()
            var that =this
            uni.$on('editBank',function(data){
                console.log('监听到事件来自 editBank:' ,data);
                that.getBankList(true)
            })
                
        },
        methods:{   
            selectBankDo(item){
                this.selectBank=item
                uni.$emit('selectBank',{info:this.selectBank})
                uni.navigateBack({delta:1})
            },
            jumpEditBank(item ){
                if(item  && item.id){
                    uni.navigateTo({
                        url: '/pagesA/pages/add-bank-card/add-bank-card?item='+JSON.stringify(item)
                    })
                }else{
                    uni.navigateTo({
                        url: '/pagesA/pages/add-bank-card/add-bank-card'
                    })
                }
            },
            async getBankList(isRefresh){
                var that =this
                let res = await that.$u.api.getBankList({tokenType:1  })
                var tmpId = (that.selectBank && that.selectBank.id)?that.selectBank.id:null
                that.selectBank =null
                if (res.code === 200) {
                    that.bankList = res.data || []
                    if(that.bankList.length>0 ){
                        if( !tmpId ){
                            that.selectBank = that.bankList[0]
                        }else{
                            var tt = false
                            that.bankList.forEach(item =>{
                                if(tmpId == item.id){
                                    tt=true
                                    that.selectBank = item
                                }
                            })
                        }
                    } 
                    if(isRefresh){
                        console.log('selectBank=====',that.selectBank)
                        uni.$emit('selectBank',{info:that.selectBank})
                    }
                }
                
            },
            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>
    page {
        background-color: #F9F9FB;
    }
</style>
<style lang="scss" scoped>
    .box {
        width: 100%;
        .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);
        }
        .list {
            width: 100%;
            padding: 0 30rpx;
            box-sizing: border-box;
            background-color: #ffffff;
            .active {
                .list-item-b {
                    font-weight: 600 !important;
                    font-size: 30rpx !important;
                    color: #222222 !important;
                }
            }
            .list-item {
                width: 100%;
                height: 102rpx;
                display: flex;
                align-items: center;
                justify-content: space-between;
                border-bottom: 1rpx solid #E5E5E5;
                &:last-child {
                    border: none !important;
                }
                .list-item-a {
                    flex-shrink: 0;
                    width: 60rpx;
                }
                .list-item-b {
                    flex: 1;
                    font-weight: 400;
                    font-size: 30rpx;
                    color: #222222;
                }
                .list-item-c {
                    font-weight: 400;
                    font-size: 28rpx;
                    color: #004096;
                }
            }
        }
    }
</style>