Authored by yyq

Merge branch 'develop' of git.yoho.cn:fe/xianyu-ufo-app-web into develop

... ... @@ -63,7 +63,7 @@ export default {
name: name[0],
subName: name[1],
price,
store_id: info.storage_id,
storage_id: info.storage_id,
available: info.storage_num > 0 && price !== '-',
};
});
... ...
... ... @@ -100,7 +100,7 @@ export default {
name: name[0],
subName: name[1],
price,
store_id: info.storage_id,
storage_id: info.storage_id,
available: info.storage_num > 0 && price !== '-',
};
},
... ... @@ -111,6 +111,7 @@ export default {
size_id: info.id,
name: name[0],
subName: name[1],
storage_id: info.storage_id,
available: info.text !== '-',
};
},
... ...
... ... @@ -2,5 +2,9 @@ export default [{
name: 'ProductDetail',
path: '/xianyu/product/:productId.html',
component: () => import(/* webpackChunkName: "product" */ './product-detail'),
props: true,
props({params}) {
return {
productId: parseInt(params.productId, 10),
};
},
}];
... ...
... ... @@ -62,6 +62,9 @@
<img class="ref-img" v-lazy="prdDetailTip"/>
</div>
<img class="ref-img" v-lazy="prdDetailImage" />
<div class="recommend" v-if="recommend"><h2>相关推荐</h2>
<product-list :list="recommend" />
</div>
</cube-scroll>
</div>
<div class="footer">
... ... @@ -88,6 +91,7 @@ import { createNamespacedHelpers } from 'vuex';
import ImgSize from '../../components/img-size';
import { getImgUrl } from '../../common/utils';
import ProductList from '../list/components/productList';
import ActivityListSheet from './components/activity-list-sheet';
import prdDetailTip from '../../statics/image/product/prdDetailTip.png';
... ... @@ -106,6 +110,7 @@ export default {
SizeRequestSheet,
BuySheet,
ImgSize,
ProductList,
'cube-button': Button,
'cube-slide': Slide,
'cube-slide-item': Slide.Item,
... ... @@ -130,7 +135,7 @@ export default {
};
},
computed: {
...mapGetters(['productDetail', 'imageList', 'resource', 'activity']),
...mapGetters(['productDetail', 'imageList', 'resource', 'activity', 'recommend']),
productDec() {
const goods = get(this.productDetail, 'goods_list[0]', {});
... ... @@ -184,10 +189,10 @@ export default {
time: 0,
});
},
loadData(id, loading) {
loadData(productId = this.productId, loading) {
loading && loading.show();
this.fetchProductInfo({productId: this.productId}).then(() => {
return this.fetchProductInfo({productId}).then(() => {
loading && loading.hide();
}).catch(() => {
loading && loading.hide();
... ... @@ -288,7 +293,7 @@ export default {
}
.banner-title {
font-family: PingFang-SC-Light;
/* font-family: PingFang-SC-Light; */
border: 1px solid #000;
font-size: 30px;
line-height: 100px;
... ... @@ -344,14 +349,14 @@ export default {
}
&-name {
font-family: PingFang-SC-Regular;
/* font-family: PingFang-SC-Regular; */
font-size: 28px;
color: #999;
letter-spacing: 0;
}
&-value {
font-family: SFProText-Medium;
/* font-family: SFProText-Medium; */
font-size: 28px;
color: #000;
letter-spacing: 0;
... ... @@ -378,6 +383,7 @@ export default {
flex-basis: auto;
border-top: 1px solid $primary-color;
line-height: 60px;
font-size: 28px;
}
.sell {
... ... @@ -397,4 +403,13 @@ export default {
}
}
}
.recommend {
h2 {
font-size: 40px;
line-height: 56px;
padding: 32px 0;
text-align: center;
}
}
</style>
... ...
... ... @@ -30,7 +30,7 @@ export default {
},
async updateTradeInfo({commit, state}, {productId, sizeInfo, tradeTypeInfo}) {
if (sizeInfo) {
commit(Types.UPDATE_SELECTED_RPODUCT_SIZE, {productId, sizeId: sizeInfo.size_id});
commit(Types.UPDATE_SELECTED_RPODUCT_SIZE, {productId, sizeId: sizeInfo.size_id});
}
if (tradeTypeInfo) {
... ... @@ -40,19 +40,20 @@ export default {
return {
productId,
sizeId: state.selectedProductInfo.sizeId,
storageId: state.selectedProductInfo.storageId,
tradeTypeId: state.selectedProductInfo.tradeTypeId,
};
},
async getSelectedTradeProduct({state, commit, dispatch}, {productId, sizeId, tradeTypeId}) {
async getSelectedTradeProduct({state, commit, dispatch}, {productId, storageId, tradeTypeId}) {
productId = parseInt(productId, 10);
sizeId = parseInt(sizeId, 10);
storageId = parseInt(storageId, 10);
tradeTypeId = parseInt(tradeTypeId, 10);
if (!(state.selectedProductInfo && state.selectedProductInfo.productId == productId ||
if (!(state.selectedProductInfo && state.selectedProductInfo.productId === productId ||
state.products.byId[productId])) {
await dispatch('fetchProductInfo', {productId});
}
commit(Types.UPDATE_SELECTED_RPODUCT_SIZE, {productId, sizeId});
commit(Types.UPDATE_SELECTED_RPODUCT_SIZE, {productId, storageId});
commit(Types.UPDATE_SELECTED_TRADE_TYPE, {productId, tradeTypeId});
return state.selectedProductInfo;
... ...
... ... @@ -24,6 +24,7 @@ export default function() {
productId: null,
product: {},
sizeId: null,
storageId: null,
size: {},
tradeTypeId: null,
tradeType: {},
... ... @@ -44,6 +45,15 @@ export default function() {
activity(state, getters) {
return get(getters.productDetail, 'activity', []);
},
recommend(state, getters) {
const list = get(getters.productDetail, 'recommend', []);
if (list && list.length !== 0) {
return list;
}
return null;
},
selectedSize(state) {
return state.selectedProductInfo.size;
}
... ...
... ... @@ -7,6 +7,7 @@ function ensureSelectedProduct(state, productId) {
productId,
product: state.products.byId[productId],
sizeId: null,
storageId: null,
size: {},
tradeTypeId: null,
tradeType: {}
... ... @@ -26,12 +27,22 @@ export default {
state.products.byId[productId].isFav = isFav;
}
},
[Types.UPDATE_SELECTED_RPODUCT_SIZE](state, { productId, sizeId}) {
[Types.UPDATE_SELECTED_RPODUCT_SIZE](state, { productId, sizeId, storageId}) {
ensureSelectedProduct(state, productId);
state.selectedProductInfo.sizeId = sizeId;
const sizeList = get(state.selectedProductInfo.product, 'goods_list[0].size_list', []);
state.selectedProductInfo.size = find(sizeList, (size) => size.size_id === sizeId) || {};
let sizeInfo;
if (storageId) {
sizeInfo = find(sizeList, (size) => size.storage_id === storageId) || {};
} else {
sizeInfo = find(sizeList, (size) => size.size_id === sizeId) || {};
}
state.selectedProductInfo.sizeId = sizeInfo.size_id;
state.selectedProductInfo.storageId = sizeInfo.storage_id;
state.selectedProductInfo.size = sizeInfo;
},
[Types.UPDATE_SELECTED_TRADE_TYPE](state, { productId, tradeTypeId}) {
ensureSelectedProduct(state, productId);
... ...
... ... @@ -4,4 +4,3 @@ export const UPDATE_SELECTED_RPODUCT_SIZE = 'UPDATE_SELECTED_RPODUCT_SIZE';
export const UPDATE_SELECTED_TRADE_TYPE = 'UPDATE_SELECTED_TRADE_TYPE';
export const PRODUCT_REQUEST_SIZE = 'PRODUCT_REQUEST_SIZE';
... ...
... ... @@ -3,7 +3,7 @@ module.exports = {
'/api/ufo/product': {
ufo: true,
auth: false,
api: 'ufo.product.data2',
api: 'ufo.product.data3',
params: {
product_id: {type: Number}, // 商品id
},
... ...