emailTemplate.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. const sendEmail = require('./Email')
  2. class emailTemplate {
  3. stramptoTime(time) {
  4. if (time < 10)
  5. return '';
  6. return new Date(+time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' });
  7. }
  8. async checkEmail(email, code) {
  9. const time = new Date().getTime()
  10. await sendEmail(email, 'RunForge - 邮箱验证码',
  11. `<html lang="zh-CN">
  12. <head>
  13. <meta charset="UTF-8">
  14. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  15. <title>RunForge - 邮箱验证码</title>
  16. <style>
  17. body {
  18. font-family: Arial, sans-serif;
  19. background-color: #f4f4f4;
  20. margin: 0;
  21. padding: 0;
  22. }
  23. .container {
  24. width: 80%;
  25. margin: 20px auto;
  26. background-color: #fff;
  27. padding: 20px;
  28. border-radius: 8px;
  29. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  30. }
  31. .head {
  32. display: flex;
  33. justify-content: center;
  34. align-items: center;
  35. gap:10px;
  36. color: #2c3e50;
  37. }
  38. p {
  39. font-size: 16px;
  40. color: #34495e;
  41. line-height: 1.6;
  42. text-indent: 2em;
  43. }
  44. .code {
  45. margin: 20px 0;
  46. font-size: 1.5em;
  47. text-align: center;
  48. font-weight: bold;
  49. }
  50. .important {
  51. color: #e74c3c;
  52. font-weight: bold;
  53. }
  54. .footer {
  55. font-size: 14px;
  56. text-align: center;
  57. color: #7f8c8d;
  58. margin-top: 50px;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div class="container">
  64. <div class="head">
  65. <h2>RunForge - 邮箱验证码</h2>
  66. </div>
  67. <p>尊敬的用户:</p>
  68. <p>您正在本站进行邮箱验证操作,如非您本人操作,请忽略此邮件。</p>
  69. <p>您的验证码为:</p>
  70. <div class="code">
  71. ${code}
  72. </div>
  73. <p class="important">验证码5分钟内有效,超时请重新获取</p>
  74. <p class="footer">Copyright © 2025 RunForge</p>
  75. </div>
  76. </body>
  77. </html>`
  78. )
  79. }
  80. async registerSuccess(email, username) {
  81. const time = new Date().getTime()
  82. await sendEmail(email, '您已成功注册RunForge账号',
  83. `<html lang="zh-CN">
  84. <head>
  85. <meta charset="UTF-8">
  86. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  87. <title>RunForge - 注册成功提醒</title>
  88. <style>
  89. body {
  90. font-family: Arial, sans-serif;
  91. background-color: #f4f4f4;
  92. margin: 0;
  93. padding: 0;
  94. }
  95. .container {
  96. width: 80%;
  97. margin: 20px auto;
  98. background-color: #fff;
  99. padding: 20px;
  100. border-radius: 8px;
  101. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  102. }
  103. .head {
  104. display: flex;
  105. justify-content: center;
  106. align-items: center;
  107. gap: 10px;
  108. color: #2c3e50;
  109. }
  110. p {
  111. font-size: 16px;
  112. color: #34495e;
  113. line-height: 1.6;
  114. text-indent: 2em;
  115. }
  116. .info {
  117. background-color: #ecf0f1;
  118. padding: 15px;
  119. border-radius: 5px;
  120. margin: 20px 0;
  121. }
  122. .info p {
  123. margin: 5px 0;
  124. }
  125. .important {
  126. color: #e74c3c;
  127. font-weight: bold;
  128. }
  129. .footer {
  130. font-size: 14px;
  131. text-align: center;
  132. color: #7f8c8d;
  133. margin-top: 50px;
  134. }
  135. </style>
  136. </head>
  137. <body>
  138. <div class="container">
  139. <div class="head">
  140. <h2>RunForge - 注册成功提醒</h2>
  141. </div>
  142. <p>尊敬的 ${username}:</p>
  143. <p>您已成功注册RunForge账号:</p>
  144. <div class="info">
  145. <p><strong>用户名:</strong> ${username}</p>
  146. <p><strong>注册时间:</strong> ${this.stramptoTime(time)}</p>
  147. </div>
  148. <p class="footer">Copyright © 2025 RunForge</p>
  149. </div>
  150. </body>
  151. </html>`
  152. )
  153. }
  154. async updateSuccess(email, data) {
  155. await sendEmail(email, '乐跑账号更新成功提醒',
  156. `<html lang="zh-CN">
  157. <head>
  158. <meta charset="UTF-8">
  159. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  160. <title>乐跑账号更新成功提醒</title>
  161. <style>
  162. body {
  163. font-family: Arial, sans-serif;
  164. background-color: #f4f4f4;
  165. margin: 0;
  166. padding: 0;
  167. }
  168. .container {
  169. width: 80%;
  170. margin: 20px auto;
  171. background-color: #fff;
  172. padding: 20px;
  173. border-radius: 8px;
  174. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  175. }
  176. .head {
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. gap: 10px;
  181. color: #2c3e50;
  182. }
  183. p {
  184. font-size: 16px;
  185. color: #34495e;
  186. line-height: 1.6;
  187. text-indent: 2em;
  188. }
  189. .info {
  190. background-color: #ecf0f1;
  191. padding: 15px;
  192. border-radius: 5px;
  193. margin: 20px 0;
  194. }
  195. .info p {
  196. margin: 5px 0;
  197. }
  198. .important {
  199. color: #e74c3c;
  200. font-weight: bold;
  201. }
  202. .footer {
  203. font-size: 14px;
  204. text-align: center;
  205. color: #7f8c8d;
  206. margin-top: 50px;
  207. }
  208. </style>
  209. </head>
  210. <body>
  211. <div class="container">
  212. <div class="head">
  213. <h2>乐跑账号更新好啦,宝宝快看看~ 🎉💖✨</h2>
  214. </div>
  215. <p>亲爱的 ${data.name} 宝宝 🌸:</p>
  216. <p>嘻嘻~ 你已经成功更新了乐跑账号的登录信息啦 🥰💌:</p>
  217. <div class="info">
  218. <p><strong>学号:</strong> ${data.account} 🎓</p>
  219. <p><strong>年级:</strong> ${data.grade_id} 📚</p>
  220. <p><strong>学院:</strong> ${data.academy_name} 🏫</p>
  221. <p><strong>更新时间:</strong> ${this.stramptoTime(new Date().getTime())} ⏰</p>
  222. </div>
  223. <p class="important">
  224. ${data.auto_run === 0
  225. ? '现在还没有帮宝宝开启自动乐跑呢 🐾💦 如果想要开始跑跑的话,记得登录后去RunForge手动点一下哦~ 🌈💕'
  226. : '已经为宝宝开启了自动乐跑啦 🏃‍♀️✨ 登录后系统会乖乖替你完成乐跑 💖 记得留意邮箱提醒哟~ 📬'}
  227. </p>
  228. <p class="important">宝宝要记得不要在其他设备上登录“智慧体育”小程序哦 🚫📱,不然会失效,到时候又要重新登录啦 😢💦~</p>
  229. <p class="important">有问题随时喊RunForge客服小可爱呀 💕💌 我们都会耐心陪宝宝解决的哟 ✨🥰</p>
  230. <p class="footer">Copyright © 2025 RunForge 🌟</p>
  231. </div>
  232. </body>
  233. </html>`
  234. )
  235. }
  236. async lepaoOver(email, data) {
  237. await sendEmail(email, '🎉乐跑完成祝贺',
  238. `<!DOCTYPE html>
  239. <html lang="zh-CN">
  240. <head>
  241. <meta charset="UTF-8">
  242. <title>🎉 RunForge - 乐跑完成祝贺</title>
  243. <style>
  244. body {
  245. background-color: #fffaf4;
  246. margin: 0;
  247. padding: 0;
  248. font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  249. }
  250. .container {
  251. max-width: 620px;
  252. margin: 40px auto;
  253. padding: 30px;
  254. background-color: #fff;
  255. border-radius: 14px;
  256. box-shadow: 0 8px 25px rgba(255, 183, 77, 0.2);
  257. border: 2px dashed #ffe0b2;
  258. }
  259. .head {
  260. text-align: center;
  261. margin-bottom: 30px;
  262. }
  263. .head h2 {
  264. color: #ff7043;
  265. font-size: 26px;
  266. margin: 0;
  267. }
  268. p {
  269. color: #444;
  270. font-size: 16px;
  271. line-height: 1.8;
  272. }
  273. .info {
  274. background-color: #fff3e0;
  275. border-left: 5px solid #ffb74d;
  276. padding: 15px 20px;
  277. margin: 25px 0;
  278. border-radius: 10px;
  279. }
  280. .info p {
  281. margin: 8px 0;
  282. }
  283. .footer {
  284. text-align: center;
  285. color: #bbb;
  286. font-size: 14px;
  287. margin-top: 40px;
  288. }
  289. .highlight {
  290. color: #ff5722;
  291. font-weight: bold;
  292. }
  293. </style>
  294. </head>
  295. <body>
  296. <div class="container">
  297. <div class="head">
  298. <h2>乐跑目标完成🎉</h2>
  299. </div>
  300. <p>亲爱的 <span class="highlight">${data.name}</span> 宝宝 ꒰。•ᴗ•。꒱:</p>
  301. <p>
  302. ✨恭喜恭喜~你已经火力全开地完成了设定乐跑目标啦!🎊<br>
  303. 不得不说,你就是我们心中的 <strong>小跑神</strong> 🌟💨,坚持到最后真的超级棒!💪( •̀ᄇ• ́)و
  304. </p>
  305. <p>
  306. 跑过的风,晒过的阳,每一步都是你努力的见证!🌤️🍃<br>
  307. 我们在远程为你打Call中 📣📣📣 ~真的好佩服佩服你!
  308. </p>
  309. <p>
  310. 这一学期和你一起“并肩作战”,我们感到非常幸运!🧡<br>
  311. 希望你收获了健康,也收获了快乐~o(≧▽≦)o
  312. </p>
  313. <p>
  314. 📬 如果有任何问题,随时给我们戳小窗~我们在线等你哟 (´▽`)ノ♪
  315. </p>
  316. <p>
  317. 🥳 祝你假期躺赢、学习加buff、每天都开心到冒泡泡!✧*。٩(ˊᗜˋ*)و✧*。<br>
  318. 📚 新学期我们一起继续加速奔跑吧~Let's gooo!🔥🔥
  319. </p>
  320. <p>
  321. 🧡我们已经为您关闭了自动乐跑功能,如您需要继续乐跑,还可前往RunForge自行开启哦!
  322. </p>
  323. <p class="footer">Copyright © 2025 RunForge</p>
  324. </div>
  325. </body>
  326. </html>
  327. `
  328. )
  329. }
  330. async lepaoSuccess(email, data) {
  331. const target_count = Number(data.target_count) || 0
  332. const total_num = Number(data.total_num) || 0
  333. const timeSec = Number(data.time) || 0
  334. const distanceKm = Number(data.distance) || 0
  335. const passTit = data.pass_tit != null && data.pass_tit !== '' ? data.pass_tit : '—'
  336. const paceStr =
  337. distanceKm > 0 && timeSec > 0
  338. ? this.calculatePace(timeSec, distanceKm)
  339. : '—'
  340. const timeStr = timeSec > 0 ? this.formatSecondsToMinSec(timeSec) : '—'
  341. let goalHtml = ''
  342. if (target_count === 0) {
  343. goalHtml = `
  344. <p><strong>累计次数:</strong> ${total_num} 次 ✨</p>`
  345. } else {
  346. const remain = Math.max(0, target_count - total_num)
  347. const hitGoal = total_num >= target_count
  348. goalHtml = `
  349. <p><strong>目标次数:</strong> ${target_count} 次 🎯</p>
  350. <p><strong>累计次数:</strong> ${total_num} 次 ✨</p>`
  351. }
  352. await sendEmail(email, '乐跑成功提醒',
  353. `<html lang="zh-CN">
  354. <head>
  355. <meta charset="UTF-8">
  356. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  357. <title>乐跑成功提醒</title>
  358. <style>
  359. body {
  360. font-family: Arial, sans-serif;
  361. background-color: #f4f4f4;
  362. margin: 0;
  363. padding: 0;
  364. }
  365. .container {
  366. width: 80%;
  367. margin: 20px auto;
  368. background-color: #fff;
  369. padding: 20px;
  370. border-radius: 8px;
  371. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  372. }
  373. .head {
  374. display: flex;
  375. justify-content: center;
  376. align-items: center;
  377. gap: 10px;
  378. color: #2c3e50;
  379. }
  380. p {
  381. font-size: 16px;
  382. color: #34495e;
  383. line-height: 1.6;
  384. text-indent: 2em;
  385. }
  386. .info {
  387. background-color: #ecf0f1;
  388. padding: 15px;
  389. border-radius: 5px;
  390. margin: 20px 0;
  391. }
  392. .info p {
  393. margin: 5px 0;
  394. text-indent: 0;
  395. }
  396. .important {
  397. color: #e74c3c;
  398. font-weight: bold;
  399. }
  400. .footer {
  401. font-size: 14px;
  402. text-align: center;
  403. color: #7f8c8d;
  404. margin-top: 50px;
  405. }
  406. </style>
  407. </head>
  408. <body>
  409. <div class="container">
  410. <div class="head">
  411. <h2>乐跑成功啦 🎉💖</h2>
  412. </div>
  413. <p>亲爱的 ${data.name} 宝宝:</p>
  414. <p>耶耶耶~ 我们已经乖乖帮你完成了一次乐跑啦 ✨🏃‍♀️💨</p>
  415. <div class="info">
  416. <p><strong>学号:</strong> ${data.account}</p>
  417. <p><strong>跑区:</strong> ${passTit} 🌈</p>
  418. <p><strong>跑步时间:</strong> ${timeStr} ⏱️</p>
  419. <p><strong>平均配速:</strong> ${paceStr} 🐇</p>
  420. <p><strong>跑步距离:</strong> ${distanceKm || '—'} Km 💕</p>
  421. ${goalHtml}
  422. </div>
  423. <p class="important">如果宝宝开启了自动乐跑,要记得不要在其他设备上登录“智慧体育”小程序哦 🚫📱,不然登录就会失效,要重新来一次啦~</p>
  424. <p class="important">有问题随时找RunForge客服小可爱呀 💌 我们会陪你耐心解决的~</p>
  425. <p class="footer">Copyright © 2025 RunForge ✨</p>
  426. </div>
  427. </body>
  428. </html>`
  429. )
  430. }
  431. async lepaoFail(email, data) {
  432. const time = new Date().getTime()
  433. await sendEmail(email, '乐跑失败提醒',
  434. `<html lang="zh-CN">
  435. <head>
  436. <meta charset="UTF-8">
  437. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  438. <title>乐跑失败提醒</title>
  439. <style>
  440. body {
  441. font-family: Arial, sans-serif;
  442. background-color: #f4f4f4;
  443. margin: 0;
  444. padding: 0;
  445. }
  446. .container {
  447. width: 80%;
  448. margin: 20px auto;
  449. background-color: #fff;
  450. padding: 20px;
  451. border-radius: 8px;
  452. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  453. }
  454. .head {
  455. display: flex;
  456. justify-content: center;
  457. align-items: center;
  458. gap: 10px;
  459. color: #2c3e50;
  460. }
  461. p {
  462. font-size: 16px;
  463. color: #34495e;
  464. line-height: 1.6;
  465. text-indent: 2em;
  466. }
  467. .info {
  468. background-color: #ecf0f1;
  469. padding: 15px;
  470. border-radius: 5px;
  471. margin: 20px 0;
  472. }
  473. .info p {
  474. margin: 5px 0;
  475. }
  476. .important {
  477. color: #e74c3c;
  478. font-weight: bold;
  479. }
  480. .footer {
  481. font-size: 14px;
  482. text-align: center;
  483. color: #7f8c8d;
  484. margin-top: 50px;
  485. }
  486. </style>
  487. </head>
  488. <body>
  489. <div class="container">
  490. <div class="head">
  491. <h2>乐跑没有成功呢 😢💦</h2>
  492. </div>
  493. <p>亲爱的 ${data.name ?? data.account} 宝宝 🌸:</p>
  494. <p>我们刚刚尝试帮你完成乐跑的时候,遇到了一点小意外呢 💔💦:</p>
  495. <div class="info">
  496. <p><strong>学号:</strong> ${data.account} 🎓</p>
  497. <p><strong>时间:</strong> ${this.stramptoTime(time)} ⏰</p>
  498. <p><strong>失败原因:</strong> ${data.reason} 😭</p>
  499. </div>
  500. <p class="important">宝宝如果是登录失效的话 🥺✨,要记得重新启动RunForge乐跑登录器,再登录“智慧体育”小程序就可以啦 💕</p>
  501. <p class="important">如果还是不懂,随时可以来找RunForge客服小可爱哟 💌 我们会耐心陪宝宝解决问题的 🌈🥰</p>
  502. <p class="footer">Copyright © 2025 RunForge 💖</p>
  503. </div>
  504. </body>
  505. </html>`
  506. )
  507. }
  508. async orderNewReply(email, data) {
  509. await sendEmail(email, 'RunForge - 工单状态更新提醒',
  510. `<html lang="zh-CN">
  511. <head>
  512. <meta charset="UTF-8">
  513. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  514. <title>工单状态更新提醒</title>
  515. <style>
  516. body {
  517. font-family: Arial, sans-serif;
  518. background-color: #f4f4f4;
  519. margin: 0;
  520. padding: 0;
  521. }
  522. .container {
  523. width: 80%;
  524. margin: 20px auto;
  525. background-color: #fff;
  526. padding: 20px;
  527. border-radius: 8px;
  528. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  529. }
  530. .head {
  531. display: flex;
  532. justify-content: center;
  533. align-items: center;
  534. gap: 10px;
  535. color: #2c3e50;
  536. }
  537. p {
  538. font-size: 16px;
  539. color: #34495e;
  540. line-height: 1.6;
  541. text-indent: 2em;
  542. }
  543. .info {
  544. background-color: #ecf0f1;
  545. padding: 15px;
  546. border-radius: 5px;
  547. margin: 20px 0;
  548. }
  549. .info p {
  550. margin: 5px 0;
  551. }
  552. .important {
  553. color: #e74c3c;
  554. font-weight: bold;
  555. }
  556. .footer {
  557. font-size: 14px;
  558. text-align: center;
  559. color: #7f8c8d;
  560. margin-top: 50px;
  561. }
  562. </style>
  563. </head>
  564. <body>
  565. <div class="container">
  566. <div class="head">
  567. <h2>工单状态更新提醒</h2>
  568. </div>
  569. <p>尊敬的用户:</p>
  570. <p>您编号为${data.id}的工单有新的回复:</p>
  571. <div class="info">
  572. <p><strong>回复内容:</strong> ${data.content}</p>
  573. <p><strong>回复时间:</strong> ${this.stramptoTime(new Date().getTime())}</p>
  574. </div>
  575. <p class="important">${data.files.length > 0 ? '当前回复内含有附件,前往RunForge官网内查看' : ''}</p>
  576. <p class="important">请前往RunForge官网回复工单,请勿直接回复邮件。</p>
  577. <p class="footer">Copyright © 2025 RunForge</p>
  578. </div>
  579. </body>
  580. </html>`
  581. )
  582. }
  583. async sendCountRequestNotifyAdmins(email, data) {
  584. await sendEmail(email, 'RunForge - 赠送次数待审核提醒',
  585. `<html lang="zh-CN">
  586. <head>
  587. <meta charset="UTF-8">
  588. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  589. <title>赠送次数待审核提醒</title>
  590. <style>
  591. body {
  592. font-family: Arial, sans-serif;
  593. background-color: #f4f4f4;
  594. margin: 0;
  595. padding: 0;
  596. }
  597. .container {
  598. width: 80%;
  599. margin: 20px auto;
  600. background-color: #fff;
  601. padding: 20px;
  602. border-radius: 8px;
  603. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  604. }
  605. .head {
  606. display: flex;
  607. justify-content: center;
  608. align-items: center;
  609. gap: 10px;
  610. color: #2c3e50;
  611. }
  612. p {
  613. font-size: 16px;
  614. color: #34495e;
  615. line-height: 1.6;
  616. text-indent: 2em;
  617. }
  618. .info {
  619. background-color: #ecf0f1;
  620. padding: 15px;
  621. border-radius: 5px;
  622. margin: 20px 0;
  623. }
  624. .info p {
  625. margin: 5px 0;
  626. text-indent: 0;
  627. }
  628. .important {
  629. color: #e74c3c;
  630. font-weight: bold;
  631. }
  632. .footer {
  633. font-size: 14px;
  634. text-align: center;
  635. color: #7f8c8d;
  636. margin-top: 50px;
  637. }
  638. </style>
  639. </head>
  640. <body>
  641. <div class="container">
  642. <div class="head">
  643. <h2>赠送次数待审核提醒</h2>
  644. </div>
  645. <p>尊敬的管理员:</p>
  646. <p>系统收到一条新的赠送次数申请,请及时审核处理:</p>
  647. <div class="info">
  648. <p><strong>申请ID:</strong> ${data.requestId}</p>
  649. <p><strong>赠送人:</strong> ${data.senderUsername}</p>
  650. <p><strong>接收人:</strong> ${data.receiverUsername}</p>
  651. <p><strong>赠送次数:</strong> ${data.count}</p>
  652. <p><strong>申请时间:</strong> ${this.stramptoTime(data.createTime)}</p>
  653. </div>
  654. <p class="important">请前往 RunForge 管理后台进行审核,请勿直接回复邮件。</p>
  655. <p class="footer">Copyright © 2025 RunForge</p>
  656. </div>
  657. </body>
  658. </html>`
  659. )
  660. }
  661. async lepaoAdminWarning(email, data) {
  662. const time = new Date().getTime()
  663. const safe = (v) => (v === undefined || v === null) ? '' : String(v)
  664. const subject = `RunForge - 乐跑异常告警(${safe(data.server || '')})`
  665. await sendEmail(email, subject,
  666. `<html lang="zh-CN">
  667. <head>
  668. <meta charset="UTF-8">
  669. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  670. <title>RunForge - 乐跑异常告警</title>
  671. <style>
  672. body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin:0; padding:0; }
  673. .container { width: 86%; max-width: 760px; margin: 20px auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
  674. .head { text-align:center; color:#2c3e50; }
  675. .info { background-color:#ecf0f1; padding: 14px 16px; border-radius: 6px; margin: 18px 0; }
  676. .info p { margin: 8px 0; text-indent: 0; word-break: break-all; }
  677. .tag { display:inline-block; background:#ffe8e6; color:#c0392b; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
  678. .footer { font-size: 12px; text-align:center; color:#7f8c8d; margin-top: 30px; }
  679. </style>
  680. </head>
  681. <body>
  682. <div class="container">
  683. <div class="head">
  684. <h2>乐跑异常告警 <span class="tag">非常见错误</span></h2>
  685. </div>
  686. <p>尊敬的管理员:</p>
  687. <p>系统在自动乐跑流程中捕获到一条非常见错误(已自动过滤“当天已跑 / 不在时间 / 登录过期”三类常见错误)。请关注是否为接口变更、代理异常或程序缺陷。</p>
  688. <div class="info">
  689. <p><strong>服务器:</strong> ${safe(data.server)}</p>
  690. <p><strong>账号:</strong> ${safe(data.account)}</p>
  691. <p><strong>姓名:</strong> ${safe(data.name)}</p>
  692. <p><strong>任务:</strong> ${safe(data.taskType)}</p>
  693. <p><strong>TraceId:</strong> ${safe(data.traceId)}</p>
  694. <p><strong>时间:</strong> ${this.stramptoTime(time)}</p>
  695. <p><strong>错误信息:</strong> ${safe(data.reason)}</p>
  696. <p><strong>错误码:</strong> ${safe(data.code)}</p>
  697. </div>
  698. <p class="footer">Copyright © 2025 RunForge</p>
  699. </div>
  700. </body>
  701. </html>`
  702. )
  703. }
  704. async sendCountRequestApproved(email, data) {
  705. await sendEmail(email, 'RunForge - 赠送次数审核通过提醒',
  706. `<html lang="zh-CN">
  707. <head>
  708. <meta charset="UTF-8">
  709. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  710. <title>赠送次数审核通过提醒</title>
  711. <style>
  712. body {
  713. font-family: Arial, sans-serif;
  714. background-color: #f4f4f4;
  715. margin: 0;
  716. padding: 0;
  717. }
  718. .container {
  719. width: 80%;
  720. margin: 20px auto;
  721. background-color: #fff;
  722. padding: 20px;
  723. border-radius: 8px;
  724. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  725. }
  726. .head {
  727. display: flex;
  728. justify-content: center;
  729. align-items: center;
  730. gap: 10px;
  731. color: #2c3e50;
  732. }
  733. p {
  734. font-size: 16px;
  735. color: #34495e;
  736. line-height: 1.6;
  737. text-indent: 2em;
  738. }
  739. .info {
  740. background-color: #ecf0f1;
  741. padding: 15px;
  742. border-radius: 5px;
  743. margin: 20px 0;
  744. }
  745. .info p {
  746. margin: 5px 0;
  747. text-indent: 0;
  748. }
  749. .footer {
  750. font-size: 14px;
  751. text-align: center;
  752. color: #7f8c8d;
  753. margin-top: 50px;
  754. }
  755. </style>
  756. </head>
  757. <body>
  758. <div class="container">
  759. <div class="head">
  760. <h2>赠送次数审核通过提醒</h2>
  761. </div>
  762. <p>尊敬的用户:</p>
  763. <p>您收到的一笔赠送次数申请已审核通过,次数已到账:</p>
  764. <div class="info">
  765. <p><strong>赠送人:</strong> ${data.senderUsername}</p>
  766. <p><strong>到账次数:</strong> ${data.count}</p>
  767. <p><strong>审核时间:</strong> ${this.stramptoTime(data.reviewTime)}</p>
  768. </div>
  769. <p class="footer">Copyright © 2025 RunForge</p>
  770. </div>
  771. </body>
  772. </html>`
  773. )
  774. }
  775. async sendCountRequestRejected(email, data) {
  776. await sendEmail(email, 'RunForge - 赠送次数审核失败提醒',
  777. `<html lang="zh-CN">
  778. <head>
  779. <meta charset="UTF-8">
  780. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  781. <title>赠送次数审核失败提醒</title>
  782. <style>
  783. body {
  784. font-family: Arial, sans-serif;
  785. background-color: #f4f4f4;
  786. margin: 0;
  787. padding: 0;
  788. }
  789. .container {
  790. width: 80%;
  791. margin: 20px auto;
  792. background-color: #fff;
  793. padding: 20px;
  794. border-radius: 8px;
  795. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  796. }
  797. .head {
  798. display: flex;
  799. justify-content: center;
  800. align-items: center;
  801. gap: 10px;
  802. color: #2c3e50;
  803. }
  804. p {
  805. font-size: 16px;
  806. color: #34495e;
  807. line-height: 1.6;
  808. text-indent: 2em;
  809. }
  810. .info {
  811. background-color: #ecf0f1;
  812. padding: 15px;
  813. border-radius: 5px;
  814. margin: 20px 0;
  815. }
  816. .info p {
  817. margin: 5px 0;
  818. text-indent: 0;
  819. }
  820. .important {
  821. color: #e74c3c;
  822. font-weight: bold;
  823. }
  824. .footer {
  825. font-size: 14px;
  826. text-align: center;
  827. color: #7f8c8d;
  828. margin-top: 50px;
  829. }
  830. </style>
  831. </head>
  832. <body>
  833. <div class="container">
  834. <div class="head">
  835. <h2>赠送次数审核失败提醒</h2>
  836. </div>
  837. <p>尊敬的用户:</p>
  838. <p>您发起的一笔赠送次数申请未通过审核,已将次数退回到您的账户:</p>
  839. <div class="info">
  840. <p><strong>接收人:</strong> ${data.receiverUsername}</p>
  841. <p><strong>退回次数:</strong> ${data.count}</p>
  842. <p><strong>审核时间:</strong> ${this.stramptoTime(data.reviewTime)}</p>
  843. <p><strong>拒绝原因:</strong> ${data.rejectReason}</p>
  844. </div>
  845. <p class="important">如有疑问,请前往 RunForge 联系客服处理。</p>
  846. <p class="footer">Copyright © 2025 RunForge</p>
  847. </div>
  848. </body>
  849. </html>`
  850. )
  851. }
  852. async powerCheck(email, data) {
  853. await sendEmail(email, '宿舍电费提醒',
  854. `<html lang="zh-CN">
  855. <head>
  856. <meta charset="UTF-8">
  857. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  858. <title>宿舍电费提醒</title>
  859. <style>
  860. body {
  861. font-family: Arial, sans-serif;
  862. background-color: #f4f4f4;
  863. margin: 0;
  864. padding: 0;
  865. }
  866. .container {
  867. width: 80%;
  868. margin: 20px auto;
  869. background-color: #fff;
  870. padding: 20px;
  871. border-radius: 8px;
  872. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  873. }
  874. .head {
  875. display: flex;
  876. justify-content: center;
  877. align-items: center;
  878. gap: 10px;
  879. color: #2c3e50;
  880. }
  881. p {
  882. font-size: 16px;
  883. color: #34495e;
  884. line-height: 1.6;
  885. text-indent: 2em;
  886. }
  887. .info {
  888. background-color: #ecf0f1;
  889. padding: 15px;
  890. border-radius: 5px;
  891. margin: 20px 0;
  892. }
  893. .info p {
  894. margin: 5px 0;
  895. }
  896. .important {
  897. color: #e74c3c;
  898. font-weight: bold;
  899. }
  900. .footer {
  901. font-size: 14px;
  902. text-align: center;
  903. color: #7f8c8d;
  904. margin-top: 50px;
  905. }
  906. </style>
  907. </head>
  908. <body>
  909. <div class="container">
  910. <div class="head">
  911. <h2>宿舍电费提醒</h2>
  912. </div>
  913. <p>尊敬的用户:</p>
  914. <p>${data.building}${data.room}宿舍电费已低于预设提醒阈值,请留意:</p>
  915. <div class="info">
  916. <p><strong>校区:</strong> ${data.area}</p>
  917. <p><strong>楼栋:</strong> ${data.building}</p>
  918. <p><strong>寝室号:</strong> ${data.room}</p>
  919. <p><strong>当前余额:</strong> ¥${data.now_balance}</p>
  920. <p><strong>提醒阈值:</strong> ¥${data.lowest}</p>
  921. <p><strong>扣费时间:</strong> ${data.now_change_time}</p>
  922. </div>
  923. <p class="important">当前电费已低于预设提醒阈值${Number(data.lowest - data.now_balance).toFixed(2)}元,请及时充值</p>
  924. <p class="footer">Copyright © 2025 RunForge ✨</p>
  925. </div>
  926. </body>
  927. </html>`
  928. )
  929. }
  930. // 时长计算
  931. formatSecondsToMinSec(totalSeconds) {
  932. const minutes = Math.floor(totalSeconds / 60);
  933. const seconds = totalSeconds % 60;
  934. return `${minutes}分${seconds.toString().padStart(2, '0')}秒`;
  935. }
  936. // 配速计算
  937. calculatePace(seconds, kilometers) {
  938. const paceInSeconds = seconds / kilometers;
  939. const minutes = Math.floor(paceInSeconds / 60);
  940. const remainingSeconds = Math.round(paceInSeconds % 60);
  941. return `${minutes}'${remainingSeconds.toString().padStart(2, '0')}''`;
  942. }
  943. }
  944. const EmailTemplate = new emailTemplate()
  945. module.exports = EmailTemplate