修改配置请求全部放到一个接口里
This commit is contained in:
247
utils/init.js
247
utils/init.js
@@ -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 => {
|
||||
@@ -81,229 +177,238 @@ export function init() {
|
||||
|
||||
// #endif
|
||||
|
||||
|
||||
configInit()
|
||||
|
||||
// configInit()
|
||||
|
||||
|
||||
}
|
||||
|
||||
export function configInit(){
|
||||
const {zhengbu,danbu,adUnitId,playType,isGuanggao,isGuanggaody,kefu,kefuPhone}=$cache_config
|
||||
if(zhengbu===null||zhengbu===undefined){
|
||||
export function configInit() {
|
||||
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) {
|
||||
uni.setStorageSync('zhengbu', res.data.value)
|
||||
$cache_config.set('zhengbu',res.data.value)
|
||||
$cache_config.set('zhengbu', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(danbu===null||danbu===undefined){
|
||||
|
||||
if (danbu === null || danbu === undefined) {
|
||||
httpsRequest.getT('/app/common/type/818').then(res => { //是否开启购买单集视频 818
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('danbu', res.data.value)
|
||||
$cache_config.set('danbu',res.data.value)
|
||||
$cache_config.set('danbu', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 微信激励广告id 252
|
||||
if(adUnitId===null||adUnitId===undefined){
|
||||
if (adUnitId === null || adUnitId === undefined) {
|
||||
httpsRequest.getT('/app/common/type/252').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('adUnitId', res.data.value)
|
||||
$cache_config.set('adUnitId',res.data.value)
|
||||
$cache_config.set('adUnitId', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 播放类型 1:抖音云 2:三方云
|
||||
if(playType===null||playType===undefined){
|
||||
if (playType === null || playType === undefined) {
|
||||
httpsRequest.getT('/app/common/type/821').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('playType', res.data.value)
|
||||
$cache_config.set('playType',res.data.value)
|
||||
$cache_config.set('playType', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 是否开启看广告(微信) 251
|
||||
if(isGuanggao===null||isGuanggao===undefined){
|
||||
if (isGuanggao === null || isGuanggao === undefined) {
|
||||
httpsRequest.getT('/app/common/type/251').then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data && res.data.value) {
|
||||
uni.setStorageSync('isGuanggao', res.data.value)
|
||||
$cache_config.set('isGuanggao',res.data.value)
|
||||
$cache_config.set('isGuanggao', res.data.value)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 是否开启看广告(抖音) 254
|
||||
if(isGuanggaody===null||isGuanggaody===undefined){
|
||||
if (isGuanggaody === null || isGuanggaody === undefined) {
|
||||
httpsRequest.getT('/app/common/type/254').then(res => {
|
||||
if (res.code == 0) {
|
||||
if (res.data && res.data.value) {
|
||||
uni.setStorageSync('isGuanggaody', res.data.value)
|
||||
$cache_config.set('isGuanggaody',res.data.value)
|
||||
$cache_config.set('isGuanggaody', res.data.value)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(kefu===null||kefu===undefined){
|
||||
|
||||
if (kefu === null || kefu === undefined) {
|
||||
httpsRequest.getT('/app/common/type/202').then(res => { //客服配置 1 二维码客服 2 微信公众号客服 3电话客服
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefu', res.data.value)
|
||||
$cache_config.set('kefu',res.data.value)
|
||||
$cache_config.set('kefu', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(kefuPhone===null||kefuPhone===undefined){
|
||||
|
||||
if (kefuPhone === null || kefuPhone === undefined) {
|
||||
httpsRequest.getT('/app/common/type/206').then(res => { //客服电话
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuPhone', res.data.value)
|
||||
$cache_config.set('kefuPhone',res.data.value)
|
||||
$cache_config.set('kefuPhone', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if($cache_config.kefuUrl===null||$cache_config.kefuUrl===undefined){
|
||||
|
||||
if ($cache_config.kefuUrl === null || $cache_config.kefuUrl === undefined) {
|
||||
httpsRequest.getT('/app/common/type/204').then(res => { //微信客服链接
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuUrl', res.data.value)
|
||||
$cache_config.set('kefuUrl',res.data.value)
|
||||
$cache_config.set('kefuUrl', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if($cache_config.kefuAppId===null||$cache_config.kefuAppId===undefined){
|
||||
|
||||
if ($cache_config.kefuAppId === null || $cache_config.kefuAppId === undefined) {
|
||||
httpsRequest.getT('/app/common/type/203').then(res => { //微信客服appid
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kefuAppId', res.data.value)
|
||||
$cache_config.set('kefuAppId',res.data.value)
|
||||
$cache_config.set('kefuAppId', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//会员开关
|
||||
if($cache_config.isVips===null||$cache_config.isVips===undefined){
|
||||
if ($cache_config.isVips === null || $cache_config.isVips === undefined) {
|
||||
httpsRequest.getT('/app/common/type/248').then(res => { //会员开关
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('isVips', res.data.value)
|
||||
$cache_config.set('isVips',res.data.value)
|
||||
$cache_config.set('isVips', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//热搜词 249
|
||||
if($cache_config.moreSearch===null||$cache_config.moreSearch===undefined){
|
||||
if ($cache_config.moreSearch === null || $cache_config.moreSearch === undefined) {
|
||||
httpsRequest.getT('/app/common/type/249').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('moreSearch', res.data.value)
|
||||
$cache_config.set('moreSearch',res.data.value)
|
||||
$cache_config.set('moreSearch', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//安卓下载地址 49
|
||||
if($cache_config.AppUrl===null||$cache_config.AppUrl===undefined){
|
||||
if ($cache_config.AppUrl === null || $cache_config.AppUrl === undefined) {
|
||||
httpsRequest.getT('/app/common/type/49').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('AppUrl', res.data.value)
|
||||
$cache_config.set('AppUrl',res.data.value)
|
||||
$cache_config.set('AppUrl', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//微信虚拟支付OfferID 823
|
||||
if($cache_config.OfferID===null||$cache_config.OfferID===undefined){
|
||||
if ($cache_config.OfferID === null || $cache_config.OfferID === undefined) {
|
||||
httpsRequest.getT('/app/common/type/823').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('OfferID', res.data.value)
|
||||
$cache_config.set('OfferID',res.data.value)
|
||||
$cache_config.set('OfferID', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//微信虚拟支付环境(0 米大师正式环境, 1 米大师沙箱环境) 824
|
||||
if($cache_config.payEnv===null||$cache_config.payEnv===undefined){
|
||||
if ($cache_config.payEnv === null || $cache_config.payEnv === undefined) {
|
||||
httpsRequest.getT('/app/common/type/824').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('payEnv', res.data.value)
|
||||
$cache_config.set('payEnv',res.data.value)
|
||||
$cache_config.set('payEnv', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//充值提示 825
|
||||
if($cache_config.moneyTips===null||$cache_config.moneyTips===undefined){
|
||||
if ($cache_config.moneyTips === null || $cache_config.moneyTips === undefined) {
|
||||
httpsRequest.getT('/app/common/type/825').then(res => { //热搜词
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('moneyTips', res.data.value)
|
||||
$cache_config.set('moneyTips',res.data.value)
|
||||
$cache_config.set('moneyTips', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//是否开启卡密充值 855
|
||||
if($cache_config.kmPaySel===null||$cache_config.kmPaySel===undefined){
|
||||
if ($cache_config.kmPaySel === null || $cache_config.kmPaySel === undefined) {
|
||||
httpsRequest.getT('/app/common/type/855').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('kmPaySel', res.data.value)
|
||||
$cache_config.set('kmPaySel',res.data.value)
|
||||
$cache_config.set('kmPaySel', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//是否开启分类 849
|
||||
if($cache_config.homeTypeSel===null||$cache_config.homeTypeSel===undefined){
|
||||
if ($cache_config.homeTypeSel === null || $cache_config.homeTypeSel === undefined) {
|
||||
httpsRequest.getT('/app/common/type/849').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('homeTypeSel', res.data.value)
|
||||
$cache_config.set('homeTypeSel',res.data.value)
|
||||
$cache_config.set('homeTypeSel', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//是否开启收益充值余额 856
|
||||
if($cache_config.syPaySel===null||$cache_config.syPaySel===undefined){
|
||||
if ($cache_config.syPaySel === null || $cache_config.syPaySel === undefined) {
|
||||
httpsRequest.getT('/app/common/type/856').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('syPaySel', res.data.value)
|
||||
$cache_config.set('syPaySel',res.data.value)
|
||||
$cache_config.set('syPaySel', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//抖音im客服 857
|
||||
if($cache_config.imId===null||$cache_config.imId===undefined){
|
||||
if ($cache_config.imId === null || $cache_config.imId === undefined) {
|
||||
httpsRequest.getT('/app/common/type/857').then(res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('imId', res.data.value)
|
||||
$cache_config.set('imId',res.data.value)
|
||||
$cache_config.set('imId', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
if($cache_config.isAccountPay===null||$cache_config.isAccountPay===undefined){
|
||||
if ($cache_config.isAccountPay === null || $cache_config.isAccountPay === undefined) {
|
||||
httpsRequest.getT('/app/common/type/858').then(res => { //是否开启公众号充值
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('isAccountPay', res.data.value)
|
||||
$cache_config.set('isAccountPay',res.data.value)
|
||||
$cache_config.set('isAccountPay', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//抖音广告id
|
||||
if($cache_config.dyadUnitId===null||$cache_config.dyadUnitId===undefined){
|
||||
if ($cache_config.dyadUnitId === null || $cache_config.dyadUnitId === undefined) {
|
||||
httpsRequest.getT('/app/common/type/860').then(res => { //抖音广告
|
||||
if (res.code == 0 && res.data) {
|
||||
uni.setStorageSync('dyadUnitId', res.data.value)
|
||||
$cache_config.set('dyadUnitId',res.data.value)
|
||||
$cache_config.set('dyadUnitId', res.data.value)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user