本帖最后由 zh648990 于 2021-12-25 13:35 编辑
首先上效果图
腾讯云免费额度 100万次请求 相当于白嫖
实现原理是用户微信扫码二维码请求链接,并提交手机号再次请求推送消息的APP API 达到如上图效果
推送消息的APP 苹果用户下载 Bark 安卓用户暂时没有找到
首先,在腾讯云搜索云函数-函数服务-新建-自定义创建-Web函数-完成
函数名称默认即可
然后在src目录下上传 style.css 和 js.js 文件 并在 app.py 里修改代码并点击部署
[Python] 纯文本查看 复制代码 from flask import Flask
from flask import request
import requests
# 实例 flask 对象
app = Flask(__name__)
@app.route('/')
def index():
"""
主页
"""
with open('./style.css', mode='r', encoding='utf-8') as f1:
style = f1.read()
with open('./js.js', mode='r', encoding='utf-8') as f2:
js = f2.read()
return """
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>呼叫车主</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<style>{}</style>
<script>{}</script>
</head>
<body>
<!--头像-->
<div class="head">
<div class="img">
<img src="https://s4.ax1x.com/2021/12/25/TU8thR.png">
</div>
<p>呼叫车主</p>
</div>
<!--登陆-->
<form action="/main">
<div class="item">
<input type="text" name="number" maxlength="11" placeholder="请输入您的手机号" autocomplete="off" class="name">
</div>
<div class="submit"><button>提交</button></div>
</form>
</body>
</html>
""".format(style, js)
@app.route('/main')
def main():
"""
车主发送信息
"""
number = request.values.get('number')
# 推送API
url = f'你APP里面的链接/呼叫车主/{number} 正在呼叫您来挪车?sound=minuet'
# 发送请求
requests.get(url=url)
return """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
<title>呼叫成功</title>
</head>
<body>
呼叫成功
</body>
</html>
"""
if __name__ == '__main__':
app.run(host='0.0.0.0', port=9000)
[Python] 纯文本查看 复制代码 url = f'你APP里面的链接/呼叫车主/{number} 正在呼叫您来挪车?sound=minuet'
修改成你APP服务器里面的链接,呼叫车主 是推送标题,随意修改 ,{number} 是用户提交的手机号变量,请勿修改,正在呼叫您来挪车 是推送的内容 随意修改。 ?sound=minuet 是推送的铃声不喜欢可以修改其他的或者删除 建议留着
腾讯云的这个web不能直接读取目录文件有点坑,图片链接是找的免费图床,css和js是open来读取传递
把请求链接转换成二维码并写上微信扫一扫呼叫车主等字样就可以了
请求的页面是网上随便找的,还有一个返回呼叫成功的页面我没有找到好看的 我也不会前端,找个高手完善下
css和js不能上传附件我以代码的形式上传 自行修改并上传到src目录下
[CSS] 纯文本查看 复制代码 * {
margin: 0;
padding: 0;
border: 0;
list-style: none;
text-decoration: none;
color: inherit;
font-weight: normal;
font-family: "微软雅黑";
box-sizing: border-box;
font-style: normal;
}
body {
width: 100%;
overflow-x: hidden;
background: url([img]https://s4.ax1x.com/2021/12/25/TUGRIJ.png[/img]) top left no-repeat;
background-size: 100%;
}
img {
vertical-align: middle;
max-width: 100%;
}
a:hover, a:active, a:visited, a:link, a:focus {
-webkit-tap-highlight-color: transparent;
outline: none;
text-decoration: none;
}
/*头像*/
.head .img {
width: 1.45rem;
height: 1.45rem;
background: #FFFFFF;
border-radius: 50%;
margin: 0 auto;
margin-top: 1.25rem;
text-align: center;
overflow: hidden;
}
.head img {
width: 1.25rem;
}
.head p {
text-align: center;
color: #FFFFFF;
font-size: .36rem;
padding-top: .15rem;
}
/*登陆表单*/
form {
width: 100%;
height: auto;
overflow: hidden;
padding: 1.85rem .45rem .45rem .45rem;
}
form .item {
display: flex;
align-items: center;
height: .85rem;
margin-bottom: .35rem;
font-size: .30rem;
color: #333333;
}
form .item input {
width: 100%;
height: 100%;
display: inline-block;
border: .01rem solid #ebebeb;
border-radius: .85rem;
box-shadow: 0px 0px 10px rgba(200, 200, 200, .1);
padding-left: .8rem;
outline: none;
}
form .item input.name {
background: url([img]https://s4.ax1x.com/2021/12/25/TUG4R1.png[/img]) left .3rem center no-repeat;
background-size: .23rem .35rem;
}
form .item span {
flex-shrink: 0;
display: inline-block;
width: 1.6rem;
margin-left: .2rem;
height: 100%;
line-height: .85rem;
border-radius: .85rem;
background: #1f6ecf;
font-size: .24rem;
color: #fff;
text-align: center;
}
form .item span.disabled {
background: #808080;
}
form .submit {
padding: .2rem .2rem;
}
form .submit button {
height: .85rem;
line-height: .85rem;
text-align: center;
font-size: .34rem;
color: #FFFFFF;
border-radius: .85rem;
outline: none;
box-shadow: 0 .15rem .15rem rgba(31, 110, 207, .2);
display: inline-block;
width: 100%;
background: #1f6ecf;
}
[JavaScript] 纯文本查看 复制代码 (function flexible (window, document) {
var docEl = document.documentElement
var dpr = window.devicePixelRatio || 1
// adjust body font size
function setBodyFontSize () {
if (document.body) {
document.body.style.fontSize = (12 * dpr) + 'px'
}
else {
document.addEventListener('DOMContentLoaded', setBodyFontSize)
}
}
setBodyFontSize();
// set 1rem = viewWidth / 10
function setRemUnit () {
var rem = docEl.clientWidth / 7.5
docEl.style.fontSize = rem + 'px'
}
setRemUnit()
// reset rem unit on page resize
window.addEventListener('resize', setRemUnit)
window.addEventListener('pageshow', function (e) {
if (e.persisted) {
setRemUnit()
}
})
// detect 0.5px supports
if (dpr >= 2) {
var fakeBody = document.createElement('body')
var testElement = document.createElement('div')
testElement.style.border = '.5px solid transparent'
fakeBody.appendChild(testElement)
docEl.appendChild(fakeBody)
if (testElement.offsetHeight === 1) {
docEl.classList.add('hairlines')
}
docEl.removeChild(fakeBody)
}
}(window, document))
|