增加数据缓存,去除部分请求的重复/
This commit is contained in:
237
App.vue
237
App.vue
@@ -1,9 +1,34 @@
|
||||
<script>
|
||||
import config from '@/common/config.js'
|
||||
import {isH5Android} from '@/utils/app.js'
|
||||
import {init} from '@/utils/init.js'
|
||||
import store from './store/index.js'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('onLaunch')
|
||||
// #ifdef H5
|
||||
//防止刷新过快
|
||||
if(process.env.NODE_ENV === 'production'){
|
||||
const prveTime=uni.getStorageSync('time')
|
||||
const time=Date.now()
|
||||
uni.setStorageSync('time',time)
|
||||
if(prveTime&&time-prveTime<=2000){
|
||||
uni.setStorageSync('isDisabledAll',true)
|
||||
uni.request=()=>{
|
||||
|
||||
}
|
||||
uni.removeStorageSync('prveTime')
|
||||
return uni.showToast({
|
||||
title:'休息一会儿吧,你刷新的太过频繁了!',
|
||||
icon:'error'
|
||||
})
|
||||
}else{
|
||||
uni.removeStorageSync('isDisabledAll')
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
|
||||
|
||||
let that = this
|
||||
// #ifdef MP-WEIXIN || MP-TOUTIAO
|
||||
//是否开启小程序自动登录 881
|
||||
@@ -302,36 +327,7 @@
|
||||
// }
|
||||
// }, 3000);
|
||||
|
||||
|
||||
//#ifdef H5
|
||||
|
||||
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
||||
if (res.code == 0 && res.data) {
|
||||
if (res.data.value == '是') {
|
||||
let ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf('micromessenger') !== -1) {
|
||||
let openid = uni.getStorageSync('openId');
|
||||
let userId = uni.getStorageSync('userId');
|
||||
if (!userId) {
|
||||
if (openid) {
|
||||
that.$u.get('/app/Login/openid/login?openId=' + openid).then(
|
||||
res => {
|
||||
if (res.code == 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('userName', res.user.userName)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user
|
||||
.invitationCode)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endif
|
||||
|
||||
//#ifdef APP-PLUS
|
||||
// APP检测更新 具体打包流程可以参考:https://ask.dcloud.net.cn/article/35667
|
||||
plus.screen.lockOrientation('portrait-primary'); //竖屏正方向锁定
|
||||
@@ -644,6 +640,7 @@
|
||||
},
|
||||
onShow: function() {
|
||||
|
||||
|
||||
// #ifdef H5
|
||||
// isH5Android()
|
||||
// #endif
|
||||
@@ -672,183 +669,9 @@
|
||||
// uni.setStorageSync('kefu', res.data.value)
|
||||
// }
|
||||
// });
|
||||
//微信小程序IOS系统支付功能开关 882
|
||||
this.$u.get('/app/common/type/882').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
let value = res.data.value
|
||||
const sysInfo = uni.getSystemInfoSync()
|
||||
// #ifdef MP-WEIXIN
|
||||
if (sysInfo.osName == 'ios') { //是ios系统
|
||||
if (value == '是') { //开启
|
||||
uni.setStorageSync('isWxIosPay', true)
|
||||
} else { //关闭
|
||||
uni.setStorageSync('isWxIosPay', false)
|
||||
}
|
||||
} else { //不是ios下,直接打开
|
||||
uni.setStorageSync('isWxIosPay', true)
|
||||
}
|
||||
// #endif
|
||||
//不在微信小程序也直接打开
|
||||
// #ifndef MP-WEIXIN
|
||||
uni.setStorageSync('isWxIosPay', true)
|
||||
// #endif
|
||||
}
|
||||
});
|
||||
//是否开启苹果登录 833
|
||||
this.$u.get('/app/common/type/833').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('checkIosLogin', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启苹果支付 834
|
||||
this.$u.get('/app/common/type/834').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('checkIosPay', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启微信登录 835
|
||||
this.$u.get('/app/common/type/835').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('checkWxLogin', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启手机号一键登录 836
|
||||
this.$u.get('/app/common/type/836').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('checkPhoneLogin', res.data.value)
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/817').then(res => { //是否开启购买整部视频 817
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('zhengbu', res.data.value)
|
||||
}
|
||||
});
|
||||
|
||||
this.$u.get('/app/common/type/818').then(res => { //是否开启购买单集视频 818
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('danbu', res.data.value)
|
||||
}
|
||||
});
|
||||
// 微信激励广告id 252
|
||||
this.$u.get('/app/common/type/252').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('adUnitId', res.data.value)
|
||||
}
|
||||
});
|
||||
// 播放类型 1:抖音云 2:三方云
|
||||
this.$u.get('/app/common/type/821').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('playType', res.data.value)
|
||||
}
|
||||
});
|
||||
// 是否开启看广告(微信) 251
|
||||
this.$u.get('/app/common/type/251').then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data && res.data.value) {
|
||||
uni.setStorageSync('isGuanggao', res.data.value)
|
||||
}
|
||||
}
|
||||
});
|
||||
// 是否开启看广告(抖音) 254
|
||||
this.$u.get('/app/common/type/254').then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data && res.data.value) {
|
||||
uni.setStorageSync('isGuanggaody', res.data.value)
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/202').then(res => { //客服配置 1 二维码客服 2 微信公众号客服 3电话客服
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefu', res.data.value)
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/206').then(res => { //客服电话
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuPhone', res.data.value)
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/204').then(res => { //微信客服链接
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuUrl', res.data.value)
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/203').then(res => { //微信客服appid
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuAppId', res.data.value)
|
||||
}
|
||||
});
|
||||
//会员开关
|
||||
this.$u.get('/app/common/type/248').then(res => { //会员开关
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('isVips', res.data.value)
|
||||
}
|
||||
});
|
||||
//热搜词 249
|
||||
this.$u.get('/app/common/type/249').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('moreSearch', res.data.value)
|
||||
}
|
||||
});
|
||||
//安卓下载地址 49
|
||||
this.$u.get('/app/common/type/49').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('AppUrl', res.data.value)
|
||||
}
|
||||
});
|
||||
//微信虚拟支付OfferID 823
|
||||
this.$u.get('/app/common/type/823').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('OfferID', res.data.value)
|
||||
}
|
||||
});
|
||||
//微信虚拟支付环境(0 米大师正式环境, 1 米大师沙箱环境) 824
|
||||
this.$u.get('/app/common/type/824').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('payEnv', res.data.value)
|
||||
}
|
||||
});
|
||||
//充值提示 825
|
||||
this.$u.get('/app/common/type/825').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('moneyTips', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启卡密充值 855
|
||||
this.$u.get('/app/common/type/855').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kmPaySel', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启分类 849
|
||||
this.$u.get('/app/common/type/849').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('homeTypeSel', res.data.value)
|
||||
}
|
||||
});
|
||||
//是否开启收益充值余额 856
|
||||
this.$u.get('/app/common/type/856').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('syPaySel', res.data.value)
|
||||
}
|
||||
});
|
||||
//抖音im客服 857
|
||||
this.$u.get('/app/common/type/857').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('imId', res.data.value)
|
||||
}
|
||||
});
|
||||
this.$u.get('/app/common/type/858').then(res => { //是否开启公众号充值
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('isAccountPay', res.data.value)
|
||||
}
|
||||
});
|
||||
//抖音广告id
|
||||
this.$u.get('/app/common/type/860').then(res => { //抖音广告
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('dyadUnitId', res.data.value)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
init()
|
||||
|
||||
// #ifdef H5
|
||||
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
||||
//是否开启pc端使用 850
|
||||
|
||||
Reference in New Issue
Block a user