|
|
@@ -20,6 +20,12 @@ var qqmapsdk;
|
|
|
* 小程序地图调用
|
|
|
*/
|
|
|
function onClickWxchartAddress() {
|
|
|
+ const key = config.key; //使用在腾讯位置服务申请的key
|
|
|
+ const referer = 'wx76a9a06e5b4e693e'; //调用插件的app的名称
|
|
|
+ const category = '小区';
|
|
|
+ wx.navigateTo({
|
|
|
+ url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer + '&category=' + category
|
|
|
+ });
|
|
|
const key = config.key; //使用在腾讯位置服务申请的key
|
|
|
const referer = 'wx76a9a06e5b4e693e'; //调用插件的app的名称
|
|
|
const category = '小区';
|
|
|
@@ -32,6 +38,17 @@ function onClickWxchartAddress() {
|
|
|
* @param {*} functionCode
|
|
|
*/
|
|
|
function hasRight(functionCode) {
|
|
|
+ let rights = app.globalData.user.rights
|
|
|
+ let value = false
|
|
|
+ if (rights != null && rights.length > 0) {
|
|
|
+ rights.forEach(item => {
|
|
|
+ if (item.FunctionCode == functionCode) {
|
|
|
+ value = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return value
|
|
|
let rights = app.globalData.user.rights
|
|
|
let value = false
|
|
|
if (rights != null && rights.length > 0) {
|
|
|
@@ -51,6 +68,22 @@ function hasRight(functionCode) {
|
|
|
* @param {*} minus
|
|
|
*/
|
|
|
function navigatePosition(selectid, minus) {
|
|
|
+ //1、返回一个查询实例
|
|
|
+ const query = wx.createSelectorQuery();
|
|
|
+ //2、选择要跳转的节点id
|
|
|
+ query.select('#' + selectid).boundingClientRect();
|
|
|
+ //3、获取显示区域的尺寸、滚动等位置等信息,然后添加节点的滚动位置查询
|
|
|
+ query.selectViewport().scrollOffset();
|
|
|
+ //4、执行跳转
|
|
|
+ query.exec((res) => {
|
|
|
+ //5、res[0]是步骤2中的数据,res[1]是步骤3中的数据
|
|
|
+ if (res[0] && res[1]) {
|
|
|
+ //6、将页面滚动到目标位置 减300不是固定的 根据自己的要求调
|
|
|
+ wx.pageScrollTo({
|
|
|
+ //7、计算滚动到目标的位置
|
|
|
+ scrollTop: res[0].top + res[1].scrollTop - minus,
|
|
|
+ duration: 300
|
|
|
+ })
|
|
|
//1、返回一个查询实例
|
|
|
const query = wx.createSelectorQuery();
|
|
|
//2、选择要跳转的节点id
|
|
|
@@ -80,6 +113,7 @@ function toThousandCents(num) {
|
|
|
if (num == undefined) {
|
|
|
return 0;
|
|
|
}
|
|
|
+ });
|
|
|
var num = num + '';
|
|
|
var d = '';
|
|
|
if (num.slice(0, 1) == '-') {
|
|
|
@@ -106,12 +140,35 @@ function toThousandCents(num) {
|
|
|
}
|
|
|
return d + (result + num2)
|
|
|
}
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 导航
|
|
|
*/
|
|
|
function navigate(address) {
|
|
|
-
|
|
|
+ qqmapsdk.geocoder({
|
|
|
+ //获取表单传入地址
|
|
|
+ address: address,
|
|
|
+ //地址参数,例:固定地址,address: '北京市海淀区彩和坊路海淀西大街74号'
|
|
|
+ success: function (res) {//成功后的回调
|
|
|
+ var res = res.result;
|
|
|
+ var latitude = res.location.lat;
|
|
|
+ var longitude = res.location.lng;
|
|
|
+
|
|
|
+ wx.openLocation({
|
|
|
+ latitude,
|
|
|
+ longitude,
|
|
|
+ scale: 18
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function (error) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '地址无法导航',
|
|
|
+ image: '/static/image/warning.png',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: function (res) {
|
|
|
qqmapsdk.geocoder({
|
|
|
//获取表单传入地址
|
|
|
address: address,
|
|
|
@@ -165,6 +222,8 @@ function setSkuIcon(skuData) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ })
|
|
|
+}
|
|
|
}
|
|
|
/**
|
|
|
* @desc : 设置行的图标路径
|
|
|
@@ -226,6 +285,23 @@ function setRowImagePath(it) {
|
|
|
* @param {*} loc
|
|
|
*/
|
|
|
function reverseGeocoder(loc) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ qqmapsdk.reverseGeocoder({
|
|
|
+ location: {
|
|
|
+ latitude: loc.latitude,
|
|
|
+ longitude: loc.longitude
|
|
|
+ } || '',
|
|
|
+ //get_poi: 1, //是否返回周边POI列表:1.返回;0不返回(默认),非必须参数
|
|
|
+ success: function (res) {//成功后的回调
|
|
|
+ resolve(res)
|
|
|
+ },
|
|
|
+ fail: function (error) {
|
|
|
+ resolve('')
|
|
|
+ },
|
|
|
+ complete: function (res) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
return new Promise(resolve => {
|
|
|
qqmapsdk.reverseGeocoder({
|
|
|
location: {
|
|
|
@@ -251,6 +327,25 @@ function reverseGeocoder(loc) {
|
|
|
* @param {*} toloc
|
|
|
*/
|
|
|
function calculateDistance(fromloc, toloc) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ //调用距离计算接口
|
|
|
+ qqmapsdk.calculateDistance({
|
|
|
+ //mode: 'straight',//可选值:'driving'(驾车)、'walking'(步行),不填默认:'walking',可不填 新增直线距离计算,‘straight’(直线)
|
|
|
+ //from参数不填默认当前地址
|
|
|
+ //获取表单提交的经纬度并设置from和to参数(示例为string格式)
|
|
|
+ from: fromloc, //若起点有数据则采用起点坐标,若为空默认当前地址
|
|
|
+ to: toloc, //终点坐标
|
|
|
+ success: function (res) {//成功后的回调
|
|
|
+ var destinationDistance = res.result.elements[0].distance;
|
|
|
+ console.log("calculateDistance-ok", res);
|
|
|
+ resolve(destinationDistance)
|
|
|
+ },
|
|
|
+ fail: function (error) {
|
|
|
+ console.log("calculateDistance-error", error);
|
|
|
+ resolve(0)
|
|
|
+ },
|
|
|
+ complete: function (res) {
|
|
|
+ }
|
|
|
return new Promise(resolve => {
|
|
|
//调用距离计算接口
|
|
|
qqmapsdk.calculateDistance({
|
|
|
@@ -272,6 +367,7 @@ function calculateDistance(fromloc, toloc) {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -281,6 +377,14 @@ function calculateDistance(fromloc, toloc) {
|
|
|
* @param {*} lng
|
|
|
*/
|
|
|
function bdMap_to_wxMap(lat, lng) {
|
|
|
+ let pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
+ let x = lng - 0.0065;
|
|
|
+ let y = lat - 0.006;
|
|
|
+ var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
|
|
|
+ var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
|
|
|
+ let lngv = z * Math.cos(theta);
|
|
|
+ let latv = z * Math.sin(theta);
|
|
|
+ return { 'longitude': lngv, 'latitude': latv };
|
|
|
let pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
let x = lng - 0.0065;
|
|
|
let y = lat - 0.006;
|
|
|
@@ -297,6 +401,14 @@ function bdMap_to_wxMap(lat, lng) {
|
|
|
* @param {*} lng
|
|
|
*/
|
|
|
function wxMap_to_bdMap(lat, lng) {
|
|
|
+ let pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
+ let x = lng;
|
|
|
+ let y = lat;
|
|
|
+ var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
|
|
|
+ var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
|
|
|
+ let lngv = z * Math.cos(theta) + 0.0065;
|
|
|
+ let latv = z * Math.sin(theta) + 0.006;
|
|
|
+ return { 'longitude': lngv, 'latitude': latv };
|
|
|
let pi = 3.14159265358979324 * 3000.0 / 180.0;
|
|
|
let x = lng;
|
|
|
let y = lat;
|
|
|
@@ -310,6 +422,11 @@ function wxMap_to_bdMap(lat, lng) {
|
|
|
* 在onload时间中新建qq地址对象
|
|
|
*/
|
|
|
function openQQMap() {
|
|
|
+ if (qqmapsdk === undefined || qqmapsdk === null) {
|
|
|
+ qqmapsdk = new QQMapWX({
|
|
|
+ key: '7I3BZ-VADCX-TJQ4C-TN5O4-F4BZE-RDFCK'
|
|
|
+ });
|
|
|
+ }
|
|
|
if (qqmapsdk === undefined || qqmapsdk === null) {
|
|
|
qqmapsdk = new QQMapWX({
|
|
|
key: '7I3BZ-VADCX-TJQ4C-TN5O4-F4BZE-RDFCK'
|
|
|
@@ -393,6 +510,9 @@ function countLastAmount(choosedGoodsList, followFlag) {
|
|
|
* @param {*} functionCode
|
|
|
*/
|
|
|
function hasButtonRight(functionCode) {
|
|
|
+ let buttonRights = app.globalData.buttonRights
|
|
|
+ let orderAuditVisible = buttonRights.indexOf(functionCode)
|
|
|
+ return orderAuditVisible == -1 ? false : true
|
|
|
let buttonRights = app.globalData.buttonRights
|
|
|
let orderAuditVisible = buttonRights.indexOf(functionCode)
|
|
|
return orderAuditVisible == -1 ? false : true
|
|
|
@@ -420,6 +540,9 @@ function hasInputPageItemMust(functionCode) {
|
|
|
* @param {*} functionCode
|
|
|
*/
|
|
|
function hasPageUUidRight(uuid) {
|
|
|
+ let pageRights = app.globalData.pageRights
|
|
|
+ let pageVisible = pageRights.indexOf(uuid)
|
|
|
+ return pageVisible == -1 ? false : true
|
|
|
if (uuid) {
|
|
|
let pageRights = app.globalData.pageRights
|
|
|
let pageVisible = pageRights.indexOf(uuid)
|
|
|
@@ -454,6 +577,17 @@ function isUserSensitive() {
|
|
|
* 导出函数
|
|
|
*/
|
|
|
module.exports = {
|
|
|
+ openQQMap,
|
|
|
+ navigate,
|
|
|
+ reverseGeocoder,
|
|
|
+ calculateDistance,
|
|
|
+ hasButtonRight,
|
|
|
+ hasRight,
|
|
|
+ wxMap_to_bdMap,
|
|
|
+ bdMap_to_wxMap,
|
|
|
+ onClickWxchartAddress,
|
|
|
+ hasPageUUidRight
|
|
|
+
|
|
|
openQQMap,
|
|
|
navigate,
|
|
|
toThousandCents,
|