修改配置请求全部放到一个接口里

This commit is contained in:
2025-01-04 11:28:21 +08:00
parent 38af72524b
commit b8f0c0f5e9
2 changed files with 177 additions and 79 deletions

View File

@@ -299,12 +299,6 @@
// #endif
// setInterval(d => { //定时器,定时去调取聊天未读消息
// let userId = uni.getStorageSync('userId')
// if (userId) {
@@ -639,7 +633,7 @@
},
onShow: function() {
init()
// #ifdef H5
// isH5Android()
@@ -670,7 +664,6 @@
// }
// });
init()
// #ifdef H5
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {

View File

@@ -1,6 +1,102 @@
import httpsRequest from '@/common/httpRequest.js'
import { $cache_config } from '@/store/cashe';
export function init() {
import {
$cache_config
} from '@/store/cashe';
function getIsPauseServe() {
return new Promise((reslove, reject) => {
uni.request({
url: '',
method: 'get',
data: {},
success() {
reslove()
}
})
})
}
const $map = {
882: 'isWxIosPay',
833: 'checkIosLogin',
834: 'checkIosPay',
835: 'checkWxLogin',
836: 'checkPhoneLogin',
108: 'isOpenWxWebAutoLogin',
817: 'zhengbu',
818: 'danbu',
252: 'adUnitId',
821: 'playType',
251: 'isGuanggao',
254: 'isGuanggaody',
202: 'kefu',
206: 'kefuPhone',
204: 'kefuUrl',
203: 'kefuAppId',
248: 'isVips',
249: 'moreSearch',
49: 'AppUrl',
823: 'OfferID',
824: 'payEnv',
825: 'moneyTips',
855: 'kmPaySel',
849: 'homeTypeSel',
856: 'syPaySel',
857: 'imId',
858: 'isAccountPay',
860: 'dyadUnitId',
881: '',
109: ''
}
function callback() {
if (key == 'isOpenWxWebAutoLogin' && res.data[i] == '是') {
// 是否开启公众号自动登陆 108
let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) {
let openid = uni.getStorageSync('openId');
let userId = uni.getStorageSync('userId');
if (!userId) {
if (openid) {
httpsRequest.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)
}
});
}
}
}
}
}
export async function init() {
console.log($cache_config);
if($cache_config._isEmpty){
httpsRequest.getT('/app/common/getAppUseKv').then(res => {
console.log(res);
if (res.code == 0) {
for (let i in $map) {
const key = $map[i]
if (key) {
// uni.setStorageSync(key, res.data[i])
$cache_config.set(key, res.data[i])
// callback()
}
}
}
})
}
return
// const res=await getIsPauseServe()
// #ifdef APP
//微信小程序IOS系统支付功能开关 882
httpsRequest.getT('/app/common/type/882').then(res => {
@@ -82,13 +178,22 @@ export function init() {
// #endif
configInit()
// configInit()
}
export function configInit() {
const {zhengbu,danbu,adUnitId,playType,isGuanggao,isGuanggaody,kefu,kefuPhone}=$cache_config
const {
zhengbu,
danbu,
adUnitId,
playType,
isGuanggao,
isGuanggaody,
kefu,
kefuPhone
} = $cache_config
if (zhengbu === null || zhengbu === undefined) {
httpsRequest.getT('/app/common/type/817').then(res => { //是否开启购买整部视频 817
if (res.code == 0 && res.data) {