Selaa lähdekoodia

Initial Commit

feat
JinxChen 2 vuotta sitten
vanhempi
commit
f19eb34cf5
25 muutettua tiedostoa jossa 565 lisäystä ja 0 poistoa
  1. +19
    -0
      miniprogram/app.js
  2. +42
    -0
      miniprogram/app.json
  3. +1
    -0
      miniprogram/app.wxss
  4. BIN
      miniprogram/images/icon/help.png
  5. BIN
      miniprogram/images/icon/icon_home.png
  6. BIN
      miniprogram/images/icon/icon_home_active.png
  7. BIN
      miniprogram/images/icon/icon_list.png
  8. BIN
      miniprogram/images/icon/icon_list_active.png
  9. BIN
      miniprogram/images/icon/icon_more.png
  10. BIN
      miniprogram/images/icon/icon_more_active.png
  11. BIN
      miniprogram/images/icon/icon_partner.png
  12. BIN
      miniprogram/images/icon/icon_partner_active.png
  13. BIN
      miniprogram/images/icon/no_wifi.png
  14. +1
    -0
      miniprogram/model/index.js
  15. +211
    -0
      miniprogram/pages/home/home.js
  16. +3
    -0
      miniprogram/pages/home/home.json
  17. +31
    -0
      miniprogram/pages/home/home.wxml
  18. +96
    -0
      miniprogram/pages/home/home.wxss
  19. +67
    -0
      miniprogram/pages/more/more.js
  20. +3
    -0
      miniprogram/pages/more/more.json
  21. +4
    -0
      miniprogram/pages/more/more.wxml
  22. +7
    -0
      miniprogram/pages/more/more.wxss
  23. +7
    -0
      miniprogram/sitemap.json
  24. +6
    -0
      miniprogram/style/app.wxss
  25. +67
    -0
      project.config.json

+ 19
- 0
miniprogram/app.js Näytä tiedosto

@@ -0,0 +1,19 @@
//app.js
App({
onLaunch: function () {
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
env: 'cloud1-7g8hw3qu242eeb5f',
traceUser: true, //将用户访问记录到用户管理中
})
}

this.globalData = {}
}
})

+ 42
- 0
miniprogram/app.json Näytä tiedosto

@@ -0,0 +1,42 @@
{
"pages": [
"pages/home/home",
"pages/more/more"
],
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
},
"window": {
"backgroundTextStyle": "dark",
"navigationBarBackgroundColor": "#1772cb",
"navigationBarTitleText": "随手精灵",
"navigationBarTextStyle": "white"
},
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#13227a",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/home/home",
"iconPath": "images/icon/icon_home.png",
"selectedIconPath": "images/icon/icon_home_active.png",
"text": "首页"
},
{
"pagePath": "pages/more/more",
"iconPath": "images/icon/icon_more.png",
"selectedIconPath": "images/icon/icon_more_active.png",
"text": "更多"
}
]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true,
"sitemapLocation": "sitemap.json"
}

+ 1
- 0
miniprogram/app.wxss Näytä tiedosto

@@ -0,0 +1 @@
@import 'style/app.wxss';

BIN
miniprogram/images/icon/help.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.0KB

BIN
miniprogram/images/icon/icon_home.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.4KB

BIN
miniprogram/images/icon/icon_home_active.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.6KB

BIN
miniprogram/images/icon/icon_list.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 1.4KB

BIN
miniprogram/images/icon/icon_list_active.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.2KB

BIN
miniprogram/images/icon/icon_more.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 1.1KB

BIN
miniprogram/images/icon/icon_more_active.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.2KB

BIN
miniprogram/images/icon/icon_partner.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 1.7KB

BIN
miniprogram/images/icon/icon_partner_active.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 5.9KB

BIN
miniprogram/images/icon/no_wifi.png Näytä tiedosto

Before After
Width: 81  |  Height: 81  |  Size: 2.1KB

+ 1
- 0
miniprogram/model/index.js Näytä tiedosto

@@ -0,0 +1 @@
export const VersionModel = '2.0.0F';

+ 211
- 0
miniprogram/pages/home/home.js Näytä tiedosto

@@ -0,0 +1,211 @@
// pages/home/home.js
Page({

/**
* 页面的初始数据
*/
data: {
wlanList: [
], //当前wlan列表
isConnectWlan: null, //是否已经连接上WLAN
connectWlanBssid: '', //当前连接WLAN的SSID
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.onStartWifi();
// todo 获取从微信公众号跳转的参数
},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},
navigateTo() {
wx.navigateTo({
url: '/pages/lifecyle/lifecyle'
})
},
switchTab() {
wx.switchTab({
url: "/pages/list/list",
})
},
// 加载wifi模板
onStartWifi() {
let that = this;
wx.startWifi({
success(res) {
console.log("成功", res.errMsg);
that.getWifiList();
},
fail(res) {
console.log("失败", res.errMsg);
wx.showModal({
title: '温馨提示',
content: `当前用户未打开WIFI和GPS`,
showCancel: false,
success(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
}
});
},
// 获取当前链接的wifi信息
getConnectedWifi: function () {
let that = this;
wx.getConnectedWifi({
success(res) {
console.log(res);
if(res) {
// 如果已经连接上WLAN
that.setData({
isConnectWlan: true,
connectWlanBssid: res.wifi.BSSID,
})
}
},
fail(res) {
console.log(res.errMsg);
that.setData({
isConnectWlan: false
})
}
})
},
// 刷新
onRefresh() {
this.getWifiList();
},
// 搜索不到WLAN
onHelp() {
wx.showModal({
title: '温馨提示',
content: `请您前往手机-设置-WLAN,打开WLAN开关并且打开手机的GPS`,
showCancel: false,
})
},
// 保存WLAN信息
onSave(value) {
const currentWlanInfo = value.currentTarget.dataset.name;
console.log("当前点击的WLAN信息", currentWlanInfo);
wx.showModal({
title: '温馨提示',
content: `当前选中WLANBSSID是:
${currentWlanInfo.BSSID}
`,
cancelText: '关闭',
confirmText: '复制',
success: (res) => {
if (res.confirm) {
wx.setClipboardData({
data: `${currentWlanInfo.BSSID}`,
})
}
}
})
// todo 调取接口
},
// 获取当前连接的周边的wifi列表
getWifiList() {
let that = this;
// 先获取当前连接的wifi信息
that.getConnectedWifi();
wx.showLoading({
title: '获取中WLAN...'
});
wx.getWifiList({
success(res) {
console.log("getWifiList", res);
wx.hideLoading();
wx.showToast({
title: '获取成功',
icon: 'success'
});
wx.onGetWifiList((result) => {
// 筛选wifi名称为空的数据
let wifiList = result.wifiList.filter(item => {
return item.SSID !== '';
});
// ,如果有已连接的wifi则将已连接的wifi移动到第一位,否则不做任何操作
if(that.data.connectWlanBssid !== '') {
//let newWifiList = that.data.wlanList;
// 找到与当前已连接wifi相同bssid数据的下标
const index = wifiList.findIndex(v => v.BSSID === that.data.connectWlanBssid);
//根据该对象在数组的下标从数组中移出
const moveObj = wifiList.splice(index, 1);
//把当前数据插入到数据首位
wifiList.splice(0, 0, ...moveObj);
that.setData({
wlanList: wifiList
})
} else {
that.setData({
wlanList: wifiList
})
}
});
},
fail(res) {
console.log(res.errMsg);
wx.hideLoading();
wx.showModal({
title: '温馨提示',
content: '当前用户未打开WIFI和GPS',
showCancel: false,
})
},
});
}
})

+ 3
- 0
miniprogram/pages/home/home.json Näytä tiedosto

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "首页"
}

+ 31
- 0
miniprogram/pages/home/home.wxml Näytä tiedosto

@@ -0,0 +1,31 @@
<view class="home-container">
<!--header -->
<view class="header">
<text>设备不支持5G类型以及机场,酒店等热点WLAN。如未获取到,请打开WIFI和GPS后刷新页面。点击WLAN即可查看对应的WlAN信息。</text>
</view>
<!-- list -->
<view class="disable-wlan">
<text>可用WLAN列表</text>
<button class="disable-wlan-btn" type="primary" size="mini" bindtap="onRefresh" wx:if="{{wlanList.length > 0}}">刷新</button>
</view>
<!-- body -->
<view class="body">
<view class="wlan-list" wx:if="{{wlanList.length > 0}}">
<view class="wlan-item" wx:for="{{wlanList}}" wx:key="index">
<view bindtap="onSave" data-name="{{wlanList[index]}}" class="{{index === 0 && isConnectWlan ? 'isConnect' : ''}}">
<text class="wlan-item-text" wx:if="{{index === 0 && isConnectWlan}}">(当前手机连接网络)</text>
{{wlanList[index].SSID}}
</view>
</view>
</view>
<view class="wlan-list-empty" wx:else="{{wlanList.length === 0}}">
<image class="no_wifi" src="../../images/icon/no_wifi.png"></image>
<text bindtap="onHelp">找不到WLAN?</text>
<button type="primary" bindtap="onRefresh">刷新</button>
</view>
</view>
<!-- footer -->
<view class="footer">
<image class="help" src="../../images/icon/help.png"></image><text bindtap="onHelp">搜索不到WLAN</text>
</view>
</view>

+ 96
- 0
miniprogram/pages/home/home.wxss Näytä tiedosto

@@ -0,0 +1,96 @@
/* pages/home/home.wxss.wxss */
.home-container {
position: relative;
height: 100vh;
overflow: hidden;
background-color: #f2f4f5;
}
.header {
height: 80px;
display: flex;
justify-content: center;
align-items: center;
padding: 0 20px;
background-color: #fff;
font-size: 14px;
color: gray;
}
.disable-wlan {
height: 50px;
line-height: 50px;
margin-top: 15px;
padding: 0 20px;
display: flex;
justify-content: space-between;
align-items: center;
background-color: white;
}
.disable-wlan-btn {
width: 120px;
display: flex;
justify-content: space-between;
align-items: center;
}
.refresh-img {
height: 25px;
width: 25px;
}
.body {
height: calc(100vh - 205px);
overflow: auto;
background-color: #f2f4f5;
}
.wlan-list {
flex: 1;
background-color: #f2f4f5;
overflow: auto;
}
.wlan-list-empty {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.no_wifi {
height: 80px;
width: 80px;
margin-bottom: 10px;
opacity: .6;
}
button {
width: 120px;
margin: 10px 0;
}
.wlan-item {
height: 65px;
line-height: 65px;
padding-left: 20px;
margin: 5px 0;
background-color: #fff;
white-space: nowrap;
overflow-y: hidden;
}
.wlan-item-text {
font-size: 14px;
}
.isConnect {
color: #2599ff;
}
.footer {
height: 55px;
display: flex;
justify-content: center;
align-items: center;
color: #2599ff;
background-color: #fff;
position: absolute;
bottom: 5px;
left: 0;
right: 0;
}
.help {
height: 25px;
width: 25px;
margin-right: 5px;
}

+ 67
- 0
miniprogram/pages/more/more.js Näytä tiedosto

@@ -0,0 +1,67 @@
// pages/more/more.js
import { VersionModel } from '../../model/index'
Page({

/**
* 页面的初始数据
*/
data: {
version: VersionModel, //版本号
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

}
})

+ 3
- 0
miniprogram/pages/more/more.json Näytä tiedosto

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "更多"
}

+ 4
- 0
miniprogram/pages/more/more.wxml Näytä tiedosto

@@ -0,0 +1,4 @@
<!--pages/more/more.wxml-->
<view class="more-container">
<text>当前小程序版本号:{{version}}</text>
</view>

+ 7
- 0
miniprogram/pages/more/more.wxss Näytä tiedosto

@@ -0,0 +1,7 @@
.more-container {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

+ 7
- 0
miniprogram/sitemap.json Näytä tiedosto

@@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

+ 6
- 0
miniprogram/style/app.wxss
File diff suppressed because it is too large
Näytä tiedosto


+ 67
- 0
project.config.json Näytä tiedosto

@@ -0,0 +1,67 @@
{
"miniprogramRoot": "miniprogram/",
"cloudfunctionRoot": "cloudfunctions/",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"minifyWXML": true,
"useStaticServer": true
},
"appid": "wx64cc3af90544c0cd",
"projectname": "cloudbase",
"libVersion": "2.14.1",
"condition": {
"miniprogram": {
"list": [
{
"name": "db guide",
"pathName": "pages/databaseGuide/databaseGuide",
"query": ""
}
]
}
},
"compileType": "miniprogram",
"srcMiniprogramRoot": "miniprogram/",
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
},
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
}

Loading…
Peruuta
Tallenna