username@email.com
2024-03-25 99e2324eea7af7dd8da898277abd6f2cbb32e3f2
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
<template>
    <view>
        <u-toast ref="uToast" /><u-no-network></u-no-network>
        <u-navbar title="提交申请" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
        <!-- 标题栏 -->
        <view class="head-box">
            <view class="head-img-wrap">
                <image class="head-img" :src="$globalConstVars.apiFilesUrl + '/static/images/agent/applyBg.jpg'" mode="widthFix"></image>
            </view>
        </view>
        <!-- 表单 -->
        <view class="coreshop-bg-white coreshop-border-radius-10 coreshop-padding-15 coreshop-margin-10">
            <u--form :model="form" :rules="rules" ref="uForm" errorType="message" labelPosition="left" labelWidth="80">
                <u-form-item label="姓名" prop="name" borderBottom>
                    <u--input type="text" placeholder='请填您的姓名' v-model="form.name" />
                </u-form-item>
                <u-form-item label="微信" prop="weixin" borderBottom>
                    <u--input type="text" placeholder='请填您的微信' v-model="form.weixin" />
                </u-form-item>
                <u-form-item label="QQ" prop="qq" borderBottom>
                    <u--input type="number" placeholder='请填您的QQ' v-model="form.qq" />
                </u-form-item>
                <u-form-item label="手机" prop="mobile" borderBottom>
                    <u--input type="number" placeholder='请填写您的手机号码' v-model="form.mobile" />
                </u-form-item>
                <view class="coreshop-padding-15 flex coreshop-flex-nowrap">
                    <u-checkbox-group>
                        <u-checkbox v-model="form.checked" @change="checkboxChange">我已经阅读并接受</u-checkbox>
                        <text class="coreshop-text-orange coreshop-padding-left-10  coreshop-padding-right-10 coreshop-font-15 coreshop-vertical-align-sub" @click="goAgreement()">"代理协议"</text>
                    </u-checkbox-group>
                </view>
            </u--form>
            <view class="coreshop-padding-15">
                <u-button type="primary" size="normal" @click="submit()">申请成为代理商</u-button>
            </view>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                form: {
                    name: '',
                    weixin: '',
                    qq: '',
                    mobile: '',
                    checked: false,
                    isAgreement: 'off'
                },
                rules: {
                    name: [
                        {
                            required: true,
                            message: '请输入姓名',
                            trigger: ['blur', 'change']
                        },
                        {
                            min: 2,
                            max: 4,
                            message: '长度在2-4个字符之间'
                        }
                    ],
                    weixin: [
                        {
                            required: true,
                            message: '请输入微信',
                            trigger: ['blur', 'change']
                        }
                    ],
                    qq: [
                        {
                            required: true,
                            message: '请输入QQ',
                            trigger: ['blur', 'change']
                        },
                        {
                            type: "number",
                            message: 'QQ必须为数字',
                            trigger: ['change', 'blur']
                        },
                    ],
                    mobile: [
                        {
                            required: true,
                            message: '请输入手机号码',
                            trigger: ['blur', 'change']
                        },
                        {
                            validator: (rule, value, callback) => {
                                return this.$u.test.mobile(value);
                            },
                            message: '手机号码不正确',
                            trigger: ['change', 'blur'],
                        }
                    ]
                }
            }
        },
        onReady() {
            this.$refs.uForm.setRules(this.rules);
        },
        methods: {
            checkboxChange(n) {
                this.form.checked = n;
                console.log('change', n);
            },
            submit() {
                this.$refs.uForm.validate().then(res => {
                    if (this.form.checked == false) {
                        this.$u.toast('请勾选代理协议')
                        return false;
                    }
                    this.form.isAgreement = "on";
 
                    // 提交审核
                    let data = {
                        name: this.form.name,
                        weixin: this.form.weixin,
                        qq: this.form.qq,
                        mobile: this.form.mobile,
                        agreement: this.form.isAgreement,
                    }
                    this.$u.api.applyAgent(data).then(res => {
                        if (res.status) {
                            this.$refs.uToast.show({ message: res.msg, type: 'success', url: '/pages/member/agent/applyState/applyState' })
                        } else {
                            this.$u.toast(res.msg);
                        }
                    });
                }).catch(errors => {
                    uni.$u.toast('提交的数据校验失败,请输入合法信息!')
                })
            },
            goAgreement() {
                uni.navigateTo({
                    url: '/pages/member/agent/agreement/agreement'
                })
            }
        }
    }
</script>
<style lang="scss" scoped>
    @import 'apply.scss';
</style>