lion 3 years ago
parent 6f0b50dcdf
commit 9dda1e1de2

@ -54,7 +54,12 @@
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
"usingComponents" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "获取地点"
}
}
},
"vueVersion" : "2",
"h5" : {

@ -1,6 +1,6 @@
<template>
<view class="wrap">
<uni-forms ref="form" :modelValue="form" :rules="rules" label-align="right">
<uni-forms ref="form" :modelValue="form" :rules="rules" :label-width='85' label-align="right">
<uni-section title="访视信息" type="line">
<uni-forms-item label="访视时间" required="">
<uni-datetime-picker type="date" :clear-icon="false" v-model="form.viewtime"
@ -58,8 +58,9 @@
<uni-forms-item label="户籍地址">
<uni-easyinput type="text" v-model="form.address" placeholder="请输入户籍地址"></uni-easyinput>
</uni-forms-item>
<uni-forms-item label="现居住地" required>
<uni-easyinput type="text" @focus='chooseReside' v-model="form.reside" placeholder="请输入现居住地"></uni-easyinput>
<uni-forms-item label="现居住地" required>
<uni-easyinput type="text" @focus='chooseReside' v-model="form.reside"
placeholder="请输入现居住地"></uni-easyinput>
<!-- <uni-easyinput type="text" v-model="form.reside" placeholder="请输入现居住地"></uni-easyinput> -->
</uni-forms-item>
</uni-section>
@ -157,20 +158,105 @@
selectChange(e, type) {
console.log(e, type)
},
chooseReside(){
var that = this;
console.log(parseFloat(that.form.latitude),parseFloat(that.form.longitude))
let _latlog= that.gcoord.transformFromWGSToGCJ(parseFloat(that.form.latitude),parseFloat(that.form.longitude));
uni.chooseLocation({
longitude:_latlog.longitude,
latitude: _latlog.latitude,
success: res => {
console.log(res)
that.form.reside = res.address;
that.form.longitude = res.longitude;
that.form.latitude = res.latitude;
}
});
// #ifdef MP-WEIXIN
// getLocationInfo
async getLocationInfo() {
let that = this
//
uni.getSetting({
success(res) {
console.log(res)
//
if (!res.authSetting['scope.userLocation']) {
//
uni.authorize({
scope: 'scope.userLocation',
success() {
//-- 使
uni.getLocation({
type: 'wgs84',
success: function(res) {
console.log(res)
console.log('当前位置的经度1' + res.longitude)
console.log('当前位置的纬度1' + res.latitude)
},
fail(error) {
uni.showToast({
title: '获取地址失败,请检查手机是否打开定位功能,未打开将导致部分功能不可用',
icon: 'none'
});
}
})
},
fail(error) {
//----
console.log('拒绝授权', error)
uni.showModal({
title: '提示',
content: '若点击不授权,将无法使用位置功能',
showCancel: false,
// cancelText: '',
// cancelColor: '#999',
confirmText: '授权',
confirmColor: '#f94218',
success(res) {
console.log(res)
if (res.confirm) {
//
uni.openSetting({
success(res) {
console.log(res.authSetting)
}
})
} else if (res.cancel) {
//
console.log('用户点击不授权')
}
}
})
}
})
} else {
//
uni.getLocation({
type: 'wgs84',
success: function(res) {
console.log(res)
console.log('当前位置的经度1' + res.longitude)
console.log('当前位置的纬度1' + res.latitude)
},
fail(error) {
uni.showToast({
title: '获取地址失败,请检查手机是否打开定位功能,未打开将导致部分功能不可用',
icon: 'none'
});
console.log('失败', error)
}
})
}
}
})
},
// #endif
chooseReside() {
var that = this;
console.log(parseFloat(that.form.latitude), parseFloat(that.form.longitude))
// let _latlog= {
// longitude:that.form.longitude,
// latitude: that.form.latitude,
// }
let _latlog = that.gcoord.transformFromWGSToGCJ(parseFloat(that.form.latitude), parseFloat(that.form
.longitude));
uni.chooseLocation({
longitude: _latlog.longitude,
latitude: _latlog.latitude,
success: res => {
console.log(res)
that.form.reside = res.address;
that.form.longitude = res.longitude;
that.form.latitude = res.latitude;
}
});
},
getLabel() {
let that = this

File diff suppressed because one or more lines are too long

@ -12,5 +12,10 @@
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"permission": {
"scope.userLocation": {
"desc": "获取地点"
}
},
"usingComponents": {}
}

@ -361,6 +361,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
//
//
//
//
var _default = {
data: function data() {
return {
@ -396,9 +397,104 @@ var _default = {
selectChange: function selectChange(e, type) {
console.log(e, type);
},
// getLocationInfo方法为用户点击后调用
getLocationInfo: function getLocationInfo() {
var _this = this;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
var that;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
that = _this; // 获取用户是否开启 授权获取当前的地理位置、速度的权限。
uni.getSetting({
success: function success(res) {
console.log(res);
// 如果没有授权
if (!res.authSetting['scope.userLocation']) {
// 则拉起授权窗口
uni.authorize({
scope: 'scope.userLocation',
success: function success() {
//点击允许后--就一直会进入成功授权的回调 就可以使用获取的方法了
uni.getLocation({
type: 'wgs84',
success: function success(res) {
console.log(res);
console.log('当前位置的经度1' + res.longitude);
console.log('当前位置的纬度1' + res.latitude);
},
fail: function fail(error) {
uni.showToast({
title: '获取地址失败,请检查手机是否打开定位功能,未打开将导致部分功能不可用',
icon: 'none'
});
}
});
},
fail: function fail(error) {
//点击了拒绝授权后--就一直会进入失败回调函数--此时就可以在这里重新拉起授权窗口
console.log('拒绝授权', error);
uni.showModal({
title: '提示',
content: '若点击不授权,将无法使用位置功能',
showCancel: false,
// cancelText: '不授权',
// cancelColor: '#999',
confirmText: '授权',
confirmColor: '#f94218',
success: function success(res) {
console.log(res);
if (res.confirm) {
// 选择弹框内授权
uni.openSetting({
success: function success(res) {
console.log(res.authSetting);
}
});
} else if (res.cancel) {
// 选择弹框内 不授权
console.log('用户点击不授权');
}
}
});
}
});
} else {
// 有权限则直接获取
uni.getLocation({
type: 'wgs84',
success: function success(res) {
console.log(res);
console.log('当前位置的经度1' + res.longitude);
console.log('当前位置的纬度1' + res.latitude);
},
fail: function fail(error) {
uni.showToast({
title: '获取地址失败,请检查手机是否打开定位功能,未打开将导致部分功能不可用',
icon: 'none'
});
console.log('失败', error);
}
});
}
}
});
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
chooseReside: function chooseReside() {
var that = this;
console.log(parseFloat(that.form.latitude), parseFloat(that.form.longitude));
// let _latlog= {
// longitude:that.form.longitude,
// latitude: that.form.latitude,
// }
var _latlog = that.gcoord.transformFromWGSToGCJ(parseFloat(that.form.latitude), parseFloat(that.form.longitude));
uni.chooseLocation({
longitude: _latlog.longitude,
@ -463,21 +559,21 @@ var _default = {
});
},
loadDetail: function loadDetail() {
var _this = this;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
var _this2 = this;
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
var that;
return _regenerator.default.wrap(function _callee$(_context) {
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context.prev = _context.next) {
switch (_context2.prev = _context2.next) {
case 0:
that = _this;
_this.util.request({
that = _this2;
_this2.util.request({
api: '/api/admin/base-form/show',
method: "get",
data: {
id: _this.select.id,
table_name: _this.select.tableName,
show_relation: _this.select.show_relation
id: _this2.select.id,
table_name: _this2.select.tableName,
show_relation: _this2.select.show_relation
},
utilSuccess: function utilSuccess(res) {
that.form = res;
@ -493,23 +589,23 @@ var _default = {
});
case 2:
case "end":
return _context.stop();
return _context2.stop();
}
}
}, _callee);
}, _callee2);
}))();
},
submit: function submit() {
var _this2 = this;
var _this3 = this;
this.form.checkstatus = '待审核';
this.form.id = '';
this.$refs['form'].validate().then(function (res) {
_this2.util.request({
_this3.util.request({
api: '/api/admin/base-form/save',
method: "post",
data: _objectSpread({
table_name: _this2.select.submitName
}, _this2.form),
table_name: _this3.select.submitName
}, _this3.form),
utilSuccess: function utilSuccess(res) {
uni.showToast({
title: "提交成功",

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save