233 lines
5.9 KiB
Vue
233 lines
5.9 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;
|
||
|
//#ifdef H5
|
||
|
util.loadJS('https://res.wx.qq.com/open/js/jweixin-1.6.0.js')
|
||
|
util.loadJS('https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js')
|
||
|
//#endif
|
||
|
var currentPage = {};
|
||
|
export default {
|
||
|
onLaunch: function(optionL) {
|
||
|
console.log('uni.$u.config.v');
|
||
|
console.log(uni.$u.config.v);
|
||
|
that = this;
|
||
|
uni.removeStorageSync('qr_scan_data');
|
||
|
console.log("神经病啊:::::::",optionL)
|
||
|
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.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();
|
||
|
console.log(currentPage);
|
||
|
if (!currentPage.length) {
|
||
|
setTimeout(function() {
|
||
|
that.globalData.getCurPage();
|
||
|
console.log("232112");
|
||
|
}, 10);
|
||
|
} else {
|
||
|
let curRoute = currentPage[currentPage.length - 1].route;
|
||
|
let noneedLogin = false;
|
||
|
console.log("222222222222",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;
|
||
|
},
|
||
|
// 获取实名认证信息
|
||
|
checkIDCardVerify: function(messageQ) {
|
||
|
return
|
||
|
let message = '该功能需要实名认证后使用'
|
||
|
if (messageQ) {
|
||
|
message = messageQ;
|
||
|
}
|
||
|
util.loginByCode().then(function(userInfo) {
|
||
|
if (userInfo.idcardverify) {
|
||
|
} else {
|
||
|
uni.showModal({
|
||
|
title: '提示',
|
||
|
content: message,
|
||
|
cancelText:"下次再说",
|
||
|
success: function(confirm) {
|
||
|
if (confirm.confirm) {
|
||
|
uni.navigateTo({
|
||
|
url: '/pages/member/idcard/index'
|
||
|
});
|
||
|
} else {
|
||
|
uni.navigateBack({})
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
/**
|
||
|
* 获取用户是否绑定手机
|
||
|
* @param canCancel 是否可以取消绑定弹窗提示? 默认 可以true
|
||
|
*/
|
||
|
checkBindMobile: function(canCancel = true, tipsText = '请绑定手机号后使用,否则您在其他平台的账号数据将无法同步') {
|
||
|
//#ifdef H5
|
||
|
uni.redirectTo({
|
||
|
url: '/pages/login/index'
|
||
|
});
|
||
|
//#endif
|
||
|
let userInfo = uni.getStorageSync('userInfo');
|
||
|
if (userInfo && userInfo.mobile && userInfo.mobile != null) {
|
||
|
return true;
|
||
|
} else {
|
||
|
uni.showModal({
|
||
|
title: '提示',
|
||
|
content: tipsText,
|
||
|
confirmText: '去绑定',
|
||
|
cancelText: '以后再说',
|
||
|
showCancel: canCancel,
|
||
|
success: function(confirm) {
|
||
|
if (confirm.confirm) {
|
||
|
uni.navigateTo({
|
||
|
url: '/pages/login/index?needreturnback=yes'
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
return 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>
|
||
|
|
||
|
|
||
|
|