users/App.vue

192 lines
5.6 KiB
Vue

<style lang="scss">
@import 'uni_modules/uview-ui/index.scss';
</style>
<script>
const core = require('./src/utils/core.js');
const util = require('./src/utils/util.js');
const config = require('./src/config/config.js');
const location = require('./src/utils/location/location.js');
let that;
var currentPage = {};
export default {
onLaunch: function(optionL) {
// optionL 路径
// that = this;
// uni.removeStorageSync('qr_scan_data');
// if (optionL && typeof optionL.query != 'undefined' && optionL.query) {
// uni.setStorageSync('appLaunchOptions', optionL);
// //#ifdef MP-ALIPAY
// uni.setStorageSync('qr_scan_data', optionL.query);
// //#endif
// }
// //getCurrentPages(): 获取当前页面栈数组,存储在 currentPage 中。这通常用于需要访问和操作当前页面信息的场景。
// if (getCurrentPages()) {
// currentPage = getCurrentPages();
// }
// //用于初始化或更新全局数据。
// that.globalData.fUpdate();
},
onShow: function(optionL) {
// init
// if (optionL && typeof optionL.query != 'undefined' && optionL.query) {
// uni.setStorageSync('appLaunchOptions', optionL);
// //#ifdef MP-ALIPAY
// uni.setStorageSync('qr_scan_data', optionL.query);
// //#endif
// }
// if (getCurrentPages()) {
// currentPage = getCurrentPages();
// }
// that.globalData.getCurPage();
// util.getCurrentSys();
},
onHide: function() {
// that.globalData.removeCache('mypos');
// // 每次关闭小程序都,移除支付宝保存的商家付款码信息
// uni.removeStorageSync('qr_scan_data');
},
globalData: {
// getCurPage: function() {
// currentPage = getCurrentPages();
// if (!currentPage.length) {
// setTimeout(function() {
// that.globalData.getCurPage();
// }, 10);
// } else {
// let curRoute = currentPage[currentPage.length - 1].route;
// let noneedLogin = false;
// console.log("app curRoute", curRoute);
// // 直接入口页面,不需要登录
// for (let i = 0; i < that.globalData.config.white_page_list.length; i++) {
// if (curRoute.indexOf(that.globalData.config.white_page_list[i]) > -1) {
// noneedLogin = true;
// break;
// }
// }
// if (noneedLogin) {} else {
// util.loginByCode().then(loginByCodeRes => {
// that.globalData.init();
// });
// }
// }
// },
// 强制更新
fUpdate: function() {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
});
updateManager.onUpdateReady(function() {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
},
init: function() {
that.globalData.getConfig();
that.globalData.removeCache('showpop');
},
requirejs: function(page) {
return require('src/utils/' + page + '.js');
},
// getConfig: function() {
// if (null !== this.api)
// return {
// api: this.api,
// approot: this.approot,
// appid: this.appid
// };
// var thirdConfig = uni.getExtConfigSync();
// return (this.api = thirdConfig.config.api), (this.approot = thirdConfig.config.approot), (this.appid =
// thirdConfig.config.appid), thirdConfig.config;
// },
// getCache: function(key, cb) {
// var timeout = +new Date() / 1000,
// res = '';
// timeout = parseInt(timeout);
// try {
// (res = uni.getStorageSync(key + this.appid)).expire > timeout || 0 == res.expire ? (res = res
// .value) : ((res = ''), this.removeCache(key));
// } catch (e) {
// res = void 0 === cb ? '' : cb;
// }
// return (res = res || '');
// },
// setCache: function(key, value, timeout) {
// var time = +new Date() / 1000,
// res = true,
// data = {
// expire: timeout ? time + parseInt(timeout) : 0,
// value: value
// };
// try {
// uni.setStorageSync(key + this.appid, data);
// } catch (e) {
// res = false;
// }
// return res;
// },
// removeCache: function(key) {
// var res = true;
// try {
// uni.removeStorageSync(key + this.appid);
// } catch (e) {
// res = false;
// }
// return res;
// },
/**
* 获取用户是否绑定手机
* @param canCancel 是否可以取消绑定弹窗提示? 默认 可以true
*/
checkBindMobile: function(canCancel = true, tipsText = '请绑定手机号后使用,否则您在其他平台的账号数据将无法同步') {
return new Promise((resolve, reject) => {
let userInfo = uni.getStorageSync('userInfo');
if (userInfo && userInfo.mobile && userInfo.mobile != null) {
resolve(true);
} else {
uni.showModal({
title: '提示',
content: tipsText,
confirmText: '允许绑定',
cancelText: '以后再说',
showCancel: canCancel,
success: function(confirm) {
resolve(confirm.confirm);
},
fail: function() {
reject(false);
}
});
}
});
},
// appid: 'wx231bd3f08954da9e',
// userInfo: null,
// util: util,
// config: config,
// getLocation: location.getLocation,
// request: util.request,
// globalDataClose: {
// // 是否为黑名单用户
// flag: false
// }
},
methods: {}
};
</script>
<style>
@import './app.css';
</style>