Skip to content

Commit 9cd1307

Browse files
committed
update 电信
1 parent 42ada9c commit 9cd1307

1 file changed

Lines changed: 30 additions & 40 deletions

File tree

‎Task/telecomInfinity.js‎

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ let config = {
4141
delay: 0, //自定义延迟签到,单位毫秒,(如填200则每个接口延迟0.2秒执行),默认无延迟
4242
info: 1, //是否显示手机归属地,1为显示,0为不显示
4343
}
44-
const $ = new Env(config.name)
45-
d = new Date();
46-
Y = d.getFullYear(),
47-
M = $.getdata('Mon').slice(-2)||d.getMonth() //上月
44+
let $ = new Env(config.name),
45+
Y = $.time('yyyy'),
46+
M = $.getdata('Mon').slice(-2)||$.time('MM') ; //查询前几个月,可以')'号后减几
47+
4848
let AUTHTOKEN = $.getdata(config.authTokenKey)
4949
let COOKIE = $.getdata(config.CookieKey)
5050
var requests = {
@@ -82,7 +82,6 @@ var requests = {
8282
}
8383
}
8484

85-
//console.log(requests.bill)
8685
if (isGetCookie = typeof $request !== 'undefined') {
8786
GetCookie()
8887
$.done()
@@ -101,7 +100,7 @@ function GetCookie() {
101100
if (cookieVal) {
102101
if ($.setdata(cookieVal, config.authTokenKey)) {
103102
$.msg(config.name, '获取authToken: 成功', '')
104-
// $.log.info(`[${config.name}] 获取authToken: 成功, authToken: ${cookieVal}, Cookie: [${COOKIE}]` )
103+
// console.log(`[${config.name}] 获取authToken: 成功, authToken: ${cookieVal}, Cookie: [${COOKIE}]` )
105104
}
106105
}
107106
}
@@ -181,25 +180,14 @@ function parseData(detail, balance, info, bill) {
181180
}
182181

183182
function notify(data, balance, exdata, bldata) {
183+
//console.log(data.items)
184184
try{
185185
var subtitle = ""
186186
if (config.info) {
187187
subtitle = "【手机】" + exdata.mobileShort + " (" + exdata.province + "-" + exdata.city + ")"
188188
}
189-
var productname = "中国电信"
190-
if (typeof data.items[1].offerType == 11) {
191-
productname = data.items[1].productOFFName
192-
}
193-
else if (typeof data.items[0].productOFFName != "undefined") {
194-
productname = data.items[0].productOFFName
195-
}
196-
var message = "【套餐】" + productname
197-
var voiceAmount = " "
198-
var voiceUsage = " "
199-
var voiceBalance = " "
200-
var msgUsage = ""
201-
var msgBalance = ""
202-
var msgAmount = ""
189+
let productname = "中国电信", voiceAmount = " ", voiceUsage = " ", voiceBalance = " ", msgUsage = "", msgBalance = "", msgAmount = "",usagedCommon,balanceCommon,totalCommon;
190+
203191
if(data.usedCommon){
204192
usagedCommon = formatFlow(data.usedCommon/1024)
205193
}
@@ -208,44 +196,46 @@ function notify(data, balance, exdata, bldata) {
208196
}
209197
if(data.totalCommon){
210198
totalCommon = formatFlow(data.totalCommon/1024)
211-
}
199+
} //流量信息
200+
212201
for (i=0;i<data.items.length;i++){
213202
for (k=0;k<data.items[i].items.length;k++){
214-
if(data.items[i].items[k].nameType == 131100){
203+
if(data.items[i].items[k].nameType == '131100'){
215204
voiceAmount = data.items[i].items[k].ratableAmount
216205
voiceBalance = data.items[i].items[k].balanceAmount
217206
voiceUsage = data.items[i].items[k].usageAmount
218-
};
219-
if(data.items[i].items[k].nameType == 401100||data.items[i].items[k].nameType == 431100){
207+
}; //语音余量
208+
if(data.items[i].items[k].nameType == '401100'||data.items[i].items[k].nameType == '431100'){
220209
msgUsage = data.items[i].items[k].usageAmount
221210
msgAmount = data.items[i].items[k].ratableAmount
222211
msgBalance = data.items[i].items[k].balanceAmount
223-
};
212+
}; //短信余量
213+
214+
if (data.items[i].offerType == '11'|| data.items[i].offerType == '21') {
215+
productname = data.items[i].productOFFName
216+
}; //主套餐名称
224217
if(data.items[i].productOFFName == "畅享套餐"){
225218
usagedCommon = formatFlow(data.items[i].items[k].usageAmount/1024)
226219
balanceCommon = data.items[i].items[k].ratableResourcename
227220
totalCommon = data.items[i].productOFFName
221+
}; // 畅享套餐
228222
}
229-
else if(data.items[i].items[k].nameType == 331101){
230-
productname = data.items[i].productOFFName
231-
usagedCommon = formatFlow(data.items[i].items[k].usageAmount/1024)
232-
balanceCommon = formatFlow(data.items[i].items[k].balanceAmount/1024)
233-
totalCommon = formatFlow(data.items[i].items[k].ratableAmount/1024)
234-
}
235-
}
236223
}
224+
message = "【套餐】" + productname
237225
if (voiceUsage) {
238226
var voice = "【通话】已用: " + voiceUsage + "分钟 剩余: " + voiceBalance + "分钟 合计: " + voiceAmount + "分钟"
239-
message = message + "\n" + voice
227+
message += "\n" + voice
240228
}
241229
if (msgUsage) {
242230
msginfo = "【短信】已用: " + msgUsage + "条 剩余: " + msgBalance + "条 合计: " + msgAmount + "条"
243-
message = message + "\n" + msginfo
231+
message += "\n" + msginfo
244232
}
245-
const flow = "【流量】已用: " + usagedCommon + " 剩余:" + balanceCommon + " 合计:" + totalCommon
246-
message = message + "\n" + flow
247-
const cost = "【话费】剩余: " + (Number(balance.totalBalanceAvailable)/100).toFixed(2) + "元"
248-
message = message + "\n" + cost
233+
if (usagedCommon){
234+
flow = "【流量】已用: " + usagedCommon + " 剩余:" + balanceCommon + " 合计:" + totalCommon
235+
message += "\n" + flow
236+
}; //以上为套餐用量
237+
238+
message += "\n" +"【话费】剩余: " + (Number(balance.totalBalanceAvailable)/100).toFixed(2) + "元"
249239
if (bldata != '无'){message += ` ${M}月消费合计: `+ bldata.items[0].sumCharge/100+'元'};
250240
if (bldata == '无'){
251241
message = message + "\n" + `【${M}月账单】 `+ bldata
@@ -255,11 +245,11 @@ message = message + "\n" + `【${M}月账单】 `+ bldata
255245
billcharge[1].charge/100+'元'+ "\n "+ billcharge[2].chargetypeName + ': '+
256246
billcharge[2].charge/100+'元'+ "\n "+ billcharge[0].chargetypeName + ': '+ billcharge[0].charge/100+'元'
257247
message = message + "\n" + bills
258-
}
248+
}; //账单明细
259249
$.msg(config.name, subtitle, message)
260250
}
261251
catch(err){
262-
console.log("查询错误,错误原因:"+ err+'\n账单响应数据:'+bldata+'\n请将以上数据反馈给作者')
252+
console.log("查询错误,错误原因:"+ err+'\n账单响应数据:'+JSON.stringify(bldata)+'\n请将以上数据机主姓名删除后反馈给作者')
263253
}
264254
}
265255

0 commit comments

Comments
 (0)