| 55 | } |
| 56 | doWork() |
| 57 | function doWork(){ |
| 58 | let body = {} |
| 59 | let notifyContent = '错误!未获取到数据' |
| 60 | // 先查看ip是否是中国,是中国则使用代理加速链接 |
| 61 | $.get(option,function (error, response, data) { |
| 62 | let jsonObj = JSON.parse(response.body) |
| 63 | if(jsonObj.country === 'China') |
| 64 | apiUrl = proxy + url + ymCode // 链接前面加代理 |
| 65 | let option2 = { |
| 66 | url: apiUrl, |
| 67 | headers: {} |
| 68 | } |
| 69 | let nlDate = '' // 农历 如 正月初一 |
| 70 | let desc = '' // 节日或描述 如 上元节 四九 |
| 71 | // 请求日历数据 |
| 72 | $.get(option2, function (error, response, data) { |
| 73 | let jsonObj = JSON.parse(response.body) |
| 74 | let result = jsonObj.data[0].almanac |
| 75 | result.forEach(function (i) { |
| 76 | if( i.year === dateArray[0] && i.month === dateArray[1] && i.day === dateArray[2] ) |
| 77 | { |
| 78 | nlDate = date + ' ' + i.lMonth + '月' + i.lDate |
| 79 | // 拼接今日节日 |
| 80 | desc += i.desc?i.desc:'' |
| 81 | desc += i.term?' ' + i.term:'' |
| 82 | desc += i.value?' ' + i.value:'' |
| 83 | // 拼接消息体 |
| 84 | notifyContent = '干支纪法:' + i.gzYear + '年 ' + i.gzMonth + '月 ' + i.gzDate + '日\n农历:' + i.lMonth + '月' + i.lDate + '\n今日:' + desc + '\n忌:' + i.avoid + '\n宜:' + i.suit |
| 85 | } |
| 86 | }) |
| 87 | $.isSurge() ? body = { |
| 88 | title: title, |
| 89 | content: notifyContent, |
| 90 | icon: 'list.bullet.rectangle', |
| 91 | 'icon-color': '#5AC8FA' |
| 92 | } : body = {title: title, content: notifyContent, icon: 'calendar', backgroundColor: '#9999FF'} |
| 93 | console.log('\n内容:\n' + notifyContent) |
| 94 | $.msg(title, nlDate, notifyContent) |
| 95 | $.isSurge || $.isStash ? $.done(body) : $.done() |
| 96 | }) |
| 97 | }) |
| 98 | } |
| 99 | |
| 100 | |
| 101 | /********************************* |