mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-05-09 19:47:22 +08:00
### 0.3.8 专业版:
【优化】增加腾讯位置服务插件-微信小程序地图选点插件,替换以前的js调用腾讯地图选点插件。
This commit is contained in:
@@ -78,6 +78,8 @@ const install = (Vue, vm) => {
|
|||||||
let saveUserShipWx = (params, config = {}) => http.post('/Api/User/SaveUserShip', params, { custom: { methodName: 'user.saveusership', needToken: true } });
|
let saveUserShipWx = (params, config = {}) => http.post('/Api/User/SaveUserShip', params, { custom: { methodName: 'user.saveusership', needToken: true } });
|
||||||
//获取区域ID
|
//获取区域ID
|
||||||
let getAreaId = (params, config = {}) => http.post('/Api/User/GetAreaId', params, { custom: { methodName: 'user.getareaid', needToken: false } });
|
let getAreaId = (params, config = {}) => http.post('/Api/User/GetAreaId', params, { custom: { methodName: 'user.getareaid', needToken: false } });
|
||||||
|
//根据区/县名称获取城市id信息
|
||||||
|
let getAreaIdByName = (params, config = {}) => http.post('/Api/User/GetAreaIdByName', params, { custom: { methodName: 'user.getareaid', needToken: false } });
|
||||||
// 获取收货地址详情
|
// 获取收货地址详情
|
||||||
let shipDetail = (params, config = {}) => http.post('/Api/User/GetShipDetail', params, { custom: { methodName: 'user.getshipdetail', needToken: true } });
|
let shipDetail = (params, config = {}) => http.post('/Api/User/GetShipDetail', params, { custom: { methodName: 'user.getshipdetail', needToken: true } });
|
||||||
// 收货地址编辑
|
// 收货地址编辑
|
||||||
@@ -439,6 +441,7 @@ const install = (Vue, vm) => {
|
|||||||
saveUserShip,
|
saveUserShip,
|
||||||
saveUserShipWx,
|
saveUserShipWx,
|
||||||
getAreaId,
|
getAreaId,
|
||||||
|
getAreaIdByName,
|
||||||
shipDetail,
|
shipDetail,
|
||||||
editShip,
|
editShip,
|
||||||
removeShip,
|
removeShip,
|
||||||
|
|||||||
@@ -110,9 +110,15 @@
|
|||||||
"es6": true,
|
"es6": true,
|
||||||
"checkSiteMap": false
|
"checkSiteMap": false
|
||||||
},
|
},
|
||||||
|
"plugins": {
|
||||||
|
"chooseLocation": {
|
||||||
|
"version": "1.0.9",
|
||||||
|
"provider": "wx76a9a06e5b4e693e"
|
||||||
|
}
|
||||||
|
},
|
||||||
"permission": {
|
"permission": {
|
||||||
"scope.userLocation": {
|
"scope.userLocation": {
|
||||||
"desc" : "用于获取您附近的门店列表"
|
"desc": "你的位置信息将用于小程序定位"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"optimization": {
|
"optimization": {
|
||||||
|
|||||||
@@ -19,41 +19,32 @@
|
|||||||
<u--input v-model="form.mobile" placeholder="请填写收货人手机号" />
|
<u--input v-model="form.mobile" placeholder="请填写收货人手机号" />
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<u-form-item label="选取区域" borderBottom>
|
<u-form-item label="省市县" borderBottom>
|
||||||
<coreshop-select v-model="show" mode="mutil-column-auto" :list="pickerList" :default-value="pickerIndex" @confirm="onConfirm"></coreshop-select>
|
<coreshop-select v-model="show" mode="mutil-column-auto" :list="pickerList" :default-value="pickerIndex" @confirm="onConfirm"></coreshop-select>
|
||||||
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
|
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
|
||||||
<!-- #ifndef APP-NVUE -->
|
<!-- #ifndef APP-NVUE -->
|
||||||
<u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
|
<u-input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
|
||||||
<template slot="suffix">
|
<template slot="suffix">
|
||||||
<u-button text="选择" type="success" size="mini" @click="show = true"></u-button>
|
<u-button text="请选择" type="success" size="mini" @click="toMap"></u-button>
|
||||||
</template>
|
</template>
|
||||||
</u-input>
|
</u-input>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
<!-- #ifdef APP-NVUE -->
|
<!-- #ifdef APP-NVUE -->
|
||||||
<u--input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
|
<u--input :value="pickerValue" type="select" disabled placeholder="请选择省市区区域">
|
||||||
<template slot="suffix">
|
<template slot="suffix">
|
||||||
<u-button text="选择" type="success" size="mini" @click="show = true"></u-button>
|
<u-button text="请选择" type="success" size="mini" @click="toMap"></u-button>
|
||||||
</template>
|
</template>
|
||||||
</u--input>
|
</u--input>
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
|
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
<u-form-item label="选取街道" borderBottom>
|
<u-form-item label="地点" borderBottom>
|
||||||
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
|
<!-- 注意:由于兼容性差异,如果需要使用前后插槽,nvue下需使用u--input,非nvue下需使用u-input -->
|
||||||
<!-- #ifndef APP-NVUE -->
|
<!-- #ifndef APP-NVUE -->
|
||||||
<u-input :value="form.street" type="text" disabled placeholder="请选择街道">
|
<u-input :value="form.street" type="text" disabled placeholder="请选择"></u-input>
|
||||||
<template slot="suffix">
|
|
||||||
<u-button text="选择" type="success" size="mini" @click="toMap"></u-button>
|
|
||||||
</template>
|
|
||||||
</u-input>
|
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
<!-- #ifdef APP-NVUE -->
|
<!-- #ifdef APP-NVUE -->
|
||||||
<u--input :value="form.street" type="text" disabled placeholder="请选择街道">
|
<u--input :value="form.street" type="text" disabled placeholder="请选择"></u--input>
|
||||||
<template slot="suffix">
|
|
||||||
<u-button text="选择" type="success" size="mini" @click="toMap"></u-button>
|
|
||||||
</template>
|
|
||||||
</u--input>
|
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
|
||||||
@@ -83,6 +74,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const chooseLocation = requirePlugin('chooseLocation');
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -96,6 +88,8 @@
|
|||||||
latitude: '',
|
latitude: '',
|
||||||
street: ''
|
street: ''
|
||||||
},
|
},
|
||||||
|
longitude: 0,
|
||||||
|
latitude: 0,
|
||||||
region: ['湖南省', '怀化市', '鹤城区'],
|
region: ['湖南省', '怀化市', '鹤城区'],
|
||||||
areaId: 0,
|
areaId: 0,
|
||||||
checked: false,
|
checked: false,
|
||||||
@@ -152,7 +146,47 @@
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onShow() {
|
||||||
|
const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
|
||||||
|
if (location != null) {
|
||||||
|
this.form.latitude = location.latitude;
|
||||||
|
this.form.longitude = location.longitude;
|
||||||
|
|
||||||
|
this.region = [location.province, location.district, location.city];
|
||||||
|
//let data = {
|
||||||
|
// provinceName: location.province,
|
||||||
|
// cityName: location.district,
|
||||||
|
// countyName: location.city
|
||||||
|
//};
|
||||||
|
this.form.street = location.name;
|
||||||
|
this.form.address = location.address;
|
||||||
|
|
||||||
|
let postData = {
|
||||||
|
id: location.district
|
||||||
|
}
|
||||||
|
this.$u.api.getAreaIdByName(postData).then(res => {
|
||||||
|
if (res.status) {
|
||||||
|
this.areaId = res.data.areaId;
|
||||||
|
this.pickerValue = res.data.fullName;
|
||||||
|
} else {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '地区选择出现问题,请重新选择地区',
|
||||||
|
showCancel: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
console.log("location1:", location);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUnload() {
|
||||||
|
// 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
|
||||||
|
chooseLocation.setLocation(null);
|
||||||
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
|
this.getMyLocation();
|
||||||
if (e.shipId) {
|
if (e.shipId) {
|
||||||
//编辑
|
//编辑
|
||||||
this.id = e.shipId;
|
this.id = e.shipId;
|
||||||
@@ -168,6 +202,21 @@
|
|||||||
this.$refs.uForm.setRules(this.rules);
|
this.$refs.uForm.setRules(this.rules);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 获取自己的位置信息
|
||||||
|
getMyLocation() {
|
||||||
|
let _this = this;
|
||||||
|
uni.getLocation({
|
||||||
|
type: 'wgs84',
|
||||||
|
success: function (res) {
|
||||||
|
_this.longitude = res.longitude;
|
||||||
|
_this.latitude = res.latitude;
|
||||||
|
},
|
||||||
|
fail: function () {
|
||||||
|
_this.$u.toast("获取位置信息失败")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
onConfirm(e) {
|
onConfirm(e) {
|
||||||
let provinceName = e[0].label;
|
let provinceName = e[0].label;
|
||||||
let cityName = e[1].label;
|
let cityName = e[1].label;
|
||||||
@@ -365,12 +414,24 @@
|
|||||||
this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey];
|
this.pickerIndex = [this.provinceKey, this.cityKey, this.areaKey];
|
||||||
},
|
},
|
||||||
toMap() {
|
toMap() {
|
||||||
if (!this.pickerValue) {
|
const txMapkey = this.$store.state.config.qqMapKey; //使用在腾讯位置服务申请的key
|
||||||
this.$u.toast('请先获取省市区信息');
|
const referer = this.$store.state.config.shopName; //调用插件的app的名称
|
||||||
return false;
|
const location = JSON.stringify({
|
||||||
} else {
|
latitude: this.form.latitude == "" ? this.latitude : this.form.latitude,
|
||||||
this.$u.route('/pages/member/address/map/map', { pickerValue: this.pickerValue, areaId: this.areaId, longitude: this.form.longitude, latitude: this.form.latitude });
|
longitude: this.form.longitude == "" ? this.longitude : this.form.longitude
|
||||||
}
|
});
|
||||||
|
const category = '';
|
||||||
|
|
||||||
|
wx.navigateTo({
|
||||||
|
url: 'plugin://chooseLocation/index?key=' + txMapkey + '&referer=' + referer + '&location=' +
|
||||||
|
location + '&category=' + category
|
||||||
|
});
|
||||||
|
//if (!this.pickerValue) {
|
||||||
|
// this.$u.toast('请先获取省市区信息');
|
||||||
|
// return false;
|
||||||
|
//} else {
|
||||||
|
// this.$u.route('/pages/member/address/map/map', { pickerValue: this.pickerValue, areaId: this.areaId, longitude: this.form.longitude, latitude: this.form.latitude });
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -561,6 +561,30 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 根据区/县名称获取城市id信息
|
||||||
|
/// <summary>
|
||||||
|
/// 根据区/县名称获取城市id信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<WebApiCallBack> GetAreaIdByName([FromBody] FMStringId entity)
|
||||||
|
{
|
||||||
|
var jm = new WebApiCallBack();
|
||||||
|
|
||||||
|
var dataArea = await _areaServices.QueryByClauseAsync(p => p.name == entity.id && p.depth == 3);
|
||||||
|
if (dataArea == null) return jm;
|
||||||
|
var fullName = await _areaServices.GetAreaFullName(dataArea.id);
|
||||||
|
jm.status = true;
|
||||||
|
jm.data = new
|
||||||
|
{
|
||||||
|
areaId = dataArea.id,
|
||||||
|
fullName = fullName.data
|
||||||
|
};
|
||||||
|
return jm;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 注销登录
|
#region 注销登录
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注销登录
|
/// 注销登录
|
||||||
|
|||||||
Reference in New Issue
Block a user