-
Notifications
You must be signed in to change notification settings - Fork 5
/
COVID-19.js
193 lines (169 loc) · 6.31 KB
/
COVID-19.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// 别人框架抄过来的,可以加配置信息,懒得改了
const inputValue = "1"
if (inputValue) {
let resp =await $http.post({
url: "https://smartgate.ywtbsupappw.sh.gov.cn/ebus/suishenma/epidemicPrevention/getNucleicAcidTest",
// header 需要使用微信的随申办抓包,目测"X-Tif-Did"、"X-Tif-Sid"、"Token"、"Authentication" 都是需要的
header: {
"Connection": "keep-alive",
"X-Tif-Did": "",
"X-Tif-Sid": "",
"Content-Type": "application/json",
"Authentication": "",
"Token": "",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.23(0x18001725) NetType/4G Language/zh_CN",
"Referer": "https://servicewechat.com/wxc5059c3803665d9c/456/page-frame.html",
"Accept-Encoding": "gzip",
},
//后面有个sessionId,需要加一下?
body: {"params":{},"userSystemData":{"brand":"iPhone","model":"iPhone 13 Pro Max<iPhone14,3>","version":"8.0.23","system":"iOS 15.5","platform":"ios","SDKVersion":"2.24.5","windowWidth":428},"sessionId":""}
});
let data = resp.data.data
let username = data.name
let sampleDate = data.sampleDate
let title = data.collectModeName
let logo = "https://wx.qlogo.cn/mmhead/Q3auHgzwzM76niaZYsWjwHial7D9wvGqOwlL8F9BYLOicicTTuPOAibN4Xw/0"
let counters =[0,1]
let counter_view = []
let type_view = []
const now = new Date();
const sampleDate_datetime = new Date(sampleDate.replace(/-/g,"/"))
const expireDate = parseInt(72-(now.getTime()-sampleDate_datetime)/60/60/1000)
// 本来想多放点数据的,发现没有,for也不改了
for (var i in counters) {
counter_view.push({
type: "text",
props: {
text: expireDate.toString()+"h",
font: $font("bold", 18),
light: "#282828",
dark: "white",
minimumScaleFactor: 0.5,
lineLimit: 1
}
})
type_view.push({
type: "text",
props: {
text: "72h倒计时",
font: $font(10),
color: $color("#aaaaaa"),
minimumScaleFactor: 0.5,
lineLimit: 1
}
})
}
$widget.setTimeline({
render: ctx => {
//$widget.family = 0
const family = ctx.family;
const width = $widget.displaySize.width
const height = $widget.displaySize.height
const logo_view = {
type: "image",
props: {
uri: logo,
frame: {
width: 60,
height: 60
},
resizable: true,
cornerRadius: 15
}
}
const desc = {
type: "text",
props: {
text: "上次核酸",
font: $font(10),
color: $color("#aaaaaa"),
minimumScaleFactor: 0.5,
lineLimit: 1
}
}
const title_view = {
type: "text",
props: {
text: title,
font: family == 0 ? $font("bold", 20) : $font("bold", 25),
light: "#282828",
dark: "white",
minimumScaleFactor: 0.5,
lineLimit: 1
}
}
const path_view = {
type: "text",
props: {
text: "@" + sampleDate,
font: $font(10),
color: $color("#2481cc"),
minimumScaleFactor: 0.5,
lineLimit: 1
}
}
const small_widget = [
{
type: "hstack",
props: {
alignment: $widget.verticalAlignment.center,
frame: {
width: width - 30,
height: 60
},
spacing: 0
},
views: [
logo_view,
{
type: "vstack",
props: {
alignment: $widget.horizontalAlignment.center,
frame: {
maxWidth: Infinity,
maxHeight: Infinity
},
spacing: 0
},
views: [
counter_view.concat(type_view)[0],
counter_view.concat(type_view)[counter_view.concat(type_view).length / 2]
]
}
]
},
spacerMaker(10, width - 30),
desc,
spacerMaker(3, width - 30),
title_view,
spacerMaker(3, width - 30),
path_view
]
// blaunch ,是app store 需要安装「小捷径」才能跳转
return {
type: "vstack",
props: {
alignment: $widget.horizontalAlignment.leading,
frame: {
width: width - 30,
height: height
},
spacing: 0,
widgetURL: "blaunch://wx?id=gh_d4acc9de8978&path=pages/suishenma/jiankangma/index.html?needLogin=false&scene=0"
},
views: small_widget
}
}
})
}
function spacerMaker(height, width) {
return {
type: "spacer",
props: {
frame: {
width: width,
height: height
}
}
}
}