<%@ 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>
    <script src="https://www.shouyinbei.net/resources/js/alipayjsapi.min3.1.1.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="page-title tcenter bluebg white h40 white positionr">
    <div>
        <span>提示</span>
    </div>
</div>
<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">获取定位</button>
        </div>
    </div>
</div>
<form id="form" class="hiddenForm">

    <input type="hidden" id="code" name="code" value="${code}">
    <input type="hidden" id="auth_code" name="auth_code" value="${auth_code}">
    <input type="hidden" id="userAuthCode" name="userAuthCode" value="${userAuthCode}">

    <input type="hidden" id="merchantCode" name="merchantCode" value="${merchantCode}">
    <input type="hidden" id="userAppId" name="userAppId" value="${userAppId}">
    <input type="hidden" id="qrNo" name="qrNo" value="${qrNo}">

    <input type="hidden" id="payType" name="payType" value="${payType}">
    <input type="hidden" id="cokus" name="cokus" value="${cokus}">
    <input type="hidden" id="province" name="province" value="">
</form>
</body>
<script>
    function ready(callback) {
        // 如果jsbridge已经注入则直接调用
        if (window.AlipayJSBridge) {
            callback && callback();
        } else {
            // 如果没有注入则监听注入的事件
            document.addEventListener('AlipayJSBridgeReady', callback, false);
        }
    }
    ready(function() {
        document.querySelector('.read').addEventListener('click', function() {
            AlipayJSBridge.call('getCurrentLocation', { bizType: '$s',requestType:1}, function(result) {
                if (result.error) {
                    AlipayJSBridge.call('alert', {
                        title: '提示',
                        message: result.errorMessage,
                        button: '确定'
                    }, function(e) {
                    });
                    return;
                }else{
                    let province = result.province;
                    $("#province").val(province);
                    let data = $("#form").serialize();
                    window.location.href = ctx + "/merchant/h5pay?"+data;
                }
            });
        });
    });
</script>
</html>