zengh
2022-05-09 52c39f5e2711e5535b689b66dfa5e100c7882b7f
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<template>
    <view class="policeDetails">
        <!-- 自定义顶部导航栏 -->
        <u-navbar :is-back="true" title="事件上报" :background="background" back-icon-color="#FFF" title-color="#FFF">
            <view class="navbar-right" slot="right">历史上报</view>
        </u-navbar>
        <!-- <view class="row address">
            <view class="title">地址</view>
            <input v-model="place" placeholder="请输入地址" />
        </view> -->
        <view class="time">
            <view class="title">时间</view>
            <e-picker :showValue="date" fields="month" mode="dateTime" :style="{color:stimeColor}" class="select_time"
                @change="stimeChange">{{stime||'请选择时间'}}</e-picker>
        </view>
        <view class="desc">
            <view class="title">描述</view>
            <textarea placeholder="请输入描述" v-model="result"></textarea>
        </view>
        <view class="photo">
            <view class="title">照片上传</view>
            <view class="main">
                <image @tap="takePhoto" src="../../static/workbench/policeDerails/xiangji.png" mode=""></image>
            </view>
        </view>
        <seeImgs :imgs="imgs" :videos="[]" @del="delImg" :type="'imgs'"></seeImgs>
        <view class="video">
            <view class="title">视频上传</view>
            <view class="main">
                <image @tap="takeVideo" src="../../static/workbench/policeDerails/shiping11.png" mode=""></image>
            </view>
        </view>
        <view class="row address">
            <view class="title">地址</view>
            <input v-model="place" placeholder="请输入地址" />
        </view>
        <seeImgs :imgs="[]" :videos="videos" @del="delVideo" :type="'videos'"></seeImgs>
        <!-- <view class="form-btn">
            <view class="butb" @click="upData">提交</view>
        </view> -->
        <u-button class="butb" @click="upData">提交</u-button>
    </view>
</template>
 
<script>
    import seeImgs from '../../components/seeImges/seeImges.vue';
    import navBarTop from '../../components/nav-bar-top/nav-bar-top.vue';
    export default {
        components: {
            navBarTop,
            seeImgs
        },
        data() {
            return {
                datas: '',
                stime: '',
                date: '',
                stimeColor: "#808080",
                result: '',
                place: "",
                imgs: [],
                videos: [],
                title: '事件上报',
                backImage: '../../static/images/nav/back02.png',
                background: {
                    backgroundColor: "#103289"
                }
            }
        },
        methods: {
            //返回上一页
            goBack() {
                uni.navigateBack({})
            },
 
            //日期选择
            stimeChange(e) {
                // this.stime = e.substr(0,e.length-3);
                this.showValue = e.substr(0, e.length - 3),
                    this.stime = e;
                //修改颜色
                this.stimeColor = "#000000";
            },
 
            //上传
            upData() {
                console.log('开始上传');
                var dataList = {
                    sname: this.$store.state.puserName,
                    snumber: this.$store.state.puserID,
                    phone: this.$store.state.puserIphone,
                    stime: this.stime,
                    result: this.result,
                    place: this.place,
                    status: 1,
                    tpaddress: "",
                    spaddress: ""
                };
                if (this.imgs.length > 0) {
                    var i = this.imgs;
                    for (var k in i) {
                        // console.log(i[k].src)
                        dataList.tpaddress += i[k].src + ','
                    }
                    dataList.tpaddress = dataList.tpaddress.substring(0, dataList.tpaddress.length - 1);
                }
                if (this.videos.length > 0) {
                    var i = this.videos;
                    for (var k in i) {
                        // console.log(i[k].src)
                        dataList.spaddress += i[k].src + ','
                    }
                    dataList.spaddress = dataList.spaddress.substring(0, dataList.spaddress.length - 1);
                }
                // console.log(dataList)
                uni.showLoading({
                    title: "提交中...",
                    mask: true
                })
                uni.request({
                    url: this.$store.state.piAPI + 'feedback/feedback/saves',
                    data: dataList,
                    method: 'POST',
                    header: {
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    success: (res) => {
                        if (res.data.code == 200) {
                            uni.showToast({
                                title: '提交成功!',
                                duration: 2000
                            });
                        }
                    }
                });
            },
 
            //图片上传
            takePhoto() {
                var that = this;
                uni.chooseImage({
                    count: 4, //可选择数量,默认9
                    sizeType: ['compressed', 'original'], //上传压缩图,原图
                    sourceType: ['album', 'camera'], //从相册选择或从使用相机
                    success: async (res) => {
                        for (var i = 0; i < res.tempFiles.length; i++) {
                            if (res.tempFiles[i].size > 10 * 1024 * 1000) { //上传图片大小限制
                                uni.showToast({
                                    title: "照片大小不能10MB",
                                    icon: "none"
                                })
                                return
                            }
                        }
                        var tempFilePath = res.tempFilePaths;
                        // try {
                        uni.showLoading({
                            title: "上传中...",
                            mask: true
                        })
                        var that = this;
                        // 循环调用uni.uploadFile ,因微信小程序只支持单文件上传
                        for (var i = 0; i < tempFilePath.length; i++) {
                            uni.uploadFile({
                                // url: 'https://web.byisf.com/api/blade-jfpts/depl/put-depl', //仅为示例,非真实的接口地址
                                url: that.$store.state.piAPI + '/depl/put-depl',
                                filePath: tempFilePath[i],
                                name: 'file',
                                formData: {
                                    'user': 'test' // 上传附带参数
                                },
                                success: (data) => {
                                    uni.showToast({
                                        title: '上传图片成功!',
                                        duration: 1000
                                    });
                                    // 根据接口具体返回格式   赋值具体对应url
                                    that.imgs.push({
                                        id: i,
                                        src: JSON.parse(data.data).data
                                    })
                                }
                            });
                        }
                    }
                });
            },
            //图片删除
            delImg(index) {
                this.imgs.splice(index, 1);
            },
            //视频上传
            takeVideo() {
                var that = this;
                wx.chooseVideo({
                    sourceType: ['album', 'camera'],
                    maxDuration: 60,
                    camera: 'back',
                    success(res) {
                        var tempFilePath = res.tempFilePath;
                        // try {
                        uni.showLoading({
                            title: "上传中...",
                            mask: true
                        })
                        uni.uploadFile({
                            // url: 'https://web.byisf.com/api/blade-jfpts/depl/put-depl', 
                            url: that.$store.state.piAPI + '/depl/put-depl',
                            filePath: tempFilePath,
                            name: 'file',
                            formData: {
                                'user': 'test' // 上传附带参数
                            },
                            success: (data) => {
                                uni.showToast({
                                    title: '上传视频成功!',
                                    duration: 1000
                                });
                                // 根据接口具体返回格式   赋值具体对应url
                                that.videos.push({
                                    id: that.videos.length,
                                    src: JSON.parse(data.data).data
                                })
                            }
                        });
                    }
                })
            },
            //视频删除
            delVideo(index) {
                this.videos.splice(index, 1);
            },
        },
        mounted() {
            //去除组件自带的导航条下划线
            var dom = document.getElementsByClassName('uni-navbar--border');
            dom[0].style.borderBottomStyle = 'none';
        }
    }
</script>
 
<style lang="scss">
    .navbar-right {
        color: #fff;
        font-size: 0.7rem;
        margin-right: 1.5rem;
        margin-top: 0.2rem;
    }
 
    .uni-nav-bar-info {
        // font-weight: 550;
 
        .title {
            position: fixed;
            right: 42%;
            font-weight: 550;
            letter-spacing: 1px;
        }
 
        .uni-nav-bar-left {
            display: flex;
            justify-items: center;
 
            image {
                // background-color: #00BFFF;
                margin-left: 1rem;
                width: 1.6rem;
                height: 1.6rem;
                border-radius: 100px;
            }
        }
 
        .right {
            display: flex;
 
            .title-right {
                position: relative;
                font-size: 0.7rem;
                color: #808080;
                right: 0.5rem;
                top: 0.2rem;
            }
        }
 
 
    }
 
 
    .policeDetails {
        width: 88%;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
 
        .address {
            width: 100%;
            height: 100rpx;
            display: flex;
            justify-content: center;
            flex-direction: column;
            // border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
            // border-top: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
 
            .title {
                font-size: 15px;
            }
 
            input {
                flex: 1;
                font-size: 14px;
            }
        }
 
        .time {
            width: 100%;
            height: 100rpx;
            display: flex;
            align-items: center;
            // border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
 
            .title {
                float: left;
                font-size: 15px;
            }
 
            .select_time {
                margin-left: 20px;
                font-size: 14px;
            }
        }
 
        .desc {
            width: 100%;
            height: 15rem;
            display: flex;
            flex-direction: column;
            // border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
 
            .title {
                height: 100rpx;
                line-height: 100rpx;
                font-size: 15px;
            }
 
            textarea {
                // background-color: #00BFFF;
                width: 100%;
                // border: 1px solid #808080;
                line-height: 1.5;
                font-size: 14px;
                flex: 1;
                padding-left: 0.2rem;
            }
        }
 
        .photo {
            width: 100%;
            height: 120rpx;
            display: flex;
            align-items: center;
 
            .title {
                font-size: 15px;
                float: left;
            }
 
            image {
                width: 60rpx;
                height: 60rpx;
                margin-left: 20px;
            }
        }
 
        .video {
            width: 100%;
            height: 120rpx;
            display: flex;
            align-items: center;
            // border-bottom: 1px solid rgba($color: #f3f3f3, $alpha: 0.7);
 
            .title {
                font-size: 15px;
                float: left;
            }
 
            image {
                width: 60rpx;
                height: 60rpx;
                margin-left: 20px;
            }
        }
 
 
        .butb {
            margin: 30rpx 50rpx 50rpx;
            border: none;
            width: 572rpx;
            height: 86rpx;
            line-height: 86rpx;
            box-sizing: border-box;
            border-radius: 15rpx;
            background-color: #103289;
            color: #ffffff;
        }
    }
</style>