提交 c750bdc8 编写于 作者: 金晖's avatar 金晖

更新前端框架和页面

上级 f0f29d61
import requests
def get_trade_hospital():
url = 'http://project.picahealth.com/get_trade_hospital'
# print(url)
res = requests.get(url) # 使用params参数传递
# print(res.json())
res = res.json()['data']['trade_hospital']
return res
if __name__ == '__main__':
print(get_trade_hospital())
from model.test import main from model.get_token_page import get_token
from model.index import main_page
from pywebio.platform.flask import webio_view from pywebio.platform.flask import webio_view
from flask import Flask from flask import Flask
from model.insurance_page import insurance
app = Flask(__name__) app = Flask(__name__)
# `task_func` is PyWebIO task function # `task_func` is PyWebIO task function
app.add_url_rule('/web/create', 'webio_view', webio_view(main), app.add_url_rule('/index', '首页', webio_view(main_page),
methods=['GET', 'POST', 'OPTIONS']) # need GET,POST and OPTIONS methods
app.add_url_rule('/web/insurance', '保险测试页面', webio_view(insurance),
methods=['GET', 'POST', 'OPTIONS']) # need GET,POST and OPTIONS methods methods=['GET', 'POST', 'OPTIONS']) # need GET,POST and OPTIONS methods
app.add_url_rule('/web/get_token', '获取用户token', webio_view(get_token),
methods=['GET', 'POST', 'OPTIONS']) # need GET,POST and OPTIONS methods
app.run(debug=True, host='0.0.0.0', port=8889) app.run(debug=True, host='0.0.0.0', port=8889)
# import tornado.ioloop # import tornado.ioloop
...@@ -30,6 +40,6 @@ app.run(debug=True, host='0.0.0.0', port=8889) ...@@ -30,6 +40,6 @@ app.run(debug=True, host='0.0.0.0', port=8889)
# tornado.ioloop.IOLoop.current().start() # tornado.ioloop.IOLoop.current().start()
# if __name__ == '__main__': # if __name__ == '__main__':
# pywebio.start_server(main, port=8889, debug=True, cdn=False, auto_open_webbrowser=True) # pywebio.start_server(main_page, port=8889, debug=True, cdn=False, auto_open_webbrowser=True)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/ # See PyCharm help at https://www.jetbrains.com/help/pycharm/
import pywebio.output as output
import pywebio.input as input
def get_token():
output.put_markdown('# 根据手机号获取token')
input.input_group("受益人信息",
[input.input(label='手机号:', type='text', validate=None, name='user_name', value=None,
placeholder='请输入手机号',
required=True),
input.radio(label="Which Continent?",
options=['Africa', 'Asia'], name='user_name3',
inline=True),
input.input(label='手机号2:', type='text', validate=None, name='user_name2', value=None,
placeholder='请输入手机号2',
required=True), output.radio("Which Continent?",
options=['Africa', 'Asia', 'Australia', 'Europe',
'North America', 'South America'],
inline=True)]
)
def check_age(p):
if p < 10:
return 'Too young!!'
if p > 60:
return 'Too old!!'
from pywebio.input import *
from pywebio.output import *
from pywebio.session import *
from pywebio.pin import *
from pywebio import start_server
# The width ratio of the left and right code blocks is 2:3, which is equivalent to size='2fr 10px 3fr'
from controller.request_method import get_trade_hospital
def main_page():
put_row(
[
# 左边布局
(put_column(
# 左上布局
[
# 放置图片
put_image(open('./static/image/pyWebIO.png', 'rb').read()),
# 左下布局
put_scrollable(
put_column([
put_link('*获取token', '/web/get_token').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*获取unionId', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*获取手机信息(仅线上)', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*清除小程序授权', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*保险测试工具', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*模块化参数创建', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*人群归属查询', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
put_link('*XXLjob执行工具', '/web/insurance').style(
'font-weight:bolder;font-size:18px;font-family:宋体;color:black'),
],
size='auto auto')
, height=600, keep_bottom=True)
],
size='auto auto')),
None,
# 右边布局
put_scrollable((
put_tabs([
{'title': '主要服务机构(前5)', 'content': put_table(get_trade_hospital(), header=["机构类型", "数量"])},
{'title': '测试质量', 'content': put_markdown('~~Strikethrough~~')},
{'title': '自动化监控', 'content': [
put_table([
['Commodity', 'Price'],
['Apple', '5.5'],
['Banana', '7'],
]),
put_link('pywebio', 'https://github.com/wang0618/PyWebIO')
]},
])), height=705, keep_bottom=True)
],
size='30% 2px 70%')
import pywebio.output as output
import pywebio.input as input
import requests
import re
def insurance():
# ``dark``, ``sketchy``, ``minty``, ``yeti``
# pywebio.config(title='云鹊测试平台')
with output.use_scope('scope1'): # 创建并进入scope 'scope1'
output.put_markdown('# 保险测试页(云鹊流程)')
with output.use_scope('scope2'): # 创建并进入scope 'scope1'
output.put_collapse(title='操作指引:',
content=['1.创建权益订单(提交后可获得二维码,请截图保存)\r', '2.微信扫码(首次需问卷筛查,非首次则查看筛查结果)\r',
'3.系统将根据问卷评分判断是否需要筛查\r',
'4.若需筛查,则进入云鹊筛查流程\r\r', 'PS:若要体验筛查流程,问卷年龄往大填,症状选择严重'],
open=False).style('color: red; font-size: 12px')
with output.use_scope('scope3'): # 创建并进入scope 'scope1'
ip = input.input_group("受益人信息",
[input.input(label='姓名:', type='text', validate=None, name='user_name', value=None,
action=None,
onchange=None,
placeholder='请输入姓名', required=True, readonly=None, datalist=None,
help_text=None),
input.input(label='手机号:', type='text', validate=check_mobile, name='mobile_phone',
value=None,
action=None,
onchange=None,
placeholder='请输入手机号', required=True, readonly=None, datalist=None,
help_text=None),
input.input(label='身份证:', type='text', validate=check_id_card, name='id_card',
value=None,
action=None,
onchange=None,
placeholder='请输入身份证', required=True, readonly=None, datalist=None,
help_text=None)
])
name = ip['user_name']
phone = ip['mobile_phone']
idcard = ip['id_card']
# 请求接口
res = req(name, phone, idcard)
url = res['data']['oss_url']
order_id = res['data']['mx_order_no']
message = res['message']
# 跳转结果页
output.put_image(url, title='微信扫码', width='280px', height='280px')
output.put_text('订单号:' + order_id, position=-2)
output.put_text(message, position=-1)
def req(name, phone, idcard):
url = 'http://project.picahealth.com/create_mx_test_order?name=' + name + '&phone=' + phone + '&id_card=' + idcard
# print(url)
res = requests.get(url) # 使用params参数传递
# print(res.json())
res = res.json()
return res
def check_id_card(id_card):
if len(id_card) < 18:
return '输入身份证号小于18位'
elif len(id_card) > 18:
return '输入的身份证号大于18位'
def check_mobile(mobile):
if re.match(r'1[3,4,5,7,8]\d{9}', mobile) and len(mobile) == 11:
return
else:
return '请输入正确的手机号!'
from pywebio.input import input_group
from pywebio.output import *
from pywebio.session import *
from pywebio import start_server
# 实现网页跳转
def task_1():
put_text('task_1')
put_buttons(['去页面2'], [lambda: go_app('task_B')])
def task_2():
put_text('task_2')
put_buttons(['去页面1'], [lambda: go_app('task_A')])
def index():
put_row(
put_text('123'),
input_group("Basic info", [input('Name', name='name'), input('Age', name='age')])
)
# equal to `start_server({'index': index, 'task_1': task_1, 'task_2': task_2})`
start_server([index,task_1,task_2])
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册