linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
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
<template>
    <view>
        <view class="content bgc-ff">
            <u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="90"
                :labelStyle="{fontSize:'28rpx'}">
                <u-form-item label="工作主题" prop="info.workTheme" borderBottom>
                    <u-input v-model="info.workTheme" border="none" placeholder="请输入工作主题" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="当前位置" prop="address" borderBottom>
                    <view class="address-row flex">
                        <view class="address-content f-28" v-if="info.address">
                            {{info.address}}
                        </view>
                        <view class="address-content f-28 c-99" v-if="!info.address">
                            请选择地址
                        </view>
                        <view class="location-btn c-main f-24" @click="getLocation()">
                            获取地址
                        </view>
                    </view>
                </u-form-item>
                <u-form-item label="工作内容" prop="info.workContent" :borderBottom="false" ref="item1">
                    <u-input v-model="info.workContent" border="none" placeholder="请输入工作内容" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
            </u-form>
        </view>
        <view class="upload bgc-ff">
            <view class="f-28">场所图片</view>
            <view class="mt-20">
                <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
                    :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple" :maxCount="uploadConfig.maxCount"
                    :capture="uploadConfig.capture" @afterRead="afterReadImg" @delete="deletePic">
                    <view class="upload-item upload-icon flex_base">
                        <u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
                    </view>
                </u-upload>
            </view>
        </view>
 
        <!-- <view class="footer">
            <button class="footer-btn">提交</button>
        </view> -->
 
        <footer-btn @click="submitInfo" />
 
 
    </view>
 
</template>
 
<script>
    import uploadMixin from "@/mixin/uploadMixin";
    import {
        addCheckIn
    } from "@/api/checkIn/checkIn.js"
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                info: {
                    workTheme: "",
                    workContent: "",
                    address: ""
                },
                form: {
                    images: []
                },
                rules: {
                    'workTheme': {
                        type: 'string',
                        required: true,
                        message: '请输入工作主题',
                        trigger: ['blur', 'change']
                    },
                    'workContent': {
                        type: 'string',
                        required: true,
                        message: '请输入工作内容',
                        trigger: ['blur', 'change']
                    },
                    'address': {
                        type: 'string',
                        required: true,
                        message: '请选择地址',
                        trigger: ['blur', 'change']
                    },
                },
 
            }
        },
        methods: {
            getLocation() {
                uni.chooseLocation({
                    success: (res) => {
                        this.$set(this.info, "address", res.address);
                        this.$set(this.info, "lat", res.latitude);
                        this.$set(this.info, "lng", res.longitude)
                    }
                })
            },
 
            submitInfo() {
                this.$refs.form.validate().then(valid => {
                    if (this.form.images.length > 0) {
                        let urls = []
                        this.form.images.forEach(e => {
                            urls.push(e.name)
                        })
                        this.info.img = urls.join(",")
                    }
                    addCheckIn(this.info).then(res => {
                        uni.showToast({
                            title: '提交成功',
                            success() {
                                setTimeout(() => {
                                    // this.$u.func.globalNavigator("", "navBack")
                                   uni.navigateBack();
                                }, 1000)
                            }
                        })
                    })
                })
            }
        }
    }
</script>
 
<style lang="less">
    page {
        background-color: #F5F5F5;
    }
 
    .content {
        margin: 20rpx 30rpx;
        padding: 0 30rpx;
    }
 
    .row {
        padding: 20rpx 0;
        border-bottom: 1px solid
    }
 
    .location-btn {
        width: 116rpx;
        height: 46rpx;
        line-height: 46rpx;
        border-radius: 4rpx;
        border: 1px solid currentColor;
        padding: 0;
        background-color: #fff;
    }
 
    .upload {
        margin: 0 30rpx;
        padding: 30rpx;
 
        .upload-item {
            width: 140rpx;
            height: 140rpx;
            border: 1px solid #EEEEEE;
        }
    }
 
    .address-row {
        flex: 1;
        justify-content: flex-end;
        align-items: center;
    }
 
    .address-content {
        width: calc(100% - 116rpx - 20rpx);
        margin-right: 20rpx;
        text-align: right;
    }
 
    .location-btn {
        width: 116rpx;
        height: 46rpx;
        line-height: 46rpx;
        border-radius: 4rpx;
        border: 1px solid currentColor;
        padding: 0;
        background-color: #fff;
        text-align: center;
    }
</style>