| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760 |
- const sendEmail = require('./Email')
- class emailTemplate {
- stramptoTime(time) {
- if (time < 10)
- return '';
- return new Date(+time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' });
- }
- async checkEmail(email, code) {
- const time = new Date().getTime()
- await sendEmail(email, 'RunForge - 邮箱验证码',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 邮箱验证码</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap:10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .code {
- margin: 20px 0;
- font-size: 1.5em;
- text-align: center;
- font-weight: bold;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 邮箱验证码</h2>
- </div>
-
- <p>尊敬的用户:</p>
- <p>您正在本站进行邮箱验证操作,如非您本人操作,请忽略此邮件。</p>
- <p>您的验证码为:</p>
- <div class="code">
- ${code}
- </div>
- <p class="important">验证码5分钟内有效,超时请重新获取</p>
- <p class="footer">Copyright © 2025 RunForge</p>
- </div>
- </body>
- </html>`
- )
- }
- async registerSuccess(email, username) {
- const time = new Date().getTime()
- await sendEmail(email, '您已成功注册RunForge账号',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 注册成功提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 注册成功提醒</h2>
- </div>
- <p>尊敬的 ${username}:</p>
- <p>您已成功注册RunForge账号:</p>
- <div class="info">
- <p><strong>用户名:</strong> ${username}</p>
- <p><strong>注册时间:</strong> ${this.stramptoTime(time)}</p>
- </div>
- <p class="footer">Copyright © 2025 RunForge</p>
- </div>
- </body>
- </html>`
- )
- }
- async updateSuccess(email, data) {
- await sendEmail(email, 'RunForge - 乐跑账号更新成功提醒',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 乐跑账号更新成功提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 乐跑账号更新好啦,宝宝快看看~ 🎉💖✨</h2>
- </div>
- <p>亲爱的 ${data.name} 宝宝 🌸:</p>
- <p>嘻嘻~ 你已经成功更新了乐跑账号的登录信息啦 🥰💌:</p>
- <div class="info">
- <p><strong>学号:</strong> ${data.account} 🎓</p>
- <p><strong>年级:</strong> ${data.grade_id} 📚</p>
- <p><strong>学院:</strong> ${data.academy_name} 🏫</p>
- <p><strong>更新时间:</strong> ${this.stramptoTime(new Date().getTime())} ⏰</p>
- </div>
- <p class="important">
- ${data.auto_run === 0
- ? '现在还没有帮宝宝开启自动乐跑呢 🐾💦 如果想要开始跑跑的话,记得登录后去RunForge手动点一下哦~ 🌈💕'
- : '已经为宝宝开启了自动乐跑啦 🏃♀️✨ 登录后系统会乖乖替你完成乐跑 💖 记得留意邮箱提醒哟~ 📬'}
- </p>
- <p class="important">宝宝要记得不要在其他设备上登录“智慧体育”小程序哦 🚫📱,不然会失效,到时候又要重新登录啦 😢💦~</p>
- <p class="important">有问题随时喊RunForge客服小可爱呀 💕💌 我们都会耐心陪宝宝解决的哟 ✨🥰</p>
- <p class="footer">Copyright © 2025 RunForge 🌟</p>
- </div>
- </body>
- </html>`
- )
- }
- async lepaoOver(email, data) {
- await sendEmail(email, '🎉 RunForge - 乐跑完成祝贺',
- `<!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <title>🎉 RunForge - 乐跑完成祝贺</title>
- <style>
- body {
- background-color: #fffaf4;
- margin: 0;
- padding: 0;
- font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
- }
- .container {
- max-width: 620px;
- margin: 40px auto;
- padding: 30px;
- background-color: #fff;
- border-radius: 14px;
- box-shadow: 0 8px 25px rgba(255, 183, 77, 0.2);
- border: 2px dashed #ffe0b2;
- }
- .head {
- text-align: center;
- margin-bottom: 30px;
- }
- .head h2 {
- color: #ff7043;
- font-size: 26px;
- margin: 0;
- }
- p {
- color: #444;
- font-size: 16px;
- line-height: 1.8;
- }
- .info {
- background-color: #fff3e0;
- border-left: 5px solid #ffb74d;
- padding: 15px 20px;
- margin: 25px 0;
- border-radius: 10px;
- }
- .info p {
- margin: 8px 0;
- }
- .footer {
- text-align: center;
- color: #bbb;
- font-size: 14px;
- margin-top: 40px;
- }
- .highlight {
- color: #ff5722;
- font-weight: bold;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>🏃♀️RunForge - 乐跑任务通关啦!🎉</h2>
- </div>
- <p>亲爱的 <span class="highlight">${data.name}</span> 同学 ꒰。•ᴗ•。꒱:</p>
- <p>
- ✨恭喜恭喜~你已经火力全开地完成了本学期的乐跑任务啦!🎊<br>
- 不得不说,你就是我们心中的 <strong>小跑神</strong> 🌟💨,坚持到最后真的超级棒!💪( •̀ᄇ• ́)و
- </p>
- <p>
- 跑过的风,晒过的阳,每一步都是你努力的见证!🌤️🍃<br>
- RunForge在远程为你打Call中 📣📣📣 ~真的好佩服佩服你!
- </p>
- <p>
- 这一学期和你一起“并肩作战”,我们感到非常幸运!🧡<br>
- 希望你收获了健康,也收获了快乐~o(≧▽≦)o
- </p>
- <p>
- 📬 如果有任何问题,随时给我们戳小窗~我们在线等你哟 (´▽`)ノ♪
- </p>
- <p>
- 🥳 祝你假期躺赢、学习加buff、每天都开心到冒泡泡!✧*。٩(ˊᗜˋ*)و✧*。<br>
- 📚 新学期我们一起继续加速奔跑吧~Let's gooo!🔥🔥
- </p>
- <p>
- 🧡我们已经为您关闭了自动乐跑功能,如您需要继续乐跑,还可前往RunForge自行开启哦!
- </p>
- <p class="footer">Copyright © 2025 RunForge</p>
- </div>
- </body>
- </html>
- `
- )
- }
- async lepaoSuccess(email, data) {
- await sendEmail(email, 'RunForge - 乐跑成功提醒',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 乐跑成功提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 乐跑成功啦 🎉💖</h2>
- </div>
- <p>亲爱的 ${data.name} 宝宝:</p>
- <p>耶耶耶~ RunForge已经乖乖帮你完成了一次乐跑啦 ✨🏃♀️💨</p>
- <div class="info">
- <p><strong>学号:</strong> ${data.account}</p>
- <p><strong>跑区:</strong> ${data.pass_tit} 🌈</p>
- <p><strong>跑步时间:</strong> ${this.formatSecondsToMinSec(data.time)} ⏱️</p>
- <p><strong>平均配速:</strong> ${this.calculatePace(data.time, data.distance)} 🐇</p>
- <p><strong>跑步距离:</strong> ${data.distance} Km 💕</p>
- <p><strong>累计次数:</strong> ${data.total_num} 次 ✨</p>
- <p><strong>剩余次数:</strong> ${data.term_num - data.total_num >= 0 ? (data.term_num - data.total_num) : '已完成'} 次 🎯</p>
- </div>
- <p class="important">如果宝宝开启了自动乐跑,要记得不要在其他设备上登录“智慧体育”小程序哦 🚫📱,不然登录就会失效,要重新来一次啦~</p>
- <p class="important">有问题随时找RunForge客服小可爱呀 💌 我们会陪你耐心解决的~</p>
- <p class="footer">Copyright © 2025 RunForge ✨</p>
- </div>
- </body>
- </html>`
- )
- }
- async lepaoFail(email, data) {
- const time = new Date().getTime()
- await sendEmail(email, 'RunForge - 乐跑失败提醒',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 乐跑失败提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 乐跑没有成功呢 😢💦</h2>
- </div>
- <p>亲爱的 ${data.name ?? data.account} 宝宝 🌸:</p>
- <p>RunForge刚刚尝试帮你完成乐跑的时候,遇到了一点小意外呢 💔💦:</p>
- <div class="info">
- <p><strong>学号:</strong> ${data.account} 🎓</p>
- <p><strong>时间:</strong> ${this.stramptoTime(time)} ⏰</p>
- <p><strong>失败原因:</strong> ${data.reason} 😭</p>
- </div>
- <p class="important">宝宝如果是登录失效的话 🥺✨,要记得重新启动RunForge乐跑登录器,再登录“智慧体育”小程序就可以啦 💕</p>
- <p class="important">如果还是不懂,随时可以来找RunForge客服小可爱哟 💌 我们会耐心陪宝宝解决问题的 🌈🥰</p>
- <p class="footer">Copyright © 2025 RunForge 💖</p>
- </div>
- </body>
- </html>`
- )
- }
- async orderNewReply(email, data) {
- await sendEmail(email, 'RunForge - 工单状态更新提醒',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 工单状态更新提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 工单状态更新提醒</h2>
- </div>
- <p>尊敬的用户:</p>
- <p>您编号为${data.id}的工单有新的回复:</p>
- <div class="info">
- <p><strong>回复内容:</strong> ${data.content}</p>
- <p><strong>回复时间:</strong> ${this.stramptoTime(new Date().getTime())}</p>
- </div>
- <p class="important">${data.files.length > 0 ? '当前回复内含有附件,前往RunForge官网内查看' : ''}</p>
- <p class="important">请前往RunForge官网回复工单,请勿直接回复邮件。</p>
- <p class="footer">Copyright © 2025 RunForge</p>
- </div>
- </body>
- </html>`
- )
- }
- async powerCheck(email, data) {
- await sendEmail(email, 'RunForge - 宿舍电费提醒',
- `<html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>RunForge - 宿舍电费提醒</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- background-color: #f4f4f4;
- margin: 0;
- padding: 0;
- }
- .container {
- width: 80%;
- margin: 20px auto;
- background-color: #fff;
- padding: 20px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- }
- .head {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- color: #2c3e50;
- }
- p {
- font-size: 16px;
- color: #34495e;
- line-height: 1.6;
- text-indent: 2em;
- }
- .info {
- background-color: #ecf0f1;
- padding: 15px;
- border-radius: 5px;
- margin: 20px 0;
- }
- .info p {
- margin: 5px 0;
- }
- .important {
- color: #e74c3c;
- font-weight: bold;
- }
- .footer {
- font-size: 14px;
- text-align: center;
- color: #7f8c8d;
- margin-top: 50px;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <div class="head">
- <h2>RunForge - 宿舍电费提醒</h2>
- </div>
- <p>尊敬的用户:</p>
- <p>${data.building}${data.room}宿舍电费已低于预设提醒阈值,请留意:</p>
- <div class="info">
- <p><strong>校区:</strong> ${data.area}</p>
- <p><strong>楼栋:</strong> ${data.building}</p>
- <p><strong>寝室号:</strong> ${data.room}</p>
- <p><strong>当前余额:</strong> ¥${data.now_balance}</p>
- <p><strong>提醒阈值:</strong> ¥${data.now_balance}</p>
- <p><strong>扣费时间:</strong> ${data.now_change_time}</p>
- </div>
- <p class="important">当前电费已低于预设提醒阈值${Number(data.lowest - data.now_balance).toFixed(2)}元,请及时充值</p>
- <p class="footer">Copyright © 2025 RunForge ✨</p>
- </div>
- </body>
- </html>`
- )
- }
- // 时长计算
- formatSecondsToMinSec(totalSeconds) {
- const minutes = Math.floor(totalSeconds / 60);
- const seconds = totalSeconds % 60;
- return `${minutes}分${seconds.toString().padStart(2, '0')}秒`;
- }
- // 配速计算
- calculatePace(seconds, kilometers) {
- const paceInSeconds = seconds / kilometers;
- const minutes = Math.floor(paceInSeconds / 60);
- const remainingSeconds = Math.round(paceInSeconds % 60);
- return `${minutes}'${remainingSeconds.toString().padStart(2, '0')}''`;
- }
- }
- const EmailTemplate = new emailTemplate()
- module.exports = EmailTemplate
|