Authored by baoss

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

... ... @@ -10,8 +10,13 @@ axios.defaults.headers = {
'X-Requested-With': 'XMLHttpRequest'
};
const errHandle = (error) => {
const errHandle = (error, store) => {
console.log(error);
if (error.response && error.response.status == 401) {
store.dispatch('setNeedLogin', { needLogin: true });
}
return Promise.reject({
code: 500,
message: '服务器开小差了~'
... ... @@ -22,7 +27,9 @@ const request = (options, store) => {
return axios(options).then((res) => {
return res.data;
}, errHandle);
}, error => {
return errHandle(error, store)
});
};
export const createApi = (context, store) => {
... ... @@ -32,7 +39,7 @@ export const createApi = (context, store) => {
url,
params,
method: 'get',
}), options, store);
}, options), store);
},
post(url, data, options) {
return request(Object.assign({
... ...
<template>
<div class="father-img" v-if="isEmptyList && showGuide">
<div class="guide-image" @click="guideDismiss"></div>
</div>
<div v-else>
<LayoutApp title="选择地址" :show-back="true" :back-action="goBack">
<CubeScroll class="main-container" ref="scroll" :options="scrollOpts">
<div class="user-list">
... ... @@ -39,6 +43,7 @@
<div class="add-btn" :data-add="1" @click="toEditorPage">新增地址</div>
</CubeScroll>
</LayoutApp>
</div>
</template>
<script>
... ... @@ -67,11 +72,24 @@ export default {
},
pageName: '',
selectedAddressId: '',
query: {}
query: {},
isEmptyList: false,
showGuide: false
};
},
watch: {
addressList() {
if (this.addressList.length === 0) {
this.isEmptyList = true;
this.showGuide = true;
} else {
this.isEmptyList = false;
this.showGuide = false;
}
}
},
computed: {
...mapState(['addressList'])
...mapState(['addressList']),
},
methods: {
...mapMutations(['SET_USER_ADDRESS_INFO', 'STORE_UPDATE_ADDRESS_INFO']),
... ... @@ -83,7 +101,9 @@ export default {
goBack() {
this.$router.go(-1);
},
guideDismiss() {
this.showGuide = false;
},
toEditorPage(event) {
event.stopPropagation();
let isAdd = !!parseInt(event.currentTarget.dataset.add);
... ... @@ -150,6 +170,21 @@ export default {
}
}
.father-img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.guide-image {
width: 100%;
height: 100%;
background: url(~statics/image/address/guide_x@3x.png) no-repeat;
background-size: 100% 100%;
}
.user-list {
background-color: white;
... ...
... ... @@ -61,8 +61,8 @@ export default {
options: {
pullUpLoad: true,
},
scrollEvents: ['scroll','scroll-end'],
title:'闲鱼潮',
scrollEvents: ['scroll', 'scroll-end'],
title: '闲鱼潮',
scrollY: 0,
navTop: 0,
navHeight: 0,
... ... @@ -113,7 +113,7 @@ export default {
noItemStyle() {
return {
height: this.total + 'px'
}
};
}
},
watch: {
... ... @@ -135,6 +135,7 @@ export default {
this.init();
this.PAGE_URL = window.location.href;
// 首页进入上报
this.$store.dispatch('reportYas', {
params: {
... ... @@ -157,9 +158,10 @@ export default {
this.navTop = this.$refs.topSource.offsetHeight;
this.navHeight = get(this.$refs, 'scrollNav.offsetHeight') || 0;
this.total = this.$refs.scroll.$el.offsetHeight - this.navHeight;
this.reportYas()
this.reportYas();
});
},
// 曝光上报
getReportEle(scrollY) {
this.homeYasParams = [];
... ... @@ -168,53 +170,57 @@ export default {
let eleHeight = 0;
let eleTop = 0;
let reportParams = {};
if(item.template_name !== 'guessLike') {
if (item.template_name !== 'guessLike') {
eleHeight = this.$refs[index][0].$el.offsetHeight;
eleTop = this.$refs[index][0].$el.offsetTop;
} else {
eleHeight = this.navHeight;
eleTop = this.navTop;
}
if(scrollY) { // 滚动时
if(scrollHeight + scrollY > eleTop && item.template_name === 'guessLike') {
if (scrollY) { // 滚动时
if (scrollHeight + scrollY > eleTop && item.template_name === 'guessLike') {
// console.log('guessLike report')
item.data.forEach((val, i) => {
reportParams = {...val.reportParams,PAGE_URL: this.PAGE_URL}
this.homeYasParams.push(reportParams)
})
reportParams = {...val.reportParams, PAGE_URL: this.PAGE_URL};
this.homeYasParams.push(reportParams);
});
}
if(scrollY < (eleTop + eleHeight) && item.template_name !== 'guessLike') {
if (scrollY < (eleTop + eleHeight) && item.template_name !== 'guessLike') {
// console.log(item.template_name)
let reportMoreParams = {}
let reportMoreParams = {};
item.data.forEach((val, i) => {
reportParams = {...val.reportParams,PAGE_URL: this.PAGE_URL}
reportParams = {...val.reportParams, PAGE_URL: this.PAGE_URL};
this.homeYasParams.push(reportParams)
if(item.template_name === 'image_list') {
reportMoreParams = Object.assign({},reportParams,{I_INDEX: 0})
this.homeYasParams.push(reportParams);
if (item.template_name === 'image_list') {
reportMoreParams = Object.assign({}, reportParams, {I_INDEX: 0});
}
})
Object.keys(reportMoreParams).length && this.homeYasParams.push(reportMoreParams)
});
Object.keys(reportMoreParams).length && this.homeYasParams.push(reportMoreParams);
}
} else { // 默认进入时
if(eleTop < scrollHeight) { // 获取每个元素距顶部高度 小于可视区高度即曝光
if (eleTop < scrollHeight) { // 获取每个元素距顶部高度 小于可视区高度即曝光
// console.log(item.template_name)
let reportMoreParams = {}
let reportMoreParams = {};
item.data.forEach((val, i) => {
reportParams = {...val.reportParams,PAGE_URL: this.PAGE_URL}
this.homeYasParams.push(reportParams)
if(item.template_name === 'image_list') {
reportMoreParams = Object.assign({},reportParams,{I_INDEX: 0})
reportParams = {...val.reportParams, PAGE_URL: this.PAGE_URL};
this.homeYasParams.push(reportParams);
if (item.template_name === 'image_list') {
reportMoreParams = Object.assign({}, reportParams, {I_INDEX: 0});
}
})
Object.keys(reportMoreParams).length && this.homeYasParams.push(reportMoreParams)
});
Object.keys(reportMoreParams).length && this.homeYasParams.push(reportMoreParams);
}
}
})
});
},
reportYas(scrollY) {
this.getReportEle(scrollY)
this.getReportEle(scrollY);
// console.log(this.homeYasParams)
this.$store.dispatch('reportYas', {
params: {
... ... @@ -224,11 +230,12 @@ export default {
});
},
setYasParam: function(params) {
console.log('setYas')
console.log('setYas');
let {total, list} = this.productList;
if (params && typeof params === 'object' && Object.keys(params).length) {
let P_NAME = 'XY_UFOSearchList', TYPE_ID = 1, P_PARAM = '', PRD_LIST = [];
for (let item of list) {
PRD_LIST.push(item.id);
}
... ... @@ -236,44 +243,46 @@ export default {
if (key === 'brand') {
P_NAME = 'XY_UFOBrandList';
TYPE_ID = 3;
P_PARAM = params[key]
P_PARAM = params[key];
}
if (key === 'series') {
P_NAME = 'XY_UFOSeriesList';
TYPE_ID = 2;
P_PARAM = params[key]
P_PARAM = params[key];
}
if (key === 'productPool') {
P_NAME = 'XY_UFOProductPoolList';
TYPE_ID = 4;
P_PARAM = params[key]
P_PARAM = params[key];
}
}
this.listYasParams = Object.assign({},{
this.listYasParams = Object.assign({}, {
P_NAME,
P_PARAM,
TYPE_ID,
TAB_ID: Number(params.index) + 1,
TAB_NAME: params.title,
PRD_LIST: PRD_LIST.toString(),
TOTAL: total})
TOTAL: total});
// console.log(this.listYasParams)
}
},
getIndex({index,params}) {
getIndex({index, params}) {
this.selectedCategory = params;
this.active = Number(index);
this.isShow && this.$refs.scroll.scrollTo(this.navTop);
this.setYasParam({index,...params});
this.setYasParam({index, ...params});
},
scrollEndHandler({y}) {
let scrollHeight = Math.abs(y)
this.$refs.product && this.$refs.product.yasShowEvent(scrollHeight+this.navTop);
if(scrollHeight >= this.navTop) {
return
let scrollHeight = Math.abs(y);
this.$refs.product && this.$refs.product.yasShowEvent(scrollHeight + this.navTop);
if (scrollHeight >= this.navTop) {
return;
}
this.reportYas(scrollHeight)
this.reportYas(scrollHeight);
},
scrollHandler({ y }) {
this.scrollY = -y;
... ... @@ -281,9 +290,11 @@ export default {
if (this.navTop) {
if (this.scrollY >= this.navTop) {
this.isShow = true;
// this.isA = false;
} else {
this.isShow = false;
// this.isA = true;
}
}
... ... @@ -293,8 +304,9 @@ export default {
this.searchParams = Object.assign({}, queryString.parse(str), this.listBaseParams);
await this.fetchList(this.searchParams);
// 列表上报数据
this.setYasParam({index: 0, ...this.searchParams})
this.setYasParam({index: 0, ...this.searchParams});
},
async onPullingUp() {
... ... @@ -334,7 +346,7 @@ export default {
delete searchParams[key];
}
}
try{
try {
let result = await this.fetchProductList({
...searchParams,
page,
... ... @@ -357,15 +369,14 @@ export default {
list[key] = data[key];
}
}
if(!Object.keys(data).includes('product_list')) {
list.list = []
}
this.productList = list;
}
}catch(e) {
} catch (e) {
// console.log(e);
if (this.productList.page <= 1) {
this.productList.list = [];
}
}
},
goSearch() {
... ...
... ... @@ -223,6 +223,9 @@ export default function(mergeState = {}) {
// pass
}
},
setNeedLogin({ commit }, { needLogin }) {
commit(Types.SET_NEED_LOGIN, { needLogin });
},
async getSysConfigQiugou({ commit, state }) {
// /ufo-gateway/?method=ufo.resource.getConfigTypeContent&code=bid_switch_h5
// {"alg":"SALT_MD5","code":200,"data":"1","md5":"c13a1ace2c5883be18643551bd17ebcd","message":"操作成功"}
... ...