-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathrates.js
More file actions
41 lines (36 loc) · 1.17 KB
/
Copy pathrates.js
File metadata and controls
41 lines (36 loc) · 1.17 KB
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
const url = "https://api.exchangerate-api.com/v4/latest/CNY";
$httpClient.get(url, function(error, response, data) {
if (error) {
$done();
return;
}
const rates = JSON.parse(data).rates;
const usdToCny = (1 / rates.USD).toFixed(2);
const cnyToHkd = rates.HKD.toFixed(2);
const cnyToJpy = rates.JPY.toFixed(2);
const cnyToKrw = rates.KRW.toFixed(2);
const eurToCny = (1 / rates.EUR).toFixed(2);
const gbpToCny = (1 / rates.GBP).toFixed(2);
const tryToCny = rates.TRY.toFixed(2);
const timestamp = new Date().toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
hour12: false
});
const content = `
🇺🇸1美元兑换 ${usdToCny}🇨🇳人民币
🇨🇳1人民币兑换 ${cnyToHkd}🇭🇰港币
🇨🇳1人民币兑换 ${cnyToJpy}🇯🇵日元
🇨🇳1人民币兑换 ${cnyToKrw}🇰🇷韩元
🇨🇳1人民币兑换 ${tryToCny}🇹🇷里拉
🇪🇺1欧元兑换 ${eurToCny}🇨🇳人民币
🇬🇧1英镑兑换 ${gbpToCny}🇨🇳人民币
`;
const panel = {
title: `🪙当前汇率信息 ${timestamp}`,
content: content,
icon: "bitcoinsign.circle",
"icon-color": "#EF8F1C"
};
$done(panel);
});