2023-05-09 11:03:38 +08:00
|
|
|
import moment from 'moment'
|
|
|
|
import lodash from 'lodash'
|
|
|
|
import base from './base.js'
|
|
|
|
import MysInfo from './mys/mysInfo.js'
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
export default class Note extends base {
|
2023-05-09 11:03:38 +08:00
|
|
|
constructor (e) {
|
|
|
|
super(e)
|
|
|
|
this.model = 'dailyNote'
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 生成体力图片 */
|
2023-05-09 11:03:38 +08:00
|
|
|
static async get (e) {
|
|
|
|
let note = new Note(e)
|
|
|
|
return await note.getData()
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2023-05-09 11:03:38 +08:00
|
|
|
async getData () {
|
2023-05-31 03:19:27 +08:00
|
|
|
let seed_id = lodash.sample('abcdefghijklmnopqrstuvwxyz0123456789', 16).replace(/,/g, '')
|
|
|
|
let device_fp = await MysInfo.get(this.e, 'getFp', {
|
2023-05-28 14:01:31 +08:00
|
|
|
seed_id
|
|
|
|
})
|
2023-05-31 03:19:27 +08:00
|
|
|
let res = await MysInfo.get(this.e, 'dailyNote', {
|
|
|
|
headers: {
|
|
|
|
'x-rpc-device_fp': device_fp?.data?.device_fp
|
|
|
|
}
|
|
|
|
})
|
2023-05-09 11:03:38 +08:00
|
|
|
let resUser
|
|
|
|
if (!res || res.retcode !== 0) return false
|
2023-05-28 14:01:31 +08:00
|
|
|
|
2023-03-04 14:30:13 +08:00
|
|
|
/** 截图数据 */
|
2023-05-09 11:03:38 +08:00
|
|
|
let data = this.e.isSr ? this.noteSr(res) : this.noteData(res)
|
2023-05-28 14:01:31 +08:00
|
|
|
|
2023-05-09 11:03:38 +08:00
|
|
|
let screenData = this.screenData
|
2023-05-06 16:29:11 +08:00
|
|
|
if (this.e.isSr) {
|
2023-05-09 11:03:38 +08:00
|
|
|
resUser = await MysInfo.get(this.e, 'UserGame')
|
2023-05-31 03:19:27 +08:00
|
|
|
resUser.data?.list?.forEach(v => this.e.uid.includes(v.game_biz))
|
2023-05-09 11:03:38 +08:00
|
|
|
if (!resUser || resUser.retcode !== 0) return false
|
2023-05-06 16:29:11 +08:00
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
return {
|
|
|
|
name: this.e.sender.card,
|
|
|
|
quality: 80,
|
2023-05-06 16:29:11 +08:00
|
|
|
...screenData,
|
2023-05-28 15:25:23 +08:00
|
|
|
...data, ...resUser?.data?.list[0]
|
2023-05-09 11:03:38 +08:00
|
|
|
}
|
2023-05-06 16:29:11 +08:00
|
|
|
}
|
2023-05-09 11:03:38 +08:00
|
|
|
|
|
|
|
noteSr (res) {
|
|
|
|
let { data } = res
|
|
|
|
let nowDay = moment().date()
|
|
|
|
let nowUnix = Number(moment().format('X'))
|
2023-05-06 16:29:11 +08:00
|
|
|
/** 树脂 */
|
2023-05-09 11:03:38 +08:00
|
|
|
let resinMaxTime
|
2023-05-06 16:29:11 +08:00
|
|
|
if (data.stamina_recover_time > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
let d = moment.duration(data.stamina_recover_time, 'seconds')
|
|
|
|
let day = Math.floor(d.asDays())
|
|
|
|
let hours = d.hours()
|
|
|
|
let minutes = d.minutes()
|
|
|
|
let seconds = d.seconds()
|
|
|
|
resinMaxTime = hours + '小时' + minutes + '分钟' + seconds + '秒'
|
2023-05-06 17:41:07 +08:00
|
|
|
//精确到秒。。。。
|
2023-05-09 11:03:38 +08:00
|
|
|
if (day > 0) {
|
|
|
|
resinMaxTime = day + '天' + hours + '小时' + minutes + '分钟' + seconds + '秒'
|
|
|
|
} else if (hours > 0) {
|
|
|
|
resinMaxTime = hours + '小时' + minutes + '分钟' + seconds + '秒'
|
|
|
|
} else if (minutes > 0) {
|
|
|
|
resinMaxTime = minutes + '分钟' + seconds + '秒'
|
|
|
|
} else if (seconds > 0) {
|
|
|
|
resinMaxTime = seconds + '秒'
|
2023-05-06 16:29:11 +08:00
|
|
|
}
|
2023-06-01 21:39:47 +08:00
|
|
|
if ((day > 0) || (hours > 0) || (seconds > 0)) {
|
|
|
|
let total_seconds = 3600*hours + 60*minutes + seconds
|
|
|
|
const now = new Date()
|
|
|
|
const dateTimes = now.getTime() + total_seconds * 1000
|
|
|
|
const date = new Date(dateTimes)
|
|
|
|
const dayDiff = date.getDate() - now.getDate()
|
|
|
|
const str = dayDiff === 0 ? '今日' : '明日'
|
|
|
|
const timeStr = `${date.getHours().toString().padStart(2, '0')}:${date
|
|
|
|
.getMinutes()
|
|
|
|
.toString()
|
|
|
|
.padStart(2, '0')}`
|
|
|
|
let recoverTimeStr = ` | [${str}]${timeStr}`
|
|
|
|
resinMaxTime += recoverTimeStr
|
|
|
|
}
|
2023-05-06 16:29:11 +08:00
|
|
|
}
|
2023-05-09 11:03:38 +08:00
|
|
|
data.bfStamina = data.current_stamina / data.max_stamina * 100 + '%'
|
2023-05-06 16:29:11 +08:00
|
|
|
/** 派遣 */
|
2023-05-09 11:03:38 +08:00
|
|
|
for (let item of data.expeditions) {
|
|
|
|
let d = moment.duration(item.remaining_time, 'seconds')
|
|
|
|
let day = Math.floor(d.asDays())
|
|
|
|
let hours = d.hours()
|
|
|
|
let minutes = d.minutes()
|
|
|
|
item.dateTime = ([day + '天', hours + '时', minutes + '分'].filter(v => !['0天', '0时', '0分'].includes(v))).join('')
|
|
|
|
item.bfTime = (72000 - item.remaining_time) / 72000 * 100 + '%'
|
|
|
|
if (item.avatars.length == 1) {
|
2023-05-06 16:29:11 +08:00
|
|
|
item.avatars.push('派遣头像')
|
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
2023-05-06 16:29:11 +08:00
|
|
|
// 标识属性图标~
|
2023-05-09 11:03:38 +08:00
|
|
|
let icon = lodash.sample(['希儿', '白露', '艾丝妲', '布洛妮娅', '姬子', '卡芙卡', '克拉拉', '停云', '佩拉', '黑塔', '希露瓦', '银狼'])
|
2023-05-06 16:29:11 +08:00
|
|
|
let week = [
|
2023-05-09 11:03:38 +08:00
|
|
|
'星期日',
|
|
|
|
'星期一',
|
|
|
|
'星期二',
|
|
|
|
'星期三',
|
|
|
|
'星期四',
|
|
|
|
'星期五',
|
|
|
|
'星期六'
|
|
|
|
]
|
|
|
|
let day = `${week[moment().day()]}`
|
2023-05-06 16:29:11 +08:00
|
|
|
return {
|
|
|
|
uid: this.e.uid,
|
2023-05-09 11:03:38 +08:00
|
|
|
saveId: this.e.uid, icon, day,
|
|
|
|
resinMaxTime, nowDay: moment(new Date()).format('YYYY年MM月DD日'),
|
|
|
|
...data
|
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
2023-05-09 11:03:38 +08:00
|
|
|
noteData (res) {
|
|
|
|
let { data } = res
|
|
|
|
|
|
|
|
let nowDay = moment().date()
|
|
|
|
let nowUnix = Number(moment().format('X'))
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
/** 树脂 */
|
2023-05-09 11:03:38 +08:00
|
|
|
let resinMaxTime
|
2023-03-04 14:30:13 +08:00
|
|
|
if (data.resin_recovery_time > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
resinMaxTime = nowUnix + Number(data.resin_recovery_time)
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2023-05-09 11:03:38 +08:00
|
|
|
let maxDate = moment.unix(resinMaxTime)
|
|
|
|
resinMaxTime = maxDate.format('HH:mm')
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
if (maxDate.date() != nowDay) {
|
2023-05-09 11:03:38 +08:00
|
|
|
resinMaxTime = `明天 ${resinMaxTime}`
|
2023-03-04 14:30:13 +08:00
|
|
|
} else {
|
2023-05-09 11:03:38 +08:00
|
|
|
resinMaxTime = ` ${resinMaxTime}`
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 派遣 */
|
2023-05-09 11:03:38 +08:00
|
|
|
let remainedTime = ''
|
2023-03-04 14:30:13 +08:00
|
|
|
if (data.expeditions && data.expeditions.length >= 1) {
|
2023-05-09 11:03:38 +08:00
|
|
|
remainedTime = lodash.map(data.expeditions, 'remained_time')
|
|
|
|
remainedTime = lodash.min(remainedTime)
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
if (remainedTime > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
remainedTime = nowUnix + Number(remainedTime)
|
|
|
|
let remainedDate = moment.unix(remainedTime)
|
|
|
|
remainedTime = remainedDate.format('HH:mm')
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
if (remainedDate.date() != nowDay) {
|
2023-05-09 11:03:38 +08:00
|
|
|
remainedTime = `明天 ${remainedTime}`
|
2023-03-04 14:30:13 +08:00
|
|
|
} else {
|
2023-05-09 11:03:38 +08:00
|
|
|
remainedTime = ` ${remainedTime}`
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 宝钱 */
|
2023-05-09 11:03:38 +08:00
|
|
|
let coinTime = ''
|
2023-03-04 14:30:13 +08:00
|
|
|
if (data.home_coin_recovery_time > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
let coinDay = Math.floor(data.home_coin_recovery_time / 3600 / 24)
|
|
|
|
let coinHour = Math.floor((data.home_coin_recovery_time / 3600) % 24)
|
|
|
|
let coinMin = Math.floor((data.home_coin_recovery_time / 60) % 60)
|
2023-03-04 14:30:13 +08:00
|
|
|
if (coinDay > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
coinTime = `${coinDay}天${coinHour}小时${coinMin}分钟`
|
2023-03-04 14:30:13 +08:00
|
|
|
} else {
|
2023-05-06 16:29:11 +08:00
|
|
|
let coinDate = moment.unix(
|
|
|
|
nowUnix + Number(data.home_coin_recovery_time)
|
2023-05-09 11:03:38 +08:00
|
|
|
)
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
if (coinDate.date() != nowDay) {
|
2023-05-09 11:03:38 +08:00
|
|
|
coinTime = `明天 ${coinDate.format('HH:mm')}`
|
2023-03-04 14:30:13 +08:00
|
|
|
} else {
|
2023-05-09 11:03:38 +08:00
|
|
|
coinTime = coinDate.format('HH:mm')
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-06 16:29:11 +08:00
|
|
|
let week = [
|
2023-05-09 11:03:38 +08:00
|
|
|
'星期日',
|
|
|
|
'星期一',
|
|
|
|
'星期二',
|
|
|
|
'星期三',
|
|
|
|
'星期四',
|
|
|
|
'星期五',
|
|
|
|
'星期六'
|
|
|
|
]
|
|
|
|
let day = `${moment().format('MM-DD HH:mm')} ${week[moment().day()]}`
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
/** 参量质变仪 */
|
|
|
|
if (data?.transformer?.obtained) {
|
2023-05-09 11:03:38 +08:00
|
|
|
data.transformer.reached = data.transformer.recovery_time.reached
|
|
|
|
let recoveryTime = ''
|
2023-03-04 14:30:13 +08:00
|
|
|
|
|
|
|
if (data.transformer.recovery_time.Day > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
recoveryTime += `${data.transformer.recovery_time.Day}天`
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
if (data.transformer.recovery_time.Hour > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
recoveryTime += `${data.transformer.recovery_time.Hour}小时`
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
if (data.transformer.recovery_time.Minute > 0) {
|
2023-05-09 11:03:38 +08:00
|
|
|
recoveryTime += `${data.transformer.recovery_time.Minute}分钟`
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
2023-05-09 11:03:38 +08:00
|
|
|
data.transformer.recovery_time = recoveryTime
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
uid: this.e.uid,
|
|
|
|
saveId: this.e.uid,
|
|
|
|
resinMaxTime,
|
|
|
|
remainedTime,
|
|
|
|
coinTime,
|
|
|
|
day,
|
2023-05-09 11:03:38 +08:00
|
|
|
...data
|
|
|
|
}
|
2023-03-04 14:30:13 +08:00
|
|
|
}
|
|
|
|
}
|