commit 0de99924742ac7b845e4a2f20b55fe1a67e85249 Author: TonyChyi Date: Fri Dec 27 22:44:32 2024 +0800 init diff --git a/app.js b/app.js new file mode 100644 index 0000000..4af33be --- /dev/null +++ b/app.js @@ -0,0 +1,2 @@ +// app.js +App({}) diff --git a/app.json b/app.json new file mode 100644 index 0000000..0c0bf6e --- /dev/null +++ b/app.json @@ -0,0 +1,14 @@ +{ + "pages": [ + "pages/index/index", + "pages/connect-wifi/connect-wifi", + "pages/success/success", + "pages/fail/fail" + ], + "entryPagePath": "pages/connect-wifi/connect-wifi", + "permission": { + "scope.userLocation": { + "desc": "您的位置信息将用于连接WiFi" + } + } +} \ No newline at end of file diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..06c6fc9 --- /dev/null +++ b/app.wxss @@ -0,0 +1,10 @@ +/**app.wxss**/ +.container { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 200rpx 0; + box-sizing: border-box; +} diff --git a/gen_qr_code.js b/gen_qr_code.js new file mode 100644 index 0000000..5c66859 --- /dev/null +++ b/gen_qr_code.js @@ -0,0 +1,35 @@ +const config = { + access_token = 'access_token', + ssid = 'ssid', + password = 'password' +}; + +const axios = require('axios'); + +const generateQrCode = async (path, scene) => { + const url = `https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=${coonfig.access_token}`; + + const params = { + scene: scene, // 参数,格式为json字符串 + page: path, // 扫码后跳转的小程序页面路径 + width: 430 // 二维码的宽度 + }; + + try { + const response = await axios({ + method: 'POST', + url: url, + data: params, + responseType: 'arraybuffer' // 重要:需要设置响应类型为arraybuffer + }); + + // 将response.data(一个Buffer)写入文件 + fs.writeFileSync('qrcode.png', response.data); + console.log('小程序码已生成'); + } catch (error) { + console.error('生成小程序码失败', error); + } +}; + +// 使用示例 +generateQrCode('pages/connect-wifi/connect-wifi', `{"SSID":"${config.ssid}","password":"${config.password}"}`); diff --git a/pages/connect-wifi/connect-wifi.js b/pages/connect-wifi/connect-wifi.js new file mode 100644 index 0000000..f54904c --- /dev/null +++ b/pages/connect-wifi/connect-wifi.js @@ -0,0 +1,84 @@ +// pages/connect-wifi/connect-wifi.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + wifiInfo: { + SSID: 'test', + password: '' + }, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + const scene = decodeURIComponent(options.scene); + this.data.wifiInfo = JSON.parse(scene) + this.connectWifi(this.data.wifiInfo) + }, + + connectWifi(wifiInfo) { + wx.connectWifi({ + ...wifiInfo, + manual: true, + success: () => { + wx.navigateTo({ + url: '/pages/success/success', + }) + }, + fail: (err)=> {} + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/connect-wifi/connect-wifi.json b/pages/connect-wifi/connect-wifi.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/connect-wifi/connect-wifi.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/connect-wifi/connect-wifi.wxml b/pages/connect-wifi/connect-wifi.wxml new file mode 100644 index 0000000..563c953 --- /dev/null +++ b/pages/connect-wifi/connect-wifi.wxml @@ -0,0 +1,4 @@ + + + 你将连接到 {{wifiInfo.SSID}} + \ No newline at end of file diff --git a/pages/connect-wifi/connect-wifi.wxss b/pages/connect-wifi/connect-wifi.wxss new file mode 100644 index 0000000..aabf57f --- /dev/null +++ b/pages/connect-wifi/connect-wifi.wxss @@ -0,0 +1 @@ +/* pages/connect-wifi/connect-wifi.wxss */ \ No newline at end of file diff --git a/pages/fail/fail.js b/pages/fail/fail.js new file mode 100644 index 0000000..768ac60 --- /dev/null +++ b/pages/fail/fail.js @@ -0,0 +1,66 @@ +// pages/fail/fail.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/fail/fail.json b/pages/fail/fail.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/fail/fail.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/fail/fail.wxml b/pages/fail/fail.wxml new file mode 100644 index 0000000..d0e6194 --- /dev/null +++ b/pages/fail/fail.wxml @@ -0,0 +1,4 @@ + + + 连接失败,请退出小程序重新扫码 + \ No newline at end of file diff --git a/pages/fail/fail.wxss b/pages/fail/fail.wxss new file mode 100644 index 0000000..e9c3561 --- /dev/null +++ b/pages/fail/fail.wxss @@ -0,0 +1 @@ +/* pages/fail/fail.wxss */ \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js new file mode 100644 index 0000000..2066c4f --- /dev/null +++ b/pages/index/index.js @@ -0,0 +1,2 @@ +// index.js +Page({}) diff --git a/pages/index/index.json b/pages/index/index.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/index/index.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml new file mode 100644 index 0000000..de5e1c0 --- /dev/null +++ b/pages/index/index.wxml @@ -0,0 +1,6 @@ + + + + Weixin + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss new file mode 100644 index 0000000..8c2b75a --- /dev/null +++ b/pages/index/index.wxss @@ -0,0 +1,10 @@ +/**index.wxss**/ +page { + height: 100vh; + display: flex; + flex-direction: column; +} +.scrollarea { + flex: 1; + overflow-y: hidden; +} diff --git a/pages/success/success.js b/pages/success/success.js new file mode 100644 index 0000000..91358e2 --- /dev/null +++ b/pages/success/success.js @@ -0,0 +1,66 @@ +// pages/success/success.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/success/success.json b/pages/success/success.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/success/success.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/success/success.wxml b/pages/success/success.wxml new file mode 100644 index 0000000..6b8e679 --- /dev/null +++ b/pages/success/success.wxml @@ -0,0 +1,4 @@ + + + 连接成功了 + \ No newline at end of file diff --git a/pages/success/success.wxss b/pages/success/success.wxss new file mode 100644 index 0000000..6ddea23 --- /dev/null +++ b/pages/success/success.wxss @@ -0,0 +1 @@ +/* pages/success/success.wxss */ \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..b8f8b06 --- /dev/null +++ b/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx127af54b7533d89e", + "compileType": "miniprogram", + "libVersion": "3.7.3", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..e2e03b6 --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "wifi-assistant", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..cd24f35 --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file