|
|
|
@ -3,8 +3,8 @@ |
|
|
|
|
<view class="example"> |
|
|
|
|
<!-- 基础表单校验 --> |
|
|
|
|
<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData"> |
|
|
|
|
<uni-forms-item class="content" label="名称" required name="name"> |
|
|
|
|
<input v-model="valiFormData.name" placeholder="请输入名称" /> |
|
|
|
|
<uni-forms-item class="content" label="名称" required name="pointName"> |
|
|
|
|
<input v-model="valiFormData.pointName" placeholder="请输入名称" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item class="content" label="坐标" required name="location"> |
|
|
|
|
<view class="uni-input-wrapper"> |
|
|
|
@ -90,16 +90,16 @@ export default { |
|
|
|
|
media: [], //数据源 |
|
|
|
|
// 校验表单数据 |
|
|
|
|
valiFormData: { |
|
|
|
|
name: '', |
|
|
|
|
location: '', |
|
|
|
|
longitude: '', |
|
|
|
|
latitude: '', |
|
|
|
|
pointName: '', |
|
|
|
|
lon: '', |
|
|
|
|
lat: '', |
|
|
|
|
remark: '', |
|
|
|
|
imgpath: '' |
|
|
|
|
img: '', |
|
|
|
|
location:'' |
|
|
|
|
}, |
|
|
|
|
// 校验规则 |
|
|
|
|
rules: { |
|
|
|
|
name: { |
|
|
|
|
pointName: { |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
@ -144,7 +144,7 @@ export default { |
|
|
|
|
// let token = res.data.data; //拿到必须的token |
|
|
|
|
urlList.forEach((item) => { |
|
|
|
|
this.uploadTask = uni.uploadFile({ |
|
|
|
|
url: 'http://39.105.17.128:8199/api/tool/uploadImg', //上传接口,仅为示例 |
|
|
|
|
url: 'http://localhost:18080/common/upload', //上传接口,仅为示例 |
|
|
|
|
filePath: item.src, |
|
|
|
|
name: 'file', |
|
|
|
|
// formData: { |
|
|
|
@ -153,13 +153,13 @@ export default { |
|
|
|
|
success: (res) => { |
|
|
|
|
let data = JSON.parse(res.data); //返回的数据 |
|
|
|
|
console.log(data); |
|
|
|
|
if (!data.data.src) { |
|
|
|
|
if (data.code != 200) { |
|
|
|
|
item.status = 'error'; |
|
|
|
|
item.progress = '上传失败'; |
|
|
|
|
} else { |
|
|
|
|
item.status = 'success'; |
|
|
|
|
item.progress = '上传成功'; |
|
|
|
|
item.src = data.data.src; |
|
|
|
|
item.src = data.fileName; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -184,11 +184,10 @@ export default { |
|
|
|
|
arr.push(item.src); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this_.valiFormData.imgpath = arr.join(','); |
|
|
|
|
this_.valiFormData.img = arr.join(','); |
|
|
|
|
uni.request({ |
|
|
|
|
header: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
|
|
|
|
url: 'http://39.105.17.128:8199/api/tool/saveData', //仅为示例,并非真实接口地址。 |
|
|
|
|
header: { 'Content-Type': 'application/json' }, |
|
|
|
|
url: 'http://192.168.130.154:18080/mobile/point', //仅为示例,并非真实接口地址。 |
|
|
|
|
data: this_.valiFormData, |
|
|
|
|
method: 'POST', |
|
|
|
|
success: (res) => { |
|
|
|
@ -197,7 +196,7 @@ export default { |
|
|
|
|
}); |
|
|
|
|
console.log('success', this_.valiFormData); |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: `校验通过` |
|
|
|
|
title: `保存成功` |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch((err) => { |
|
|
|
@ -211,8 +210,8 @@ export default { |
|
|
|
|
success: function (res) { |
|
|
|
|
console.log('当前位置的经度:' + res.longitude); |
|
|
|
|
console.log('当前位置的纬度:' + res.latitude); |
|
|
|
|
this_.valiFormData.longitude = res.longitude; |
|
|
|
|
this_.valiFormData.latitude = res.latitude; |
|
|
|
|
this_.valiFormData.lon = res.longitude; |
|
|
|
|
this_.valiFormData.lat = res.latitude; |
|
|
|
|
this_.valiFormData.location = '经度:' + res.longitude + ',纬度:' + res.latitude; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|