1 Star 4 Fork 5

名牛云 / mn_demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
App.vue 2.29 KB
一键复制 编辑 原始数据 按行查看 历史
hnlg666 提交于 2022-01-12 03:06 . 上线框架开发demo
<script>
import * as $apis from './apis/index.js'
import store from './store'
import $mUtils from './common/utils.js'
export default {
onLaunch: function(item) {
console.log(item)
// 启动参数
let query = item.query;
// 获取后台图片配置并存储
// getInitConfig()
// 分享进入处理
shareIn(item)
// #ifdef MP
updateApp()
// #endif
},
onShow: function() {
},
onHide: function() {
// console.log('App Hide')
}
}
// 分享进入逻辑
function shareIn(item) {
// 扫码进入处理逻辑
const {
scene,
query
} = item;
if (query.scene) {
let obj = {
dateTime: new Date().getTime(),
scene,
...query.scene
};
store.commit('SET_SCENE',obj);
}
}
// 获取后台配置
function getInitConfig() {
$apis.initConfig().then((res) => {
let jsonStr = JSON.stringify(res);
uni.setStorage({
key: 'initConfig',
data: jsonStr,
success: function() {
}
});
store.commit('SET_INITCONFIG', res);
})
}
/**
* 更新小程序
*/
function updateApp() {
if (uni.canIUse('getUpdateManager')) {
const updateManager = uni.getUpdateManager()
//判断是否有新的小程序
updateManager.onCheckForUpdate(function(res) {
if (res.hasUpdate) {
updateManager.onUpdateReady(function() {
uni.clearStorage() //清理缓存
uni.showModal({
showCancel: false,
title: '更新提示',
content: '新版本已经升级完成,请重启应用!',
success: function(res) {
updateManager.applyUpdate()
}
})
})
//新的版本下载失败
updateManager.onUpdateFailed(function() {
uni.showModal({
showCancel: false,
title: '已经有新版本了哟~',
content: '新版本自动升级失败了~请您删除当前小程序,重新搜索打开哟~',
success: function(res) {
updateManager.applyUpdate()
}
})
})
}
})
} else {
uni.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
}
</script>
<style lang="scss">
@import "./static/iconfont/iconfont.css";
@import url("common/css/animate.css");
@import url("common/css/common.scss");
@import "uview-ui/index.scss";
</style>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/buwangyun/mn-demo.git
git@gitee.com:buwangyun/mn-demo.git
buwangyun
mn-demo
mn_demo
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891