zhaojs
2023-06-09 bef3a652349b7b79c914afcc013d7229706a2b3b
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="bindingZFB-wrapper wrapperLayer borderBox">
        <titleBar :titleText='pageTitle' :pageForm='"bindingZFB"'></titleBar>
        <view class="pageContent-container colCen">
            <view class="zfbicon defIcon">
                <image src="../../../static/images/mine/tools/bindingzfb.png" mode=""></image>
            </view>
            <view class="form-container colCen borderBox">
                <view class="usernam-container colCen">
                    <view class="boxtitle">
                        姓名
                    </view>
                    <view class="inputbox rowCen">
                        <input class="nostyle-input" type="text" v-model="username" placeholder="请输入姓名" placeholder-class="placeholderstyle" />
                    </view>
                </view>
                <view class="usernam-container colCen">
                    <view class="boxtitle">
                        支付宝
                    </view>
                    <view class="inputbox rowCen">
                        <input class="nostyle-input" type="text" v-model="zfbnum" placeholder="请输入支付宝帐号" placeholder-class="placeholderstyle" />
                    </view>
                </view>
                <view class="confirmBtn colCen" @click="openModel()">
                    <view class="btn-container rowCenCen">
                        <view>确定</view>
                    </view>
                </view>
            </view>
        </view>
 
        <!-- 模态窗 -->
        <u-modal v-model="showModel" show-cancel-button :content="content" @confirm="confirm" :async-close="true">
        </u-modal>
        <u-toast ref="uToast" />
    </view>
</template>
 
<script>
    import titleBar from '../../../components/backTitlebar.vue';
    import utils from '../../../utils/utils.js'
    export default {
        components: {
            titleBar
        },
        data() {
            return {
                pageTitle: '支付宝绑定',
                username: '',
                zfbnum: '',
                zfbinfo: '',
                zfbid: '',
                showModel: false,
                content: '确认信息无误并提交?'
            }
        },
        onLoad(options) {
            this.getzfnInfo()
 
            if (utils.getCacheSync('zfbinfo')) {
                this.pageTitle = '支付宝修改'
            } else {
                this.zfbinfo = ''
                this.pageTitle = '支付宝绑定'
            }
        },
        methods: {
            getzfnInfo(){
                var that = this;
                this.$u.api.getUserInfo({}).then(e => {
                    var user = e.data.userinfo;
                    if(user.true_name && user.zfb_account){
                        that.username = user.true_name
                        that.zfbnum = user.zfb_account
                        that.pageTitle = '支付宝修改'
                    }else{
                        this.zfbinfo= ''
                        this.pageTitle = '支付宝绑定'
                    }
                    util.setCache('userInfo', e.data.userinfo)
                }).catch(function (err) {
                    console.log(err)
                })
            },
            openModel() {
                if (this.username != '' && this.zfbnum != '') {
                    this.showModel = true;
                } else {
                    this.$refs.uToast.show({
                        title: '输入的信息有误',
                        type: 'error',
                    })
                }
            },
            confirm() {
                var that = this;
                this.$u.api.bindZfb({
                    truename: this.username,
                    zfbAccount: this.zfbnum
                }).then(e => {
                    if(e.code == 1)return that.$alert(e.msg);
                    that.showModel = false;
                    that.$refs.uToast.show({
                        title: '绑定成功',
                        type: 'success',
                        back: true
                    })
                }).catch(function (err) {
                    return that.$alert('绑定失败');
                })
            },
        }
    }
</script>
 
<style lang="scss">
    .bindingZFB-wrapper {
        min-height: 100vh;
        background-color: #FFFFFF;
 
        .pageContent-container {
            width: 100%;
 
            .zfbicon {
                width: 125rpx;
                height: 125rpx;
                margin-top: 40rpx;
            }
 
            .form-container {
                width: 100%;
                padding: 0 32rpx;
                margin-top: 70rpx;
 
                .usernam-container {
                    width: 100%;
                    margin-top: 30rpx;
 
                    .boxtitle {
                        width: 100%;
                        font-size: 28rpx;
                        font-weight: 500;
                        color: #333333;
                    }
 
                    .inputbox {
                        width: 100%;
                        height: 80rpx;
                        margin-top: 20rpx;
                        font-size: 28rpx;
                        font-weight: 400;
                        color: #333333;
                        border-bottom: 1rpx solid #EFF1F7;
                    }
                }
 
                .confirmBtn {
                    width: 100%;
 
                    .btn-container {
                        width: 100%;
                        height: 80rpx;
                        border-radius: 40rpx;
                        background: linear-gradient(266deg, #7619EC, #A429F3);
                        font-size: 28rpx;
                        font-weight: 500;
                        color: #FFFFFF;
                        margin-top: 70rpx;
                    }
                }
            }
        }
    }
</style>