Files
chaozhanggui/pluss-wap-page/src/main/webapp/WEB-INF/jsp/merchant/wxLocation.jsp
junshuai 62548736a7 add file
2022-07-23 13:54:07 +08:00

103 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<jsp:include page="../../common.jsp" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>提示</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
<style>
html {
font-family: Source Sans Pro,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;
word-spacing: .03125rem;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.lineH2{
line-height: 2rem;
}
p{
font-size: 16px;
}
.btn{
border: 0;
border-radius: 20px;
height: 1.8rem;
background-color: #FF586A;
color: #fff;
font-size: .8rem;
width: 80%;
}
</style>
</head>
<body style="background:#ffff;">
<div class="login_form ml20 mr20 mt50">
<div class="weui-cells weui-cells_form mt50 tcenter">
<div class=" f55 white dlblock radiusp50 padding15">
<img src="${resourcePath}/images/error_img.png" width="100" height="100">
</div>
<div class="lineH2" style="text-align: center;">
<p>您的付款距离与店铺过远,请当面付款!</p>
<p>如位置判断有误,授权获取定位后支付!</p>
</div>
<div class="mt30" style="display: ${empty province ? 'block' : 'none'}">
<button class="btn read" onclick="getLocation()">获取定位</button>
</div>
</div>
</div>
</body>
<script>
wx.config({
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来若要查看传入的参数可以在pc端打开参数信息会通过log打出仅在pc端时才会打印。
appId: '${appId}', // 必填,公众号的唯一标识
timestamp: '${timestamp}', // 必填,生成签名的时间戳
nonceStr: '${noncestr}', // 必填,生成签名的随机串
signature: '${sign}',// 必填,签名
jsApiList: ["getLocation"], // 必填需要使用的JS接口列表
verifyJsApiList:["geoLocation"]
});
wx.ready(function(){
// config信息验证后会执行ready方法所有接口调用都必须在config接口获得结果之后config是一个客户端的异步操作所以如果需要在页面加载时就调用相关接口则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口则可以直接调用不需要放在ready函数中。
});
wx.error(function(res){
// config信息验证失败会执行error函数如签名过期导致验证失败具体错误信息可以打开config的debug模式查看也可以在返回的res参数中查看对于SPA可以在这里更新签名。
});
function getLocation(){
$.showLoading("获取中...");
wx.miniProgram.geoLocation({
type: 'gcj02', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02'
success: function (res) {
let latitude = res.latitude; // 纬度浮点数范围为90 ~ -90
let longitude = res.longitude; // 经度浮点数范围为180 ~ -180。
getAddress(latitude,longitude);
},cancel:function (){
$.alert("请先授权获取位置信息!");
},fail:function (res){
$.alert(JSON.stringify(res));
}
});
}
function getAddress(latitude,longitude){
let url = ctx + "/wechat/getAddress";
$.post(url,{lat:latitude,lng:longitude},function (res){
$.hideLoading();
if(res.code != 200){
return $.alert(res.message,"系统提示");
}
window.localStorage.setItem("province",res.data);
window.location.href = ctx + "/merchant/recharge?storeId=${storeId}&appOpenId=${appOpenId}"
})
}
</script>
</html>