2 Star 0 Fork 0

jinamin/iot-front-moible

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.vue 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
jinamin 提交于 2024-03-04 09:55 . PAD更新代码
<script>
import storage from "@/utils/storage.js"
import { saveProduction } from "@/api/quality.js"
export default {
onLaunch () {
setTimeout(() => {
plus.screen.unlockOrientation() //解除屏幕方向的锁定,但是不一定是竖屏
plus.screen.lockOrientation('landscape-primary') //锁定横屏
// plus.screen.lockOrientation('landscape-secondary')
},500)
plus.navigator.setFullscreen(false); //隐藏状态栏(应用全屏:只能隐藏状态栏,标题栏和虚拟返回键都还可以显示)
// 加载系统信息
this.$store.dispatch('SystemInfo')
let systemInfo = uni.getSystemInfoSync();
this.systemLocale = systemInfo.language;
this.applicationLocale = uni.getStorageSync('lang');
this.isAndroid = systemInfo.platform.toLowerCase() === 'android';
uni.onLocaleChange((e) => {
this.applicationLocale = e.locale;
})
systemInfo.language = this.applicationLocale
this.$store.commit('SET_SYSTEM_INFO',systemInfo)
},
onShow () {
const data = uni.getStorageSync("offlineCaching")
if (Array.isArray(data)) {
uni.setStorageSync("offlineCaching", {})
}
setInterval(() => {
const currentSewingId = storage.get('currentSewingId')
let offlineCaching = uni.getStorageSync('offlineCaching')
const targetList = offlineCaching[currentSewingId] || []
if (!targetList || !targetList.length) return
uni.request({
url: "http://www.baidu.com",
success: () => {
console.log("网络状态正常~~~")
this.isConnected = true
while (targetList && targetList.length) {
const params = targetList.shift()
try {
saveProduction(params, { custom: { loading: false } })
if (!targetList.length) {
offlineCaching[currentSewingId] = []
uni.setStorageSync('offlineCaching', offlineCaching)
console.log("准备commit CHANGE_CACHE_IDX");
this.$store.commit('CHANGE_CACHE_IDX')
}
} catch (err) {
console.log(err);
}
}
},
fail: () => {
console.log("网络状态异常");
this.isConnected = false
}
})
}, 5000)
},
onHide () {
},
}
</script>
<style lang="scss">
@import url("@/static/icons/iconfont-weapp-icon.css");
@import "@/uni_modules/uview-ui/index.scss";
@import "@/static/style.scss";
</style>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinamin/iot-front-moible.git
git@gitee.com:jinamin/iot-front-moible.git
jinamin
iot-front-moible
iot-front-moible
main

搜索帮助