Authored by zhangxiaoru

取下载弹窗的资源码

... ... @@ -39,14 +39,7 @@ exports.familyVip = (req, res, next) => {
};
exports.downLoadData = (req, res, next) => {
let params = {
yohoCode: '940a47540078396366bcb8b64b1ed0e7',
nowCode: 'ac12681cc68993fcfd20e40536a2aed2',
marsCode: '9f48cba22034cda2df8493ec9187797e',
coffeeCode: '357cae962a4e1a99d8f156850ad5dc78',
littleCode: 'ab1cbfb5b33d4e174ddb7ec49f734968',
greenCode: 'c2778fe64439251b67ffd1338fe982fb',
};
let params = req.query.codeArr;
req.ctx(family).downLoadData(params).then(result => {
res.json(result);
... ...
... ... @@ -57,6 +57,30 @@ class familyModel extends global.yoho.BaseModel {
cache: true
}).then(result => {
if (result && result.code === 200 && result.data) {
return resourcesProcess(result.data);
} else {
return result;
}
});
}
/**
* 资源位
*/
_getdownPop(param) {
return service.get('operations/api/v5/resource/get', {
content_code: param.code,
}, {
code: 200,
cache: true
}).then(result => {
if (result && result.code === 200 && result.data) {
_.forEach(result.data, function(val) {
val.appName = param.name;
});
return resourcesProcess(result.data);
} else {
return result;
... ... @@ -296,12 +320,12 @@ class familyModel extends global.yoho.BaseModel {
/**
* 下载弹窗数据处理
*/
_downLoadProce(data, name) {
_downLoadProce(data) {
let singleData;
_.forEach(data, function(val) {
singleData = _.assign(singleData, {
appName: name,
appName: val.appName,
imgList: val.data
});
});
... ... @@ -313,41 +337,17 @@ class familyModel extends global.yoho.BaseModel {
* 下载弹窗信息
*/
downLoadData(params) {
return Promise.all([
this._getTrendPop(params.yohoCode),
this._getTrendPop(params.nowCode),
this._getTrendPop(params.marsCode),
this._getTrendPop(params.coffeeCode),
this._getTrendPop(params.littleCode),
this._getTrendPop(params.greenCode)
]).then((result) => {
return Promise.map(params, (val) => {
return this._getdownPop(val);
}).then((result) => {
let finData = {
downLoadData: []
};
if (result[0]) {
finData.downLoadData.push(this._downLoadProce(result[0], 'yohobuy'));
}
if (result[1]) {
finData.downLoadData.push(this._downLoadProce(result[1], 'now'));
}
if (result[2]) {
finData.downLoadData.push(this._downLoadProce(result[2], 'mars'));
}
if (result[3]) {
finData.downLoadData.push(this._downLoadProce(result[3], 'coffee'));
}
if (result[4]) {
finData.downLoadData.push(this._downLoadProce(result[4], 'little'));
}
if (result[5]) {
finData.downLoadData.push(this._downLoadProce(result[5], 'green'));
}
_.forEach(result, (val) => {
finData.downLoadData.push(this._downLoadProce(val));
});
return finData;
});
... ... @@ -373,7 +373,7 @@ class familyModel extends global.yoho.BaseModel {
list.push({
value: data.num,
name: data.source,
percent: data.proportion,
percent: parseInt(data.proportion, 10) * 100 + '%',
color: data.colour
});
... ...
This diff could not be displayed because it is too large.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(0);
/***/ })
/******/ ]);
\ No newline at end of file
... ... @@ -176,9 +176,21 @@ class FamilyIndex extends Page {
// 下载弹窗初始页面渲染
downLoadInfo() {
let codeArr = [];
$('.content-item').each(function() {
codeArr.push({
name: $(this).data('name'),
code: $(this).data('code')
});
});
this.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/home/family/downLoadData'
url: location.protocol + '//m.yohobuy.com/home/family/downLoadData',
data: {
codeArr: codeArr
}
}).then(result => {
$('.yoho-family-page').append(this.view.downLoadInfo(result));
... ...
... ... @@ -288,7 +288,6 @@
float: right;
color: #b0b0b0;
width: 50px;
margin-left: 77px;
}
}
... ...