Authored by 陈峰

merge

... ... @@ -64,6 +64,8 @@ const component = {
product.formatPrice = product.format_sales_price !== '0' ? product.format_sales_price : product.format_market_price;//eslint-disable-line
product.isDiscount = product.market_price > product.sales_price;
product.coverImage = product.goods_list[0].color_image;
res.render('pdetail', {
module: 'product',
page: 'detail',
... ...
... ... @@ -83,7 +83,7 @@ const model = {
* 判断是否收藏
* @param params
*/
isFavorite(params){
isFavorite(params) {
return api.get('/favorite', Object.assign({
method: 'app.favorite.isFavoriteNew'
}, params));
... ...
... ... @@ -4,15 +4,11 @@
<div class="ssr show-box first-box">
<div class="image-swipe">
<div class="swipe-wrap">
<div class="swiper-container swiper-container-horizontal">
<div class="ssr-swiper-container">
<div class="swiper-wrapper">
{{#each goods_list}}
{{#if color_image}}
<div class="swiper-slide" style="width: 300px;" data-swiper-slide-index="0">
<img width="100%" src="{{image2 color_image w=580 h=770 q=80}}/interlace/1">
<div class="ssr-swiper">
<img width="100%" src="{{image2 coverImage w=580 h=770 q=80}}/interlace/1">
</div>
{{/if}}
{{/each}}
</div>
</div>
</div>
... ...
... ... @@ -20,7 +20,7 @@ yoho.ready(() => {
if (ssrs) {
ssrs.remove();
}
}, 500);
}, 100);
}
});
});
... ...
... ... @@ -283,6 +283,23 @@ const yoho = {
},
/**
* 频道跳转
* @param args {""}
* @param success
* @param fail
*/
goChannel(args, success, fail) {
if (this.isApp && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'go.channel',
arguments: args
});
} else {
tip(tipInfo);
}
},
/**
* 分享
* @param args {"title":"标题","des":"描述","img":"icon地址","url":"网页地址"}
* @param success
... ...
... ... @@ -39,11 +39,18 @@ export default {
return {
chosenVal: '',
show: false,
chosen: {},
chosen: [],
choiceName: '品牌',
showMore: false,
allChoices: [],
initialChoices: []
initialChoices: [],
gsFilter: null,
secondSort: []
}
},
computed: {
isGs() {
return typeMap[this.name] === 'group_sort';
}
},
methods: {
... ... @@ -56,15 +63,54 @@ export default {
bus.$emit('expand.choice.only', this.name);
},
toggleChoice(index, choice) {
choice.isChosen = !choice.isChosen;
let change;
this.isGs && this.delSecondSort();
if (this.isGs) {
change = {
isChosen: !choice.isChosen,
category_name: choice.category_name,
relation_parameter: choice.relation_parameter
};
} else {
change = {
id: choice.id,
name: choice.name,
isChosen: !choice.isChosen
};
}
this.allChoices.splice(index, 1, change);
if (!change.isChosen) {
let id1, id2;
!choice.isChosen && (delete this.chosen[index]);
choice.isChosen && (this.chosen[index] = choice);
_.each(this.chosen, (ch, idx) => {
id1 = this.isGs ? ch.relation_parameter.sort : ch.id;
id2 = this.isGs ? choice.relation_parameter.sort : choice.id;
if (id1 === id2) {
this.chosen.splice(idx, 1);
return false;
}
});
} else {
this.chosen.push(change);
}
this.calcChosenVal();
this.calcChosenStr();
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
},
calcChosenVal() {
delSecondSort(){
if (this.chosen.length && this.secondSort.length) { // 选择三级分类时排除所有二级分类
_.each(this.chosen, (item, index) => {
if (this.secondSort.indexOf(item.relation_parameter.sort.replace(/,$/, '')) > -1) {
this.chosen.splice(index, 1);
}
});
this.calcChosenStr();
}
},
calcChosenStr(){
let name;
let names = [];
let keys = Object.keys(this.chosen);
... ... @@ -96,10 +142,10 @@ export default {
},
clearChosenVal(){
this.show = false;
this.chosen = {};
this.chosen = [];
this.chosenVal = '';
this.allChoices = this.initialChoices.slice();
bus.$emit('subChosen.change', this.name, this.chosen);
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
},
searchChosenVal() {
this.show = false;
... ... @@ -107,29 +153,78 @@ export default {
foldExcept(name) {
this.show = this.name === name;
},
subFilterChange(sub) {
subFilterChange(sub, filter){
if (typeMap[this.name] === sub.subType) {
let names = [];
const len = sub.value.length;
if (sub.value && sub.value.length) {
this.allChoices = this.initialChoices.slice();
if (!len) {
this.chosen = [];
this.chosenVal = '';
} else {
const gs = sub.subType === 'group_sort';
_.each(sub.value, item => {
// 所有品类信息
// 用于选择三级分类的时候清除非三级分类
if (gs && !this.gsFilter) {
this.calcSecondSort(filter);
}
this.chosen = [];
this.allChoices = this.initialChoices.slice();
_.each(sub.value, (item, index) => {
names.push(item.name);
_.each(this.allChoices, (choice, index) => {
const isSort = this.name === '品类';
const id = isSort ? choice.category_id : choice.id;
const id = gs ?
choice.relation_parameter.sort :
choice.id;
if (item.id === id) {
choice.isChosen = !choice.isChosen;
this.chosen[index] = choice;
let chosen = {};
if (gs) {
chosen = {
isChosen: true,
category_name: item.name,
relation_parameter: choice.relation_parameter
};
} else {
chosen = {
id: choice.id,
name: choice.name,
isChosen: true
};
}
this.allChoices.splice(index, 1, chosen);
}
});
if (gs) {
item.relation_parameter = {
sort: item.id
};
item.category_name = item.name;
}
this.chosen.push(item);
});
this.show = false;
this.chosenVal = names.join(',');
}
this.show = false;
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
}
},
calcSecondSort(filter){
_.each(filter, item => {
let idArr = [];
_.each(item.sub, subItm => {
idArr.push(subItm.relation_parameter.sort);
});
this.secondSort.push(idArr.join(','));
});
}
},
created(){
... ...
... ... @@ -233,23 +233,27 @@ export default {
this.$refs.filterSub.isVisible = true;
},
subFilterChange(sub){
bus.$emit('subFilter.change', sub);
let filter = {};
if (sub.subType === 'group_sort') {
filter = this.filter['group_sort'];
}
bus.$emit('subFilter.change', sub, filter);
},
subChosenChange(name, chosen) {
let keyArr = Object.keys(chosen);
if (keyArr.length) {
if (chosen.length) {
let id, nm;
this.values[name] = [];
_.each(keyArr, key => {
_.each(chosen, item => {
id = name !== 'group_sort' ?
chosen[key].id :
chosen[key].relation_parameter.sort;
item.id :
item.relation_parameter.sort;
nm = name !== 'group_sort' ?
chosen[key].name :
chosen[key].category_name;
item.name :
item.category_name;
this.values[name].push({
id,
... ...
... ... @@ -14,7 +14,7 @@
<div class="my-header unlisted" v-else>
<span class="auth username">登录/注册</span>
</div>
<div class="change-channel" @click="isShowChannel = true">
<div class="change-channel" @click="goChannel">
<span class="label">切换购物频道</span>
<span class="channel">{{curChannel}}<span class="icon icon-right"></span></span>
</div>
... ... @@ -36,13 +36,6 @@
</div>
<div class="my-order">
<!--<a class="order-title auth" href="/me/order?type=1">
我的订单
<span class="read-order">
查看全部订单 <span class="icon icon-right"></span>
</span>
</a>-->
<div class="order-type clearfix">
<a class="type-item auth" href="/me/order?type=2">
<span class="icon icon-card"></span>
... ... @@ -164,6 +157,10 @@
channel_id: data
});
},
goChannel() {
yoho.goChannel();
return false;
},
goTel() {
yoho.goTel({
tel: '400-889-9646'
... ... @@ -345,8 +342,6 @@
.my-header {
height: 260px;
/* background: resolve("me/header-bg.png"); */
background: #fff;
background-size: cover;
padding: 0 30px;
... ... @@ -368,8 +363,6 @@
height: 170px;
border-radius: 50%;
margin: 0 auto;
/* border: 3px solid #b0b0b0; */
background: resolve("me/user-icon.png");
background-size: 100%;
vertical-align: middle;
... ... @@ -539,7 +532,7 @@
font-size: 34px;
line-height: 72px;
color: #fff;
background: #ff081c;
background: #000;
text-align: center;
border-radius: 50%;
transform: scale(0.5);
... ... @@ -596,8 +589,6 @@
}
.tel {
/* padding-right: 10px; */
.icon-right {
margin-left: 10px;
}
... ...
... ... @@ -111,6 +111,28 @@
};
</script>
<style>
#ssr {
.ssr-swiper-container {
background-color: #f7f7f7;
}
.ssr-swiper {
width: 620px;
padding: 0 20px;
background-color: #fff;
transform: translateX(590px);
font-size: 0;
img {
width: 580px;
height: 770px;
}
}
}
.image-swipe {
overflow: hidden;
... ...
... ... @@ -3,6 +3,7 @@
<cheader title="新品抢先看"></cheader>
<filter-box :val="order" :filter="filterConfig" v-if="enableOrder"></filter-box>
<product-list :data="productList" :state="listState" class="list-items"></product-list>
<shopping-bag :cart-count="cartCount" v-if="isApp"></shopping-bag>
</div>
</template>
<script>
... ... @@ -16,6 +17,7 @@
import lazyload from 'vue-lazyload';
import infinitScroll from 'vue-infinite-scroll';
import ProductList from 'component/product/list.vue';
import shoppingBag from 'component/product/shopping-bag.vue';
import FilterBox from 'component/product/filter/index.vue';
let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
... ... @@ -27,6 +29,7 @@
export default {
data: function() {
return {
isApp: yoho.isApp,
isiOS: yoho.isiOS,
sortName: locationQuery.sort_name,
filterConfig: null,
... ... @@ -43,7 +46,8 @@
// state
inSearching: false, // 请求中
enableOrder: false,
order: ''
order: '',
cartCount: 0
};
},
computed: {
... ... @@ -68,7 +72,8 @@
components: {
cheader,
ProductList,
FilterBox
FilterBox,
shoppingBag
},
methods: {
search() {
... ... @@ -120,6 +125,14 @@
this.page = 0;
this.productList = [];
this.search();
},
refreshCart: function() {
$.get('/product/cart-count.json').then(result=> {
if (result.code === 200) {
this.cartCount = result.data.cart_goods_count;
}
});
}
},
watch: {
... ... @@ -146,6 +159,11 @@
self.filter = val;
});
// 读取购物车数量
if (this.isApp) {
this.refreshCart();
}
this.search();
}
};
... ...