/** * c.k 2017/11/15 创建 * c.y 2018/3/16 修改 (把增加了获取项目的动态配置的方法) * 获取设备的信息以及渠道号 * 获取项目的名称,logo,协议等等动态配置 */ import device from '../tool/deviceInfo'; // 设备信息 import channel from '../tool/channel'; // 获取渠道编号 import jsBridge from '../tool/jsBridge'; // 安卓/iOS获取设备的信息已经cn值 import systemApi from '../api/api'; import codeManage from '../api/statusCodeManage'; // 设置客户端的信息 function setClientInfo () { // 当前的设备信息 let currentDeviceInfo = { 'ostype': device.getDeviceType(), // 系统类型 'cn': '', 'resolution': window.screen.height + '*' + window.screen.width, 'chanNo': '', // jtjinfu 100 channel.GetUrlParam('chanNo') 'childChan': '', // '308' 100, appStore 'isApp': '0', 'areaCode':'510100' // 'appVersion':"1.0.0" }; let _newClientInfo = window.localStorage.getItem('newClientInfo'); if(_newClientInfo){ _newClientInfo = JSON.parse(_newClientInfo); _newClientInfo.cn = channel.getCnVal(); if(!_newClientInfo.areaCode){ _newClientInfo.areaCode = '510100'; // 界面刷新覆盖默认值 } window.localStorage.setItem('newClientInfo', JSON.stringify(_newClientInfo)); }else{ currentDeviceInfo.cn = channel.getCnVal(); window.localStorage.setItem('newClientInfo', JSON.stringify(currentDeviceInfo)); } // 如果设置是安卓/iOS的话,就通过jsBridge来获取设备信息,以及cn值 jsBridge.fetchDeviceInfo(); // let _deviceInfo = window.localStorage.getItem('deviceInfo'); // if (_deviceInfo) { // _deviceInfo = JSON.parse(_deviceInfo); // for (let key in _deviceInfo) { // currentDeviceInfo[key] = _deviceInfo[key]; // } // } else { // currentDeviceInfo.ostype = '03'; // } } // 获取项目的配置信息,项目的标题,logo,协议 function fetchProductConfig () { return systemApi.getProductConfig(); } // 配置产品信息 function setProductInfo (prodConfig, prodTitle) { window.localStorage.setItem('newProdConfig', prodConfig.replace(/commerce/g,'finlean_wallet')); document.getElementById('productTitle').innerHTML = prodTitle; } // 设置项目配置信息 async function setProductConfig () { // 获取当前渠道号 let clientInfo = JSON.parse(window.localStorage.getItem('newClientInfo')); let localChannelNo = clientInfo.cn; let localChannelNum = clientInfo.chanNo; try { let productConfig = await fetchProductConfig(); // 如果本地有chanNo if (localChannelNum) { let currentProdConfig = productConfig.chanBaseInfo[localChannelNum]; setProductInfo(JSON.stringify(currentProdConfig), currentProdConfig.title); } else { // 根据本地渠道号 LAf4,获取渠道编号 100 let currentChannelNum = productConfig.chanSign[localChannelNo]; // 根据当前渠道获取对应的产品信息, 并进行设置 if (currentChannelNum) { let currentProdConfig = productConfig.chanBaseInfo[currentChannelNum]; setProductInfo(JSON.stringify(currentProdConfig), currentProdConfig.title); } } } catch (error) { codeManage.showTipOfStatusCode(error); } } export { setClientInfo, setProductConfig }