Browse Source

[优化] 推荐页面逻辑

test
邓平艺 4 years ago
parent
commit
42bb7f3871
  1. 2
      common/api.js
  2. 19
      components/lf-waterfall/lf-waterfall.vue
  3. 2
      pages/goodsDetail/index.vue
  4. 47
      pages/recommList/index.vue

2
common/api.js

@ -1,7 +1,7 @@
// appId: 正式 null | 测试 wxb35ef055a4dd8ad4
export const DEV = "dev"; // dev 测试 | prod 正式
export const VERSION = '1.0.0'; // 版本号
export const DEVURL = 'http://hainan.lanzulive.com'; // 测试服请求地址
export const DEVURL = 'https://hainan.lanzulive.com'; // 测试服请求地址
// export const DEVURL = 'http://hainan.com'; // 测试服请求地址
export const PRODURL = ''; // 正式服请求地址

19
components/lf-waterfall/lf-waterfall.vue

@ -69,16 +69,21 @@
},
data(){
return {
dataList: []
}
},
computed: {
dataList: {
get() { return this.list; },
set(newValue) { console.log('newvalue',newValue) }
},
watch: {
list(val){
this.dataList = val;
}
},
onShow(){
// computed: {
// dataList: {
// get() { return this.list; },
// set(newValue) { console.log('newvalue',newValue) }
// },
// },
created(){
},
destroyed() {

2
pages/goodsDetail/index.vue

@ -207,7 +207,7 @@
let title = goods.name;
let imageUrl = goods.share_cover || goods.cover;
let path = '/pages/route/index?route=goods_detail&id='+ goods.id;
console.log("path", path);
return {
title,
path,

47
pages/recommList/index.vue

@ -12,7 +12,7 @@
<view class="loading-more lf-m-b-10">
<text :class="{'loading-more-text': tabItem.loadingClass}" v-if="tabItem.list.length">{{tabItem.loadingText}}</text>
<lf-nocontent v-else></lf-nocontent>
<!-- <view>
<!-- <view>
{{tabItem.list.length}}
</view> -->
</view>
@ -29,7 +29,8 @@
return {
tab_list: [],
current: 0,
windowHeight: 0
windowHeight: 0,
show_count: 0
}
},
components: {
@ -37,10 +38,13 @@
},
onShow(){
this.windowHeight = getApp().globalData.windowHeight;
this.getCategory()
},
onHide() {
this.$refs.uWaterfall[this.current].clear();
if(this.show_count >= 1){
this.clearTabItem();
this.getData();
}else{
this.getCategory();
}
this.show_count++;
},
methods: {
getCategory(options = {}) {
@ -58,11 +62,6 @@
isPage: true
}
});
if(options.type == 'pageRefresh'){
uni.stopPullDownRefresh();
}else if(options.type == 'scrollRefresh'){
this.tab_list[this.current].isRefresher = false;
}
this.tab_list = tab_list;
this.getData()
}).catch(err => {
@ -79,6 +78,7 @@
tab_item.loadingClass = false;
tab_item.loadingText = '没有更多数据啦~';
}
tab_item.isRefresher = false;
if(tab_item.page == 1){
tab_item.list = res.data.data;
}else{
@ -89,10 +89,6 @@
})
},
tabChange(index){
this.$refs.uWaterfall[index].clear();
this.tab_list[index].list = [];
// this.getCategory({type: 'pageRefresh'});
console.log(this.$refs)
this.current = index;
if(this.tab_list[index].list.length <= 0){
this.getData(); // tab
@ -117,16 +113,21 @@
// scroll-view
onRefresherrefresh(){
this.$u.throttle(() => {
this.$refs.uWaterfall[this.current].clear();
this.tab_list[this.current].isRefresher = true;
this.getCategory({type: 'scrollRefresh'});
this.clearTabItem();
this.getData();
}, 200);
},
// page
onPullDownRefresh(){
//
this.getCategory({type: 'pageRefresh'});
},
clearTabItem(){
let tab_item = this.tab_list[this.current];
tab_item.page = 1;
tab_item.isPage = true;
tab_item.isRefresher = true;
tab_item.loadingClass = true;
tab_item.loadingText = '正在加载中';
tab_item.list = [];
this.$set(this.tab_list, this.current, tab_item);
this.$refs.uWaterfall[this.current].clear();
}
}
}
</script>

Loading…
Cancel
Save