@@ -13,6 +13,10 @@ const isExistStr = (str, arr) => {
1313 return arr . includes ( temp ) ;
1414} ;
1515
16+ const isSkylinePage = ( str ) => {
17+ return str . includes ( 'skyline' ) ;
18+ } ;
19+
1620const getImageList = ( ) => {
1721 const imageFolderDir = path . resolve ( __dirname , `../../site/public/assets/qrcode` ) ;
1822 const images = fs . readdirSync ( imageFolderDir ) ;
@@ -26,14 +30,19 @@ const getImageList = () => {
2630const getNewPageList = ( list ) => {
2731 const pageList = [ ] ;
2832 const imageOldList = getImageList ( ) ;
33+
2934 list . forEach ( ( item ) => {
3035 if ( Object . prototype . toString . call ( item ) === '[object Object]' ) {
3136 item . pages . forEach ( ( subItem ) => {
32- if ( ! isExistStr ( item . root + subItem , imageOldList ) ) {
37+ if (
38+ item . root === subItem &&
39+ ! isExistStr ( item . root + subItem , imageOldList ) &&
40+ ! isSkylinePage ( `${ item . root } ${ subItem } ` )
41+ ) {
3342 pageList . push ( item . root + subItem ) ;
3443 }
3544 } ) ;
36- } else if ( ! isExistStr ( item , imageOldList ) ) {
45+ } else if ( ! isExistStr ( item , imageOldList ) && ! isSkylinePage ( item ) ) {
3746 pageList . push ( item ) ;
3847 }
3948 } ) ;
@@ -45,7 +54,7 @@ const getUnlimitedQRCodeImage = (appid, appSecret) => {
4554 getAccessToken ( appid , appSecret ) . then ( ( e ) => {
4655 if ( e . access_token ) {
4756 const token = e . access_token ;
48- console . log ( '== access_token 2h内有效= ' , token ) ;
57+ console . log ( 'access_token 2h内有效: ' , token ) ;
4958 const baseParameter = {
5059 width : 280 , // 小程序码大小
5160 // check_path: false,
@@ -65,8 +74,8 @@ const getUnlimitedQRCodeImage = (appid, appSecret) => {
6574 page : item , // 扫码进入的小程序页面路径
6675 scene : `name=${ temp [ 0 ] } ` , // 标识
6776 } ;
68- getUnlimitedQRCode ( token , JSON . stringify ( { ...specialParameter , ...baseParameter } ) , { ...baseConfig } ) . then (
69- ( res ) => {
77+ getUnlimitedQRCode ( token , JSON . stringify ( { ...specialParameter , ...baseParameter } ) , { ...baseConfig } )
78+ . then ( ( res ) => {
7079 // 因为微信接口 getwxacodeunlimit 成功时返回的是 Buffer ,失败时返回 JSON 结构。这里把返回数据全部当成 Buffer 处理,所以 res.length < 200, 则表示获取失败。
7180 if ( res . length < 200 ) {
7281 const { errcode, errmsg } = JSON . parse ( res . toString ( ) ) ;
@@ -90,8 +99,10 @@ const getUnlimitedQRCodeImage = (appid, appSecret) => {
9099 }
91100 } ,
92101 ) ;
93- } ,
94- ) ;
102+ } )
103+ . catch ( ( e ) => {
104+ console . log ( e ) ;
105+ } ) ;
95106 } ) ;
96107 }
97108 } ) ;
0 commit comments