Authored by 李奇

开关请求添加

@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 // export const ACTIVITY_HOST = 'https://action.yoho.cn'; 4 // export const ACTIVITY_HOST = 'https://action.yoho.cn';
5 // export const APP_REPORT_HOST = 'https://app.yoho.cn/collect/v3'; 5 // export const APP_REPORT_HOST = 'https://app.yoho.cn/collect/v3';
6 // export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile'; 6 // export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile';
  7 +// export const ICONFIG_HOST = 'https://iconfig.yoho.cn/lb/v3';
7 8
8 // 测试环境 9 // 测试环境
9 export const API_HOST = 'http://api-test3.dev.yohocorp.com'; 10 export const API_HOST = 'http://api-test3.dev.yohocorp.com';
@@ -11,6 +12,7 @@ export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com'; @@ -11,6 +12,7 @@ export const SERVICE_HOST = 'http://api-test3.dev.yohocorp.com';
11 export const ACTIVITY_HOST = 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com'; 12 export const ACTIVITY_HOST = 'http://yoho-activity-platform.test3.ingress.dev.yohocorp.com';
12 export const APP_REPORT_HOST = 'http://app.yoho.cn/collect/v3'; 13 export const APP_REPORT_HOST = 'http://app.yoho.cn/collect/v3';
13 export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile'; 14 export const LOG_EVENT_HOST = 'https://analysis.yohobuy.com/yas_mobile';
  15 +export const ICONFIG_HOST = 'http://iconfig.yoho.cn/lb/v3';
14 16
15 export const MINI_APP_TYPE = 29; 17 export const MINI_APP_TYPE = 29;
16 export const MINI_QR_TYPE = 16; 18 export const MINI_QR_TYPE = 16;
  1 +import Promise from '../vendors/es6-promise';
  2 +import {APP_VERSION, ICONFIG_HOST} from '../libs/config';
  3 +import {encrypt, decrypt} from '../utils/icfg-aes';
  4 +import {stringify} from '../vendors/query-string';
  5 +
  6 +let iconfSwitch = function (app) {
  7 + let data = {};
  8 + let device = app.globalData.systemInfo;
  9 +
  10 + data.app_ver = APP_VERSION;
  11 + data.uid = app.getUid() || '';
  12 + data.os = device.platform.indexOf('ios') > -1 ? 0 : 1;
  13 + data.osv = device.osv || device.version;
  14 + data.model = device.model;
  15 + data.udid = app.globalData.udid ? app.globalData.udid : '';
  16 + data.patchv = '';
  17 + data.ci = (app.getUnion_type() ? app.getUnion_type() : app.globalData.ch) || '';
  18 +
  19 + return new Promise(function (resolve, reject) {
  20 + wx.request({
  21 + url: `${ICONFIG_HOST}?${encrypt(stringify(data))}`,
  22 + success({data} = {}) {
  23 + resolve(JSON.parse(decrypt(data)));
  24 + },
  25 + fail(err) {
  26 + reject(err);
  27 + }
  28 + });
  29 + })
  30 +
  31 +};
  32 +
  33 +export default iconfSwitch;