Commit af5ed6ad by zhangzhen

处理wifi连接相关

parent a69592a1
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
<script> <script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar'; import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import {getUserInfo,loginOut} from "@/api/index.js" import {getUserInfo,loginOut,systemConfig} from "@/api/index.js"
import config from "@/config/index.config" import config from "@/config/index.config"
import LoginPop from "@/components/login/login" import LoginPop from "@/components/login/login"
...@@ -178,8 +178,8 @@ ...@@ -178,8 +178,8 @@
} }
}, },
onShow() { onShow() {
this.onGetSysConfig();
this.onCheckUserLogin(); this.onCheckUserLogin();
this.onGetSysConfig();
}, },
onLoad() { onLoad() {
// 隐藏原生的tabbar // 隐藏原生的tabbar
...@@ -188,6 +188,21 @@ ...@@ -188,6 +188,21 @@
methods: { methods: {
onGetSysConfig(){ onGetSysConfig(){
let sysConfigList = uni.getStorageSync('sysConfig') let sysConfigList = uni.getStorageSync('sysConfig')
if(!sysConfigList){
systemConfig().then(res=>{
if(res.data.code == 200){
uni.setStorage({
key:'sysConfig',
data: res.data.rows,
success: () => {
this.onGetSysConfig();
}
})
}
})
return;
}
let wifi = sysConfigList.find(item=>item.configKey === 'wechat.wifi') let wifi = sysConfigList.find(item=>item.configKey === 'wechat.wifi')
if(wifi){ if(wifi){
let w = wifi.configValue.split(';') let w = wifi.configValue.split(';')
...@@ -254,7 +269,15 @@ ...@@ -254,7 +269,15 @@
phoneNumber:this.servicePhone phoneNumber:this.servicePhone
}) })
}else if(val == 2){ }else if(val == 2){
this.$refs.popup.open() if(this.wifiData.name && this.wifiData.password){
this.$refs.popup.open()
}else{
uni.showToast({
icon:"none",
title:"无法进行WIFI连接"
})
}
}else if(val === 3){ }else if(val === 3){
uni.navigateTo({ uni.navigateTo({
url:'/pages/storeList/storeList' url:'/pages/storeList/storeList'
...@@ -274,24 +297,28 @@ ...@@ -274,24 +297,28 @@
}) })
}, },
onConnectWifi(){ onConnectWifi(){
uni.connectWifi({ uni.startWifi({
SSID:this.wifiData.name, success:()=>{
BSSID:this.wifiData.name, uni.connectWifi({
password:this.wifiData.password, SSID:this.wifiData.name,
success: () => { BSSID:this.wifiData.name,
uni.showToast({ password:this.wifiData.password,
icon:"none", success: () => {
title:'连接成功' uni.showToast({
}) icon:"none",
}, title:'连接成功'
fail: (err) => { })
uni.showToast({ },
icon:'none', fail: (err) => {
title:err.errMsg uni.showToast({
icon:'none',
title:"WIFI连接失败"
})
},
complete: (res) => {
console.log(res,909090)
}
}) })
},
complete: (res) => {
console.log(res,909090)
} }
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment