init
This commit is contained in:
commit
0de9992474
14
app.json
Normal file
14
app.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
app.wxss
Normal file
10
app.wxss
Normal file
@ -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;
|
||||||
|
}
|
35
gen_qr_code.js
Normal file
35
gen_qr_code.js
Normal file
@ -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}"}`);
|
84
pages/connect-wifi/connect-wifi.js
Normal file
84
pages/connect-wifi/connect-wifi.js
Normal file
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
3
pages/connect-wifi/connect-wifi.json
Normal file
3
pages/connect-wifi/connect-wifi.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
4
pages/connect-wifi/connect-wifi.wxml
Normal file
4
pages/connect-wifi/connect-wifi.wxml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!--pages/connect-wifi/connect-wifi.wxml-->
|
||||||
|
<view class="container">
|
||||||
|
<text>你将连接到 {{wifiInfo.SSID}}</text>
|
||||||
|
</view>
|
1
pages/connect-wifi/connect-wifi.wxss
Normal file
1
pages/connect-wifi/connect-wifi.wxss
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* pages/connect-wifi/connect-wifi.wxss */
|
66
pages/fail/fail.js
Normal file
66
pages/fail/fail.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// pages/fail/fail.js
|
||||||
|
Page({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad(options) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
3
pages/fail/fail.json
Normal file
3
pages/fail/fail.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
4
pages/fail/fail.wxml
Normal file
4
pages/fail/fail.wxml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!--pages/fail/fail.wxml-->
|
||||||
|
<view class="container">
|
||||||
|
<text>连接失败,请退出小程序重新扫码</text>
|
||||||
|
</view>
|
1
pages/fail/fail.wxss
Normal file
1
pages/fail/fail.wxss
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* pages/fail/fail.wxss */
|
2
pages/index/index.js
Normal file
2
pages/index/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// index.js
|
||||||
|
Page({})
|
1
pages/index/index.json
Normal file
1
pages/index/index.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
6
pages/index/index.wxml
Normal file
6
pages/index/index.wxml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<!--index.wxml-->
|
||||||
|
<scroll-view class="scrollarea" scroll-y type="list">
|
||||||
|
<view class="container">
|
||||||
|
Weixin
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
10
pages/index/index.wxss
Normal file
10
pages/index/index.wxss
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**index.wxss**/
|
||||||
|
page {
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.scrollarea {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
66
pages/success/success.js
Normal file
66
pages/success/success.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// pages/success/success.js
|
||||||
|
Page({
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面加载
|
||||||
|
*/
|
||||||
|
onLoad(options) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面初次渲染完成
|
||||||
|
*/
|
||||||
|
onReady() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面显示
|
||||||
|
*/
|
||||||
|
onShow() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面隐藏
|
||||||
|
*/
|
||||||
|
onHide() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期函数--监听页面卸载
|
||||||
|
*/
|
||||||
|
onUnload() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||||||
|
*/
|
||||||
|
onPullDownRefresh() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面上拉触底事件的处理函数
|
||||||
|
*/
|
||||||
|
onReachBottom() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户点击右上角分享
|
||||||
|
*/
|
||||||
|
onShareAppMessage() {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
3
pages/success/success.json
Normal file
3
pages/success/success.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
4
pages/success/success.wxml
Normal file
4
pages/success/success.wxml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<!--pages/success/success.wxml-->
|
||||||
|
<view class="container">
|
||||||
|
<text>连接成功了</text>
|
||||||
|
</view>
|
1
pages/success/success.wxss
Normal file
1
pages/success/success.wxss
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* pages/success/success.wxss */
|
28
project.config.json
Normal file
28
project.config.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
7
project.private.config.json
Normal file
7
project.private.config.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||||
|
"projectname": "wifi-assistant",
|
||||||
|
"setting": {
|
||||||
|
"compileHotReLoad": true
|
||||||
|
}
|
||||||
|
}
|
7
sitemap.json
Normal file
7
sitemap.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||||
|
"rules": [{
|
||||||
|
"action": "allow",
|
||||||
|
"page": "*"
|
||||||
|
}]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user