|
@@ -8,29 +8,36 @@
|
|
|
<text class="necessary">*</text>
|
|
|
站点名称:
|
|
|
</view>
|
|
|
- <input name="userName" v-model="formMess.siteName"></input>
|
|
|
+ <input name="userName" v-model="siteName"></input>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
<view class="title"><text class="necessary">*</text>地址:</view>
|
|
|
- <input name="input" v-model="formMess.address"></input>
|
|
|
+ <input name="input" v-model="address"></input>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
<view class="title"><text class="necessary">*</text>经度:</view>
|
|
|
- <input name="input" v-model="formMess.longitude"></input>
|
|
|
+ <input name="input" v-model="longitude"></input>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
- <view class="title"><text class="necessary">*</text>维度:</view>
|
|
|
- <input name="input" v-model="formMess.latitude"></input>
|
|
|
+ <view class="title"><text class="necessary">*</text>纬度:</view>
|
|
|
+ <input name="input" v-model="latitude"></input>
|
|
|
+ </view>
|
|
|
+ <view class="form-item">
|
|
|
+ <view class="title"></view>
|
|
|
+ <button class=" cu-btn " style="padding:10rpx 20rpx" @click="getLocation()">
|
|
|
+ <image src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
|
|
|
+ 获取当前经纬度
|
|
|
+ </button>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
<view class="title"><text class="necessary">*</text>联系人:</view>
|
|
|
- <input name="input" v-model="formMess.userName"></input>
|
|
|
+ <input name="input" v-model="userName"></input>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
<view class="title"><text class="necessary">*</text>手机号码:</view>
|
|
|
- <input name="input" v-model="formMess.phone"></input>
|
|
|
- </view>
|
|
|
-
|
|
|
+ <input name="input" v-model="phone"></input>
|
|
|
+ </view>
|
|
|
+
|
|
|
|
|
|
<view class="btn-area submitBottomBtn padding-lr-sm">
|
|
|
<button class="bg-blue round margin-top" @click="addSubmit">提 交 </button>
|
|
@@ -56,9 +63,16 @@
|
|
|
<input name="input" v-model="siteMessage.longitude"></input>
|
|
|
</view>
|
|
|
<view class="form-item">
|
|
|
- <view class="title">维度:</view>
|
|
|
+ <view class="title">纬度:</view>
|
|
|
<input name="input" v-model="siteMessage.latitude"></input>
|
|
|
</view>
|
|
|
+ <!-- <view class="form-item">
|
|
|
+ <view class="title"></view>
|
|
|
+ <button class=" cu-btn " style="padding:10rpx 20rpx" @click="getLocation2()">
|
|
|
+ <image src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
|
|
|
+ 获取当前经纬度
|
|
|
+ </button>
|
|
|
+ </view> -->
|
|
|
<view class="form-item">
|
|
|
<view class="title">联系人:</view>
|
|
|
<input name="input" v-model="siteMessage.userName"></input>
|
|
@@ -77,20 +91,21 @@
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
-<script>
|
|
|
+<script>
|
|
|
+ //引入js sdk的封装
|
|
|
+ import * as jwx from '../../util/jssdk.js'
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
|
|
|
- id: 0,
|
|
|
- formMess: {
|
|
|
- "siteName": "",
|
|
|
- "userName": "",
|
|
|
- "phone": "",
|
|
|
- "address": "",
|
|
|
- "longitude": "",
|
|
|
- "latitude": "",
|
|
|
- },
|
|
|
+ id: 0,
|
|
|
+ latitude: "",
|
|
|
+ siteName: "",
|
|
|
+ userName: "",
|
|
|
+ phone: "",
|
|
|
+ address: "",
|
|
|
+ longitude: "",
|
|
|
siteMessage:{}
|
|
|
}
|
|
|
},
|
|
@@ -107,69 +122,78 @@
|
|
|
title: '站点新增'
|
|
|
});
|
|
|
}
|
|
|
- // this.getLocation()
|
|
|
+
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
getLocation(){
|
|
|
- alert(1)
|
|
|
- uni.getLocation({
|
|
|
-
|
|
|
- type: 'wgs84',
|
|
|
- success: function (res) {
|
|
|
- alert(2)
|
|
|
- console.log('当前位置的经度:' + res.longitude);
|
|
|
- console.log('当前位置的纬度:' + res.latitude);
|
|
|
- }
|
|
|
+ // 将this赋值给that
|
|
|
+ let that = this
|
|
|
+ // 微信公众号获取位置
|
|
|
+ jwx.configWeiXin(jweixin => {
|
|
|
+ wx.getLocation({
|
|
|
+ type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
|
|
+ success: function (res) {
|
|
|
+ // var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
|
|
|
+ // var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
|
|
|
+ // var speed = res.speed; // 速度,以米/每秒计
|
|
|
+ // var accuracy = res.accuracy; // 位置精度
|
|
|
+
|
|
|
+ that.longitude=res.longitude
|
|
|
+ that.latitude=res.latitude
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- },
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//新增验证并提交
|
|
|
addSubmit() {
|
|
|
- if (!this.formMess.siteName) {
|
|
|
+ if (!this.siteName) {
|
|
|
uni.showToast({
|
|
|
title: "请输入站点名称...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!this.formMess.address) {
|
|
|
+ if (!this.address) {
|
|
|
uni.showToast({
|
|
|
title: "请输入地址...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!this.formMess.longitude) {
|
|
|
+ if (!this.longitude) {
|
|
|
uni.showToast({
|
|
|
title: "请输入经度...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!this.formMess.latitude) {
|
|
|
+ if (!this.latitude) {
|
|
|
uni.showToast({
|
|
|
title: "请输入纬度...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!this.formMess.userName) {
|
|
|
+ if (!this.userName) {
|
|
|
uni.showToast({
|
|
|
title: "请输入联系人...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!this.formMess.phone) {
|
|
|
+ if (!this.phone) {
|
|
|
uni.showToast({
|
|
|
title: "请输入手机号码...",
|
|
|
icon: "none"
|
|
|
});
|
|
|
return
|
|
|
}
|
|
|
- if (!/^1[345678]\d{9}$/.test(this.formMess.phone)){
|
|
|
+ if (!/^1[345678]\d{9}$/.test(this.phone)){
|
|
|
uni.showToast({
|
|
|
title: "请输入正确的手机号码...",
|
|
|
icon:"none"
|
|
@@ -177,12 +201,12 @@
|
|
|
return
|
|
|
}
|
|
|
this.getAddSite({
|
|
|
- "siteName": this.formMess.siteName,
|
|
|
- "userName": this.formMess.userName,
|
|
|
- "phone": this.formMess.phone,
|
|
|
- "address": this.formMess.address,
|
|
|
- "longitude": this.formMess.longitude,
|
|
|
- "latitude": this.formMess.latitude
|
|
|
+ "siteName": this.siteName,
|
|
|
+ "userName": this.userName,
|
|
|
+ "phone": this.phone,
|
|
|
+ "address": this.address,
|
|
|
+ "longitude": this.longitude,
|
|
|
+ "latitude": this.latitude
|
|
|
})
|
|
|
},
|
|
|
|