Skip to content

Commit ac22ac1

Browse files
committed
chore: update the QR code of the page
1 parent 218bc52 commit ac22ac1

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

script/qrcode/index.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1620
const getImageList = () => {
1721
const imageFolderDir = path.resolve(__dirname, `../../site/public/assets/qrcode`);
1822
const images = fs.readdirSync(imageFolderDir);
@@ -26,14 +30,19 @@ const getImageList = () => {
2630
const 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
});

site/public/assets/qrcode/col.png

43.5 KB
Loading
47 KB
Loading
44.3 KB
Loading

0 commit comments

Comments
 (0)