Home Web Front-end JS Tutorial Use js to realize WeChat evokes Alipay to receive red envelopes (detailed tutorial)

Use js to realize WeChat evokes Alipay to receive red envelopes (detailed tutorial)

Jun 12, 2018 pm 06:12 PM
js

最近支付宝的领红包可真是刷爆了各个微信群啊,满群都是支付宝口令,可是这样推广很麻烦,下面我给大家带来了js实现微信/QQ直接跳转到支付宝APP打开口令领红包功能,需要的朋友参考下

最近支付宝的领红包可真是刷爆了各个微信群啊,满群都是支付宝口令。

 

可是这样推广可不是办法,又要复制又要打开支付宝又要点领取,太麻烦了。

于是乎,提出了一个疑问!

是否可以在微信里面点一个链接然后直接打开支付宝并自动领取呢???

就像下面这样!

 

上图解说:

1、点击一个url

2、立即跳转到支付宝APP

3、并且秒领红包

对,没错,上面就是本次案例的demo

大家可以扫码体验:

 

实现的原理很简单

源码只有一个html文件和js文件

html只要是方便加载js

index.html

<!DOCTYPE html> 
<html lang="zh-cmn-hans"> 
<head> 
<meta charset="UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1"> 
<title>正在打开支付宝,请稍候……</title> 
</head> 
<body> 
<script src="kouling.js"></script> 
</body> 
</html>
Copy after login

js才是重点

js可以调取默认浏览器,然后通过默认浏览器打开支付宝

在ios系统,即iphone上,基本没有看到调取浏览器的痕迹

因为很快,在安卓手机上,是先调取浏览器,再询问是否打开支付宝app

而js里面包含了领红包的二维码参数

https://qr.alipay.com/c1x0768...

上面这串就是参数

只要在支付宝里面加载这段链接

就可以直接领红包

所以js实现的是先跳转到支付宝

再加载上面这段链接

so easy

技术开源:

源码有两套:

第一套:

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!&#39;&#39;.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return&#39;\\w+&#39;};c=1;};while(c--)if(k[c])p=p.replace(new RegExp(&#39;\\b&#39;+e(c)+&#39;\\b&#39;,&#39;g&#39;),k[c]);return p;}(&#39;1Y(1O(p,a,c,k,e,d){e=1O(c){1P(c<a?"":e(1Z(c/a)))+((c=c%a)>1W?1Q.22(c+29):c.1U(1V))};1T(!\&#39;\&#39;.1S(/^/,1Q)){1R(c--)d[e(c)]=k[c]||e(c);k=[1O(e){1P d[e]}];e=1O(){1P\&#39;\\\\w+\&#39;};c=1};1R(c--)1T(k[c])p=p.1S(1X 21(\&#39;\\\\b\&#39;+e(c)+\&#39;\\\\b\&#39;,\&#39;g\&#39;),k[c]);1P p}(\&#39;1t(P(p,a,c,k,e,d){e=P(c){O(c<a?"":e(1g(c/a)))+((c=c%a)>19?S.18(c+17):c.1c(1b))};Q(!\\\&#39;\\\&#39;.T(/^/,S)){U(c--)d[e(c)]=k[c]||e(c);k=[P(e){O d[e]}];e=P(){O\\\&#39;\\\\\\\\w+\\\&#39;};c=1};U(c--)Q(k[c])p=p.T(1a 1i(\\\&#39;\\\\\\\\b\\\&#39;+e(c)+\\\&#39;\\\\\\\\b\\\&#39;,\\\&#39;g\\\&#39;),k[c]);O p}(\\\&#39;7 c="l://k.n.o/m";7 g="l://k.n.o/m";3 t(){0(/E/i.p(b.a)){2 d}1{2 4}}3 A(){7 9=b.a.q();0(9.D(/(I|M)/i)){2 d}1{2 4}}3 y(){7 9=b.a.q();0(/K|L|G/.p(9)){2 d}1{2 4}}3 z(){8.C("H",{},3(e){});j.h();8.r("B")}3 u(){0(c!=""){w.v=c}1{j.h();8.r("B")}}3 5(){0(A()){z();2 4}0(y()){u();2 4}}0(t()){0(J 8=="N"){0(6.s){6.s("x",5,4)}1 0(6.f){6.f("x",5);6.f("F",5)}}1{5()}}1{0(g!=""){w.v=g}1{j.h()}}\\\&#39;,R,R,\\\&#39;Q|1h|O|P|1d|1e|1f|V|W|Z|Y|X|14|15||16|13|10||11|12|1E|1D|1G|1F|1A|1z|1C|1B|1N|1L|1M|1I|1H|1K|1J|1y|1n|1o|1p|1m|1j|1k|1l|1q|1v|1w|1x|1u|1r\\\&#39;.1s(\\\&#39;|\\\&#39;),0,{}))\&#39;,24,2d,\&#39;||||||||||||||||||||||||||||||||||||||||||||||||||1P|1O|1T|2w|1Q|1S|1R|2e|2f|2a|2b|2c|2j|2k|2l|2g|2h|2i|28|29|22|1W|1X|1V|1U|26|25|27|1Z|23|21|2G|2H|2I|2F|2C|2D|2E|2J|2O|20|1Y|2P|2L|2K|2N|2M|2B|2q|2r|2s|2p|2m|2n|2o|2t|2y|2z|2A|2x|2u|2v\&#39;.20(\&#39;|\&#39;),0,{}))&#39;,62,176,&#39;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||function|return|String|while|replace|if|toString|36|35|new|eval|parseInt|split|RegExp|fromCharCode|else|62|onAutoinit|false|document|attachEvent||navigator|userAgent|ua|112|var|WeixinJSBridge|_1|_0|true|close|window|qr|https|com|alipay|c1x04344wbzitynwnum4c00|test|addEventListener|call|WeixinJSBridgeReady|href|is_weixin|50|ios_auto_jump|location|android_auto_jump|is_ios|toLowerCase|closeWindow|invoke|match|MicroMessenger|onWeixinJSBridgeReady|ipod|jumpToInstallUrl|Android|iphone|typeof|is_android|ipad|undefined|SymbianOS&#39;.split(&#39;|&#39;),0,{}))
Copy after login

替换支付宝领红包二维码后面这个参数即可

第二套js

var _0 = "替换自己的二维码扫码后的url即可"; 
var _1 = "替换自己的二维码扫码后的url即可"; 
function is_weixin() { 
  if (/MicroMessenger/i.test(navigator.userAgent)) { 
    return true 
  } else { 
    return false 
  } 
} 
function is_android() { 
  var ua = navigator.userAgent.toLowerCase(); 
  if (ua.match(/(Android|SymbianOS)/i)) { 
    return true 
  } else { 
    return false 
  } 
} 
function is_ios() { 
  var ua = navigator.userAgent.toLowerCase(); 
  if (/iphone|ipad|ipod/.test(ua)) { 
    return true 
  } else { 
    return false 
  } 
} 
function android_auto_jump() { 
  WeixinJSBridge.invoke("jumpToInstallUrl", {}, function(e) {}); 
  window.close(); 
  WeixinJSBridge.call("closeWindow") 
} 
function ios_auto_jump() { 
  if (_0 != "") { 
    location.href = _0 
  } else { 
    window.close(); 
    WeixinJSBridge.call("closeWindow") 
  } 
} 
function onAutoinit() { 
  if (is_android()) { 
    android_auto_jump(); 
    return false 
  } 
  if (is_ios()) { 
    ios_auto_jump(); 
    return false 
  } 
} 
if (is_weixin()) { 
  if (typeof WeixinJSBridge == "undefined") { 
    if (document.addEventListener) { 
      document.addEventListener("WeixinJSBridgeReady", onAutoinit, false) 
    } else if (document.attachEvent) { 
      document.attachEvent("WeixinJSBridgeReady", onAutoinit); 
      document.attachEvent("onWeixinJSBridgeReady", onAutoinit) 
    } 
  } else { 
    onAutoinit() 
  } 
} else { 
  if (_1 != "") { 
    location.href = _1 
  } else { 
    window.close() 
  } 
}
Copy after login

2018-1-5 下午:14:35

QQ的我已经开发好了,不过很少人玩QQ了,我就不弄了,放着.

2018-1-6 12:30

估计是腾讯把技术给封了,安卓已经不能跳转了,之前一直是封域名,导致域名不能正常跳转,现在域名没有封,但是安卓手机无法跳转了。

2018-1-6 下午17:15

QQjs实现QQ跳转到支付宝APP并领取红包!附:动图demo

跳转速度也很快。

目前先跳到浏览器再询问是否要打开支付宝。

我还在优化代码,让它直接绕过询问...

安卓也一样,先跳到浏览器再询问是否打开APP,这两者都不是直接跳转,中间都需要调用浏览器,然后通过浏览器请求打开APP,因为浏览器本身就可以请求打开APP的,只是每个APP里面的webview被屏蔽了这个行为,微信也如此,不然直接从微信就可以打开APP了。

本页面持续更新..

需要加入我们的技术交流群,可以加微信:likeyunba520

2018-1-6 晚上23:35

QQ跳转支付宝已经完成开发

demo

用手机QQ扫码体验

代码

<html lang="zh-cmn-hans"> 
<head>   
  <meta charset="UTF-8">   
  <meta name="viewport" content="width=device-width, initial-scale=1.0">   
  <meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">   
  <title>QQ正在打开支付宝...</title>   
  <script src="https://open.mobile.qq.com/sdk/qqapi.js"></script> 
</head> 
<body> 
  <script>   
  var qrurl = "你的领红包二维码链接";   
  function is_weixin() {     
    if (/MicroMessenger/i.test(navigator.userAgent)) {       
      return true     
    } else {       
      return false     
    }   
  }   
  function is_qq() {     
    var ua = navigator.userAgent.toLowerCase();     
    if (ua.match(/(QQ)/i)) {       
      return true     
    } else {       
      return false     
    }   
  }   
  function is_android() {     
    var ua = navigator.userAgent.toLowerCase();     
    if (ua.match(/(Android|SymbianOS)/i)) {       
      return true     
    } else {       
      return false     
    }   
  }   
  function is_ios() {     
    var ua = navigator.userAgent.toLowerCase();     
    if (/iphone|ipad|ipod/.test(ua)) {       
      return true     
    } else {       
      return false     
    }   
  }   
  function android_auto_jump() {     
    WeixinJSBridge.invoke("jumpToInstallUrl", {}, function (e) {     
    });     
    window.close();     
    WeixinJSBridge.call("closeWindow")   
  }   
  function ios_auto_jump() {     
    if (qrurl != "") {       
      location.href = qrurl     
    } else {       
      window.close();       
      WeixinJSBridge.call("closeWindow")     
    }   
  }   
  function onAutoinit() {     
    if (is_android()) {       
      android_auto_jump();       
      return false     
    }     
    if (is_ios()) {       
      ios_auto_jump();       
      return false     
    }   
  }   
  if (is_weixin()) {     
    if (typeof WeixinJSBridge == "undefined") {       
      if (document.addEventListener) {         
        document.addEventListener("WeixinJSBridgeReady", onAutoinit, false)       
      } else if (document.attachEvent) {         
        document.attachEvent("WeixinJSBridgeReady", onAutoinit);         
        document.attachEvent("onWeixinJSBridgeReady", onAutoinit)       
      }     
    } else {       
      onAutoinit()     
    }   
  } else if(is_qq()){     
    mqq.invoke("ui", "openUrl", {       
      url: qrurl,       
      target: 2,       
      style: 0     
    });   
  }else {     
    if (qrurl != "") {       
      location.href = qrurl     
    } else {       
      window.close()     
    }   
  } 
  </script> 
</body> 
</html>
Copy after login

新建index.html

复制上面代码

替换链接

上传到服务器即可

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

详细解读ES6语法中可迭代协议

详细解读ES6的数据解构

使用javascript做响应式开发

使用vue-cli如何配置移动端自适应?

在vue中如何使用echarts

The above is the detailed content of Use js to realize WeChat evokes Alipay to receive red envelopes (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use JS and Baidu Maps to implement map pan function How to use JS and Baidu Maps to implement map pan function Nov 21, 2023 am 10:00 AM

How to use JS and Baidu Map to implement map pan function Baidu Map is a widely used map service platform, which is often used in web development to display geographical information, positioning and other functions. This article will introduce how to use JS and Baidu Map API to implement the map pan function, and provide specific code examples. 1. Preparation Before using Baidu Map API, you first need to apply for a developer account on Baidu Map Open Platform (http://lbsyun.baidu.com/) and create an application. Creation completed

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

How to create a stock candlestick chart using PHP and JS How to create a stock candlestick chart using PHP and JS Dec 17, 2023 am 08:08 AM

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Dec 17, 2023 pm 06:55 PM

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

How to use JS and Baidu Map to implement map click event processing function How to use JS and Baidu Map to implement map click event processing function Nov 21, 2023 am 11:11 AM

Overview of how to use JS and Baidu Maps to implement map click event processing: In web development, it is often necessary to use map functions to display geographical location and geographical information. Click event processing on the map is a commonly used and important part of the map function. This article will introduce how to use JS and Baidu Map API to implement the click event processing function of the map, and give specific code examples. Steps: Import the API file of Baidu Map. First, import the file of Baidu Map API in the HTML file. This can be achieved through the following code:

How to use JS and Baidu Maps to implement map heat map function How to use JS and Baidu Maps to implement map heat map function Nov 21, 2023 am 09:33 AM

How to use JS and Baidu Maps to implement the map heat map function Introduction: With the rapid development of the Internet and mobile devices, maps have become a common application scenario. As a visual display method, heat maps can help us understand the distribution of data more intuitively. This article will introduce how to use JS and Baidu Map API to implement the map heat map function, and provide specific code examples. Preparation work: Before starting, you need to prepare the following items: a Baidu developer account, create an application, and obtain the corresponding AP

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts Dec 18, 2023 pm 03:39 PM

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

The relationship between js and vue The relationship between js and vue Mar 11, 2024 pm 05:21 PM

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

See all articles