123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <script>
- import initApp from "@/common/appInit.js";
- // import openApp from '@/common/openApp.js';
- export default {
- globalData: {
- searchText: "",
- appVersion: {},
- config: {},
- $i18n: {},
- $t: {},
- tabIndex: "home",
- },
- onLaunch: function () {
- // console.log('App Launch')
- this.globalData.$i18n = this.$i18n;
- this.globalData.$t = (str) => this.$t(str);
- uni.hideTabBar();
- initApp();
- // #ifdef H5
- // openApp() //创建在h5端全局悬浮引导用户下载app的功能
- // #endif
- // #ifdef APP-PLUS
- //checkIsAgree(); APP端暂时先用原生默认生成的。目前,自定义方式启动vue界面时,原生层已经请求了部分权限这并不符合国家的法规
- // #endif
- // #ifdef H5
- // checkIsAgree(); // 默认不开启。目前全球,仅欧盟国家有网页端同意隐私权限的需要。如果需要可以自己去掉注视后生效
- // #endif
- // #ifdef APP-PLUS
- //idfa有需要的用户在应用首次启动时自己获取存储到storage中
- //https://ask.dcloud.net.cn/article/36107
- /*if(~plus.storage.getItem('idfa')){
- plus.device.getInfo({//需要勾选IDFA
- success:function(e){
- console.log('idfa = '+JSON.stringify(e.idfa));
- },
- fail:function(e){
- console.log('getDeviceInfo failed: '+JSON.stringify(e));
- }
- });
- }*/
- // #endif
- // #ifdef MP-WEIXIN
- //定义更新方法
- function VersionUpdate() {
- // 判断应用的 getUpdateManager 是否在当前版本可用
- if (uni.canIUse("getUpdateManager")) {
- const updateManager = uni.getUpdateManager();
- // 向小程序后台请求完新版本信息
- updateManager.onCheckForUpdate(function (res) {
- if (res.hasUpdate) {
- //小程序有新版本,静默下载新版本,新版本下载完成
- updateManager.onUpdateReady(function () {
- //模态弹窗(确认、取消)
- uni.showModal({
- title: "更新提示",
- content: "小程序已发布新版本,是否重启?",
- success: function (res) {
- //用户点击确定
- if (res.confirm) {
- //当新版本下载完成,调用该方法会强制当前小程序应用上新版本并重启
- updateManager.applyUpdate();
- }
- //用户点击取消
- else if (res.cancel) {
- //强制用户更新,弹出第二次弹窗
- uni.showModal({
- title: "提示",
- content: "小程序已发布新版本,是否重启",
- showCancel: false, //隐藏取消按钮
- success: function (res) {
- //第二次提示后,强制更新
- if (res.confirm) {
- // 当新版本下载完成,调用该方法会强制当前小程序应用上新版本并重启
- updateManager.applyUpdate();
- } else if (res.cancel) {
- VersionUpdate();
- }
- },
- });
- }
- },
- });
- });
- // 当新版本下载失败
- updateManager.onUpdateFailed(function () {
- uni.showModal({
- title: "提示",
- content: "请您删除当前小程序,重新打开小程序",
- });
- });
- }
- });
- } else {
- // 提示用户在最新版本的客户端上体验
- uni.showModal({
- title: "温馨提示",
- content:
- "当前微信版本过低,可能无法使用该功能,请升级到最新版本后重试。",
- });
- }
- }
- //调用定义的更新方法
- VersionUpdate();
- // #endif
- },
- onShow: function () {
- console.log("App Show");
- uni.hideTabBar();
- },
- onHide: function () {
- console.log("App Hide");
- },
- };
- </script>
- <style>
- @import "@/static/iconfont.css";
- /* button {
- background: linear-gradient(to right, #6db4ff 0%, #2f71f4 100%);
- line-height: 80rpx;
- color: #fff;
- font-size: 30rpx;
- margin: 10rpx 0 0;
- border-radius: 40rpx;
- border: none;
- } */
- .data-empty {
- padding: 60rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .data-empty .empty-text {
- color: #999999;
- }
- </style>
- <style lang="scss">
- @import "@/uni_modules/uview-ui/index.scss";
- /*每个页面公共css */
- button::after {
- border: none;
- }
- uni-modal {
- z-index: 999999 !important;
- }
- </style>
|