mapdoorplate - 副本.vue
6.4 KB
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
<template>
<view class="page">
<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
<view class="content">
<view class="top-box" @click="gopath('/pages/mapdoorplate/mapdoorplatelist')">
<view>上报历史</view>
<view class="top-box-img">
<image src="../../static/right2.png"></image>
</view>
</view>
<view class="titleall-left">
<view class="titleall-left-line"></view>我要上报
</view>
<view class="message-list">
<view class="info-box">
<view class="info-box-list">
<view class="serve">
<view class="serve-title">路门牌情况</view>
<view class="serve-right">
<text>*</text>
<picker @change="bindPickerChange" :value="index" :range="array">
<view class="uni-input">{{from.road_status?array[from.road_status]:'请选择'}}
</view>
</picker>
<image src="../../static/down3.png"></image>
</view>
</view>
</view>
</view>
<view class="info-box">
<view class="info-box-list">
<view class="serve">
<view class="serve-title">名称</view>
<view>
<input v-model="from.name" placeholder="请输入" style="text-align: right;" />
</view>
</view>
</view>
</view>
<view class="info-box">
<view class="info-box-list">
<view class="serve">
<view class="serve-title">联系电话</view>
<view>
<input v-module="from.phone" placeholder="请输入" style="text-align: right;" />
</view>
</view>
</view>
</view>
<view class="info-box">
<view class="info-box-list">
<view class="serve">
<view class="serve-title">详细地址</view>
<view @tap="open">
<input v-module="from.address" placeholder="请输入" style="text-align: right;" />
</view>
</view>
</view>
</view>
</view>
<view class="message-list">
<view class="info-box">
<view class="info-box-list">
<view class="info-box-width" style="width: 100%;">
<view class="info-box-small">现场照片上传</view>
<view style="margin-top: 20rpx;width: 100%;">
<u-upload name="1" multiple :fileList="fileList" @delete="deletePic"
@afterRead="afterRead" :previewFullImage="true" :maxCount="10"></u-upload>
</view>
<!-- <view class="info-box-list-img"><image src="../../static/img.png"></image></view> -->
</view>
</view>
<view class="info-box-list">
<view class="info-box-width width100">
<view class="info-box-small">备注</view>
<view>
<textarea maxlength="-1" auto-height
placeholder="这里有相关备注这里有相关备注这里有相关备注,这里有相关备注这里有相关备注,这里有相关备注这里有相关备注。"
class="textarea"></textarea>
</view>
</view>
</view>
</view>
</view>
<view class="page-footer">
<view class="footer-buy">
<view class="cart-add" @click="mapdoorplatesuccess">
<image src="../../static/btn5.png"></image>
<text>立即上报</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import service from '@/service/service.js'
import BASE_URL from "@/common/config.js"
export default {
data() {
return {
BASE_URL,
fileList: [],
OrderType: 0,
nvConfig: {
title: "路门牌上报",
bgColor: "#ffffff",
color: "#000000",
fixedAssist: {
hide: true,
},
},
from: {
createdUser: uni.getStorageSync('USERS_KEY').userId,
status: '待处理',
name: '',
road_status: '',
latitude: '',
longitude: '',
address: '',
phone: '',
inspectionImage: ''
},
array: ['正常', '需维修', '需更换'],
};
},
onPageScroll(e) {
this.$refs.nv.pageScroll(e)
},
computed: {
pageTop() {
return parseInt(88 * uni.getSystemInfoSync().windowWidth / 750) + uni.getSystemInfoSync().statusBarHeight
}
},
onLoad(params) {
this.OrderType = params.type;
},
methods: {
gopath(e) {
uni.navigateTo({
url: e
})
},
async afterRead(event) {
for (let i = 0; i < event.file.length; i++) {
var res = await this.uploadImg(event.file[i].url)
// console.log(res)
res = JSON.parse(res.data)
this.fileList.push({
name: res.fileName,
fileId: res.newFileName,
url: this.BASE_URL + res.fileName
})
}
},
uploadImg(url) {
return new Promise((r, e) => {
uni.uploadFile({
url: this.BASE_URL + "/common/upload",
filePath: url,
name: "file",
success: (d) => r(d)
})
})
},
deletePic(event) {
this.fileList.splice(event.index, 1)
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e)
this.from.road_status = e.detail.value
},
mapdoorplatesuccess() {
this.from.road_status = this.array[this.from.road_status]
for (let i = 0; i < this.fileList.length; i++) {
if (i == 0) {
this.from.inspectionImage = this.fileList[i].name
} else {
this.from.inspectionImage = this.from.inspectionImage + ',' + this.fileList[i].name
}
}
console.log(this.from, this.fileList)
this.API.addroadSign(this.from).then(res => {
console.log(res);
if (res.code == 200) {
uni.showToast({
icon: 'success',
title: "添加成功",
})
setTimeout(() => {
uni.redirectTo({
url: '/pages/mapdoorplatesuccess/mapdoorplatesuccess',
})
}, 800)
}
})
},
open() {
let that = this
// 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
wx.chooseLocation({
success: function(res) {
console.log(res);
that.from.latitude = res.latitude
that.from.longitude = res.longitude
that.from.address = res.address
// that.arr1.plot=res.name
},
fail(err) {
console.log(err)
}
});
},
}
}
</script>
<style scoped lang="scss">
@import 'mapdoorplate.scss';
</style>