Authored by zhangxiaoru

Merge branch 'feature/family' of git.yoho.cn:fe/yohobuywap-node into feature/family

@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 const _ = require('lodash'); 3 const _ = require('lodash');
4 const moment = require('moment'); 4 const moment = require('moment');
5 const camelCase = global.yoho.camelCase; 5 const camelCase = global.yoho.camelCase;
6 -const api = global.yoho.API;  
7 const family = global.yoho.FamilyAPI; 6 const family = global.yoho.FamilyAPI;
8 const service = global.yoho.ServiceAPI; 7 const service = global.yoho.ServiceAPI;
9 const resourcesProcess = require(`${global.utils}/resources-process`); 8 const resourcesProcess = require(`${global.utils}/resources-process`);
@@ -510,9 +509,9 @@ class familyModel extends global.yoho.BaseModel { @@ -510,9 +509,9 @@ class familyModel extends global.yoho.BaseModel {
510 result[0].data.qrcodeLink = helpers.urlFormat('/home/user/qrcode', { 509 result[0].data.qrcodeLink = helpers.urlFormat('/home/user/qrcode', {
511 token: _.get(result[0], 'data.uid', null) ? 510 token: _.get(result[0], 'data.uid', null) ?
512 crypto.encryption('yoho9646yoho9646', _.get(result, 'data.uid', null) + '') : '', 511 crypto.encryption('yoho9646yoho9646', _.get(result, 'data.uid', null) + '') : '',
513 - icon: _.get(result[0], 'data.head_ico', ''),  
514 - uname: _.get(result[0], 'data.nickname', ''),  
515 - vip: _.get(result[0], 'data.vip_info.cur_level') 512 + icon: _.get(result[0], 'data.headIco', ''),
  513 + uname: _.get(result[0], 'data.nickName', ''),
  514 + vip: 0 // 从family进入二维码,暂时显示0
516 }); 515 });
517 resu = camelCase(result[0].data); 516 resu = camelCase(result[0].data);
518 } 517 }
@@ -548,6 +547,7 @@ class familyModel extends global.yoho.BaseModel { @@ -548,6 +547,7 @@ class familyModel extends global.yoho.BaseModel {
548 id: params.id 547 id: params.id
549 }, 548 },
550 param: { 549 param: {
  550 + cache: true,
551 code: 200 551 code: 200
552 } 552 }
553 }; 553 };
@@ -114,10 +114,10 @@ @@ -114,10 +114,10 @@
114 <div class="ok">完成</div> 114 <div class="ok">完成</div>
115 </div> 115 </div>
116 <div class="swiper-list"> 116 <div class="swiper-list">
117 - <div class="swiper-container"> 117 + <div class="swiper-container" id="province-c">
118 <div class="swiper-wrapper" id="province"></div> 118 <div class="swiper-wrapper" id="province"></div>
119 </div> 119 </div>
120 - <div class="swiper-container"> 120 + <div class="swiper-container" id="city-c">
121 <div class="swiper-wrapper" id="city"></div> 121 <div class="swiper-wrapper" id="city"></div>
122 </div> 122 </div>
123 <div class="swiper-line"></div> 123 <div class="swiper-line"></div>
1 import 'home/family-userInfo.page.css'; 1 import 'home/family-userInfo.page.css';
2 import 'home/family/city-swiper.css'; 2 import 'home/family/city-swiper.css';
3 -import CitySwiper from './family/city-swiper'; 3 +import CitySwiper from 'plugin/city-swiper';
4 import $ from 'yoho-jquery'; 4 import $ from 'yoho-jquery';
5 import Page from 'yoho-page'; 5 import Page from 'yoho-page';
6 import tip from 'plugin/tip'; 6 import tip from 'plugin/tip';
@@ -34,10 +34,10 @@ class UserInfo extends Page { @@ -34,10 +34,10 @@ class UserInfo extends Page {
34 cityRender 34 cityRender
35 }; 35 };
36 36
37 - this.init();  
38 this.CityId = 0; 37 this.CityId = 0;
39 this.province = this.selector.$provinceText.text(); 38 this.province = this.selector.$provinceText.text();
40 this.city = this.selector.$cityText.text(); 39 this.city = this.selector.$cityText.text();
  40 + this.init();
41 } 41 }
42 42
43 init() { 43 init() {
@@ -54,6 +54,7 @@ class UserInfo extends Page { @@ -54,6 +54,7 @@ class UserInfo extends Page {
54 } 54 }
55 }); 55 });
56 this.defaultPic(); 56 this.defaultPic();
  57 + this.getCity();
57 } 58 }
58 59
59 bindEvents() { 60 bindEvents() {
@@ -67,9 +68,14 @@ class UserInfo extends Page { @@ -67,9 +68,14 @@ class UserInfo extends Page {
67 68
68 userPic() { 69 userPic() {
69 if (yoho.isApp) { 70 if (yoho.isApp) {
70 - yoho.ready(function() { 71 + yoho.ready(() => {
71 yoho.invokeMethod('go.setAvatar', {}, (data) => { 72 yoho.invokeMethod('go.setAvatar', {}, (data) => {
72 - console.log(data); 73 + if (data) {
  74 + let reg = /(\w*){mode}(.*){width}(.*){height}(.*)/g;
  75 +
  76 + data = data.replace(reg, '$12$2100$3100$4');
  77 + this.selector.$userAvatar.css('background-image', `url(${data})`);
  78 + }
73 }); 79 });
74 }); 80 });
75 } 81 }
@@ -86,8 +92,8 @@ class UserInfo extends Page { @@ -86,8 +92,8 @@ class UserInfo extends Page {
86 92
87 this.province = $provinceActive.text(); 93 this.province = $provinceActive.text();
88 this.city = $cityActive.text(); 94 this.city = $cityActive.text();
89 - $chosenCityText = `<span class="province-text">${this.province}</span>&nbsp;  
90 - <span class="city-text">${this.city}</span>`; 95 + $chosenCityText = `<span class="province-text">
  96 + ${this.province}</span>&nbsp;<span class="city-text">${this.city}</span>`;
91 this.selector.$chosenCity.find('.inp').html($chosenCityText); 97 this.selector.$chosenCity.find('.inp').html($chosenCityText);
92 this.selector.$citySwiper.hide(); 98 this.selector.$citySwiper.hide();
93 } 99 }
@@ -141,7 +147,6 @@ class UserInfo extends Page { @@ -141,7 +147,6 @@ class UserInfo extends Page {
141 if (this.CityId === 0) { 147 if (this.CityId === 0) {
142 this.selector.$province.append(this.view.cityRender(result)); 148 this.selector.$province.append(this.view.cityRender(result));
143 new CitySwiper({ 149 new CitySwiper({
144 - swiperNum: 2, // swiper列数  
145 lineNum: 5, // 每列行数 150 lineNum: 5, // 每列行数
146 centeredSlides: true, // 剧中显示 151 centeredSlides: true, // 剧中显示
147 hidePartingLine: false // 隐藏两条分割线 152 hidePartingLine: false // 隐藏两条分割线
@@ -12,6 +12,8 @@ class CitySwiper extends Page { @@ -12,6 +12,8 @@ class CitySwiper extends Page {
12 $swiperLine: $('.city-swiper .swiper-line'), 12 $swiperLine: $('.city-swiper .swiper-line'),
13 $swiperList: $('.city-swiper .swiper-list') 13 $swiperList: $('.city-swiper .swiper-list')
14 }; 14 };
  15 + this.provinceSwiper = '';
  16 + this.citySwiper = '';
15 this.init(data); 17 this.init(data);
16 } 18 }
17 19
@@ -19,19 +21,17 @@ class CitySwiper extends Page { @@ -19,19 +21,17 @@ class CitySwiper extends Page {
19 let swiperParams = this.swiperParams(data); 21 let swiperParams = this.swiperParams(data);
20 22
21 this.setStyle(data); 23 this.setStyle(data);
22 - new Swiper('.city-swiper .swiper-container', swiperParams); 24 + this.provinceSwiper = new Swiper('.city-swiper #province-c', swiperParams);
  25 + this.citySwiper = new Swiper('.city-swiper #city-c', swiperParams);
23 } 26 }
24 27
25 setStyle(data) { 28 setStyle(data) {
26 - let wWidth = $(window).width();  
27 - let swiperWidth = wWidth / data.swiperNum || 1;  
28 let lineHeight = this.selector.$swiperList.height() / data.lineNum; 29 let lineHeight = this.selector.$swiperList.height() / data.lineNum;
29 let lineTop = lineHeight / 2; 30 let lineTop = lineHeight / 2;
30 31
31 if (data.hidePartingLine) { 32 if (data.hidePartingLine) {
32 this.selector.$swiperLine.hide(); 33 this.selector.$swiperLine.hide();
33 } 34 }
34 - this.selector.$swiper.css('width', `${swiperWidth}px`);  
35 this.selector.$swiperLine.css('height', `${lineHeight}px`); 35 this.selector.$swiperLine.css('height', `${lineHeight}px`);
36 this.selector.$swiperLine.css('margin-top', `-${lineTop}px`); 36 this.selector.$swiperLine.css('margin-top', `-${lineTop}px`);
37 } 37 }
@@ -52,6 +52,9 @@ class CitySwiper extends Page { @@ -52,6 +52,9 @@ class CitySwiper extends Page {
52 this.emit('citySwiperCb', $thisSwiper); 52 this.emit('citySwiperCb', $thisSwiper);
53 }, 53 },
54 onSlideChangeEnd: (swiper) => { 54 onSlideChangeEnd: (swiper) => {
  55 + if ($(swiper.container[0]).index() === 0) {
  56 + this.citySwiper.slideTo(0, 1000, false); // 重选省份时,城市设置为第一个
  57 + }
55 $thisSwiper = swiper.activeIndex; 58 $thisSwiper = swiper.activeIndex;
56 $thisSwiper = $(swiper.slides[`${$thisSwiper}`]); 59 $thisSwiper = $(swiper.slides[`${$thisSwiper}`]);
57 this.emit('citySwiperCb', $thisSwiper); 60 this.emit('citySwiperCb', $thisSwiper);
@@ -72,7 +72,7 @@ let functions = { @@ -72,7 +72,7 @@ let functions = {
72 if (!yoho.isLogin()) { 72 if (!yoho.isLogin()) {
73 let preInfo = `${sku}_${skn}_${buyNum}`; 73 let preInfo = `${sku}_${skn}_${buyNum}`;
74 let actCkOpthn = { 74 let actCkOpthn = {
75 - path: '/', 75 + path: '/product',
76 expires: 1 76 expires: 1
77 }; 77 };
78 78
@@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
35 } 35 }
36 36
37 .swiper-container { 37 .swiper-container {
  38 + width: 50%;
38 height: 360px; 39 height: 360px;
39 float: left; 40 float: left;
40 } 41 }