123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta content="yes" name="apple-mobile-web-app-capable">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
- <title>支付结果</title>
- <link rel="stylesheet" type="text/css" href="../common/reset.css"/>
- <script src="../common/jquery-2.1.0.js"></script>
- <script src="../common/md5.js"></script>
- <script type="text/javascript">
- document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
- window.onresize = function(){
- document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
- }
- </script>
- <style>
- .paymentResultImg{
- width: 2.72rem;
- height: 2.43rem;
- display: block;
- margin: 1.27rem auto 0;
- }
- .completeButton{
- width:2.70rem;
- height:0.46rem;
- background:linear-gradient(90deg,rgba(6,135,255,1) 0%,rgba(20,82,255,1) 100%);
- border-radius:0.10rem;
- color: #FFFFFF;
- font-size: 0.16rem;
- line-height: 0.46rem;
- text-align: center;
- border: none;
- margin: 0.49rem auto 0;
- display: block
- }
- .againPayment{
- width:2.70rem;
- height:0.46rem;
- border-radius:0.10rem;
- opacity:0.8459;
- border:0.01rem solid rgba(56,110,255,1);
- color: #386EFF;
- font-size: 0.16rem;
- text-align: center;
- line-height: 0.46rem;
- display: block;
- margin: 0.12rem auto 0;
- background: #ffffff;
- }
- .mask{
- width: 100%;
- height: 100vh;
- background: rgba(0,0,0,0.7);
- position: fixed;
- top: 0;
- left: 0;
- display: none;
- }
- .mask .content{
- width:3rem;
- height:1.56rem;
- background:rgba(255,255,255,1);
- border-radius:0.1rem;
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- margin: auto;
- }
- .mask .content .hint{
- width: 2.5rem;
- color: #222222;
- font-size: 0.16rem;
- line-height: 0.22rem;
- margin: 0.44rem auto 0.3rem;
- text-align: center;
- }
- .mask .content button{
- width:2.7rem;
- height:0.46rem;
- background:linear-gradient(90deg,rgba(6,135,255,1) 0%,rgba(20,82,255,1) 100%);
- border-radius:0.1rem;
- color: #FFFFFF;
- font-size: 0.16rem;
- line-height: 0.46rem;
- text-align: center;
- border: none;
- display: block;
- margin: auto;
- }
- </style>
- </head>
- <body>
- <img src="./img/paymentResultImg.png" class="paymentResultImg" alt="">
- <button class="completeButton" onclick="alipayMaskEvent(1)">已完成支付</button>
- <button class="againPayment" onclick="againPaymentEvent()">重新支付</button>
- <!-- 提示弹框 -->
- <div class="mask">
- <div class="content">
- <p class="hint">尚未查询到支付成功请重试!</p>
- <button onclick="alipayMaskEvent(2)">我知道了</button>
- </div>
- </div>
- <div class="alert-info" style="display: none;">
- <!-- tip提示,3s后消失 -->
- <p>请在浏览器中打开</p>
- </div>
- <!-- loading -->
- <div class="loading">
- <img src="../img/loading.gif" />
- </div>
- </body>
- </html>
- <script>
- var qs = parseQueryString(window.location.href),code='',mode='',order_id='',isSuccess=false;
- // var BASEURL = 'https://media.kuxuan-inc.com'
- var BASEURL = ''
- var userInfo = '', ttl = '', sign = '',platform = qs.platform?qs.platform:1;
- var locationPage = qs.platform == 2 ? './dou/index.html' : './index.html'
- $().ready(function(){
- if(platform == 2){//抖音
- if(getCookie('userInfoDou')){
- userInfo = JSON.parse(getCookie('userInfoDou'))
- ttl = userInfo.ttl;
- sign = hex_md5("random="+userInfo.random+"&ttl="+userInfo.ttl+"&user_id="+userInfo.id)
- init()
- }else{
- window.location.href = locationPage
- }
- }else{
- if(getCookie('userInfo')){
- userInfo = JSON.parse(getCookie('userInfo'))
- ttl = userInfo.ttl;
- sign = hex_md5("random="+userInfo.random+"&ttl="+userInfo.ttl+"&user_id="+userInfo.id)
- init()
- }else{
- window.location.href = locationPage
- }
- }
- })
- function init(){
- if(qs.order_id){
- order_id = qs.order_id
- }
- code = qs.code ? qs.code : ''
- if(qs.jsApiParameters){//微信内部支付
- weChatJSBrudge(JSON.parse(qs.jsApiParameters))
- return
- }
- if(qs.mode == 'weChat'){
- if(qs.code){
- code = qs.code
- // wxPayCheckOrder()
- }else{
- showMsg('系统错误,无订单编号')
- }
- }
- if(qs.mode == 'alipay'){//支付宝
- if(qs.code){
- code = qs.code
- aliPayCheckOrder()
- }else{
- showMsg('系统错误,无订单编号')
- }
- }
- }
- function weChatJSBrudge(data){
- var data = data;
- console.log(data)
- function onBridgeReady(){
- WeixinJSBridge.invoke(
- 'getBrandWCPayRequest', data,
- function(res){
- if(res.err_msg == "get_brand_wcpay_request:ok" ){
- // 使用以上方式判断前端返回,微信团队郑重提示:
- //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
- }
- });
- }
- if (typeof WeixinJSBridge == "undefined"){
- if( document.addEventListener ){
- document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
- }else if (document.attachEvent){
- document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
- document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
- }
- }else{
- onBridgeReady();
- }
- }
- function weChatPayment(){//微信外部支付
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: BASEURL + '/api/wxPay/wapPay',
- data:{
- 'order_id':order_id,
- 'uid':userInfo.id,
- 'ttl':ttl,
- 'sign':sign,
- 'platform':platform
- },
- success: function (res) {
- $(".loading").hide();
- if(res.errno == 0){
- if(res.rst.redirect_url){
- window.location.href = res.rst.redirect_url
- }
- }else if (res.errno == 4001 || res.errno == 4002){
- window.location.href = locationPage
- showMsg(res.err)
- }else{
- showMsg(res.err)
- }
- },
- error: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- function wxPayCheckOrder(cd,ercd){//微信查询支付状态
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: BASEURL + '/api/wxPay/checkOrder',
- data:{
- 'code':code,
- 'uid':userInfo.id,
- 'ttl':ttl,
- 'sign':sign,
- 'platform':platform
- },
- success: function (res) {
- $(".loading").hide();
- if(res.errno == 0){
- isSuccess = res.rst.data
- if(isSuccess){
- cd?cd():''
- }else{
- ercd?ercd():''
- }
- }else if (res.errno == 4001 || res.errno == 4002){
- window.location.href = locationPage
- showMsg(res.err)
- }else{
- ercd?ercd():''
- showMsg(res.err)
- }
- },
- error: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- function againPaymentEvent(){//重新支付
- if(qs.jsApiParameters){//微信内部支付
- wxPayCheckOrder(()=>{
- window.location.href = locationPage
- },()=>{
- window.location.href=BASEURL + '/api/wxPay/jsApiPay' +'?order_id='+order_id +'&uid=' + userInfo.id + '&ttl=' + ttl + '&sign=' + sign + '&platform=' + platform
- });
- return
- }
- if(qs.mode == 'weChat'){
- if(isSuccess){
- showMsg('已支付成功')
- window.location.href = locationPage
- }else{
- var ua = window.navigator.userAgent.toLowerCase();
- //通过正则表达式匹配ua中是否含有MicroMessenger字符串
- if(ua.match(/MicroMessenger/i) == 'micromessenger'){//微信内部
- window.location.href=BASEURL + '/api/wxPay/jsApiPay' +'?order_id='+order_id +'&uid=' + userInfo.id + '&ttl=' + ttl + '&sign=' + sign + '&platform=' + platform
- }else{//微信外部
- weChatPayment()
- }
- }
- }
- if(qs.mode == 'alipay'){//支付宝
- if(isSuccess){
- showMsg('已支付成功')
- window.location.href = locationPage
- }else{
- aliPayWapPay()
- }
- }
-
- }
- function aliPayWapPay(){//支付宝支付接口
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: BASEURL + '/api/aliPay/wapPay',
- data:{
- 'order_id':order_id,
- 'uid':userInfo.id,
- 'ttl':ttl,
- 'sign':sign,
- 'platform':platform
- },
- success: function (res) {
- $(".loading").hide();
- if(res.errno == 0){
- if(res.rst.redirect_url){
- window.location.href = res.rst.redirect_url
- }
- }else if (res.errno == 4001 || res.errno == 4002){
- window.location.href = locationPage
- showMsg(res.err)
- }else{
- showMsg(res.err)
- }
- },
- error: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- function aliPayCheckOrder(){//支付宝查询支付状态
- $(".loading").show();
- $.ajax({
- type: 'get',
- url: BASEURL + '/api/aliPay/checkOrder',
- data:{
- 'code':code,
- 'uid':userInfo.id,
- 'ttl':ttl,
- 'sign':sign,
- 'platform':platform
- },
- success: function (res) {
- $(".loading").hide();
- if(res.errno == 0){
- isSuccess = res.rst.data
- }else if (res.errno == 4001 || res.errno == 4002){
- window.location.href = locationPage
- showMsg(res.err)
- }else{
- showMsg(res.err)
- }
- },
- error: function () {
- showMsg('网络错误,请稍后再试~')
- $(".loading").hide();
- }
- })
- }
- function alipayMaskEvent(val){//点击支付成功
- if(val == 1){
- if(isSuccess){
- window.location.href = locationPage
- }else{
- var ua = window.navigator.userAgent.toLowerCase();
- //通过正则表达式匹配ua中是否含有MicroMessenger字符串
- if(ua.match(/MicroMessenger/i) == 'micromessenger'){//微信内部
- wxPayCheckOrder(()=>{
- window.location.href = locationPage
- },()=>{
- $('.mask').show()
- });
- }else if(qs.mode == 'weChat'){//微信外部
- wxPayCheckOrder(()=>{
- window.location.href = locationPage
- },()=>{
- $('.mask').show()
- });
- }else{//支付宝
- $('.mask').show()
- }
- }
- }
- if(val == 2){
- $('.mask').hide()
- }
- }
- //获取地址栏参数
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, function($0, $1, $2) {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- // 展示错误提示信息
- function showMsg(msg) {
- var msgBox = document.getElementsByClassName('alert-info')[0];
- msgBox.getElementsByTagName("p")[0].innerHTML=msg;
- msgBox.style.display="block";
- setTimeout(function() {
- msgBox.style.display="none";
- }, 2000);
- }
- //取Cookie的值
- function getCookie(name) {
- var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
- if (arr = document.cookie.match(reg)){
- return unescape(arr[2]);
- }else{
- return false
- }
- }
- </script>
|