陶杰
2025-01-13 efa9bfe98ba906e4c9b8f49c89f5da162a46bb0f
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<template>
    <view class="container-page" style="padding: 0rpx;">
        <view v-if="source==='step'" style="padding: 20rpx 0rpx;color: red;;background-color: #e6e6e6;">
            <view style="padding: 20rpx;text-align: center;background-color: #fff;">仅限花满芫合伙人入驻</view>
        </view>
        <view v-if="source==='step'" class="m-t-20">
            <u-steps current="0">
                <u-steps-item title="信息填写" class="u-steps-item" style="font-size: 28rpx;">
                </u-steps-item>
                <u-steps-item title="提交申请" class="u-steps-item"></u-steps-item>
            </u-steps>
        </view>
        <view class="p20">
 
            <view class="form-item before-line m-t-20" @click="uploadIcon('cover')">
                <view class="label ">头像</view>
                <view class="m-l-a m-r-0 flex m-b-12">
                    <view class="component-button-upload"></view>
                </view>
            </view>
            <view class="flex p20" style="padding-top: 0rpx;padding-bottom: 10rpx" v-if="dto.cover">
                <view class="m-t-12 m-r-10">
                    <image class="banner-img" :src="dto.cover" @click.stop="previewImg(dto.cover)"></image>
                    <view class="t-red text-center" @click.stop="dto.cover=''">删除</view>
                </view>
            </view>
 
            <view class="form-item before-line">
                <view class="label required">联系人姓名</view>
                <view class="m-l-a m-r-0 flex">
                    <input v-model="dto.name" placeholder="请输入联系人姓名"
                        style="margin-top: 16px;text-align: right;"></input>
                </view>
            </view>
<!--            <view class="form-item before-line">-->
<!--                <view class="label required">联系方式</view>-->
<!--                <view class="m-l-a m-r-0 flex">-->
<!--                    <input v-model="dto.contactTel" placeholder="请输入联系方式"-->
<!--                        style="margin-top: 16px;text-align: right;"></input>-->
<!--                </view>-->
<!--            </view>-->
            <view class="button-green-1 m-t-20 button-fixed-bottom before-line " @click="submit">更新</view>
        </view>
 
    </view>
</template>
 
<script>
    import environments from '@/environments'
    import {
        mapState
    } from 'vuex'
 
    export default {
        data() {
            return {
                id: '',
                refresh: false,
                source: '',
                api: '',
                dto: {
                    idCards: [],
                    address: '',
                    id: '',
                    userId: '',
                    name: '',
                    contactTel: '',
                    province: '',
                    city: '',
                    region: '',
                    cover: '',
                },
                requireFields: [
 
                    {
                        name: '联系人姓名',
                        key: 'name'
                    },
                    // {
                    //     name: '联系方式',
                    //     key: 'contactTel'
                    // },
 
                ],
                regionDataPlus: [],
                show_select_station: false,
                columns_station: [],
            }
        },
        onLoad(options) {
 
            if (options.id) {
                this.id = options.id
                this.getDetail()
            } else {
                //判断是不是来自登录步骤,是等话需要从缓存里面拿信息
                if (this.source === 'step') {
                    var tjson = this.$storage.getItem('cache_partner_info')
                    if (tjson) {
                        this.dto = {
                            ...this.dto,
                            ...JSON.parse(tjson)
                        }
                    }
                } else {
                    this.getCurrentInfo()
                }
 
            }
 
        },
 
        methods: {
 
            async getCurrentInfo() {
                this.$message.showLoading()
                const {
                    code,
                    data
                } = await this.$http.request('get', "/api/current/partner", {})
                if (code == 0) {
                    this.dto = {
                        ...data,
 
                    }
                    if (!this.dto.idCards) {
                        this.dto.idCards = []
                    } else if (typeof this.dto.idCards == 'string') {
                        this.dto.idCards = JSON.parse(this.dto.idCards)
                    }
 
                    this.dto.userId = this.currentInfo.id
 
                }
 
                this.$message.hideLoading()
            },
 
            async submit() {
                for (var field of this.requireFields) {
                    if (!this.dto[field.key]) {
                        this.$message.showToast(`${field.name}信息未填写`)
                        return
                    }
                }
                /*const phoneRegex = /^[1][3-9][0-9]{9}$/;
                if (!phoneRegex.test(this.dto.contactTel)) {
                    this.$message.showToast('请填写正确联系方式')
                    return
                }*/
 
                await this.$message.confirm(`是否确定提交/修改信息`)
 
                var dto = {
                    ...this.dto,
                }
                this.$message.showLoading()
                const re = await this.$http.request('post', '/api/partner/base/update', {
                    data: dto
                })
                this.$message.hideLoading()
                if (re.code == 2000 || re.code == 0) {
                    this.$message.showToast('操作成功')
                    this.$store.dispatch('getCurrentInfo')
 
                    this.backpage()
                } else {
                    console.log('error re', re)
                    if (re.code === 30000 && Array.isArray(re.msg)) {
                        this.$message.showToast('字段未填写完整')
 
                    }
                }
 
 
            },
 
            async deleteImg(key, index) {
                await this.$message.confirm('是否确认删除此图片')
                if (Array.isArray(this.dto[key])) {
                    this.dto[key].splice(index, 1)
 
                } else {
                    this.dto[key] = ''
                }
                this.$forceUpdate()
            },
            uploadIcon(key) {
                const that = this
                uni.chooseImage({
                    count: 1, // 最多可以选择的图片张数,默认9
                    sizeType: ['original', 'compressed'], //original 原图,compressed 压缩图,默认二者都有
                    sourceType: ['camera', 'album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
                    success: function({
                        errMsg,
                        tempFiles
                    }) {
                        if (errMsg === 'chooseImage:ok') {
                            // console.log(tempFiles[0])
                            if (tempFiles[0].size > 1024 * 1024 * 5) {
                                that.$message.confirm('图片最多支持5M大小,超出大小限制')
                                return
                            }
                            that.$message.showLoading()
                            that.$http.upload(tempFiles[0].path).then(async res => {
                                var pic = res.data && res.data.length > 0 && res.data[
                                    0] || {}
                                that.$message.hideLoading()
                                if (Array.isArray(that.dto[key])) {
                                    that.dto[key].push(pic || '')
 
                                } else {
                                    that.dto[key] = (pic || {}).url || ''
                                }
                                console.log("that.dto")
                                console.log(that.dto)
                                that.$forceUpdate()
                            }).catch(res => {
                                that.$message.hideLoading()
                                that.$message.showToast('文件上传失败,请联系管理员')
                            })
                        }
                    }
                })
            },
 
        },
        computed: {
            ...mapState(['currentInfo'])
        },
        components: {}
    }
</script>
 
<style lang="scss" scoped>
    .banner-img {
        width: 96rpx;
        height: 96rpx;
        border-radius: 4rpx;
        border: 2rpx dashed #CECECE;
    }
 
    .form-item {
        // padding: 40rpx;
        border-bottom: 2rpx solid #F3F3F3;
        display: flex;
        // height: 100px;
 
        .label {
            width: 300rpx;
            line-height: 60px;
 
        }
 
        .flex {
            line-height: 60px;
 
            .flex1 {
                flex: 1;
                text-align: center;
                color: var(--selfblue)
            }
 
 
        }
    }
 
    .form-item.bottom-border-no {
        border-bottom: none;
    }
 
    .container-page {
        padding: 40rpx;
        background-color: #FFFFFF;
        // min-height: calc(100vh - 80rpx);
        min-height: 100vh;
    }
 
    .style {
        width: fit-content;
        margin: 0 auto;
        line-height: 64rpx;
        border-radius: 8rpx;
        padding-left: 20rpx;
        padding-right: 20rpx;
        // padding-top: 5rpx;
        // padding-bottom: 5rpx;
        border: 2rpx solid var(--selfblue);
        background-color: var(--selfbluebg);
        min-width: 100rpx;
    }
 
 
    .style-1 {
        border: 1px solid rgb(122, 187, 255);
        border: 1px solid #409EFF;
        color: #409EFF;
        background-color: rgb(240, 247, 255);
    }
 
    .style-2 {
        border: 1px solid rgb(255, 184, 78);
        border: 1px solid #FE9044;
        color: #FE9044;
        background-color: rgb(255, 247, 235);
    }
 
    .style-3 {
        border: 1px solid #19be6b;
        color: #19be6b;
        background-color: rgb(231, 244, 238);
    }
 
    .style-4 {
        border: 1px solid #F56c6c;
        color: #F56c6c;
        background-color: rgb(254, 243, 243);
    }
 
    .reject-reason {
        word-wrap: break-word;
        /* 遇到长单词时强制换行 */
        word-break: break-all;
        /* 长单词会在任意位置换行 */
        white-space: normal;
        /* 允许换行 */
    }
</style>