@@ -62,7 +62,7 @@ export const getAccessToken = async () => {
6262 console . log ( '---' )
6363 } else {
6464 console . log ( '---' )
65- console . error ( '获取 accessToken: 请求失败' , res . data . errmsg )
65+ console . error ( '获取 accessToken: 请求失败' , res . data . errmsg || res . data )
6666 console . log ( '---' )
6767 console . log ( `40001: 请检查appId,appSecret 填写是否正确;
6868 如果第一次使用微信测试号请关闭测试号平台后重新扫码登陆测试号平台获取最新的appId,appSecret` )
@@ -426,7 +426,7 @@ export const getConstellationFortune = async (date, dateType) => {
426426/**
427427 * 获取课程表
428428 * @param courseSchedule {Array<Array<String>>|{benchmark: {date: string, isOdd: boolean}, courses: {odd: Array<Array<string>>, even:Array<Array<string>>} }}
429- * @returns { string }
429+ * @returns
430430 */
431431export const getCourseSchedule = ( courseSchedule ) => {
432432 if ( config . SWITCH && config . SWITCH . courseSchedule === false ) {
@@ -446,7 +446,19 @@ export const getCourseSchedule = (courseSchedule) => {
446446 . set ( 'millisecond' , 0 ) , 'millisecond' )
447447 const isSameKind = Math . floor ( diff / 7 / 86400000 ) % 2 === 0
448448 const kind = ( ( isSameKind && courseSchedule . benchmark . isOdd ) || ( ! isSameKind && ! courseSchedule . benchmark . isOdd ) ) ? 'odd' : 'even'
449- return ( ( courseSchedule . courses && courseSchedule . courses [ kind ] && courseSchedule . courses [ kind ] [ week ] ) || [ ] ) . join ( getLB ( ) )
449+
450+ const temp = ( ( courseSchedule . courses && courseSchedule . courses [ kind ] && courseSchedule . courses [ kind ] [ week ] ) || [ ] )
451+ const schedule = temp . join ( getLB ( ) )
452+ const wechatTestCourseSchedule = [ ]
453+ temp . forEach ( ( item , index ) => {
454+ wechatTestCourseSchedule . push ( {
455+ name : toLowerLine ( `wxCourseSchedule_${ index } ` ) ,
456+ value : item ,
457+ color : getColor ( )
458+ } )
459+ } )
460+
461+ return { schedule, wechatTestCourseSchedule}
450462}
451463
452464/**
@@ -502,6 +514,8 @@ export const getBirthdayMessage = (festivals) => {
502514 }
503515 } )
504516 let resMessage = ''
517+ const wechatTestBirthdayMessage = [ ]
518+
505519
506520 birthdayList . forEach ( ( item , index ) => {
507521 if (
@@ -521,29 +535,34 @@ export const getBirthdayMessage = (festivals) => {
521535 }
522536
523537 if ( item . diffDay === 0 ) {
524- message = `今天是 ${ item . name } 的${ age && item . isShowAge ? `${ ( item . useLunar ? 1 : 0 ) + age } 岁` : '' } 生日哦,祝${ item . name } 生日快乐!`
538+ message = `今天是 「 ${ item . name } 」 的${ age && item . isShowAge ? `${ ( item . useLunar ? 1 : 0 ) + age } 岁` : '' } ${ item . useLunar ? '阴历' : '公历 '} 生日哦,祝${ item . name } 生日快乐!`
525539 } else {
526- message = `距离 ${ item . name } 的${ age && item . isShowAge ? `${ age + 1 } 岁` : '' } 生日还有${ item . diffDay } 天`
540+ message = `距离 「 ${ item . name } 」 的${ age && item . isShowAge ? `${ age + 1 } 岁` : '' } ${ item . useLunar ? '阴历' : '公历 '} 生日还有${ item . diffDay } 天`
527541 }
528542 }
529543
530544 // 节日相关
531545 if ( item . type === '节日' ) {
532546 if ( item . diffDay === 0 ) {
533- message = `今天是 ${ item . name } 哦,要开心!`
547+ message = `今天是 「 ${ item . name } 」 哦,要开心!`
534548 } else {
535- message = `距离 ${ item . name } 还有${ item . diffDay } 天`
549+ message = `距离 「 ${ item . name } 」 还有${ item . diffDay } 天`
536550 }
537551 }
538552
539553 // 存储数据
540554 if ( message ) {
541555 resMessage += `${ message } ${ getLB ( ) } `
556+ wechatTestBirthdayMessage . push ( {
557+ name : toLowerLine ( `wxBirthday_${ index } ` ) ,
558+ value : message ,
559+ color : getColor ( )
560+ } )
542561 }
543562 }
544563 } )
545564
546- return resMessage
565+ return { resMessage, wechatTestBirthdayMessage }
547566}
548567
549568/**
@@ -732,13 +751,13 @@ export const getAggregatedData = async () => {
732751 } ) )
733752
734753 // 获取生日/生日信息
735- const birthdayMessage = getBirthdayMessage ( user . festivals )
754+ const { resMessage : birthdayMessage , wechatTestBirthdayMessage } = getBirthdayMessage ( user . festivals )
736755
737756 // 获取星座运势
738757 const constellationFortune = await getConstellationFortune ( user . horoscopeDate , user . horoscopeDateType )
739758
740759 // 获取课表信息
741- const courseSchedule = getCourseSchedule ( user . courseSchedule || config . courseSchedule ) || DEFAULT_OUTPUT . courseSchedule
760+ const { schedule : courseSchedule , wechatTestCourseSchedule } = getCourseSchedule ( user . courseSchedule || config . courseSchedule ) || DEFAULT_OUTPUT . courseSchedule
742761
743762 // 天行-早晚安
744763 const tianApiGreeting = [ {
@@ -795,6 +814,8 @@ export const getAggregatedData = async () => {
795814 . concat ( tianApiGreeting )
796815 . concat ( tianApiWeather )
797816 . concat ( tianApiNetworkHot )
817+ . concat ( wechatTestBirthdayMessage )
818+ . concat ( wechatTestCourseSchedule )
798819
799820 user . wxTemplateParams = wxTemplateParams
800821 }
@@ -1084,9 +1105,11 @@ export const sendMessage = async (templateId, user, params, usePassage) => {
10841105 const wxTemplateData = { }
10851106 if ( Object . prototype . toString . call ( params ) === '[object Array]' ) {
10861107 params . forEach ( ( item ) => {
1087- wxTemplateData [ item . name ] = {
1088- value : item . value ,
1089- color : item . color ,
1108+ if ( item && item . name ) {
1109+ wxTemplateData [ item . name ] = {
1110+ value : item . value ,
1111+ color : item . color ,
1112+ }
10901113 }
10911114 } )
10921115 }
0 commit comments