新媒体-合同签约,CA签约

paymentResult.html 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="yes" name="apple-mobile-web-app-capable">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
  7. <title>支付结果</title>
  8. <link rel="stylesheet" type="text/css" href="../common/reset.css"/>
  9. <script src="../common/jquery-2.1.0.js"></script>
  10. <script src="../common/md5.js"></script>
  11. <script type="text/javascript">
  12. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  13. window.onresize = function(){
  14. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  15. }
  16. </script>
  17. <style>
  18. .paymentResultImg{
  19. width: 2.72rem;
  20. height: 2.43rem;
  21. display: block;
  22. margin: 1.27rem auto 0;
  23. }
  24. .completeButton{
  25. width:2.70rem;
  26. height:0.46rem;
  27. background:linear-gradient(90deg,rgba(6,135,255,1) 0%,rgba(20,82,255,1) 100%);
  28. border-radius:0.10rem;
  29. color: #FFFFFF;
  30. font-size: 0.16rem;
  31. line-height: 0.46rem;
  32. text-align: center;
  33. border: none;
  34. margin: 0.49rem auto 0;
  35. display: block
  36. }
  37. .againPayment{
  38. width:2.70rem;
  39. height:0.46rem;
  40. border-radius:0.10rem;
  41. opacity:0.8459;
  42. border:0.01rem solid rgba(56,110,255,1);
  43. color: #386EFF;
  44. font-size: 0.16rem;
  45. text-align: center;
  46. line-height: 0.46rem;
  47. display: block;
  48. margin: 0.12rem auto 0;
  49. background: #ffffff;
  50. }
  51. .mask{
  52. width: 100%;
  53. height: 100vh;
  54. background: rgba(0,0,0,0.7);
  55. position: fixed;
  56. top: 0;
  57. left: 0;
  58. display: none;
  59. }
  60. .mask .content{
  61. width:3rem;
  62. height:1.56rem;
  63. background:rgba(255,255,255,1);
  64. border-radius:0.1rem;
  65. position: absolute;
  66. top: 0;
  67. left: 0;
  68. right: 0;
  69. bottom: 0;
  70. margin: auto;
  71. }
  72. .mask .content .hint{
  73. width: 2.5rem;
  74. color: #222222;
  75. font-size: 0.16rem;
  76. line-height: 0.22rem;
  77. margin: 0.44rem auto 0.3rem;
  78. text-align: center;
  79. }
  80. .mask .content button{
  81. width:2.7rem;
  82. height:0.46rem;
  83. background:linear-gradient(90deg,rgba(6,135,255,1) 0%,rgba(20,82,255,1) 100%);
  84. border-radius:0.1rem;
  85. color: #FFFFFF;
  86. font-size: 0.16rem;
  87. line-height: 0.46rem;
  88. text-align: center;
  89. border: none;
  90. display: block;
  91. margin: auto;
  92. }
  93. </style>
  94. </head>
  95. <body>
  96. <img src="./img/paymentResultImg.png" class="paymentResultImg" alt="">
  97. <button class="completeButton" onclick="alipayMaskEvent(1)">已完成支付</button>
  98. <button class="againPayment" onclick="againPaymentEvent()">重新支付</button>
  99. <!-- 提示弹框 -->
  100. <div class="mask">
  101. <div class="content">
  102. <p class="hint">尚未查询到支付成功请重试!</p>
  103. <button onclick="alipayMaskEvent(2)">我知道了</button>
  104. </div>
  105. </div>
  106. <div class="alert-info" style="display: none;">
  107. <!-- tip提示,3s后消失 -->
  108. <p>请在浏览器中打开</p>
  109. </div>
  110. <!-- loading -->
  111. <div class="loading">
  112. <img src="../img/loading.gif" />
  113. </div>
  114. </body>
  115. </html>
  116. <script>
  117. var qs = parseQueryString(window.location.href),code='',mode='',order_id='',isSuccess=false;
  118. // var BASEURL = 'https://media.kuxuan-inc.com'
  119. var BASEURL = ''
  120. var userInfo = '', ttl = '', sign = '',platform = qs.platform?qs.platform:1;
  121. var locationPage = qs.platform == 2 ? './dou/index.html' : './index.html'
  122. $().ready(function(){
  123. if(platform == 2){//抖音
  124. if(getCookie('userInfoDou')){
  125. userInfo = JSON.parse(getCookie('userInfoDou'))
  126. ttl = userInfo.ttl;
  127. sign = hex_md5("random="+userInfo.random+"&ttl="+userInfo.ttl+"&user_id="+userInfo.id)
  128. init()
  129. }else{
  130. window.location.href = locationPage
  131. }
  132. }else{
  133. if(getCookie('userInfo')){
  134. userInfo = JSON.parse(getCookie('userInfo'))
  135. ttl = userInfo.ttl;
  136. sign = hex_md5("random="+userInfo.random+"&ttl="+userInfo.ttl+"&user_id="+userInfo.id)
  137. init()
  138. }else{
  139. window.location.href = locationPage
  140. }
  141. }
  142. })
  143. function init(){
  144. if(qs.order_id){
  145. order_id = qs.order_id
  146. }
  147. code = qs.code ? qs.code : ''
  148. if(qs.jsApiParameters){//微信内部支付
  149. weChatJSBrudge(JSON.parse(qs.jsApiParameters))
  150. return
  151. }
  152. if(qs.mode == 'weChat'){
  153. if(qs.code){
  154. code = qs.code
  155. // wxPayCheckOrder()
  156. }else{
  157. showMsg('系统错误,无订单编号')
  158. }
  159. }
  160. if(qs.mode == 'alipay'){//支付宝
  161. if(qs.code){
  162. code = qs.code
  163. aliPayCheckOrder()
  164. }else{
  165. showMsg('系统错误,无订单编号')
  166. }
  167. }
  168. }
  169. function weChatJSBrudge(data){
  170. var data = data;
  171. console.log(data)
  172. function onBridgeReady(){
  173. WeixinJSBridge.invoke(
  174. 'getBrandWCPayRequest', data,
  175. function(res){
  176. if(res.err_msg == "get_brand_wcpay_request:ok" ){
  177. // 使用以上方式判断前端返回,微信团队郑重提示:
  178. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  179. }
  180. });
  181. }
  182. if (typeof WeixinJSBridge == "undefined"){
  183. if( document.addEventListener ){
  184. document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  185. }else if (document.attachEvent){
  186. document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  187. document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  188. }
  189. }else{
  190. onBridgeReady();
  191. }
  192. }
  193. function weChatPayment(){//微信外部支付
  194. $(".loading").show();
  195. $.ajax({
  196. type: 'get',
  197. url: BASEURL + '/api/wxPay/wapPay',
  198. data:{
  199. 'order_id':order_id,
  200. 'uid':userInfo.id,
  201. 'ttl':ttl,
  202. 'sign':sign,
  203. 'platform':platform
  204. },
  205. success: function (res) {
  206. $(".loading").hide();
  207. if(res.errno == 0){
  208. if(res.rst.redirect_url){
  209. window.location.href = res.rst.redirect_url
  210. }
  211. }else if (res.errno == 4001 || res.errno == 4002){
  212. window.location.href = locationPage
  213. showMsg(res.err)
  214. }else{
  215. showMsg(res.err)
  216. }
  217. },
  218. error: function () {
  219. showMsg('网络错误,请稍后再试~')
  220. $(".loading").hide();
  221. }
  222. })
  223. }
  224. function wxPayCheckOrder(cd,ercd){//微信查询支付状态
  225. $(".loading").show();
  226. $.ajax({
  227. type: 'get',
  228. url: BASEURL + '/api/wxPay/checkOrder',
  229. data:{
  230. 'code':code,
  231. 'uid':userInfo.id,
  232. 'ttl':ttl,
  233. 'sign':sign,
  234. 'platform':platform
  235. },
  236. success: function (res) {
  237. $(".loading").hide();
  238. if(res.errno == 0){
  239. isSuccess = res.rst.data
  240. if(isSuccess){
  241. cd?cd():''
  242. }else{
  243. ercd?ercd():''
  244. }
  245. }else if (res.errno == 4001 || res.errno == 4002){
  246. window.location.href = locationPage
  247. showMsg(res.err)
  248. }else{
  249. ercd?ercd():''
  250. showMsg(res.err)
  251. }
  252. },
  253. error: function () {
  254. showMsg('网络错误,请稍后再试~')
  255. $(".loading").hide();
  256. }
  257. })
  258. }
  259. function againPaymentEvent(){//重新支付
  260. if(qs.jsApiParameters){//微信内部支付
  261. wxPayCheckOrder(()=>{
  262. window.location.href = locationPage
  263. },()=>{
  264. window.location.href=BASEURL + '/api/wxPay/jsApiPay' +'?order_id='+order_id +'&uid=' + userInfo.id + '&ttl=' + ttl + '&sign=' + sign + '&platform=' + platform
  265. });
  266. return
  267. }
  268. if(qs.mode == 'weChat'){
  269. if(isSuccess){
  270. showMsg('已支付成功')
  271. window.location.href = locationPage
  272. }else{
  273. var ua = window.navigator.userAgent.toLowerCase();
  274. //通过正则表达式匹配ua中是否含有MicroMessenger字符串
  275. if(ua.match(/MicroMessenger/i) == 'micromessenger'){//微信内部
  276. window.location.href=BASEURL + '/api/wxPay/jsApiPay' +'?order_id='+order_id +'&uid=' + userInfo.id + '&ttl=' + ttl + '&sign=' + sign + '&platform=' + platform
  277. }else{//微信外部
  278. weChatPayment()
  279. }
  280. }
  281. }
  282. if(qs.mode == 'alipay'){//支付宝
  283. if(isSuccess){
  284. showMsg('已支付成功')
  285. window.location.href = locationPage
  286. }else{
  287. aliPayWapPay()
  288. }
  289. }
  290. }
  291. function aliPayWapPay(){//支付宝支付接口
  292. $(".loading").show();
  293. $.ajax({
  294. type: 'get',
  295. url: BASEURL + '/api/aliPay/wapPay',
  296. data:{
  297. 'order_id':order_id,
  298. 'uid':userInfo.id,
  299. 'ttl':ttl,
  300. 'sign':sign,
  301. 'platform':platform
  302. },
  303. success: function (res) {
  304. $(".loading").hide();
  305. if(res.errno == 0){
  306. if(res.rst.redirect_url){
  307. window.location.href = res.rst.redirect_url
  308. }
  309. }else if (res.errno == 4001 || res.errno == 4002){
  310. window.location.href = locationPage
  311. showMsg(res.err)
  312. }else{
  313. showMsg(res.err)
  314. }
  315. },
  316. error: function () {
  317. showMsg('网络错误,请稍后再试~')
  318. $(".loading").hide();
  319. }
  320. })
  321. }
  322. function aliPayCheckOrder(){//支付宝查询支付状态
  323. $(".loading").show();
  324. $.ajax({
  325. type: 'get',
  326. url: BASEURL + '/api/aliPay/checkOrder',
  327. data:{
  328. 'code':code,
  329. 'uid':userInfo.id,
  330. 'ttl':ttl,
  331. 'sign':sign,
  332. 'platform':platform
  333. },
  334. success: function (res) {
  335. $(".loading").hide();
  336. if(res.errno == 0){
  337. isSuccess = res.rst.data
  338. }else if (res.errno == 4001 || res.errno == 4002){
  339. window.location.href = locationPage
  340. showMsg(res.err)
  341. }else{
  342. showMsg(res.err)
  343. }
  344. },
  345. error: function () {
  346. showMsg('网络错误,请稍后再试~')
  347. $(".loading").hide();
  348. }
  349. })
  350. }
  351. function alipayMaskEvent(val){//点击支付成功
  352. if(val == 1){
  353. if(isSuccess){
  354. window.location.href = locationPage
  355. }else{
  356. var ua = window.navigator.userAgent.toLowerCase();
  357. //通过正则表达式匹配ua中是否含有MicroMessenger字符串
  358. if(ua.match(/MicroMessenger/i) == 'micromessenger'){//微信内部
  359. wxPayCheckOrder(()=>{
  360. window.location.href = locationPage
  361. },()=>{
  362. $('.mask').show()
  363. });
  364. }else if(qs.mode == 'weChat'){//微信外部
  365. wxPayCheckOrder(()=>{
  366. window.location.href = locationPage
  367. },()=>{
  368. $('.mask').show()
  369. });
  370. }else{//支付宝
  371. $('.mask').show()
  372. }
  373. }
  374. }
  375. if(val == 2){
  376. $('.mask').hide()
  377. }
  378. }
  379. //获取地址栏参数
  380. function parseQueryString(url) {
  381. var urlObj = {};
  382. var reg = /([^?=&]+)=([^?=&]+)/g;
  383. url.replace(reg, function($0, $1, $2) {
  384. urlObj[$1] = decodeURIComponent($2);
  385. })
  386. return urlObj;
  387. }
  388. // 展示错误提示信息
  389. function showMsg(msg) {
  390. var msgBox = document.getElementsByClassName('alert-info')[0];
  391. msgBox.getElementsByTagName("p")[0].innerHTML=msg;
  392. msgBox.style.display="block";
  393. setTimeout(function() {
  394. msgBox.style.display="none";
  395. }, 2000);
  396. }
  397. //取Cookie的值
  398. function getCookie(name) {
  399. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  400. if (arr = document.cookie.match(reg)){
  401. return unescape(arr[2]);
  402. }else{
  403. return false
  404. }
  405. }
  406. </script>