Authored by zhangxiaoru

首页资源位 潮流口令滚动

Showing 34 changed files with 464 additions and 26 deletions
... ... @@ -5,8 +5,10 @@ const family = require('../models/family');
exports.familyIndex = (req, res, next) => {
let uid = req.user.uid;
let contentCodeOne = '486e6adc7c83001b2e9e83996438fab8';
let contentCodeTwo = 'eebbcc60607ac443922d8fabe44eb222';
req.ctx(family).familyIndex(uid).then(result => {
req.ctx(family).familyIndex(uid, contentCodeOne, contentCodeTwo).then(result => {
res.render('family/index', {
page: 'family',
title: 'family',
... ...
... ... @@ -4,6 +4,8 @@ const _ = require('lodash');
const moment = require('moment');
const camelCase = global.yoho.camelCase;
const api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const resourcesProcess = require(`${utils}/resources-process`);
class familyModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -43,6 +45,24 @@ class familyModel extends global.yoho.BaseModel {
}
/**
* 资源位
*/
_getTrendPop(contentCode) {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
}, {
code: 200,
cache: true
}).then(result => {
if (result && result.code === 200 && result.data) {
return resourcesProcess(result.data);
} else {
return result;
}
});
}
/**
* 列表排序
*/
_sourceSort(source) {
... ... @@ -353,11 +373,13 @@ class familyModel extends global.yoho.BaseModel {
});
}
familyIndex(uid) {
familyIndex(uid, contentCodeOne, contentCodeTwo) {
return Promise.all([
this._userData(uid),
this._getCode(uid),
this._getAppList()
this._getAppList(),
this._getTrendPop(contentCodeOne),
this._getTrendPop(contentCodeTwo)
]).then((result) => {
let familyIndexData = {};
... ... @@ -365,7 +387,7 @@ class familyModel extends global.yoho.BaseModel {
familyIndexData = _.assign(familyIndexData, {
head_ico: result[0].data.head_ico,
nickname: result[0].data.nickname,
gender: result[0].data.gender,
gender: parseInt(result[0].data.gender, 10),
birthday: result[0].data.birthday ? moment(result[0].data.birthday).format('MM-DD') : ''
});
}
... ... @@ -378,9 +400,13 @@ class familyModel extends global.yoho.BaseModel {
familyIndexData.appList = result[2];
}
// if (result[3]) {
// familyIndexData.vipDetail = result[3];
// }
if (result[3]) {
familyIndexData.ownContent = result[3];
}
if (result[4]) {
familyIndexData.townContent = result[4];
}
return familyIndexData;
});
... ...
... ... @@ -6,10 +6,10 @@
<span class="headings"></span>
</div>
<div class="person-detail">
<span class="user-avatar" data-avatar="{{head_ico}}"></span>
<a href="/home/family/userInfo" class="user-avatar" data-avatar="{{head_ico}}"></a>
<div class="basic-info">
<span class="user-name">{{nickname}}</span>
<span class="gender {{#isEqualOr gender 1 }}boy{{/isEqualOr}}{{#isEqualOr gender 2 }}girl{{/isEqualOr}}"></span>
<span class="gender {{#isEqualOr gender 1}}boy{{/isEqualOr}}{{#isEqualOr gender 2}}girl{{/isEqualOr}}"></span>
</div>
<div class="info">
<span class="city">江苏南京</span>
... ... @@ -18,7 +18,11 @@
<div class="invition">
<span class="code trend-code">
{{#if trendWord}}
# {{trendWord}} #
#
<span class="word-outer">
<span class="trend-word">{{trendWord}}</span>
</span>
#
{{else}}
{{inviteCode}}
{{/if}}
... ... @@ -55,11 +59,25 @@
{{! 资源位}}
<div class="rec">
<div class="resource-content">
{{# ownContent}}
<div data-id="{{template_id}}" class="resource-own">
{{> family-res}}
</div>
{{/ ownContent}}
{{# townContent}}
<div data-id="{{template_id}}">
{{> resources/banner}}
{{> family-res}}
</div>
{{/ townContent}}
</div>
</div>
<div class="dia-c"></div>
{{/ familyIndexData}}
</div>
<!-- <div class="down-load-detail yohobuy">
<div class="close"></div>
<div class="back"></div>
<div class="detail-content">
</div>
</div> -->
\ No newline at end of file
... ...
{{#if singleOne}}
{{#data}}
<div class="banner-list">
<a href="{{url}}" id="{{../template_id}}" name="{{../template_intro}}">
<img src="{{image2 src w=750 h=300 q=60 mode=3}}" alt="">
</a>
</div>
{{/data}}
{{else}}
<div class="banner-center banner-center-swiper">
<ul class="banner-list swiper-wrapper clearfix">
{{#data.list}}
<li class="swiper-slide">
<a href="{{url}}" id="{{../template_id}}" name="{{../template_intro}}">
<img src="{{image2 src w=750 h=290 q=60 mode=3}}" alt="">
</a>
</li>
{{/data.list}}
</ul>
<div class="swiper-pagination" {{#unless singleOne}}style="display:block"{{/unless}}>
<div class="pagination-inner">
</div>
</div>
</div>
{{/if}}
\ No newline at end of file
... ...
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
... ...
... ... @@ -20,7 +20,7 @@
</div>
</div>
</div>
<div class="level-process yoho-level clearfix">
<div class="level-process clearfix">
<div class="line-c">
<div class="line"{{#if percent}} style="width:{{percent}}%"{{/if}}></div>
<div class="point">
... ...
... ... @@ -6,6 +6,7 @@ import yoho from 'yoho-app';
import integral from 'home/integral-paradise.hbs';
import vipDetailInfo from 'home/vip-detail.hbs';
const Swiper = require('yoho-swiper2');
const echarts = require('echarts/lib/echarts');
require('echarts/lib/chart/pie');
... ... @@ -26,7 +27,10 @@ class FamilyIndex extends Page {
$integralContent: $('.integral-content'),
$contentItem: $('.content-item'),
$close: $('.close'),
$userName: $('.user-name')
$userName: $('.user-name'),
$trendWord: $('.trend-word'),
$wordOuter: $('.word-outer'),
$bannerCenterSwiper: $('.banner-center-swiper')
};
this.view = {
... ... @@ -44,6 +48,9 @@ class FamilyIndex extends Page {
this.integralCharts();
this.bindEvents();
this.viewVipInfo();
this.initTrend();
this.trendWordMarquee();
this.resources();
}
bindEvents() {
... ... @@ -61,6 +68,42 @@ class FamilyIndex extends Page {
}
}
// 潮流口令滚动
trendWordMarquee() {
let diff = $('.word-outer').scrollLeft() - $('.trend-word').eq(0).width();
$('.word-outer').scrollLeft($('.word-outer').scrollLeft() + 1);
if (diff > 0) {
$('.word-outer').scrollLeft(Math.abs(diff));
}
}
initTrend() {
if (this.selector.$trendWord.eq(0).width() > parseInt(this.selector.$wordOuter.css('max-width'), 10)) {
this.selector.$trendWord.width(this.selector.$trendWord.width() + 40);
this.selector.$wordOuter.append('<span class="trend-word">' + this.selector.$trendWord.html() + '</span>').css({
width: 2 * this.selector.$trendWord.width()
});
this.selector.$trendWord = $('.trend-word');
this.selector.$trendWord.addClass('rem-lin');
setInterval(this.trendWordMarquee, 40);
} else {
this.selector.$trendWord = $('.trend-word');
if (this.selector.$trendWord.length > 1) {
this.selector.$trendWord.eq(1).remove();
}
this.selector.$trendWord.removeClass('rem-lin');
}
}
// 积分乐园图表
integralCharts() {
let integralData = {
... ... @@ -96,6 +139,19 @@ class FamilyIndex extends Page {
});
}
// 资源位初始化
resources() {
if (this.selector.$bannerCenterSwiper.length > 0) {
new Swiper('.banner-center-swiper', {
pagination: '.swiper-pagination',
lazyLoading: true,
lazyLoadingInPrevNext: true,
paginationClickable: true,
autoplay: 3000
});
}
}
// 查看VIP信息
viewVipInfo() {
this.ajax({
... ... @@ -131,7 +187,14 @@ class FamilyIndex extends Page {
if (result.code === 200) {
this.selector.$invition.show();
this.selector.$invitonSet.hide();
this.selector.$invition.find('.trend-code').html('# ' + trendWord + ' #');
this.selector.$invition.find('.trend-word').html(trendWord);
this.selector.$trendWord.css({
width: 'auto'
});
this.selector.$wordOuter.css({
width: 'auto'
});
this.initTrend();
} else {
this.selector.$textarea.focus();
}
... ... @@ -160,6 +223,8 @@ class FamilyIndex extends Page {
this.selector.$diaC.append(this.view.vipDetailInfo(this.vipInfo[appType]));
}
$('.vip-detail').addClass(appType);
if (this.selector.$userAvatar.data('avatar')) {
$('.base .pic').css('background-image', 'url(' + this.selector.$userAvatar.data('avatar') + ')');
}
... ...
@import "layout/swiper";
.yoho-family-page {
background-color: #f0f0f0;
margin-bottom: 40px;
.family-heade {
background: linear-gradient(#46ba8e, #67c7c0);
... ... @@ -117,6 +120,30 @@
.trend-code {
display: inline-block;
vertical-align: top;
line-height: 40px;
.word-outer {
overflow: hidden;
display: inline-block;
overflow: hidden;
vertical-align: top;
height: 40px;
max-width: 156px;
white-space: nowrap;
}
.trend-word {
display: inline-block;
overflow: hidden;
vertical-align: top;
height: 40px;
position: relative;
white-space: nowrap;
}
.rem-lin {
margin-right: -8px;
}
}
.code-set {
... ... @@ -276,6 +303,14 @@
}
}
.resource-content {
overflow: hidden;
.resource-own {
margin-bottom: 20px;
}
}
.vip-detail {
position: fixed;
top: 0;
... ... @@ -445,18 +480,6 @@
line-height: 40px;
}
}
.yoho-level {
padding: 0 30px;
.line-c {
width: 490px;
}
.point-item {
margin-right: 132px;
}
}
}
.privilege-list {
... ... @@ -559,4 +582,50 @@
}
}
}
.yohobuy {
.banner {
background-image: resolve("home/family/vip-detail/yohobuy.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
.user-info {
.level-process {
padding: 0 30px;
.line-c {
width: 490px;
}
.point-item {
margin-right: 132px;
}
}
}
}
.mars {
.banner {
background-image: resolve("home/family/vip-detail/mars.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
}
.yocoffee {
.banner {
background-image: resolve("home/family/vip-detail/yocoffee.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
}
.yogreen {
.banner {
background-image: resolve("home/family/vip-detail/yogreen.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
}
}
... ...
.down-load-detail {
position: fixed;
top: 0;
width: 100%;
height: 100%;
z-index: 5;
.close {
height: 50px;
width: 50px;
background-image: resolve("home/family/close.png");
background-size: 100%;
background-repeat: no-repeat;
position: relative;
top: 80px;
right: -668px;
z-index: 6;
}
.back {
width: 100%;
height: 100%;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: #000;
opacity: 0.5;
}
.detail-content {
width: 630px;
height: auto;
margin-top: 109px;
position: fixed;
top: 0;
left: 50%;
margin-left: -315px;
border-radius: 10px;
.banner-title {
margin: 0 auto;
}
.code {
width: 180px;
height: 180px;
margin: 0 auto;
}
}
.yohobuy {
background-color: red;
.detail-banner {
width: auto;
height: auto;
margin-top: 50px;
margin-bottom: 80px;
.banner-title {
background-image: resolve("home/family/down-load/yohobuy.png");
background-size: 100%;
background-repeat: no-repeat;
width: 380px;
height: 100px;
}
.bannner-subtitle {
border: 1px solid;
width: 330px;
height: 45px;
margin: 10px auto;
}
}
.main-description {
background-image: resolve("home/family/down-load/words.png");
background-size: 100%;
background-repeat: no-repeat;
width: 570px;
height: 360px;
margin: 0 auto;
}
.code {
background-image: resolve("home/family/down-load/erweima_yohobuy.png");
background-size: 100%;
background-repeat: no-repeat;
margin-bottom: 50px;
}
}
.mars {
background-image: resolve("home/family/down-load/mars-bg.png");
background-size: 100%;
background-repeat: no-repeat;
.detail-banner {
margin: 90px auto;
.banner-title {
background-image: resolve("home/family/down-load/mars-title.png");
background-size: 100%;
background-repeat: no-repeat;
width: 270px;
height: 110px;
}
}
.code {
background-image: resolve("home/family/down-load/erweima_mars.png");
background-size: 100%;
background-repeat: no-repeat;
margin-bottom: 90px;
}
}
.coffee {
width: 630px;
height: 600px;
background-color: #fff;
border: 1px solid;
.main-description {
margin-top: 50px;
.showcasing {
width: 670px;
height: 300px;
overflow: hidden;
position: relative;
left: -20px;
.showcasing-item {
margin-right: 20px;
width: 210px;
height: 300px;
border: 1px solid red;
float: left;
}
.showcasing-item:last-child {
margin-right: 0;
}
}
}
}
}
\ No newline at end of file
... ...