Authored by 李靖

唤起app

... ... @@ -94,6 +94,17 @@ exports.modify = (req, res, next) => {
}).catch(next);
};
exports.getCity = (req, res, next) => {
let params = {
uid: req.user.uid,
id: req.query.id
};
req.ctx(family).getCity(params).then((result) => {
res.json(result);
}).catch(next);
};
exports.coinMall = (req, res) => {
let responseData = {
module: 'home',
... ...
... ... @@ -509,11 +509,42 @@ class familyModel extends global.yoho.BaseModel {
};
return this.get(options).then(result => {
console.log(result);
return result;
});
}
getCity(params) {
let options = {
data: {
method: 'app.address.provinces',
uid: params.uid,
id: params.id
},
param: {
code: 200
}
};
return this.get(options).then(result => {
let resu = {
cityList: []
};
if (_.get(result, 'data')) {
let build = [];
_.forEach(result.data, val => {
build.push({
cityId: val.id,
cityName: val.caption
});
});
resu.cityList = build;
}
return resu;
});
}
checkType(params) {
switch (params) {
case 1:
... ...
... ... @@ -182,6 +182,7 @@ router.get('/family/vipDetailData', auth, family.familyVip); // 获取VIP信息
router.get('/family/coinDetail', auth, family.coinDetail); // 积分详情页
router.get('/family/coinDetail/getCoinData', auth, family.getCoinData); // 筛选积分详情
router.get('/family/userInfo', auth, disableBFCache, family.userInfo); // family个人信息页
router.get('/family/userInfo/getCity', auth, family.getCity); // family个人信息页-获取城市
router.get('/family/coinMall', auth, family.coinMall); // 积分商城
router.get('/family/modify', auth, family.modify); // family修改个人信息页
module.exports = router;
... ...
... ... @@ -33,7 +33,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohoefashion4In1://yoho.cn/">兑换</a>
</div>
</div>
</div>
... ... @@ -56,7 +56,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohoefashion4In1://yoho.cn/">兑换</a>
</div>
</div>
</div>
... ... @@ -79,7 +79,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohoefashion4In1://yoho.cn/">兑换</a>
</div>
</div>
</div>
... ... @@ -106,7 +106,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohomars://yohomars.com/goapp?openby:mars=">兑换</a>
</div>
</div>
</div>
... ... @@ -129,7 +129,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohomars://yohomars.com/goapp?openby:mars=">兑换</a>
</div>
</div>
</div>
... ... @@ -152,7 +152,7 @@
<div class="remain">仅剩50份</div>
</div>
<div class="right">
<a class="go-btn">兑换</a>
<a class="go-btn" href="yohomars://yohomars.com/goapp?openby:mars=">兑换</a>
</div>
</div>
</div>
... ...
... ... @@ -113,32 +113,10 @@
</div>
<div class="swiper-list">
<div class="swiper-container">
<div class="swiper-wrapper">
<div id="01" class="swiper-slide">江苏</div>
<div id="02" class="swiper-slide">浙江</div>
<div id="03" class="swiper-slide">安徽</div>
<div id="04" class="swiper-slide">福建</div>
<div id="05" class="swiper-slide">广东</div>
<div id="06" class="swiper-slide">广西</div>
<div id="07" class="swiper-slide">云南</div>
<div id="09" class="swiper-slide">内蒙古</div>
<div id="010" class="swiper-slide">黑龙江</div>
<div id="011" class="swiper-slide">新疆维吾尔自治区</div>
</div>
<div class="swiper-wrapper" id="province"></div>
</div>
<div class="swiper-container">
<div class="swiper-wrapper">
<div id="11" class="swiper-slide">南京</div>
<div id="12" class="swiper-slide">苏州</div>
<div id="13" class="swiper-slide">无锡</div>
<div id="14" class="swiper-slide">常州</div>
<div id="15" class="swiper-slide">宿迁</div>
<div id="16" class="swiper-slide">徐州</div>
<div id="17" class="swiper-slide">盐城</div>
<div id="18" class="swiper-slide">南通</div>
<div id="19" class="swiper-slide">扬州</div>
<div id="110" class="swiper-slide">连云港</div>
</div>
<div class="swiper-wrapper" id="city"></div>
</div>
<div class="swiper-line"></div>
</div>
... ...
{{#cityList}}
<div id="{{cityId}}" class="swiper-slide">{{cityName}}</div>
{{/cityList}}
... ...
... ... @@ -4,6 +4,7 @@ import CitySwiper from './family/city-swiper';
import $ from 'yoho-jquery';
import Page from 'yoho-page';
import tip from 'plugin/tip';
import cityRender from 'home/chosen-city.hbs';
class UserInfo extends Page {
constructor() {
... ... @@ -18,16 +19,31 @@ class UserInfo extends Page {
$birthday: $('.inp.birthday'),
$height: $('.inp.height'),
$weight: $('.inp.weight'),
$userAvatar: $('.user-avatar')
$userAvatar: $('.user-avatar'),
$province: $('#province'),
$city: $('#city'),
$cancelBtn: $('.swiper-header .cancel'),
$okBtn: $('.swiper-header .ok')
};
this.view = {
cityRender
};
this.init();
this.CityId = 0;
}
init() {
this.bindEvents();
this.on('citySwiperCb', (event, data) => { // 返回选中的slide对象
console.log(data);
let $data = $(data);
let $parent = $data.parents('.swiper-wrapper');
if (($parent.attr('id') === 'province')) { // 当滑动省份列表时出发城市列表
this.CityId = $data.attr('id');
this.getCity();
}
});
this.defaultPic();
}
... ... @@ -35,6 +51,21 @@ class UserInfo extends Page {
bindEvents() {
this.selector.$chosenCity.on('click', this.chosenCity.bind(this));
this.selector.$modifyInp.on('blur', this.modifyInp.bind(this));
this.selector.$cancelBtn.on('click', this.cancelFun.bind(this));
this.selector.$okBtn.on('click', this.okFun.bind(this));
}
cancelFun() {
this.selector.$citySwiper.hide();
}
okFun() {
let $provinceActive = $('#province .swiper-slide-active');
let $cityActive = $('#city .swiper-slide-active');
let $chosenCityText = `${$provinceActive.text()} ${$cityActive.text()}`;
this.selector.$chosenCity.find('.inp').text($chosenCityText);
this.selector.$citySwiper.hide();
}
defaultPic() {
... ... @@ -70,12 +101,31 @@ class UserInfo extends Page {
}
chosenCity() {
this.getCity();
this.selector.$citySwiper.show();
new CitySwiper({
swiperNum: 2, // swiper列数
lineNum: 5, // 每列行数
centeredSlides: true, // 剧中显示
hidePartingLine: false // 隐藏两条分割线
}
getCity() {
this.ajax({
url: '/home/family/userInfo/getCity',
data: {
id: this.CityId
}
}).then(result => {
if (this.CityId === 0) {
this.selector.$province.append(this.view.cityRender(result));
new CitySwiper({
swiperNum: 2, // swiper列数
lineNum: 5, // 每列行数
centeredSlides: true, // 剧中显示
hidePartingLine: false // 隐藏两条分割线
});
} else {
this.selector.$city.empty();
this.selector.$city.append(this.view.cityRender(result));
}
}).catch(error => {
console.error(error);
});
}
}
... ...
... ... @@ -43,6 +43,9 @@ class CitySwiper extends Page {
slidesPerView: data.lineNum || 1,
centeredSlides: data.centeredSlides,
loop: data.true,
observer: true,
observeParents: true,
slideToClickedSlide: true,
onInit: (swiper) => {
$thisSwiper = swiper.activeIndex;
$thisSwiper = $(swiper.slides[`${$thisSwiper}`]);
... ...